Skip to content

Commit

Permalink
resolved styling
Browse files Browse the repository at this point in the history
  • Loading branch information
gibsongreen committed Jun 18, 2024
1 parent 5763908 commit 4c760bf
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 55 deletions.
68 changes: 42 additions & 26 deletions notebooks/psf_photometry/MIRI/miri_1028.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down
83 changes: 54 additions & 29 deletions notebooks/psf_photometry/NIRCam/nircam_spacephot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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()"
]
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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))"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 4c760bf

Please sign in to comment.