Skip to content

Commit

Permalink
Fix remaining style errors
Browse files Browse the repository at this point in the history
  • Loading branch information
haticekaratay committed Dec 7, 2023
1 parent c93c020 commit 0ce8c03
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions notebooks/ifu_optimal/ifu_optimal.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,14 @@
"source": [
"import numpy as np\n",
"import scipy\n",
"import specutils\n",
"from specutils import Spectrum1D\n",
"from specutils.manipulation import spectral_slab\n",
"import jdaviz\n",
"from jdaviz import Cubeviz, Imviz, Specviz\n",
"from jdaviz import Cubeviz, Specviz\n",
"print(\"jdaviz Version={}\".format(jdaviz.__version__))\n",
"from photutils.aperture import CircularAperture, SkyCircularAperture, aperture_photometry \n",
"from photutils.aperture import CircularAperture, aperture_photometry \n",
"from astropy.io import fits\n",
"from astropy import wcs\n",
"from astropy import units as u\n",
"from astropy.stats import sigma_clip\n",
"from astropy.utils.data import download_file\n",
"import os\n",
"from astroquery.mast import Observations"
]
Expand Down Expand Up @@ -126,7 +122,7 @@
"outputs": [],
"source": [
"# Download the data file\n",
"uri = f\"mast:jwst/product/jw01335-o008_t007_nirspec_g235h-f170lp_s3d.fits\"\n",
"uri = \"mast:jwst/product/jw01335-o008_t007_nirspec_g235h-f170lp_s3d.fits\"\n",
"result = Observations.download_file(\n",
" uri, base_url=\"https://mast.stsci.edu/api/v0.1/Download/file\"\n",
")\n",
Expand Down Expand Up @@ -158,7 +154,7 @@
"# Window the wavelength range to focus on Hbeta-[OIII]\n",
"spec1d = Spectrum1D.read(filename)\n",
"slice_range = range(500, 1100, 1)\n",
"wavelength = np.array(spec1d.spectral_axis.value)[slice_range[0] : slice_range[-1] + 1]\n",
"wavelength = np.array(spec1d.spectral_axis.value)[slice_range[0]: slice_range[-1] + 1]\n",
"\n",
"# List of cube slices for aperture photometry\n",
"sci_data = []\n",
Expand Down Expand Up @@ -269,19 +265,19 @@
" ]\n",
" print(\"Good data (xmin,xmax), (ymin,ymax):\", data_xrange, data_yrange)\n",
" good_data = np.nan_to_num(\n",
" data[:, data_yrange[0] : data_yrange[1], data_xrange[0] : data_xrange[1]]\n",
" data[:, data_yrange[0]: data_yrange[1], data_xrange[0]: data_xrange[1]]\n",
" )\n",
" good_var = var[:, data_yrange[0] : data_yrange[1], data_xrange[0] : data_xrange[1]]\n",
" good_var = var[:, data_yrange[0]: data_yrange[1], data_xrange[0]: data_xrange[1]]\n",
"\n",
"except Exception:\n",
" print(\"There is no Subset 2 selected in the cube viewer.\")\n",
" region1_exists = False\n",
" data_xrange = [7, 36]\n",
" data_yrange = [6, 33]\n",
" good_data = np.nan_to_num(\n",
" data[:, data_yrange[0] : data_yrange[1], data_xrange[0] : data_xrange[1]]\n",
" data[:, data_yrange[0]: data_yrange[1], data_xrange[0]: data_xrange[1]]\n",
" )\n",
" good_var = var[:, data_yrange[0] : data_yrange[1], data_xrange[0] : data_xrange[1]]\n",
" good_var = var[:, data_yrange[0]: data_yrange[1], data_xrange[0]: data_xrange[1]]\n",
" print(\"Using default good data (xmin,xmax), (ymin,ymax):\", data_xrange, data_yrange)"
]
},
Expand Down Expand Up @@ -459,7 +455,7 @@
"try:\n",
" ax1.plot(\n",
" wavelength,\n",
" spectrum_subset1.flux.value[slice_range[0] : slice_range[-1] + 1],\n",
" spectrum_subset1.flux.value[slice_range[0]: slice_range[-1] + 1],\n",
" c=\"r\",\n",
" label=\"Subset1\",\n",
" alpha=0.4,\n",
Expand Down Expand Up @@ -541,11 +537,11 @@
"psf_model_padded = np.pad(psf_model, ((0, 0), (4, 5), (6, 7)), \"constant\")\n",
"\n",
"# Sum over wavelength\n",
"psf_model_sum = np.sum(psf_model_padded[slice_range[0] : slice_range[-1] + 1], axis=0)\n",
"psf_model_sum = np.sum(psf_model_padded[slice_range[0]: slice_range[-1] + 1], axis=0)\n",
"\n",
"# Sum over spaxels\n",
"psf_model_fnusum = np.sum(\n",
" psf_model_padded[slice_range[0] : slice_range[-1] + 1], axis=(1, 2)\n",
" psf_model_padded[slice_range[0]: slice_range[-1] + 1], axis=(1, 2)\n",
")"
]
},
Expand Down Expand Up @@ -593,9 +589,9 @@
")\n",
"\n",
"good_psf_model = psf_model_aligned[\n",
" slice_range[0] : slice_range[-1] + 1,\n",
" data_yrange[0] : data_yrange[1],\n",
" data_xrange[0] : data_xrange[1],\n",
" slice_range[0]: slice_range[-1] + 1,\n",
" data_yrange[0]: data_yrange[1],\n",
" data_xrange[0]: data_xrange[1],\n",
"]\n",
"\n",
"# Sum over wavelength\n",
Expand Down

0 comments on commit 0ce8c03

Please sign in to comment.