diff --git a/notebooks/psf_photometry/NIRCam_PSF_Photometry_Example.ipynb b/notebooks/psf_photometry/NIRCam_PSF_Photometry_Example.ipynb index 01a3ccc27..0ec62c837 100644 --- a/notebooks/psf_photometry/NIRCam_PSF_Photometry_Example.ipynb +++ b/notebooks/psf_photometry/NIRCam_PSF_Photometry_Example.ipynb @@ -54,101 +54,54 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Data Download Functions" + "## Imports" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "import os\n", - "import tarfile\n", - "import urllib.request\n", - "\n", - "# Set environmental variables\n", - "os.environ[\"WEBBPSF_PATH\"] = \"./webbpsf-data/webbpsf-data\"\n", - "os.environ[\"PYSYN_CDBS\"] = \"./grp/redcat/trds/\"\n", - "\n", - "# WEBBPSF Data\n", - "boxlink = 'https://stsci.box.com/shared/static/qxpiaxsjwo15ml6m4pkhtk36c9jgj70k.gz'\n", - "boxfile = './webbpsf-data/webbpsf-data-1.2.1.tar.gz'\n", - "synphot_url = 'http://ssb.stsci.edu/trds/tarfiles/synphot5.tar.gz'\n", - "synphot_file = './synphot5.tar.gz'\n", - "\n", - "webbpsf_folder = './webbpsf-data'\n", - "synphot_folder = './grp'\n", - "\n", - "# Gather webbpsf files\n", - "psfExist = os.path.exists(webbpsf_folder)\n", - "if not psfExist:\n", - " os.makedirs(webbpsf_folder)\n", - " urllib.request.urlretrieve(boxlink, boxfile)\n", - " gzf = tarfile.open(boxfile)\n", - " gzf.extractall(webbpsf_folder)\n", - "\n", - "# Gather synphot files\n", - "synExist = os.path.exists(synphot_folder)\n", - "if not synExist:\n", - " os.makedirs(synphot_folder)\n", - " urllib.request.urlretrieve(synphot_url, synphot_file)\n", - " gzf = tarfile.open(synphot_file)\n", - " gzf.extractall('./')" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Import Functions" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": true + }, "outputs": [], "source": [ "import glob as glob\n", "import os\n", - "import sys\n", "import tarfile\n", "import time\n", - "import urllib.request\n", + "from urllib import request\n", "\n", - "import jwst\n", "import numpy as np\n", "import pandas as pd\n", "import webbpsf\n", "from astropy import units as u\n", - "from astropy import wcs\n", "from astropy.coordinates import SkyCoord, match_coordinates_sky\n", "from astropy.io import fits\n", "from astropy.modeling.fitting import LevMarLSQFitter\n", - "from astropy.nddata import Cutout2D, NDData\n", - "from astropy.stats import gaussian_sigma_to_fwhm, sigma_clipped_stats\n", + "from astropy.nddata import NDData\n", + "from astropy.stats import sigma_clipped_stats\n", "from astropy.table import QTable, Table\n", - "from astropy.visualization import (ImageNormalize, SqrtStretch, ZScaleInterval,\n", - " simple_norm)\n", - "from astropy.wcs.utils import pixel_to_skycoord\n", - "from ipywidgets import interact\n", + "from astropy.visualization import simple_norm\n", "from jwst.datamodels import ImageModel\n", "from photutils.aperture import (CircularAnnulus, CircularAperture,\n", " aperture_photometry)\n", "from photutils.background import MADStdBackgroundRMS, MMMBackground\n", - "from photutils.centroids import centroid_2dg\n", - "from photutils.detection import DAOStarFinder, IRAFStarFinder, find_peaks\n", - "from photutils.psf import (DAOGroup, EPSFBuilder, IntegratedGaussianPRF,\n", - " IterativelySubtractedPSFPhotometry,\n", - " IterativePSFPhotometry, SourceGrouper,\n", - " extract_stars)\n", - "from webbpsf.utils import to_griddedpsfmodel" + "from photutils.detection import DAOStarFinder\n", + "from photutils.psf import (EPSFBuilder, IterativePSFPhotometry, SourceGrouper,\n", + " extract_stars)" ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2024-02-22T19:19:46.987188Z", + "iopub.status.busy": "2024-02-22T19:19:46.986921Z", + "iopub.status.idle": "2024-02-22T19:19:46.990183Z", + "shell.execute_reply": "2024-02-22T19:19:46.989446Z", + "shell.execute_reply.started": "2024-02-22T19:19:46.987167Z" + } + }, "source": [ "## Import Plotting Functions" ] @@ -160,8 +113,7 @@ "outputs": [], "source": [ "%matplotlib inline\n", - "from matplotlib import style, pyplot as plt\n", - "import matplotlib.patches as patches\n", + "from matplotlib import pyplot as plt\n", "import matplotlib.ticker as ticker\n", "\n", "plt.rcParams['image.cmap'] = 'viridis'\n", @@ -173,6 +125,47 @@ "font2 = {'family': 'helvetica', 'color': 'black', 'weight': 'normal', 'size': '20'}" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Download WebbPSF and Synphot Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Set environmental variables\n", + "os.environ[\"WEBBPSF_PATH\"] = \"./webbpsf-data/webbpsf-data\"\n", + "os.environ[\"PYSYN_CDBS\"] = \"./grp/redcat/trds/\"\n", + "\n", + "# WEBBPSF Data\n", + "boxlink = 'https://stsci.box.com/shared/static/qxpiaxsjwo15ml6m4pkhtk36c9jgj70k.gz'\n", + "boxfile = './webbpsf-data/webbpsf-data-LATEST.tar.gz'\n", + "synphot_url = 'http://ssb.stsci.edu/trds/tarfiles/synphot5.tar.gz'\n", + "synphot_file = './synphot5.tar.gz'\n", + "\n", + "webbpsf_folder = './webbpsf-data'\n", + "synphot_folder = './grp'\n", + "\n", + "# Gather webbpsf files\n", + "if not os.path.exists(webbpsf_folder):\n", + " os.makedirs(webbpsf_folder)\n", + " request.urlretrieve(boxlink, boxfile)\n", + " gzf = tarfile.open(boxfile)\n", + " gzf.extractall(webbpsf_folder)\n", + "\n", + "# Gather synphot files\n", + "if not os.path.exists(synphot_folder):\n", + " os.makedirs(synphot_folder)\n", + " request.urlretrieve(synphot_url, synphot_file)\n", + " gzf = tarfile.open(synphot_file)\n", + " gzf.extractall('./')" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -213,12 +206,11 @@ "filtlist_long = []\n", "\n", "if not glob.glob('./*cal*fits'):\n", - "\n", " print(\"Downloading images\")\n", "\n", " boxlink_images_lev2 = 'https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/stellar_photometry/images_level2.tar.gz'\n", " boxfile_images_lev2 = './images_level2.tar.gz'\n", - " urllib.request.urlretrieve(boxlink_images_lev2, boxfile_images_lev2)\n", + " request.urlretrieve(boxlink_images_lev2, boxfile_images_lev2)\n", "\n", " tar = tarfile.open(boxfile_images_lev2, 'r')\n", " tar.extractall()\n", @@ -227,12 +219,10 @@ " images = sorted(glob.glob(os.path.join(images_dir, \"*cal.fits\")))\n", "\n", "else:\n", - "\n", " images_dir = './'\n", " images = sorted(glob.glob(os.path.join(images_dir, \"*cal.fits\")))\n", "\n", "for image in images:\n", - "\n", " im = fits.open(image)\n", " f = im[0].header['FILTER']\n", " d = im[0].header['DETECTOR']\n", @@ -261,9 +251,7 @@ " unique_list_filters_long = []\n", "\n", " for x in ff_short:\n", - "\n", " if x not in unique_list_filters_short:\n", - "\n", " dict_filter_short.setdefault(x, {})\n", "\n", " for x in ff_long:\n", @@ -342,56 +330,7 @@ "source": [ "## Display the images\n", "\n", - "To check that our images do not present artifacts and can be used in the analysis, we display them using an interactive cursor that allows to shuffle through the different images for each filter.\n", - "\n", - "### Note for developers: \n", - "\n", - "this is only a sketch of what I would like to show (I am not very familiar with ipywidgets). Would it be possible to show both filters at the same time, in a 2 window panel as in the static plot below? Or even better, have a widget control that allows to select the filters available and then use interact to cycle through the images? " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# cell for display images using ipywidgets\n", - "\n", - "def browse_images(images):\n", - " n = len(images)\n", - "\n", - " def view_image(image):\n", - " det = 'NRCB1'\n", - " filt = 'F115W'\n", - " im = fits.open(dict_images[det][filt]['images'][image])\n", - "\n", - " data_sb = im[1].data\n", - " norm = simple_norm(data_sb, 'sqrt', percent=99.) \n", - " plt.figure(figsize=(10, 10))\n", - "\n", - " plt.title(filt)\n", - " plt.imshow(data_sb, norm=norm, cmap='Greys') \n", - " plt.show()\n", - "\n", - " interact(view_image, image=(0, n - 1))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "browse_images(dict_images['NRCB1']['F115W']['images'])" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Note for developers: \n", - "\n", - "Cell below should be removed once we finalize the interactive one above." + "Check that our images do not present artifacts and can be used in the analysis." ] }, { @@ -404,7 +343,6 @@ "\n", "for det in dets_short:\n", " for i, filt in enumerate(filts_short):\n", - "\n", " image = fits.open(dict_images[det][filt]['images'][0])\n", " data_sb = image[1].data\n", "\n", @@ -469,9 +407,7 @@ "outputs": [], "source": [ "def create_psf_model(fov=11, create_grid=False, num=9, save_psf=False, detsampled=False):\n", - "\n", " nrc = webbpsf.NIRCam()\n", - "\n", " nrc.detector = det \n", " nrc.filter = filt\n", "\n", @@ -494,7 +430,6 @@ " num = num\n", "\n", " if save_psf:\n", - "\n", " outname = \"./PSF_%s_samp4_G5V_fov%d_npsfs%d.fits\" % (filt, fov, num)\n", " nrc.psf_grid(num_psfs=num, oversample=4, source=src, all_detectors=False, fov_pixels=fov,\n", " save=True, outfile=outname, use_detsampled_psf=detsampled)\n", @@ -1069,7 +1004,7 @@ " psf_shape = (11, 11)\n", " \n", " phot = IterativePSFPhotometry(psf_model, psf_shape, daofind,\n", - " grouper=grouper, fitter=LevMarLSQFitter(),\n", + " grouper=grouper, fitter=fitter,\n", " maxiters=2, aperture_radius=ap_radius[j])\n", " result = phot(data_sub)\n", " \n", @@ -1226,14 +1161,14 @@ "\n", " boxlink_cat_f115w = 'https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/stellar_photometry/phot_cat_F115W.tar.gz'\n", " boxfile_cat_f115w = './phot_cat_F115W.tar.gz'\n", - " urllib.request.urlretrieve(boxlink_cat_f115w, boxfile_cat_f115w)\n", + " request.urlretrieve(boxlink_cat_f115w, boxfile_cat_f115w)\n", "\n", " tar = tarfile.open(boxfile_cat_f115w, 'r')\n", " tar.extractall()\n", "\n", " boxlink_cat_f200w = 'https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/stellar_photometry/phot_cat_F200W.tar.gz'\n", " boxfile_cat_f200w = './phot_cat_F200W.tar.gz'\n", - " urllib.request.urlretrieve(boxlink_cat_f200w, boxfile_cat_f200w)\n", + " request.urlretrieve(boxlink_cat_f200w, boxfile_cat_f200w)\n", "\n", " tar = tarfile.open(boxfile_cat_f200w, 'r')\n", " tar.extractall()\n", @@ -1484,12 +1419,12 @@ "\n", "ax1.scatter(delta_x_f115w, delta_y_f115w, s=1, color='gray')\n", "\n", - "ax1.set_xlabel('$\\Delta$ X (px)', fontdict=font2)\n", - "ax1.set_ylabel('$\\Delta$ Y (px)', fontdict=font2)\n", + "ax1.set_xlabel(r'$\\Delta$ X (px)', fontdict=font2)\n", + "ax1.set_ylabel(r'$\\Delta$ Y (px)', fontdict=font2)\n", "ax1.set_title(filt1, fontdict=font2)\n", - "ax1.text(xlim0 + 0.05, ylim1 - 0.15, ' $\\Delta$ X = %5.3f $\\pm$ %5.3f' % (d_x_f115w, sigma_d_x_f115w),\n", + "ax1.text(xlim0 + 0.05, ylim1 - 0.15, r'$\\Delta$ X = %5.3f $\\pm$ %5.3f' % (d_x_f115w, sigma_d_x_f115w),\n", " color='k', fontdict=font2)\n", - "ax1.text(xlim0 + 0.05, ylim1 - 0.30, ' $\\Delta$ Y = %5.3f $\\pm$ %5.3f' % (d_y_f115w, sigma_d_y_f115w),\n", + "ax1.text(xlim0 + 0.05, ylim1 - 0.30, r'$\\Delta$ Y = %5.3f $\\pm$ %5.3f' % (d_y_f115w, sigma_d_y_f115w),\n", " color='k', fontdict=font2)\n", "ax1.plot([0, 0], [ylim0, ylim1], color='k', lw=2, ls='--')\n", "ax1.plot([xlim0, xlim1], [0, 0], color='k', lw=2, ls='--')\n", @@ -1517,15 +1452,15 @@ "_, d_y_f200w, sigma_d_y_f200w = sigma_clipped_stats(delta_y_f200w)\n", "\n", "ax2.scatter(delta_x_f200w, delta_y_f200w, s=1, color='gray')\n", - "ax2.text(xlim0 + 0.05, ylim1 - 0.15, ' $\\Delta$ X = %5.3f $\\pm$ %5.3f' % (d_x_f200w, sigma_d_x_f200w),\n", + "ax2.text(xlim0 + 0.05, ylim1 - 0.15, r'$\\Delta$ X = %5.3f $\\pm$ %5.3f' % (d_x_f200w, sigma_d_x_f200w),\n", " color='k', fontdict=font2)\n", - "ax2.text(xlim0 + 0.05, ylim1 - 0.30, ' $\\Delta$ Y = %5.3f $\\pm$ %5.3f' % (d_y_f200w, sigma_d_y_f200w),\n", + "ax2.text(xlim0 + 0.05, ylim1 - 0.30, r'$\\Delta$ Y = %5.3f $\\pm$ %5.3f' % (d_y_f200w, sigma_d_y_f200w),\n", " color='k', fontdict=font2)\n", "ax2.plot([0, 0], [ylim0, ylim1], color='k', lw=2, ls='--')\n", "ax2.plot([xlim0, xlim1], [0, 0], color='k', lw=2, ls='--')\n", "\n", - "ax2.set_xlabel('$\\Delta$ X (px)', fontdict=font2)\n", - "ax2.set_ylabel('$\\Delta$ Y (px)', fontdict=font2)\n", + "ax2.set_xlabel(r'$\\Delta$ X (px)', fontdict=font2)\n", + "ax2.set_ylabel(r'$\\Delta$ Y (px)', fontdict=font2)\n", "ax2.set_title(filt2, fontdict=font2)\n", "\n", "plt.tight_layout()" @@ -1560,7 +1495,7 @@ "ax1.plot([xlim0, xlim1], [0, 0], color='k', lw=2, ls='--')\n", "\n", "ax1.set_xlabel(filt1 + '_inst', fontdict=font2)\n", - "ax1.set_ylabel('$\\Delta$ X (px)', fontdict=font2)\n", + "ax1.set_ylabel(r'$\\Delta$ X (px)', fontdict=font2)\n", "\n", "ax2 = plt.subplot(2, 2, 2)\n", "\n", @@ -1576,7 +1511,7 @@ "ax2.plot([xlim0, xlim1], [0, 0], color='k', lw=2, ls='--')\n", "\n", "ax2.set_xlabel(filt1 + '_inst', fontdict=font2)\n", - "ax2.set_ylabel('$\\Delta$ Y (px)', fontdict=font2)\n", + "ax2.set_ylabel(r'$\\Delta$ Y (px)', fontdict=font2)\n", "\n", "ax3 = plt.subplot(2, 2, 3)\n", "\n", @@ -1594,7 +1529,7 @@ "ax3.plot([xlim0, xlim1], [0, 0], color='k', lw=2, ls='--')\n", "\n", "ax3.set_xlabel(filt2 + '_inst', fontdict=font2)\n", - "ax3.set_ylabel('$\\Delta$ X (px)', fontdict=font2)\n", + "ax3.set_ylabel(r'$\\Delta$ X (px)', fontdict=font2)\n", "\n", "ax4 = plt.subplot(2, 2, 4)\n", "\n", @@ -1610,7 +1545,7 @@ "ax4.plot([xlim0, xlim1], [0, 0], color='k', lw=2, ls='--')\n", "\n", "ax4.set_xlabel(filt2 + '_inst', fontdict=font2)\n", - "ax4.set_ylabel('$\\Delta$ Y (px)', fontdict=font2)\n", + "ax4.set_ylabel(r'$\\Delta$ Y (px)', fontdict=font2)\n", "\n", "plt.tight_layout()" ] @@ -1796,7 +1731,7 @@ "ax2 = plt.subplot(2, 2, 2)\n", "\n", "ax2.set_xlabel(filt1 + '_inst', fontdict=font2)\n", - "ax2.set_ylabel('$\\sigma$' + filt1, fontdict=font2)\n", + "ax2.set_ylabel(r'$\\sigma$' + filt1, fontdict=font2)\n", "\n", "xlim0 = -9\n", "xlim1 = -1.5\n", @@ -1816,7 +1751,7 @@ "ax3 = plt.subplot(2, 2, 4)\n", "\n", "ax3.set_xlabel(filt2 + '_inst', fontdict=font2)\n", - "ax3.set_ylabel('$\\sigma$' + filt2, fontdict=font2)\n", + "ax3.set_ylabel(r'$\\sigma$' + filt2, fontdict=font2)\n", "\n", "ax3.set_xlim(xlim0, xlim1)\n", "ax3.set_ylim(ylim0, ylim1)\n", @@ -1879,7 +1814,7 @@ "\n", " boxlink_images_lev3 = 'https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/stellar_photometry/images_level3.tar.gz'\n", " boxfile_images_lev3 = './images_level3.tar.gz'\n", - " urllib.request.urlretrieve(boxlink_images_lev3, boxfile_images_lev3)\n", + " request.urlretrieve(boxlink_images_lev3, boxfile_images_lev3)\n", "\n", " tar = tarfile.open(boxfile_images_lev3, 'r')\n", " tar.extractall()\n", @@ -2191,10 +2126,10 @@ "\n", " boxlink_apcorr_table = 'https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/stellar_photometry/aperture_correction_table.txt'\n", " boxfile_apcorr_table = './aperture_correction_table.txt'\n", - " urllib.request.urlretrieve(boxlink_apcorr_table, boxfile_apcorr_table)\n", + " request.urlretrieve(boxlink_apcorr_table, boxfile_apcorr_table)\n", " ap_tab = './aperture_correction_table.txt'\n", "\n", - "aper_table = pd.read_csv(ap_tab, header=None, sep='\\s+', index_col=0,\n", + "aper_table = pd.read_csv(ap_tab, header=None, sep=r'\\s+', index_col=0,\n", " names=['filter', 'pupil', 'wave', 'r10', 'r20', 'r30', 'r40', 'r50', 'r60', 'r70', 'r80',\n", " 'r85', 'r90', 'sky_flux_px', 'apcorr10', 'apcorr20', 'apcorr30', 'apcorr40',\n", " 'apcorr50', 'apcorr60', 'apcorr70', 'apcorr80', 'apcorr85', 'apcorr90', 'sky_in',\n", @@ -2334,7 +2269,7 @@ "\n", "ax1.scatter(f115w_psf_matched, diff_f115w, s=50, color='k')\n", "ax1.plot([xlim0, xlim1], [zp_f115w, zp_f115w], color='r', lw=5, ls='--')\n", - "ax1.text(xlim0 + 0.05, ylim1 - 0.15, filt1 + ' Zeropoint = %5.3f $\\pm$ %5.3f' % (zp_f115w, zp_sigma_f115w), color='k', fontdict=font2)\n", + "ax1.text(xlim0 + 0.05, ylim1 - 0.15, filt1 + r' Zeropoint = %5.3f $\\pm$ %5.3f' % (zp_f115w, zp_sigma_f115w), color='k', fontdict=font2)\n", " \n", "ax2 = plt.subplot(2, 1, 2)\n", "\n", @@ -2366,7 +2301,7 @@ "\n", "ax2.scatter(f200w_psf_matched, diff_f200w, s=50, color='k')\n", "ax2.plot([xlim0, xlim1], [zp_f200w, zp_f200w], color='r', lw=5, ls='--')\n", - "ax2.text(xlim0 + 0.05, ylim1 - 0.15, filt2 + ' Zeropoint = %5.3f $\\pm$ %5.3f' % (zp_f200w, zp_sigma_f200w), color='k', fontdict=font2)\n", + "ax2.text(xlim0 + 0.05, ylim1 - 0.15, filt2 + r' Zeropoint = %5.3f $\\pm$ %5.3f' % (zp_f200w, zp_sigma_f200w), color='k', fontdict=font2)\n", " \n", "plt.tight_layout()" ] @@ -2393,10 +2328,10 @@ "\n", " boxlink_input_cat = 'https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/stellar_photometry/pointsource.cat'\n", " boxfile_input_cat = './pointsource.cat'\n", - " urllib.request.urlretrieve(boxlink_input_cat, boxfile_input_cat)\n", + " request.urlretrieve(boxlink_input_cat, boxfile_input_cat)\n", " input_cat = './pointsource.cat'\n", "\n", - "cat = pd.read_csv(input_cat, header=None, sep='\\s+', names=['ra_in', 'dec_in', 'f070w_in', 'f115w_in',\n", + "cat = pd.read_csv(input_cat, header=None, sep=r'\\s+', names=['ra_in', 'dec_in', 'f070w_in', 'f115w_in',\n", " 'f200w_in', 'f277w_in', 'f356w_in', 'f444w_in'],\n", " comment='#', skiprows=7, usecols=range(0, 8))\n", "\n", @@ -2528,7 +2463,7 @@ "ax1 = plt.subplot(2, 1, 1)\n", "\n", "ax1.set_xlabel(filt1, fontdict=font2)\n", - "ax1.set_ylabel('$\\Delta$ Mag', fontdict=font2)\n", + "ax1.set_ylabel(r'$\\Delta$ Mag', fontdict=font2)\n", "\n", "radec_input = SkyCoord(cat_sel['ra_in'], cat_sel['dec_in'], unit='deg')\n", "\n", @@ -2557,13 +2492,13 @@ "\n", "ax1.scatter(f115w_psf_cfr, diff_f115w_cfr, s=5, color='k')\n", "ax1.plot([xlim0, xlim1], [0, 0], color='r', lw=5, ls='--')\n", - "ax1.text(xlim0 + 0.05, ylim1 - 0.15, filt1 + ' $\\Delta$ Mag = %5.3f $\\pm$ %5.3f'\n", + "ax1.text(xlim0 + 0.05, ylim1 - 0.15, filt1 + r' $\\Delta$ Mag = %5.3f $\\pm$ %5.3f'\n", " % (med_diff_f115w_cfr, sig_diff_f115w_cfr), color='k', fontdict=font2)\n", "\n", "ax2 = plt.subplot(2, 1, 2)\n", "\n", "ax2.set_xlabel(filt2, fontdict=font2)\n", - "ax2.set_ylabel('$\\Delta$ Mag', fontdict=font2)\n", + "ax2.set_ylabel(r'$\\Delta$ Mag', fontdict=font2)\n", "\n", "idx_f200w_cfr, d2d_f200w_cfr, _ = match_coordinates_sky(radec_input, radec_f200w)\n", "\n", @@ -2590,7 +2525,7 @@ "\n", "ax2.scatter(f200w_psf_cfr, diff_f200w_cfr, s=5, color='k')\n", "ax2.plot([xlim0, xlim1], [0, 0], color='r', lw=5, ls='--')\n", - "ax2.text(xlim0 + 0.05, ylim1 - 0.15, filt2 + ' $\\Delta$ Mag = %5.3f $\\pm$ %5.3f'\n", + "ax2.text(xlim0 + 0.05, ylim1 - 0.15, filt2 + r' $\\Delta$ Mag = %5.3f $\\pm$ %5.3f'\n", " % (med_diff_f200w_cfr, sig_diff_f200w_cfr), color='k', fontdict=font2)\n", "\n", "plt.tight_layout()" @@ -2619,8 +2554,8 @@ "ax1.yaxis.set_major_locator(ticker.AutoLocator())\n", "ax1.yaxis.set_minor_locator(ticker.AutoMinorLocator())\n", "\n", - "ax1.set_xlabel('$\\Delta$ RA (mas)', fontdict=font2)\n", - "ax1.set_ylabel('$\\Delta$ Dec (mas)', fontdict=font2)\n", + "ax1.set_xlabel(r'$\\Delta$ RA (mas)', fontdict=font2)\n", + "ax1.set_ylabel(r'$\\Delta$ Dec (mas)', fontdict=font2)\n", "ax1.set_title(filt1, fontdict=font2)\n", "\n", "ra_f115w_inp_cfr = np.array(cat_sel['ra_in'][sep_f115w_cfr])\n", @@ -2643,9 +2578,9 @@ "ax1.plot([0, 0], [ylim0, ylim1], color='k', lw=2, ls='--')\n", "ax1.plot([xlim0, xlim1], [0, 0], color='k', lw=2, ls='--')\n", "\n", - "ax1.text(xlim0 + 0.05, ylim1 - 1.50, ' $\\Delta$ RA (mas) = %5.3f $\\pm$ %5.3f'\n", + "ax1.text(xlim0 + 0.05, ylim1 - 1.50, r'$\\Delta$ RA (mas) = %5.3f $\\pm$ %5.3f'\n", " % (med_diffra_f115w_cfr, sig_diffra_f115w_cfr), color='k', fontdict=font2)\n", - "ax1.text(xlim0 + 0.05, ylim1 - 3.0, ' $\\Delta$ Dec (mas) = %5.3f $\\pm$ %5.3f'\n", + "ax1.text(xlim0 + 0.05, ylim1 - 3.0, r'$\\Delta$ Dec (mas) = %5.3f $\\pm$ %5.3f'\n", " % (med_diffdec_f115w_cfr, sig_diffdec_f115w_cfr), color='k', fontdict=font2)\n", "\n", "ax2 = plt.subplot(1, 2, 2)\n", @@ -2664,8 +2599,8 @@ "ax2.yaxis.set_major_locator(ticker.AutoLocator())\n", "ax2.yaxis.set_minor_locator(ticker.AutoMinorLocator())\n", "\n", - "ax2.set_xlabel('$\\Delta$ RA (mas)', fontdict=font2)\n", - "ax2.set_ylabel('$\\Delta$ Dec (mas)', fontdict=font2)\n", + "ax2.set_xlabel(r'$\\Delta$ RA (mas)', fontdict=font2)\n", + "ax2.set_ylabel(r'$\\Delta$ Dec (mas)', fontdict=font2)\n", "\n", "ra_f200w_inp_cfr = np.array(cat_sel['ra_in'][sep_f200w_cfr])\n", "ra_f200w_psf_cfr = np.array(radec_f200w.ra[idx_f200w_cfr[sep_f200w_cfr]])\n", @@ -2687,9 +2622,9 @@ "ax2.plot([0, 0], [ylim0, ylim1], color='k', lw=2, ls='--')\n", "ax2.plot([xlim0, xlim1], [0, 0], color='k', lw=2, ls='--')\n", "\n", - "ax2.text(xlim0 + 0.05, ylim1 - 1.50, ' $\\Delta$ RA (mas) = %5.3f $\\pm$ %5.3f'\n", + "ax2.text(xlim0 + 0.05, ylim1 - 1.50, r'$\\Delta$ RA (mas) = %5.3f $\\pm$ %5.3f'\n", " % (med_diffra_f200w_cfr, sig_diffra_f200w_cfr), color='k', fontdict=font2)\n", - "ax2.text(xlim0 + 0.05, ylim1 - 3.0, ' $\\Delta$ Dec (mas) = %5.3f $\\pm$ %5.3f'\n", + "ax2.text(xlim0 + 0.05, ylim1 - 3.0, r'$\\Delta$ Dec (mas) = %5.3f $\\pm$ %5.3f'\n", " % (med_diffdec_f200w_cfr, sig_diffdec_f200w_cfr), color='k', fontdict=font2)\n", "\n", "plt.tight_layout()" @@ -2740,7 +2675,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.11.7" } }, "nbformat": 4, diff --git a/notebooks/psf_photometry/requirements.txt b/notebooks/psf_photometry/requirements.txt index dc69fd6f6..f1b977405 100644 --- a/notebooks/psf_photometry/requirements.txt +++ b/notebooks/psf_photometry/requirements.txt @@ -1,8 +1,7 @@ numpy>=1.25.2 pandas>=2.1.0 -jwst>=1.11.4 astropy>=5.3.3 -photutils>=1.9.0 +photutils>=1.11.0 ipywidgets>=8.1.1 matplotlib>=3.7.2 webbpsf>=1.2.1