From 0ce8c03c80d356b9b9daa3d05aa49eb10a7c93ae Mon Sep 17 00:00:00 2001 From: Hatice Karatay Date: Thu, 7 Dec 2023 14:36:30 -0500 Subject: [PATCH] Fix remaining style errors --- notebooks/ifu_optimal/ifu_optimal.ipynb | 32 +++++++++++-------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/notebooks/ifu_optimal/ifu_optimal.ipynb b/notebooks/ifu_optimal/ifu_optimal.ipynb index e06bb26f3..23b4248e8 100644 --- a/notebooks/ifu_optimal/ifu_optimal.ipynb +++ b/notebooks/ifu_optimal/ifu_optimal.ipynb @@ -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" ] @@ -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", @@ -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", @@ -269,9 +265,9 @@ " ]\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", @@ -279,9 +275,9 @@ " 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)" ] }, @@ -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", @@ -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", ")" ] }, @@ -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",