diff --git a/notebooks/psf_photometry/MIRI/miri_1028.ipynb b/notebooks/psf_photometry/MIRI/miri_1028.ipynb index 466c8bba8..04e165f06 100644 --- a/notebooks/psf_photometry/MIRI/miri_1028.ipynb +++ b/notebooks/psf_photometry/MIRI/miri_1028.ipynb @@ -194,13 +194,9 @@ "from jwst.datamodels import ImageModel\n", "\n", "# Background and PSF Functions\n", - "#\n", - "from photutils.background import MMMBackground, MADStdBackgroundRMS\n", - "from photutils.detection import DAOStarFinder\n", - "\n", - "# Photutils library and tools\n", "import photutils\n", - "from photutils import MMMBackground" + "from photutils.background import MMMBackground, MADStdBackgroundRMS\n", + "from photutils.detection import DAOStarFinder" ] }, { @@ -733,13 +729,19 @@ "outputs": [], "source": [ "# Do PSF Photometry using space_phot (details of fitting are in documentation)\n", + "jwst_obs.psf_photometry(\n", + " psfs,\n", + " source_location,\n", + " bounds={\n", + " 'flux': [-10000, 10000],\n", + " 'centroid': [-2, 2],\n", + " 'bkg': [0, 50]\n", + " },\n", + " fit_width=9,\n", + " fit_bkg=True,\n", + " fit_flux='single'\n", + ")\n", "\n", - "jwst_obs.psf_photometry(psfs, source_location, bounds={'flux': [-10000, 10000],\n", - " 'centroid': [-2, 2],\n", - " 'bkg': [0, 50]},\n", - " fit_width=9,\n", - " fit_bkg=True,\n", - " fit_flux='single')\n", "jwst_obs.plot_psf_fit()\n", "plt.show()\n", "\n", @@ -984,12 +986,19 @@ "source": [ "# Do PSF Photometry using space_phot (details of fitting are in documentation)\n", "# See detailed notes in Section 3.1 above about the fitting process and diagnostics\n", - "jwst3_obs.psf_photometry(psf3, source_location, bounds={'flux' : [-10000, 10000],\n", - " 'centroid': [-2, 2],\n", - " 'bkg': [0, 50]},\n", - " fit_width=9,\n", - " fit_bkg=True,\n", - " fit_flux=True)\n", + "jwst3_obs.psf_photometry(\n", + " psf3,\n", + " source_location,\n", + " bounds={\n", + " 'flux': [-10000, 10000],\n", + " 'centroid': [-2, 2],\n", + " 'bkg': [0, 50]\n", + " },\n", + " fit_width=9,\n", + " fit_bkg=True,\n", + " fit_flux=True\n", + ")\n", + "\n", "\n", "jwst_obs.plot_psf_fit()\n", "plt.show()\n", @@ -1448,13 +1457,20 @@ }, "outputs": [], "source": [ - "jwst3_obs.psf_photometry(psf3, source_location, bounds={'flux': [-1000, 1000],\n", - " # 'centroid': [-2, 2],\n", - " 'bkg': [0, 50]},\n", - " fit_width=9,\n", - " fit_bkg=True, \n", - " fit_centroid=False,\n", - " fit_flux=True)\n", + "jwst3_obs.psf_photometry(\n", + " psf3,\n", + " source_location,\n", + " bounds={\n", + " 'flux': [-1000, 1000],\n", + " # 'centroid': [-2, 2],\n", + " 'bkg': [0, 50]\n", + " },\n", + " fit_width=9,\n", + " fit_bkg=True,\n", + " fit_centroid=False,\n", + " fit_flux=True\n", + ")\n", + "\n", "\n", "jwst3_obs.plot_psf_fit()\n", "plt.show()\n", @@ -1779,7 +1795,7 @@ "# Create a grid for fast lookup using WebbPSF. The larger the number of grid points, the better the photometric precision.\n", "# Developer note. Would be great to have a fast/approximate look up table. \n", "jwst_obs = space_phot.observation2(lvl2)\n", - "grid = space_phot.util.get_jwst_psf_grid(jwst_obs,num_psfs=4)" + "grid = space_phot.util.get_jwst_psf_grid(jwst_obs, num_psfs=4)" ] }, { diff --git a/notebooks/psf_photometry/NIRCam/nircam_spacephot.ipynb b/notebooks/psf_photometry/NIRCam/nircam_spacephot.ipynb index 107434a87..3070c5e31 100644 --- a/notebooks/psf_photometry/NIRCam/nircam_spacephot.ipynb +++ b/notebooks/psf_photometry/NIRCam/nircam_spacephot.ipynb @@ -712,13 +712,20 @@ "source": [ "# Do PSF Photometry using space_phot (details of fitting are in documentation)\n", "# https://st-phot.readthedocs.io/en/latest/examples/plot_a_psf.html#jwst-images\n", - "jwst_obs.psf_photometry(psfs, source_location, bounds={'flux': [-10, 1000],\n", - " #'centroid': [-2,2],\n", - " 'bkg': [0, 50]},\n", - " fit_width=5,\n", - " fit_bkg=True,\n", - " fit_centroid='fixed',\n", - " fit_flux='single')\n", + "jwst_obs.psf_photometry(\n", + " psfs,\n", + " source_location,\n", + " bounds={\n", + " 'flux': [-10, 1000],\n", + " # 'centroid': [-2, 2],\n", + " 'bkg': [0, 50]\n", + " },\n", + " fit_width=5,\n", + " fit_bkg=True,\n", + " fit_centroid='fixed',\n", + " fit_flux='single'\n", + ")\n", + "\n", "jwst_obs.plot_psf_fit()\n", "plt.show()\n", "\n", @@ -778,7 +785,7 @@ "norm1 = simple_norm(ref_data, stretch='linear', min_cut=-1, max_cut=10)\n", "\n", "plt.imshow(ref_data, origin='lower',\n", - " norm=norm1, cmap='gray')\n", + " norm=norm1, cmap='gray')\n", "plt.gca().tick_params(labelcolor='none', axis='both', color='none')\n", "plt.show()" ] @@ -830,13 +837,19 @@ }, "outputs": [], "source": [ - "jwst3_obs.psf_photometry(psf3, source_location, bounds={'flux': [-10, 1000],\n", - " #'centroid': [-2,2],\n", - " 'bkg': [0, 50]},\n", - " fit_width=5,\n", - " fit_bkg=False,\n", - " fit_centroid=False,\n", - " fit_flux=True)\n", + "jwst3_obs.psf_photometry(\n", + " psf3,\n", + " source_location,\n", + " bounds={\n", + " 'flux': [-10, 1000],\n", + " # 'centroid': [-2, 2],\n", + " 'bkg': [0, 50]\n", + " },\n", + " fit_width=5,\n", + " fit_bkg=False,\n", + " fit_centroid=False,\n", + " fit_flux=True\n", + ")\n", "\n", "jwst3_obs.plot_psf_fit()\n", "plt.show()\n", @@ -1052,7 +1065,7 @@ "found_stars_sel = found_stars[mask]\n", "\n", "print('Number of stars found originally:', len(found_stars))\n", - "print('Number of stars in final selection:', len(found_stars_sel))\n" + "print('Number of stars in final selection:', len(found_stars_sel))" ] }, { @@ -1177,13 +1190,19 @@ " print('Starting', counter+1., ' of', len(skycoords), ':', source_location)\n", " # psfs = space_phot.get_jwst_psf(jwst_obs,source_location) # ,num_psfs=4)\n", " psfs = space_phot.util.get_jwst_psf_from_grid(jwst_obs, source_location, grid)\n", - " jwst_obs.psf_photometry(psfs, source_location, bounds={'flux': [-100, 1000],\n", - " 'centroid': [-2., 2.],\n", - " 'bkg': [0, 50]},\n", - " fit_width=3,\n", - " fit_bkg=False,\n", - " fit_flux='single',\n", - " maxiter=5000)\n", + " jwst_obs.psf_photometry(\n", + " psfs,\n", + " source_location,\n", + " bounds={\n", + " 'flux': [-100, 1000],\n", + " 'centroid': [-2., 2.],\n", + " 'bkg': [0, 50]\n", + " },\n", + " fit_width=3,\n", + " fit_bkg=False,\n", + " fit_flux='single',\n", + " maxiter=5000\n", + " )\n", " \n", " jwst_obs.plot_psf_fit()\n", " plt.show()\n", @@ -1286,12 +1305,18 @@ " print('Starting', counter+1., ' of', len(skycoords), ':', source_location)\n", " # psf3 = space_phot.util.get_jwst_psf_from_grid(jwst3_obs,source_location,grid)\n", " psf3 = space_phot.get_jwst3_psf(jwst_obs, jwst3_obs, source_location, num_psfs=4)\n", - " jwst3_obs.psf_photometry(psf3, source_location, bounds={'flux': [-1000, 10000],\n", - " 'centroid': [-2, 2],\n", - " 'bkg': [0, 50]},\n", - " fit_width=5,\n", - " fit_bkg=True,\n", - " fit_flux=True)\n", + " jwst3_obs.psf_photometry(\n", + " psf3,\n", + " source_location,\n", + " bounds={\n", + " 'flux': [-1000, 10000],\n", + " 'centroid': [-2, 2],\n", + " 'bkg': [0, 50]\n", + " },\n", + " fit_width=5,\n", + " fit_bkg=True,\n", + " fit_flux=True\n", + " )\n", "\n", " jwst3_obs.plot_psf_fit()\n", " plt.show()\n",