diff --git a/jdat_notebooks/IFU_cube_continuum_fit/NGC4151_FeII_ContinuumFit.ipynb b/jdat_notebooks/IFU_cube_continuum_fit/NGC4151_FeII_ContinuumFit.ipynb index 044aed18..43cb6bb4 100644 --- a/jdat_notebooks/IFU_cube_continuum_fit/NGC4151_FeII_ContinuumFit.ipynb +++ b/jdat_notebooks/IFU_cube_continuum_fit/NGC4151_FeII_ContinuumFit.ipynb @@ -46,6 +46,7 @@ "source": [ "# load important packages\n", "import time\n", + "import os\n", "from copy import copy\n", "\n", "import numpy as np\n", @@ -80,8 +81,9 @@ "metadata": {}, "outputs": [], "source": [ - "#Save and Load Objects Using Pickle\n", + "# Save and Load Objects Using Pickle\n", "import pickle\n", + "\n", "def save_obj(obj, name):\n", " with open(name, 'wb') as f:\n", " pickle.dump(obj, f, pickle.HIGHEST_PROTOCOL)\n", @@ -115,19 +117,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1: E999 SyntaxError: invalid syntax\n", - "INFO:pycodestyle:3:13: E225 missing whitespace around operator\n", - "INFO:pycodestyle:3:25: E231 missing whitespace after ','\n", - "INFO:pycodestyle:3:30: E231 missing whitespace after ','\n", - "INFO:pycodestyle:3:35: E231 missing whitespace after ','\n" - ] - } - ], + "outputs": [], "source": [ "# enable PEP8 checker for this notebook\n", "%load_ext pycodestyle_magic\n", @@ -151,23 +141,9 @@ "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:10:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:15:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:17:7: E225 missing whitespace around operator\n", - "INFO:pycodestyle:17:31: E231 missing whitespace after ','\n", - "INFO:pycodestyle:17:34: E231 missing whitespace after ','\n", - "INFO:pycodestyle:23:29: E231 missing whitespace after ','\n" - ] - } - ], - "source": [ - "#This cell accesses the datacube file, defines the wavelength grid from header information and then plots a simple\n", + "outputs": [], + "source": [ + "# This cell accesses the datacube file, defines the wavelength grid from header information and then plots a simple\n", "# 1-D collapsed spectrum of the IFU data.\n", "\n", "# Read in a 3-D IFU datacube of interest, and header.\n", @@ -176,25 +152,25 @@ "cube = fits.getdata(cube_file)\n", "header_cube = fits.getheader(cube_file)\n", "\n", - "#grab data information and wavelength definitions.\n", + "# grab data information and wavelength definitions.\n", "nz, ny, nx = cube.shape\n", "crdelt3 = header_cube['CDELT3']\n", "crval3 = header_cube['CRVAL3']\n", "\n", - "#define the wavelength grid (microns) from the header (Angstroms)\n", + "# define the wavelength grid (microns) from the header (Angstroms)\n", "# and the AGN redshift and the emission line of interest.\n", - "wave =((crdelt3 * (np.arange(0,nz,1))) + crval3)/10000.0\n", + "wave = ((crdelt3 * (np.arange(0, nz, 1))) + crval3)/10000.0\n", "redshift = 0.00332\n", "emission_line = 1.64400*(1 + redshift)\n", "emission_line_index = (np.abs(wave-emission_line)).argmin()\n", "\n", "# make a simple summed 1d spectrum of the full cube\n", - "flux1 = np.sum(cube, axis=(1,2))\n", + "flux1 = np.sum(cube, axis=(1, 2))\n", "\n", "# plot the full 1-D spectrum.\n", "plt.figure(0)\n", "plt.plot(wave, flux1)\n", - "plt.show()\n" + "plt.show()" ] }, { @@ -220,23 +196,10 @@ "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:2:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:3:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:24:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:32:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:37:75: E231 missing whitespace after ','\n" - ] - } - ], - "source": [ - "\n", - "#This cell defines the wavelength regions of interest: around the emission line, and the location\n", - "#where you want to fit and remove the continuum very accurately. Make a plot that shows the regions.\n", + "outputs": [], + "source": [ + "# This cell defines the wavelength regions of interest: around the emission line, and the location\n", + "# where you want to fit and remove the continuum very accurately. Make a plot that shows the regions.\n", "\n", "# Here we select a region that includes the emission line\n", "# wavelength plus a small range of continuum around it. \n", @@ -257,7 +220,7 @@ "continuum_limit1 = 1.656\n", "continuum_limit2 = 1.673\n", " \n", - "#Define the wavelength region around the emission - indices\n", + "# Define the wavelength region around the emission - indices\n", "wavemin = (np.abs(wave-wave_emission_limit1)).argmin()\n", "wavemax = (np.abs(wave-wave_emission_limit2)).argmin()\n", "\n", @@ -265,33 +228,24 @@ "continuummin = (np.abs(wave-continuum_limit1)).argmin()\n", "continuummax = (np.abs(wave-continuum_limit2)).argmin()\n", "\n", - "#show the region used for the emission line and continuum fit. Alter the wavelengths \n", + "# Show the region used for the emission line and continuum fit. Alter the wavelengths \n", "# above if this doesn't look good. \n", "plt.figure(1)\n", "plt.plot(wave, flux1)\n", "plt.plot(wave[wavemin:wavemax], flux1[wavemin:wavemax])\n", "plt.plot(wave[continuummin:continuummax], flux1[continuummin:continuummax],color='r')\n", - "plt.show()\n" + "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:2:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:3:1: E265 block comment should start with '# '\n" - ] - } - ], + "outputs": [], "source": [ "print(wave)\n", - "#print(wave-wave_emission_limit1)\n", - "#print(continuummin,continuummax)" + "# print(wave-wave_emission_limit1)\n", + "# print(continuummin,continuummax)" ] }, { @@ -408,7 +362,7 @@ "metadata": {}, "outputs": [], "source": [ - "HTML('')\n" + "HTML('')" ] }, { @@ -424,17 +378,9 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#PART 1\n", + "outputs": [], + "source": [ + "# PART 1\n", "HTML('')" ] }, @@ -442,18 +388,10 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], + "outputs": [], "source": [ - "#PART 2\n", - "HTML('')\n" + "# PART 2\n", + "HTML('')" ] }, { @@ -474,28 +412,13 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:63: E231 missing whitespace after ','\n", - "INFO:pycodestyle:2:76: E262 inline comment should start with '# '\n", - "INFO:pycodestyle:3:63: E231 missing whitespace after ','\n", - "INFO:pycodestyle:3:76: E262 inline comment should start with '# '\n", - "INFO:pycodestyle:4:63: E231 missing whitespace after ','\n", - "INFO:pycodestyle:4:76: E262 inline comment should start with '# '\n", - "INFO:pycodestyle:5:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#Extract spectra corresponding to the colored regions in cubeviz\n", - "spectrum1 = cubeviz.app.get_data_from_viewer('spectrum-viewer','Subset 1') #AGN Center\n", - "spectrum2 = cubeviz.app.get_data_from_viewer('spectrum-viewer','Subset 2') #Red shifted component\n", - "spectrum3 = cubeviz.app.get_data_from_viewer('spectrum-viewer','Subset 3') #Blue shifted component\n", - "#spectrum3 = cubeviz.app.get_data_from_viewer('spectrum-viewer')['Subset 3'] #Blue shifted component\n", + "outputs": [], + "source": [ + "# Extract spectra corresponding to the colored regions in cubeviz\n", + "spectrum1 = cubeviz.app.get_data_from_viewer('spectrum-viewer', 'Subset 1') # AGN Center\n", + "spectrum2 = cubeviz.app.get_data_from_viewer('spectrum-viewer', 'Subset 2') # Red shifted component\n", + "spectrum3 = cubeviz.app.get_data_from_viewer('spectrum-viewer', 'Subset 3') # Blue shifted component\n", + "# spectrum3 = cubeviz.app.get_data_from_viewer('spectrum-viewer')['Subset 3'] # Blue shifted component\n", "spectrum1" ] }, @@ -503,55 +426,29 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:1: E265 block comment should start with '# '\n" - ] - } - ], + "outputs": [], "source": [ - "#regions = cubeviz.specviz.get_spectral_regions()\n", - "#regions" + "# regions = cubeviz.specviz.get_spectral_regions()\n", + "# regions" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:1: E265 block comment should start with '# '\n" - ] - } - ], + "outputs": [], "source": [ - "#regions = cubeviz.app.get_data_from_viewer('flux-viewer')['Subset 4'] #AGN Center\n", - "#regions" + "# regions = cubeviz.app.get_data_from_viewer('flux-viewer')['Subset 4'] #AGN Center\n", + "# regions" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], + "outputs": [], "source": [ - "#regions = cubeviz.app.get" + "# regions = cubeviz.app.get" ] }, { @@ -560,31 +457,11 @@ "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - }, - { - "ename": "KeyError", - "evalue": "'Subset 4'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/var/folders/ls/7lh0_8jn0ndbm6g7plbzw8n400028t/T/ipykernel_48321/1159788268.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0mregions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0mline_region\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mregions\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"Subset 4\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 7\u001b[0m \u001b[0mcontinuum_region\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mregions\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"Subset 5\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: 'Subset 4'" - ] - } - ], - "source": [ - "#Extract the spectral regions defined in the spectral viewer\n", + "outputs": [], + "source": [ + "# Extract the spectral regions defined in the spectral viewer\n", "from specutils.spectra import SpectralRegion\n", "regions = cubeviz.specviz.get_spectral_regions()\n", - "regions\n", "\n", "line_region = regions[\"Subset 4\"]\n", "continuum_region = regions[\"Subset 5\"]" @@ -594,17 +471,9 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#Define Missing Spectral Regions if User Did Not in Cubeviz\n", + "outputs": [], + "source": [ + "# Define Missing Spectral Regions if User Did Not in Cubeviz\n", "if not regions:\n", " line_region = SpectralRegion(1.630*u.um, 1.665*u.um)\n", " \n", @@ -616,39 +485,22 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:5:29: E231 missing whitespace after ','\n", - "INFO:pycodestyle:5:49: E231 missing whitespace after ','\n", - "INFO:pycodestyle:5:79: E231 missing whitespace after ','\n", - "INFO:pycodestyle:14:34: E231 missing whitespace after ','\n", - "INFO:pycodestyle:14:48: E231 missing whitespace after ','\n", - "INFO:pycodestyle:14:72: E231 missing whitespace after ','\n", - "INFO:pycodestyle:23:35: E231 missing whitespace after ','\n", - "INFO:pycodestyle:23:49: E231 missing whitespace after ','\n", - "INFO:pycodestyle:23:73: E231 missing whitespace after ','\n" - ] - } - ], - "source": [ - "#Apply the spectral region\n", + "outputs": [], + "source": [ + "# Apply the spectral region\n", "from specutils.manipulation import extract_region\n", "\n", "if not spectrum1:\n", - " flux_agn = np.sum(cube[:,(ny//2)-3:(ny//2)+3,(nx//2)-3:(nx//2)+3], axis=(1,2))\n", + " flux_agn = np.sum(cube[:, (ny//2)-3:(ny//2)+3, (nx//2)-3:(nx//2)+3], axis=(1, 2))\n", " tmpspec = Spectrum1D(flux=flux_agn*u.Unit('count'), spectral_axis=wave*u.micron) \n", " spec_agn = extract_region(tmpspec, line_region)\n", - " spec_agn_continuum = extract_region(tmpspec, continuum_region)\n", + " spec_agn_continuum = extract_region(tmpspec, continuum_region) \n", "else: \n", " spec_agn = extract_region(spectrum1, line_region)\n", " spec_agn_continuum = extract_region(spectrum1, continuum_region)\n", "\n", "if not spectrum2:\n", - " flux_feii_red = np.sum(cube[:,(36)-3:(36)+3,(12)-3:(12)+3], axis=(1,2))\n", + " flux_feii_red = np.sum(cube[:, (36)-3:(36)+3, (12)-3:(12)+3], axis=(1, 2))\n", " tmpspec = Spectrum1D(flux=flux_feii_red*u.Unit('count'), spectral_axis=wave*u.micron) \n", " spec_feii_red = extract_region(tmpspec, line_region)\n", " spec_feii_red_continuum = extract_region(tmpspec, continuum_region)\n", @@ -657,7 +509,7 @@ " spec_feii_red_continuum = extract_region(spectrum2, continuum_region)\n", "\n", "if not spectrum3:\n", - " flux_feii_blue = np.sum(cube[:,(28)-3:(28)+3,(50)-3:(50)+3], axis=(1,2))\n", + " flux_feii_blue = np.sum(cube[:, (28)-3:(28)+3, (50)-3:(50)+3], axis=(1, 2))\n", " tmpspec = Spectrum1D(flux=flux_feii_blue*u.Unit('count'), spectral_axis=wave*u.micron) \n", " spec_feii_blue = extract_region(tmpspec, line_region)\n", " spec_feii_blue_continuum = extract_region(tmpspec, continuum_region)\n", @@ -670,45 +522,23 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:3:32: E231 missing whitespace after ','\n", - "INFO:pycodestyle:3:46: E231 missing whitespace after ','\n" - ] - } - ], - "source": [ - "#Visualize new subsets\n", + "outputs": [], + "source": [ + "# Visualize new subsets\n", "plt.figure()\n", - "plt.plot(spec_agn.spectral_axis,spec_agn.flux,color='black')" + "plt.plot(spec_agn.spectral_axis, spec_agn.flux, color='black')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:3:38: E231 missing whitespace after ','\n", - "INFO:pycodestyle:3:58: E231 missing whitespace after ','\n", - "INFO:pycodestyle:4:37: E231 missing whitespace after ','\n", - "INFO:pycodestyle:4:56: E231 missing whitespace after ','\n" - ] - } - ], - "source": [ - "#Visualize new subsets\n", + "outputs": [], + "source": [ + "# Visualize new subsets\n", "plt.figure()\n", - "plt.plot(spec_feii_blue.spectral_axis,spec_feii_blue.flux,color='b')\n", - "plt.plot(spec_feii_red.spectral_axis,spec_feii_red.flux,color='r')" + "plt.plot(spec_feii_blue.spectral_axis, spec_feii_blue.flux, color='b')\n", + "plt.plot(spec_feii_red.spectral_axis, spec_feii_red.flux, color='r')" ] }, { @@ -735,37 +565,22 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#VIDEO OF CONTINUUM FITTING\n", - "#PART 1\n", + "outputs": [], + "source": [ + "# VIDEO OF CONTINUUM FITTING\n", + "# PART 1\n", "HTML('')" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#PART 2\n", + "metadata": { + "scrolled": false + }, + "outputs": [], + "source": [ + "# PART 2\n", "HTML('')" ] }, @@ -787,17 +602,9 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#List Data from Viewer\n", + "outputs": [], + "source": [ + "# List Data from Viewer\n", "regions = cubeviz.app.get_data_from_viewer(\"uncert-viewer\")\n", "regions" ] @@ -806,20 +613,11 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:3:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#Extract Continuum Model from Cubeviz above\n", + "outputs": [], + "source": [ + "# Extract Continuum Model from Cubeviz above\n", "cont_psf_cube = cubeviz.app.get_data_from_viewer(\"uncert-viewer\", \"LinFitCont [Cube] 1\")\n", - "#cont_psf_cubee = cubeviz.app.get_data_from_viewer(\"uncert-viewer\", \"LinFitCont [Cube] 2\")" + "# cont_psf_cubee = cubeviz.app.get_data_from_viewer(\"uncert-viewer\", \"LinFitCont [Cube] 2\")" ] }, { @@ -833,90 +631,48 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:4:3: E111 indentation is not a multiple of 4\n", - "INFO:pycodestyle:6:3: E111 indentation is not a multiple of 4\n", - "INFO:pycodestyle:10:3: E111 indentation is not a multiple of 4\n", - "INFO:pycodestyle:12:3: E111 indentation is not a multiple of 4\n" - ] - } - ], - "source": [ - "#Delete any existing output in current directory\n", - "import os\n", + "outputs": [], + "source": [ + "# Delete any existing output in current directory\n", "if os.path.exists(\"NGC4151_Hband_ContinuumSubtract.fits\"):\n", - " os.remove(\"NGC4151_Hband_ContinuumSubtract.fits\")\n", + " os.remove(\"NGC4151_Hband_ContinuumSubtract.fits\")\n", "else:\n", - " print(\"The file does not exist\")\n", + " print(\"The file does not exist\")\n", "\n", - "import os\n", "if os.path.exists(\"NGC4151_Hband_ContinuumPSF.fits\"):\n", - " os.remove(\"NGC4151_Hband_ContinuumPSF.fits\")\n", + " os.remove(\"NGC4151_Hband_ContinuumPSF.fits\")\n", "else:\n", - " print(\"The file does not exist\")" + " print(\"The file does not exist\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:3:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:8:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:12:18: E225 missing whitespace around operator\n", - "INFO:pycodestyle:12:31: E231 missing whitespace after ','\n", - "INFO:pycodestyle:12:34: E231 missing whitespace after ','\n", - "INFO:pycodestyle:13:18: E225 missing whitespace around operator\n", - "INFO:pycodestyle:13:31: E231 missing whitespace after ','\n", - "INFO:pycodestyle:13:34: E231 missing whitespace after ','\n", - "INFO:pycodestyle:17:27: E231 missing whitespace after ','\n", - "INFO:pycodestyle:17:29: E231 missing whitespace after ','\n", - "INFO:pycodestyle:21:28: E231 missing whitespace after ','\n", - "INFO:pycodestyle:21:30: E231 missing whitespace after ','\n", - "INFO:pycodestyle:21:33: E225 missing whitespace around operator\n", - "INFO:pycodestyle:22:28: E231 missing whitespace after ','\n", - "INFO:pycodestyle:22:30: E231 missing whitespace after ','\n", - "INFO:pycodestyle:22:33: E225 missing whitespace around operator\n", - "INFO:pycodestyle:32:9: E265 block comment should start with '# '\n", - "INFO:pycodestyle:33:9: E265 block comment should start with '# '\n", - "INFO:pycodestyle:38:9: E265 block comment should start with '# '\n", - "INFO:pycodestyle:39:9: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#Subtract Continuum\n", - "\n", - "#Re-read in original IFU cube for manipulation\n", + "outputs": [], + "source": [ + "# Subtract Continuum\n", + "\n", + "# Re-read in original IFU cube for manipulation\n", "cube_file = 'https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/IFU_cube_continuum_fit/NGC4151_Hband.fits'\n", "newfn = download_file('https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/IFU_cube_continuum_fit/NGC4151_Hband.fits', cache=True)\n", "newheader_cube = fits.getheader(cube_file)\n", "\n", - "#Check to see if user made a continuum fit in Cubeviz, make continuum subtraction, and save output\n", + "# Check to see if user made a continuum fit in Cubeviz, make continuum subtraction, and save output\n", "if not cont_psf_cube:\n", " start_time = time.time()\n", "\n", - " cont_sub_cube=np.zeros([nz,ny,nx])\n", - " cont_psf_cube=np.zeros([nz,ny,nx])\n", + " cont_sub_cube = np.zeros([nz, ny, nx])\n", + " cont_psf_cube = np.zeros([nz, ny, nx])\n", "\n", " for i in range(1, nx-2):\n", " for j in range(1, ny-2):\n", - " flux1 = cube[:,j,i] \n", + " flux1 = cube[:, j, i] \n", " cont_fit = np.polyfit(wave[continuummin:continuummax], flux1[continuummin:continuummax], 1)\n", " fitval = np.poly1d(cont_fit)\n", " continuum = fitval(wave) \n", - " cont_sub_cube[:,j,i]= flux1 - continuum\n", - " cont_psf_cube[:,j,i]= continuum \n", + " cont_sub_cube[:, j, i] = flux1 - continuum\n", + " cont_psf_cube[:, j, i] = continuum \n", "\n", " del newheader_cube['MODE']\n", " fits.writeto('NGC4151_Hband_ContinuumSubtract.fits', cont_sub_cube, newheader_cube, overwrite=True)\n", @@ -926,14 +682,14 @@ " with fits.open(newfn, memmap=False) as cont_sub_cube:\n", " sci = cont_sub_cube['SCI'].data\n", "\n", - " #Get List of different viewers\n", - " #linfitcube = cubeviz.app.get_data_from_viewer(\"uncert-viewer\", \"LinFitCube [Cube] 1\")\n", + " # Get List of different viewers\n", + " # linfitcube = cubeviz.app.get_data_from_viewer(\"uncert-viewer\", \"LinFitCube [Cube] 1\")\n", " continuumflux = cont_psf_cube[\"flux\"]\n", "\n", " sci_contsub = sci-continuumflux\n", " cont_sub_cube['SCI'].data = sci_contsub \n", - " #cubeviz.app.load_data(newcube)\n", - " #del newheader_cube['MODE']\n", + " # cubeviz.app.load_data(newcube)\n", + " # del newheader_cube['MODE']\n", " del cont_sub_cube['PRIMARY'].header['MODE']\n", " cont_sub_cube.writeto('NGC4151_Hband_ContinuumSubtract.fits')\n", " del newheader_cube['MODE']\n", @@ -944,19 +700,10 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:7: E225 missing whitespace around operator\n" - ] - } - ], - "source": [ - "#You can also read out your model fit parameters \n", - "params=cubeviz.get_model_parameters(model_label=\"LinFitCont\")\n", + "outputs": [], + "source": [ + "# You can also read out your model fit parameters \n", + "params = cubeviz.get_model_parameters(model_label=\"LinFitCont\")\n", "params" ] }, @@ -964,36 +711,19 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:1: E265 block comment should start with '# '\n" - ] - } - ], + "outputs": [], "source": [ - "#And this is just an example of how you can acces the model fit parameter values\n", - "#params['LinFitCont_3d']['slope']" + "# And this is just an example of how you can acces the model fit parameter values\n", + "# params['LinFitCont_3d']['slope']" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#Open up a new instance of Cubeviz to visualize continuum subtracted data\n", + "outputs": [], + "source": [ + "# Open up a new instance of Cubeviz to visualize continuum subtracted data\n", "from jdaviz import CubeViz\n", "cubeviz2 = CubeViz()\n", "cubeviz2.app" @@ -1040,17 +770,9 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#VIDEO PART1\n", + "outputs": [], + "source": [ + "# VIDEO PART1\n", "HTML('')" ] }, @@ -1058,44 +780,17 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], + "outputs": [], "source": [ - "#VIDEO PART2\n", - "HTML('')\n" + "# VIDEO PART2\n", + "HTML('')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:7:1: E265 block comment should start with '# '\n" - ] - }, - { - "ename": "KeyError", - "evalue": "'Subset 1'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m/var/folders/ls/7lh0_8jn0ndbm6g7plbzw8n400028t/T/ipykernel_48321/4088308880.py\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mregions\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 11\u001b[0;31m \u001b[0mline_region\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mregions\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"Subset 1\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 12\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mline_region\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0mline_region\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mSpectralRegion\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1.6322\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mu\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mum\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m1.6563\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mu\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mum\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mKeyError\u001b[0m: 'Subset 1'" - ] - } - ], + "outputs": [], "source": [ "# Wow, that multi-component fit looks great. Good deal.\n", "\n", @@ -1103,9 +798,8 @@ "# with the Brackett model created in the above cell to create a full\n", "# 3-D model of the central emission that isn't caused by the outflow [Fe II].\n", "\n", - "#Extract the spectral regions defined in the spectral viewer\n", + "# Extract the spectral regions defined in the spectral viewer\n", "regions = cubeviz2.specviz.get_spectral_regions()\n", - "regions\n", "\n", "line_region = regions[\"Subset 1\"]\n", "if not line_region:\n", @@ -1116,19 +810,10 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:5: E225 missing whitespace around operator\n" - ] - } - ], - "source": [ - "#List spectra available in spectrum-viewer\n", - "spec=cubeviz2.app.get_data_from_viewer('spectrum-viewer') \n", + "outputs": [], + "source": [ + "# List spectra available in spectrum-viewer\n", + "spec = cubeviz2.app.get_data_from_viewer('spectrum-viewer') \n", "spec" ] }, @@ -1136,94 +821,50 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:63: E231 missing whitespace after ','\n", - "INFO:pycodestyle:2:93: E262 inline comment should start with '# '\n", - "INFO:pycodestyle:3:65: E231 missing whitespace after ','\n", - "INFO:pycodestyle:3:78: E262 inline comment should start with '# '\n", - "INFO:pycodestyle:4:86: E262 inline comment should start with '# '\n" - ] - } - ], - "source": [ - "#Get Gauss Model Spectrum and Model Cube\n", - "all_spec = cubeviz2.app.get_data_from_viewer('spectrum-viewer','Continuum Subtracted[SCI]') #AGN Center Data Cube\n", - "gauss_spec = cubeviz2.app.get_data_from_viewer('spectrum-viewer','GaussAll') #AGN Center Model Spec\n", - "gauss_cube = cubeviz2.app.get_data_from_viewer(\"uncert-viewer\", \"GaussAll [Cube] 1\") #AGN Center Model Cube" + "outputs": [], + "source": [ + "# Get Gauss Model Spectrum and Model Cube\n", + "all_spec = cubeviz2.app.get_data_from_viewer('spectrum-viewer', 'Continuum Subtracted[SCI]') # AGN Center Data Cube\n", + "gauss_spec = cubeviz2.app.get_data_from_viewer('spectrum-viewer', 'GaussAll') # AGN Center Model Spec\n", + "gauss_cube = cubeviz2.app.get_data_from_viewer(\"uncert-viewer\", \"GaussAll [Cube] 1\") # AGN Center Model Cube" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:3:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:5:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:8:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:9:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:10:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:11:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:13:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:14:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:15:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:16:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:17:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:19:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:20:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:21:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "##Save your Gauss Model Cube If Necessary\n", - "#import os\n", - "#if os.path.exists(\"gauss_model_cube.fits\"):\n", - "# os.remove(\"gauss_model_cube.fits\")\n", - "#else:\n", - "# print(\"The file does not exist\")\n", - "#\n", - "#gaussmodelflux = gauss_cube[\"flux\"]\n", - "#fits.writeto('gauss_model_cube.fits', gaussmodelflux, overwrite=True)\n", - "#print(type(gauss_cube[\"flux\"]))\n", - "#print(type(all_spec.flux))\n", - "\n", - "#Saving with 'Count' doesn't work.\n", - "#print(all_spec.flux)\n", - "#os.remove(\"all_spec.fits\")\n", - "#specref=Spectrum1D(flux=all_spec.flux*u.Unit('Jy'), spectral_axis=all_spec.spectral_axis)\n", - "#specref.write(\"all_spec.fits\")\n", - "\n", - "#os.remove(\"gauss_spec.fits\")\n", - "#specref=Spectrum1D(flux=gauss_spec.flux*u.Unit('Jy'), spectral_axis=gauss_spec.spectral_axis)\n", - "#specref.write(\"gauss_spec.fits\")\n" + "outputs": [], + "source": [ + "# Save your Gauss Model Cube If Necessary\n", + "# import os\n", + "# if os.path.exists(\"gauss_model_cube.fits\"):\n", + "# os.remove(\"gauss_model_cube.fits\")\n", + "# else:\n", + "# print(\"The file does not exist\")\n", + "\n", + "# gaussmodelflux = gauss_cube[\"flux\"]\n", + "# fits.writeto('gauss_model_cube.fits', gaussmodelflux, overwrite=True)\n", + "# print(type(gauss_cube[\"flux\"]))\n", + "# print(type(all_spec.flux))\n", + "\n", + "# Saving with 'Count' doesn't work.\n", + "# print(all_spec.flux)\n", + "# os.remove(\"all_spec.fits\")\n", + "# specref=Spectrum1D(flux=all_spec.flux*u.Unit('Jy'), spectral_axis=all_spec.spectral_axis)\n", + "# specref.write(\"all_spec.fits\")\n", + "\n", + "# os.remove(\"gauss_spec.fits\")\n", + "# specref=Spectrum1D(flux=gauss_spec.flux*u.Unit('Jy'), spectral_axis=gauss_spec.spectral_axis)\n", + "# specref.write(\"gauss_spec.fits\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#Check to see if user used Cubeviz (above), and, if not, read in premade data\n", + "outputs": [], + "source": [ + "# Check to see if user used Cubeviz (above), and, if not, read in premade data\n", "if not gauss_cube:\n", " fn = download_file('https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/IFU_cube_continuum_fit/gauss_model_cube.fits', cache=False)\n", " gauss_cube = fits.getdata(fn)\n", @@ -1243,19 +884,10 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:7: E225 missing whitespace around operator\n" - ] - } - ], - "source": [ - "#You can also read out your model fit parameters \n", - "params=cubeviz2.get_model_parameters(model_label=\"GaussAll\")\n", + "outputs": [], + "source": [ + "# You can also read out your model fit parameters \n", + "params = cubeviz2.get_model_parameters(model_label=\"GaussAll\")\n", "params" ] }, @@ -1263,42 +895,23 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:2:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:3:1: E265 block comment should start with '# '\n" - ] - } - ], + "outputs": [], "source": [ - "#Save Parameters as a Pickle File if necessary\n", - "#save_obj(params, \"gauss_params.pkl\")\n", - "#params=load_obj(\"gauss_params.pkl\")\n" + "# Save Parameters as a Pickle File if necessary\n", + "# save_obj(params, \"gauss_params.pkl\")\n", + "# params=load_obj(\"gauss_params.pkl\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:4:11: E225 missing whitespace around operator\n" - ] - } - ], - "source": [ - "#Check to see if user used Cubeviz (above), and, if not, read in premade data\n", + "outputs": [], + "source": [ + "# Check to see if user used Cubeviz (above), and, if not, read in premade data\n", "if not params:\n", " fn = download_file('https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/IFU_cube_continuum_fit/gauss_params.pkl', cache=True)\n", - " params=load_obj(fn)\n", + " params = load_obj(fn)\n", " print(\"Loaded\")" ] }, @@ -1306,63 +919,37 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:3:1: E402 module level import not at top of file\n", - "INFO:pycodestyle:8:13: E225 missing whitespace around operator\n", - "INFO:pycodestyle:9:13: E225 missing whitespace around operator\n", - "INFO:pycodestyle:10:11: E225 missing whitespace around operator\n", - "INFO:pycodestyle:11:11: E225 missing whitespace around operator\n", - "INFO:pycodestyle:12:15: E225 missing whitespace around operator\n", - "INFO:pycodestyle:13:15: E225 missing whitespace around operator\n", - "INFO:pycodestyle:16:32: E231 missing whitespace after ','\n", - "INFO:pycodestyle:16:34: E231 missing whitespace after ','\n" - ] - } - ], - "source": [ - "#Overwrite Gauss Model with only 2 of the components of interest\n", + "outputs": [], + "source": [ + "# Overwrite Gauss Model with only 2 of the components of interest\n", "gauss_cube_2component = gauss_cube*0\n", - "from astropy.modeling import models\n", "\n", "nz, ny, nx = gauss_cube_2component.shape\n", "for i in range(0, nx-1):\n", " for j in range(0, ny-1):\n", - " amp1=params['GaussAll_3d']['amplitude_0'][i][j]\n", - " amp2=params['GaussAll_3d']['amplitude_2'][i][j]\n", - " m1=params['GaussAll_3d']['mean_0'][i][j]\n", - " m2=params['GaussAll_3d']['mean_2'][i][j]\n", - " stdev1=params['GaussAll_3d']['stddev_0'][i][j]\n", - " stdev2=params['GaussAll_3d']['stddev_2'][i][j]\n", + " amp1 = params['GaussAll_3d']['amplitude_0'][i][j]\n", + " amp2 = params['GaussAll_3d']['amplitude_2'][i][j]\n", + " m1 = params['GaussAll_3d']['mean_0'][i][j]\n", + " m2 = params['GaussAll_3d']['mean_2'][i][j]\n", + " stdev1 = params['GaussAll_3d']['stddev_0'][i][j]\n", + " stdev2 = params['GaussAll_3d']['stddev_2'][i][j]\n", " g1 = models.Gaussian1D(amplitude=amp1*u.Unit('count'), mean=m1*u.m, stddev=stdev1*u.m)\n", " g2 = models.Gaussian1D(amplitude=amp2*u.Unit('count'), mean=m2*u.m, stddev=stdev2*u.m)\n", - " gauss_cube_2component[:,i,j] = g1(all_spec.spectral_axis)+g2(all_spec.spectral_axis)" + " gauss_cube_2component[:, i, j] = g1(all_spec.spectral_axis)+g2(all_spec.spectral_axis)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:5:5: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#Add the continuum cube to the new model cube\n", + "outputs": [], + "source": [ + "# Add the continuum cube to the new model cube\n", "continuum_file = 'NGC4151_Hband_ContinuumPSF.fits'\n", "newfull_header = fits.getheader(continuum_file)\n", + "\n", "with fits.open(continuum_file, memmap=False) as continuum_cube: \n", - " #print(continuum_cube[0].data)\n", + " # print(continuum_cube[0].data)\n", " continuum_data = continuum_cube[0].data\n", " full_model = gauss_cube_2component+continuum_data" ] @@ -1371,21 +958,14 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:2:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "# subtract the model to create the final cube where the [Fe II] emission is isolated.\n", - "#Re-read in original IFU cube for manipulation\n", + "outputs": [], + "source": [ + "# Subtract the model to create the final cube where the [Fe II] emission is isolated.\n", + "# Re-read in original IFU cube for manipulation\n", "cube_file = 'https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/IFU_cube_continuum_fit/NGC4151_Hband.fits'\n", "newfinalsub_header = fits.getheader(cube_file)\n", - "with fits.open(cube_file, memmap=False) as original_cube: \n", + "\n", + "with fits.open(cube_file, memmap=False) as original_cube:\n", " original_data = original_cube['SCI'].data\n", " final_sub_cube = original_data - full_model" ] @@ -1394,50 +974,29 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:4:3: E111 indentation is not a multiple of 4\n", - "INFO:pycodestyle:6:3: E111 indentation is not a multiple of 4\n", - "INFO:pycodestyle:10:3: E111 indentation is not a multiple of 4\n", - "INFO:pycodestyle:12:3: E111 indentation is not a multiple of 4\n" - ] - } - ], - "source": [ - "#Delete any existing output in current directory\n", - "import os\n", + "outputs": [], + "source": [ + "# Delete any existing output in current directory\n", "if os.path.exists(\"NGC4151_Hband_FinalSubtract.fits\"):\n", - " os.remove(\"NGC4151_Hband_FinalSubtract.fits\")\n", + " os.remove(\"NGC4151_Hband_FinalSubtract.fits\")\n", "else:\n", - " print(\"The file does not exist\")\n", + " print(\"The file does not exist\")\n", "\n", - "import os\n", "if os.path.exists(\"NGC4151_Hband_ContinuumandBrackettModel.fits\"):\n", - " os.remove(\"NGC4151_Hband_ContinuumandBrackettModel.fits\")\n", + " os.remove(\"NGC4151_Hband_ContinuumandBrackettModel.fits\")\n", "else:\n", - " print(\"The file does not exist\")" + " print(\"The file does not exist\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n" - ] - } - ], - "source": [ - "#del newfull_header['MODE']\n", + "outputs": [], + "source": [ + "# del newfull_header['MODE']\n", "del newfinalsub_header['MODE']\n", + "\n", "fits.writeto('NGC4151_Hband_ContinuumandBrackettModel.fits', full_model, newfull_header, overwrite=True)\n", "fits.writeto('NGC4151_Hband_FinalSubtract.fits', final_sub_cube, newfinalsub_header, overwrite=True)\n", "print('Continuum subtracted cube saved. PSF continuum cube saved.')" @@ -1447,36 +1006,16 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "INFO:pycodestyle:1:1: E265 block comment should start with '# '\n", - "INFO:pycodestyle:5:50: E231 missing whitespace after ','\n", - "INFO:pycodestyle:5:53: E231 missing whitespace after ','\n", - "INFO:pycodestyle:5:57: E231 missing whitespace after ','\n", - "INFO:pycodestyle:6:49: E231 missing whitespace after ','\n", - "INFO:pycodestyle:6:52: E231 missing whitespace after ','\n", - "INFO:pycodestyle:6:56: E231 missing whitespace after ','\n", - "INFO:pycodestyle:7:46: E231 missing whitespace after ','\n", - "INFO:pycodestyle:7:49: E231 missing whitespace after ','\n", - "INFO:pycodestyle:7:53: E231 missing whitespace after ','\n", - "INFO:pycodestyle:8:50: E231 missing whitespace after ','\n", - "INFO:pycodestyle:8:53: E231 missing whitespace after ','\n", - "INFO:pycodestyle:8:61: E231 missing whitespace after ','\n" - ] - } - ], - "source": [ - "#Make the final plots to illustrated\n", + "outputs": [], + "source": [ + "# Make the final plots to illustrated\n", "plt.figure()\n", "plt.xlim([1.630E-6, 1.665E-6])\n", "plt.ylim([600, 900])\n", - "plt.plot(all_spec.spectral_axis, continuum_data[:,30,30],label='Continuum')\n", - "plt.plot(all_spec.spectral_axis, original_data[:,30,30],label='Original Data')\n", - "plt.plot(all_spec.spectral_axis, full_model[:,30,30],label='2 Component Model')\n", - "plt.plot(all_spec.spectral_axis, final_sub_cube[:,30,30]+700,label='Model Subtraction+Offset')\n", + "plt.plot(all_spec.spectral_axis, continuum_data[:, 30, 30], label='Continuum')\n", + "plt.plot(all_spec.spectral_axis, original_data[:, 30, 30], label='Original Data')\n", + "plt.plot(all_spec.spectral_axis, full_model[:, 30, 30], label='2 Component Model')\n", + "plt.plot(all_spec.spectral_axis, final_sub_cube[:, 30, 30]+700, label='Model Subtraction+Offset')\n", "plt.legend()\n", "plt.show()" ]