diff --git a/_config.yml b/_config.yml index 8cd1c3728..894344bab 100644 --- a/_config.yml +++ b/_config.yml @@ -59,7 +59,6 @@ exclude_patterns: [notebooks/DrizzlePac/align_mosaics/align_mosaics.ipynb, notebooks/WFC3/ir_scattered_light_manual_corrections/Correcting_for_Scattered_Light_in_IR_Exposures_by_Manually_Subtracting_Bad_Reads.ipynb, notebooks/WFC3/photometry_examples/phot_examples.ipynb, notebooks/WFC3/tvb_flattenramp/TVB_flattenramp_notebook.ipynb, - notebooks/WFC3/uvis_pam_corrections/WFC3_UVIS_Pixel_Area_Map_Corrections_for_Subarrays.ipynb, notebooks/WFC3/uvis_time_dependent_photometry/uvis_timedep_phot.ipynb, notebooks/WFC3/zeropoints/zeropoints.ipynb] diff --git a/_toc.yml b/_toc.yml index 8e6eb2729..f5cbbd213 100644 --- a/_toc.yml +++ b/_toc.yml @@ -72,6 +72,6 @@ parts: - file: notebooks/WFC3/persistence/wfc3_ir_persistence.ipynb # - file: notebooks/WFC3/photometry_examples/phot_examples.ipynb # - file: notebooks/WFC3/tvb_flattenramp/TVB_flattenramp_notebook.ipynb -# - file: notebooks/WFC3/uvis_pam_corrections/WFC3_UVIS_Pixel_Area_Map_Corrections_for_Subarrays.ipynb + - file: notebooks/WFC3/uvis_pam_corrections/WFC3_UVIS_Pixel_Area_Map_Corrections_for_Subarrays.ipynb # - file: notebooks/WFC3/uvis_time_dependent_photometry/uvis_timedep_phot.ipynb # - file: notebooks/WFC3/zeropoints/zeropoints.ipynb diff --git a/notebooks/WFC3/uvis_pam_corrections/WFC3_UVIS_Pixel_Area_Map_Corrections_for_Subarrays.ipynb b/notebooks/WFC3/uvis_pam_corrections/WFC3_UVIS_Pixel_Area_Map_Corrections_for_Subarrays.ipynb index e15349d31..4be33422f 100644 --- a/notebooks/WFC3/uvis_pam_corrections/WFC3_UVIS_Pixel_Area_Map_Corrections_for_Subarrays.ipynb +++ b/notebooks/WFC3/uvis_pam_corrections/WFC3_UVIS_Pixel_Area_Map_Corrections_for_Subarrays.ipynb @@ -86,7 +86,7 @@ "- *astroquery* for downloading data from MAST\n", "- *matplotlib.pyplot* for plotting data\n", "- *ginga* for finding min/max outlier pixels\n", - "- *shutil* for copying files from one directory to another" + "- *urlib* for downloading files from a webpage" ] }, { @@ -100,11 +100,10 @@ "outputs": [], "source": [ "%matplotlib inline\n", - "import shutil\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", + "import urllib.request\n", "from astropy.io import fits\n", - "from astroquery.mast import Mast\n", "from astroquery.mast import Observations\n", "from ginga.util.zscale import zscale" ] @@ -305,12 +304,12 @@ "source": [ "data_512 = hdu_512[1].data\n", "\n", - "#We use zcale to find the min and max for plotting\n", + "# We use zcale to find the min and max for plotting\n", "vmin_512, vmax_512 = zscale(data_512)\n", "\n", "im = plt.imshow(data_512, vmin=vmin_512, vmax=vmax_512, origin='lower')\n", "clb = plt.colorbar(im)\n", - "_= clb.ax.set_title('Electrons')" + "_ = clb.ax.set_title('Electrons')" ] }, { @@ -369,7 +368,7 @@ "x1 = int(x0 + scihdr_512['NAXIS1'])\n", "y1 = int(y0 + scihdr_512['NAXIS2'])\n", "\n", - "print (f'(x0, y0, x1, y1) = ({x0}, {y0}, {x1}, {y1})')" + "print(f'(x0, y0, x1, y1) = ({x0}, {y0}, {x1}, {y1})')" ] }, { @@ -390,16 +389,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The UVIS CCD has two chips: UVIS1 and UVIS2.\n", - "\n", - "First, please go to the [WFC3 PAM website](https://www.stsci.edu/hst/instrumentation/wfc3/data-analysis/pixel-area-maps) and download the UVIS1 and UVIS2 PAMs under the \"Download Pixel Area Maps\" header. " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Now, we will use `shutil.copy` to copy the PAMs from your Downloads directory to the present working directory. " + "The UVIS CCD has two chips: UVIS1 and UVIS2. We will download the UVIS1 and UVIS2 PAMs from the [WFC3 PAM website](https://www.stsci.edu/hst/instrumentation/wfc3/data-analysis/pixel-area-maps)." ] }, { @@ -408,35 +398,27 @@ "metadata": {}, "outputs": [], "source": [ - "#Please add the path to your local directory in place of \"pwd\" below\n", - "#Please add the path to your Downloads folder in place of \"downloads\" below\n", - "downloads = '/Users/yourHomeDirectory/Downloads/'\n", - "pwd = '/Users/yourHomeDirectory/PAM_notebook/'" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Copy the content of source to destination\n", - "source_1 = downloads + 'UVIS1wfc3_map.fits'\n", - "source_2 = downloads + 'UVIS2wfc3_map.fits'\n", + "filenames = [\"UVIS1wfc3_map.fits\", \"UVIS2wfc3_map.fits\"]\n", + "\n", + "try:\n", + " for filename in filenames:\n", + " url = (\"https://www.stsci.edu/files/live/sites/www/files/home/hst/instrumentation/\" + \n", + " \"wfc3/data-analysis/pixel-area-maps/_documents/\")\n", + " url += filename\n", "\n", - "dest_path1 = shutil.copy(source_1, pwd) \n", - "dest_path2 = shutil.copy(source_2, pwd) \n", + " with urllib.request.urlopen(url) as response:\n", + " with open(filename, \"wb\") as out_file:\n", + " out_file.write(response.read())\n", "\n", - "# Print path of newly created file\n", - "print(\"Destination path for the UVIS1 PAM:\", dest_path1)\n", - "print(\"Destination path for the UVIS2 PAM:\", dest_path2)" + "except Exception as e:\n", + " print(f\"An error occured: {e}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Now we have our WFC3/UVIS PAM files in our working directory." + "Now, we should have our WFC3/UVIS PAM files in our working directory." ] }, { @@ -463,14 +445,14 @@ "outputs": [], "source": [ "if scihdr_512['CCDCHIP'] == 1:\n", - " pam = fits.getdata('UVIS1wfc3_map.fits')\n", - " pamcorr_data_512 = data_512 * pam[y0:y1, x0:x1]\n", + " pam = fits.getdata('UVIS1wfc3_map.fits')\n", + " pamcorr_data_512 = data_512 * pam[y0:y1, x0:x1]\n", "\n", "elif scihdr_512['CCDCHIP'] == 2:\n", - " pam = fits.getdata('UVIS2wfc3_map.fits')\n", - " pamcorr_data_512 = data_512 * pam[y0:y1, x0:x1]\n", + " pam = fits.getdata('UVIS2wfc3_map.fits')\n", + " pamcorr_data_512 = data_512 * pam[y0:y1, x0:x1]\n", "else:\n", - " raise Exception('Chip case not handled.')\n" + " raise Exception('Chip case not handled.')" ] }, { @@ -488,14 +470,13 @@ "source": [ "diff_data_512 = (pamcorr_data_512 - data_512)\n", "\n", - "\n", - "#We use zcale to find the min and max for plotting\n", + "# We use zcale to find the min and max for plotting\n", "vmin_diff_512, vmax_diff_512 = zscale(diff_data_512)\n", "\n", "im = plt.imshow(diff_data_512, vmin=vmin_diff_512, vmax=vmax_diff_512, origin='lower')\n", "\n", "clb = plt.colorbar(im)\n", - "_= clb.ax.set_title('Electrons')" + "_ = clb.ax.set_title('Electrons')" ] }, { @@ -536,14 +517,12 @@ " pamcorr_data : array\n", " PAM-corrected data.\n", " \"\"\"\n", - "\n", " data = np.copy(data)\n", " x0 = int(np.abs(scihdr['LTV1']))\n", " y0 = int(np.abs(scihdr['LTV2']))\n", " x1 = int(x0 + scihdr['NAXIS1'])\n", " y1 = int(y0 + scihdr['NAXIS2'])\n", " \n", - "\n", " if scihdr['CCDCHIP'] == 1:\n", " pam = fits.getdata(pamdir + 'UVIS1wfc3_map.fits')\n", " pamcorr_data = data * pam[y0:y1, x0:x1]\n", @@ -582,12 +561,12 @@ "metadata": {}, "outputs": [], "source": [ - "#We use zcale to find the min and max for plotting\n", + "# We use zcale to find the min and max for plotting\n", "vmin_1024, vmax_1024 = zscale(data_1024)\n", "\n", "im = plt.imshow(data_1024, vmin=vmin_1024, vmax=vmax_1024, origin='lower')\n", "clb = plt.colorbar(im)\n", - "_= clb.ax.set_title('Electrons')" + "_ = clb.ax.set_title('Electrons')" ] }, { @@ -607,13 +586,13 @@ "source": [ "diff_data_1024 = (pamcorr_data_1024-data_1024)\n", "\n", - "#We use zcale to find the min and max for plotting\n", + "# We use zcale to find the min and max for plotting\n", "vmin_diff_1024, vmax_diff_1024 = zscale(diff_data_1024)\n", "\n", "im = plt.imshow(diff_data_1024, vmin=vmin_diff_1024, vmax=vmax_diff_1024, origin='lower')\n", "\n", "clb = plt.colorbar(im)\n", - "_= clb.ax.set_title('Electrons')" + "_ = clb.ax.set_title('Electrons')" ] }, { @@ -641,12 +620,12 @@ "metadata": {}, "outputs": [], "source": [ - "#We use zcale to find the min and max for plotting\n", + "# We use zcale to find the min and max for plotting\n", "vmin_2048, vmax_2048 = zscale(data_2048)\n", "\n", "im = plt.imshow(data_2048, vmin=vmin_2048, vmax=vmax_2048, origin='lower')\n", "clb = plt.colorbar(im)\n", - "_= clb.ax.set_title('Electrons')" + "_ = clb.ax.set_title('Electrons')" ] }, { @@ -666,13 +645,13 @@ "source": [ "diff_data_2048 = (pamcorr_data_2048-data_2048)\n", "\n", - "#We use zcale to find the min and max for plotting\n", + "# We use zcale to find the min and max for plotting\n", "vmin_diff_2048, vmax_diff_2048 = zscale(diff_data_2048)\n", "\n", "im = plt.imshow(diff_data_2048, vmin=vmin_diff_2048, vmax=vmax_diff_2048, origin='lower')\n", "\n", "clb = plt.colorbar(im)\n", - "_= clb.ax.set_title('Electrons')" + "_ = clb.ax.set_title('Electrons')" ] }, { @@ -738,13 +717,6 @@ "[Top of Page](#top)\n", "\"Space " ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -763,9 +735,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.0" + "version": "3.8.12" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/notebooks/WFC3/uvis_pam_corrections/requirements.txt b/notebooks/WFC3/uvis_pam_corrections/requirements.txt index 6de0ed093..ee67db939 100644 --- a/notebooks/WFC3/uvis_pam_corrections/requirements.txt +++ b/notebooks/WFC3/uvis_pam_corrections/requirements.txt @@ -1,5 +1,5 @@ astropy==5.2.1 astroquery==0.4.6 -ginga==4.1.1 +ginga==4.0.1 matplotlib==3.7.0 numpy==1.23.4