Skip to content

Commit

Permalink
Address more of the style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
haticekaratay committed Oct 5, 2023
1 parent a8b33b9 commit 2033e8b
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Import Library\n",
"\n",
"# --------------------------------------JWST Calibration Pipeline Imports-------------------------------------------\n",
"\n",
"import jwst\n",
"import crds\n",
"from jwst import datamodels\n",
Expand All @@ -80,35 +77,43 @@
"from jwst.pipeline import Spec3Pipeline # calwebb_spec3\n",
"\n",
"print(\"JWST Calibration Pipeline Version={}\".format(jwst.__version__))\n",
"print(\"Current Operational CRDS Context = {}\".format(crds.get_default_context()))\n",
"\n",
"# ----------------------------------------------General Imports-----------------------------------------------------\n",
"\n",
"import numpy as np # noqa\n",
"import warnings # noqa\n",
"warnings.filterwarnings('ignore') # Set to 'default' to turn warnings back on\n",
"\n",
"print(\"Current Operational CRDS Context = {}\".format(crds.get_default_context()))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "968d8315-5e14-498f-a3cd-134a6ab0fcd1",
"metadata": {},
"outputs": [],
"source": [
"# --------------------------------------------File Operation Imports------------------------------------------------\n",
"\n",
"import glob # noqa\n",
"import os # noqa\n",
"import json # noqa\n",
"from shutil import copy # noqa\n",
"import glob\n",
"import os\n",
"import json\n",
"from shutil import copy\n",
"\n",
"# --------------------------------------------Astropy/Astroquery Imports--------------------------------------------\n",
"\n",
"from astropy.io import fits # noqa\n",
"from astropy import wcs # noqa\n",
"from astropy.wcs import WCS # noqa\n",
"from astropy.visualization import ImageNormalize, ManualInterval, LogStretch, LinearStretch, AsinhStretch # noqa\n",
"from astroquery.mast import Observations # noqa\n",
"from astropy.io import fits\n",
"from astropy import wcs\n",
"from astropy.wcs import WCS\n",
"from astropy.visualization import ImageNormalize, ManualInterval, LogStretch, LinearStretch, AsinhStretch\n",
"from astroquery.mast import Observations\n",
"\n",
"# ------------------------------------------------Plotting Imports--------------------------------------------------\n",
"\n",
"import matplotlib.pyplot as plt # noqa\n",
"import matplotlib as mpl # noqa\n",
"import matplotlib.gridspec as grd # noqa\n",
"from matplotlib import cm # noqa\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib as mpl\n",
"import matplotlib.gridspec as grd\n",
"from matplotlib import cm\n",
"\n",
"# ----------------------------------------------General Imports-----------------------------------------------------\n",
"\n",
"import numpy as np\n",
"import warnings\n",
"warnings.filterwarnings('ignore') # Set to 'default' to turn warnings back on\n",
"\n",
"# Use this version for non-interactive plots (easier scrolling of the notebook)\n",
"%matplotlib inline\n",
Expand Down Expand Up @@ -194,7 +199,7 @@
"\n",
" # Zoom in on a portion of the image? \n",
" if zoom_in:\n",
" # inset axis \n",
" # inset axis\n",
" axins = ax.inset_axes([0.5, 0.6, 0.5, 0.3])\n",
" \n",
" axins.imshow(data_2d, origin=\"lower\", norm=norm, aspect=aspect, cmap=cmap)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
"metadata": {},
"outputs": [],
"source": [
"# Import Library\n",
"\n",
"# --------------------------------------JWST Calibration Pipeline Imports-------------------------------------------\n",
"\n",
"import jwst\n",
Expand All @@ -79,41 +77,48 @@
"from jwst.pipeline import Detector1Pipeline # calwebb_detector1\n",
"from jwst.pipeline import Spec2Pipeline # calwebb_spec2\n",
"from jwst.pipeline import Spec3Pipeline # calwebb_spec3\n",
"from jwst.extract_1d import Extract1dStep # Extract1D Individual Step\n",
"\n",
"print(\"JWST Calibration Pipeline Version={}\".format(jwst.__version__))\n",
"print(\"Current Operational CRDS Context = {}\".format(crds.get_default_context()))\n",
"\n",
"# ----------------------------------------------General Imports-----------------------------------------------------\n",
"\n",
"import numpy as np # noqa\n",
"import warnings # noqa\n",
"warnings.filterwarnings('ignore') # Set to 'default' to turn warnings back on\n",
"\n",
"print(\"Current Operational CRDS Context = {}\".format(crds.get_default_context()))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4c5ef196-77d6-4fe5-bc06-efd86ea32be5",
"metadata": {},
"outputs": [],
"source": [
"# --------------------------------------------File Operation Imports------------------------------------------------\n",
"\n",
"import glob # noqa\n",
"import os # noqa\n",
"import asdf # noqa\n",
"import json # noqa\n",
"from shutil import copy # noqa\n",
"import glob\n",
"import os\n",
"import asdf\n",
"import json\n",
"from shutil import copy\n",
"\n",
"# --------------------------------------------Astropy/Astroquery Imports--------------------------------------------\n",
"\n",
"from astropy.io import fits # noqa\n",
"from astropy import wcs # noqa\n",
"from astropy.wcs import WCS # noqa\n",
"from astropy.visualization import ImageNormalize, ManualInterval, LogStretch, LinearStretch, AsinhStretch, SqrtStretch\n",
"import astroquery # noqa\n",
"from astroquery.mast import Mast # noqa\n",
"from astroquery.mast import Observations # noqa\n",
"from astropy.io import fits\n",
"from astropy import wcs\n",
"from astropy.wcs import WCS\n",
"from astropy.visualization import ImageNormalize, ManualInterval, LogStretch, LinearStretch, AsinhStretch\n",
"import astroquery\n",
"from astroquery.mast import Mast\n",
"from astroquery.mast import Observations\n",
"\n",
"# ------------------------------------------------Plotting Imports--------------------------------------------------\n",
"\n",
"import matplotlib.pyplot as plt # noqa\n",
"import matplotlib as mpl # noqa\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib as mpl\n",
"import matplotlib.gridspec as grd\n",
"from matplotlib import cm # noqa\n",
"from matplotlib import cm\n",
"\n",
"# ----------------------------------------------General Imports-----------------------------------------------------\n",
"\n",
"import numpy as np\n",
"import warnings\n",
"warnings.filterwarnings('ignore') # Set to 'default' to turn warnings back on\n",
"\n",
"# Use this version for non-interactive plots (easier scrolling of the notebook)\n",
"%matplotlib inline\n",
Expand Down Expand Up @@ -214,7 +219,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "3d233556",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -265,7 +270,7 @@
" \n",
" for s3d_file in s3d_file_list:\n",
" \n",
" root=s3d_file[:-9] # Root file name \n",
" root = s3d_file[:-9] # Root file name \n",
"\n",
" s3d = fits.open(s3d_file) # 3-D IFU data cube fits file\n",
" x1d3 = datamodels.open(root+'_x1d.fits') # 1-D Extracted Spectrum \n",
Expand Down Expand Up @@ -353,7 +358,7 @@
" ax1.set_xlabel('RA', fontsize=22)\n",
" ax1.set_ylabel('DEC', labelpad=-1, fontsize=22)\n",
" # ax1.grid(color='white', ls='solid')\n",
" ax1.set_title('Detector {} \\n Grating/Filter: {}/{} \\n {} microns'.format(s3d[0].header['DETECTOR'],s3d[0].header['GRATING'], s3d[0].header['FILTER'], str(slicewave)), fontsize=25)\n",
" ax1.set_title('Detector {} \\n Grating/Filter: {}/{} \\n {} microns'.format(s3d[0].header['DETECTOR'], s3d[0].header['GRATING'], s3d[0].header['FILTER'], str(slicewave)), fontsize=25)\n",
" ax1.tick_params(axis='both', which='major', labelsize=20)\n",
" ax1.coords[0].set_ticklabel(rotation=13, ha='right', pad=24)\n",
"\n",
Expand All @@ -365,13 +370,13 @@
" # ax2 = plt.subplot(3,len(wavelength_slices), int(total_num_plots/3)+plot_count)\n",
" ax2 = plt.subplot(gs[int(total_num_plots/3)+plot_count])\n",
"\n",
" # Spaxel Box Highlight \n",
" # Spaxel Box Highlight\n",
" spaxel_rect = plt.Rectangle((loc[0]-.5, loc[1]-.5), 1, 1, fill=False, color='black', linewidth=2)\n",
" ax1.add_patch(spaxel_rect)\n",
" \n",
" ax2.plot(x1d3wave, x1d3flux_loc, linewidth=1, color=colors[i])\n",
" ax2.grid(linewidth=2)\n",
" ax2.set_xlabel(r'$\\u03BB [\\u03BC$m]',fontsize=22)\n",
" ax2.set_xlabel(r'$\\u03BB [\\u03BC$m]', fontsize=22)\n",
" ax2.set_ylabel(\"Surface Brightness \\n (MJy/sr)\", fontsize=22)\n",
" ax2.set_title('Spaxel at (x, y)='+repr(loc), fontsize=25)\n",
" ax2.tick_params(axis='both', which='major', labelsize=20)\n",
Expand Down Expand Up @@ -437,22 +442,10 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "f94025d4",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'os' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[2], line 13\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m runflag:\n\u001b[1;32m 10\u001b[0m \u001b[38;5;66;03m# If you want to actually re-download the data and run everything offline, \u001b[39;00m\n\u001b[1;32m 11\u001b[0m \u001b[38;5;66;03m# then comment out this line, set runflag=True, & specify a desired local directory\u001b[39;00m\n\u001b[1;32m 12\u001b[0m output_dir \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m./nirspec_ifu_02732_rerun/\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m---> 13\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[43mos\u001b[49m\u001b[38;5;241m.\u001b[39mpath\u001b[38;5;241m.\u001b[39mexists(output_dir):\n\u001b[1;32m 14\u001b[0m os\u001b[38;5;241m.\u001b[39mmakedirs(output_dir)\n",
"\u001b[0;31mNameError\u001b[0m: name 'os' is not defined"
]
}
],
"outputs": [],
"source": [
"# To rerun the notebook and all the pipeline steps set runflag=True\n",
"runflag = True \n",
Expand Down Expand Up @@ -610,8 +603,7 @@
" title='Data Quality Map \\n Detector: {} \\n 8-Cycle Dither Position Index: {} \\n GRATING/FILTER: {}/{}'.format(ratefile_open.meta.instrument.detector,\n",
" ratefile_open.meta.dither.position_number, \n",
" ratefile_open.meta.instrument.grating,\n",
" ratefile_open.meta.instrument.filter)) \n",
" "
" ratefile_open.meta.instrument.filter))"
]
},
{
Expand Down Expand Up @@ -838,7 +830,6 @@
" ratefile_sci = ratefile_open.data # Get the pixel data (the SCI extension of the fits file)\n",
" ratefile_dq = ratefile_open.dq # The Data Quality Map Data\n",
" \n",
" \n",
" show_image(ratefile_sci, 0, 10, units='DN/s', zoom_in=[500, 550, 1250, 1300],\n",
" title='Countrate Image \\n Detector: {} \\n 8-Cycle Dither Position Index: {} \\n GRATING/FILTER: {}/{}'.format(ratefile_open.meta.instrument.detector,\n",
" ratefile_open.meta.dither.position_number, \n",
Expand Down Expand Up @@ -920,8 +911,8 @@
"\n",
"\n",
"# Characteristics of the plot \n",
"nrs1_wavelengths = [1.4, 3.3, 4.5] # Wavelength slices (microns) to take from the 3-D data cube\n",
"nrs1_spaxel_locs = [[30, 29], [28, 39], [14, 25]] #Spaxel locations for associated 1-D spectrum (one spaxel plotted per slice)\n",
"nrs1_wavelengths = [1.4, 3.3, 4.5] # Wavelength slices (microns) to take from the 3-D data cube\n",
"nrs1_spaxel_locs = [[30, 29], [28, 39], [14, 25]] # Spaxel locations for associated 1-D spectrum (one spaxel plotted per slice)\n",
"\n",
"\n",
"# Plot using the convience function defined above\n",
Expand Down
Loading

0 comments on commit 2033e8b

Please sign in to comment.