Note
Go to the end to download the full example code.
Aperture Photometry on Public HST and JWST Data
This tutorial demonstrates aperture photometry with space_phot on public HST and JWST data.
The JWST path uses the distortion-corrected (PAM-applied) data products in level-2
processing (as used by space_phot).
import os
import glob
import matplotlib.pyplot as plt
from astropy.coordinates import SkyCoord
import astropy.units as u
RUN_NETWORK = os.environ.get("SPACE_PHOT_DOCS_NETWORK", "1") == "1"
RUN_LEVEL3 = os.environ.get("SPACE_PHOT_DOCS_LEVEL3", "1") == "1"
import space_phot
HST: download or locate files
hst_obs_id = "hst_16264_12_wfc3_ir_f110w_iebc12"
sn_hst = SkyCoord("21:29:40.2110", "+0:05:24.154", unit=(u.hourangle, u.deg))
if RUN_NETWORK:
from astroquery.mast import Observations
obs_table = Observations.query_criteria(obs_id=hst_obs_id)
obs_table = obs_table[obs_table["filters"] == "F110W"]
prods = Observations.get_product_list(obs_table)
prods3 = prods[prods["calib_level"] == 3]
prods3 = prods3[prods3["productSubGroupDescription"] == "DRZ"]
prods = prods[prods["calib_level"] == 2]
prods = prods[prods["productSubGroupDescription"] == "FLT"]
Observations.download_products(prods, extension="fits")
Observations.download_products(prods3, extension="fits")
hst_files = sorted(space_phot.util.filter_dict_from_list(glob.glob("mastDownload/HST/*/*flt.fits"),
sn_hst)['F110W'])
hst_files = [x for x in hst_files if 'skycell' not in x]
else:
hst_files = sorted(space_phot.util.filter_dict_from_list(glob.glob("mastDownload/HST/*/*flt.fits"),
sn_hst)['F110W'])
hst_files = [x for x in hst_files if 'skycell' not in x]
if len(hst_files) == 0:
raise RuntimeError(
"No HST files found. Pre-download or set SPACE_PHOT_DOCS_NETWORK=1."
)
print(f"HST files: {len(hst_files)}")
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/iebc12q3q_flt.fits to ./mastDownload/HST/iebc12q3q/iebc12q3q_flt.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/iebc12q7q_flt.fits to ./mastDownload/HST/iebc12q7q/iebc12q7q_flt.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/iebc12q5q_flt.fits to ./mastDownload/HST/iebc12q5q/iebc12q5q_flt.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_16264_12_wfc3_ir_f110w_iebc12q5_flt.fits to ./mastDownload/HST/hst_16264_12_wfc3_ir_f110w_iebc12q5/hst_16264_12_wfc3_ir_f110w_iebc12q5_flt.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_16264_12_wfc3_ir_f110w_iebc12q7_flt.fits to ./mastDownload/HST/hst_16264_12_wfc3_ir_f110w_iebc12q7/hst_16264_12_wfc3_ir_f110w_iebc12q7_flt.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_16264_12_wfc3_ir_f110w_iebc12q3_flt.fits to ./mastDownload/HST/hst_16264_12_wfc3_ir_f110w_iebc12q3/hst_16264_12_wfc3_ir_f110w_iebc12q3_flt.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_skycell-p1403x18y03_wfc3_ir_f110w_all_drz.fits to ./mastDownload/HST/hst_skycell-p1403x18y03_wfc3_ir_f110w_all/hst_skycell-p1403x18y03_wfc3_ir_f110w_all_drz.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_skycell-p1403x18y03_wfc3_ir_f110w_coarse-all_drz.fits to ./mastDownload/HST/hst_skycell-p1403x18y03_wfc3_ir_f110w_coarse-all/hst_skycell-p1403x18y03_wfc3_ir_f110w_coarse-all_drz.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_skycell-p1313x18y20_wfc3_ir_f110w_coarse-all_drz.fits to ./mastDownload/HST/hst_skycell-p1313x18y20_wfc3_ir_f110w_coarse-all/hst_skycell-p1313x18y20_wfc3_ir_f110w_coarse-all_drz.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_skycell-p1313x18y20_wfc3_ir_f110w_all_drz.fits to ./mastDownload/HST/hst_skycell-p1313x18y20_wfc3_ir_f110w_all/hst_skycell-p1313x18y20_wfc3_ir_f110w_all_drz.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/iebc12020_drz.fits to ./mastDownload/HST/iebc12020/iebc12020_drz.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_16264_12_wfc3_ir_f110w_iebc12_drz.fits to ./mastDownload/HST/hst_16264_12_wfc3_ir_f110w_iebc12/hst_16264_12_wfc3_ir_f110w_iebc12_drz.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_skycell-p1312x01y20_wfc3_ir_f110w_coarse-all_drz.fits to ./mastDownload/HST/hst_skycell-p1312x01y20_wfc3_ir_f110w_coarse-all/hst_skycell-p1312x01y20_wfc3_ir_f110w_coarse-all_drz.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_skycell-p1312x01y20_wfc3_ir_f110w_all_drz.fits to ./mastDownload/HST/hst_skycell-p1312x01y20_wfc3_ir_f110w_all/hst_skycell-p1312x01y20_wfc3_ir_f110w_all_drz.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_skycell-p1402x01y03_wfc3_ir_f110w_coarse-all_drz.fits to ./mastDownload/HST/hst_skycell-p1402x01y03_wfc3_ir_f110w_coarse-all/hst_skycell-p1402x01y03_wfc3_ir_f110w_coarse-all_drz.fits ... [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_skycell-p1402x01y03_wfc3_ir_f110w_all_drz.fits to ./mastDownload/HST/hst_skycell-p1402x01y03_wfc3_ir_f110w_all/hst_skycell-p1402x01y03_wfc3_ir_f110w_all_drz.fits ... [Done]
HST files: 6
HST aperture photometry
obs_hst = space_phot.observation2(hst_files)
# Example: fixed pixel aperture + sky annulus
obs_hst.aperture_photometry(
sn_hst,
radius=3,
skyan_in=5,
skyan_out=7,
)
print("HST calibrated aperture photometry:")
print(obs_hst.aperture_result.phot_cal_table)
Cannot create flux_units from header...assuming electrons
Downloading https://sncosmo.github.io/data/bandpasses/wfc3-ir/f110w.IR.tab [Done]
HST calibrated aperture photometry:
flux fluxerr ... mjd
----------------- ------------------ ... --------------
7.698701958397255 0.7971993451017142 ... 59842.21873835
6.118353370726286 0.796095527923026 ... 59842.22349502
6.921680025931548 0.7256799970866364 ... 59842.22825206
7.171247815386379 0.7975956363699543 ... 59842.21873835
6.5779018046012 0.7959414718367382 ... 59842.22349502
6.463959695976745 0.725359805897909 ... 59842.22825206
JWST: download or locate files
jwst_obs_id = "jw02767-o002_t001_nircam_clear-f150w"
sn_jwst = SkyCoord("21:29:40.2103", "+0:05:24.158", unit=(u.hourangle, u.deg))
if RUN_NETWORK:
from astroquery.mast import Observations
obs_table = Observations.query_criteria(obs_id=jwst_obs_id)
prods = Observations.get_product_list(obs_table)
prods3 = prods[prods["calib_level"] == 3]
prods3 = prods3[prods3["productSubGroupDescription"] == "I2D"]
prods = prods[prods["calib_level"] == 2]
prods = prods[prods["productSubGroupDescription"] == "CAL"]
Observations.download_products(prods, extension="fits")
Observations.download_products(prods3, extension="fits")
jwst_files = sorted(glob.glob("mastDownload/JWST/*/*cal.fits"))
if len(jwst_files) == 0:
raise RuntimeError(
"No JWST files found. Pre-download or set SPACE_PHOT_DOCS_NETWORK=1."
)
print(f"JWST files: {len(jwst_files)}")
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00007_nrcb1/jw02767002001_02103_00007_nrcb1_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00004_nrcb2/jw02767002001_02103_00004_nrcb2_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00007_nrcb2/jw02767002001_02103_00007_nrcb2_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00004_nrcb1/jw02767002001_02103_00004_nrcb1_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00005_nrcb1/jw02767002001_02103_00005_nrcb1_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00006_nrcb1/jw02767002001_02103_00006_nrcb1_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00008_nrcb1/jw02767002001_02103_00008_nrcb1_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00002_nrcb2/jw02767002001_02103_00002_nrcb2_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00002_nrcb1/jw02767002001_02103_00002_nrcb1_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00001_nrcb1/jw02767002001_02103_00001_nrcb1_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00005_nrcb2/jw02767002001_02103_00005_nrcb2_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00006_nrcb2/jw02767002001_02103_00006_nrcb2_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00006_nrcb3/jw02767002001_02103_00006_nrcb3_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00008_nrcb3/jw02767002001_02103_00008_nrcb3_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00003_nrcb3/jw02767002001_02103_00003_nrcb3_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00001_nrcb4/jw02767002001_02103_00001_nrcb4_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00007_nrcb3/jw02767002001_02103_00007_nrcb3_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00001_nrcb2/jw02767002001_02103_00001_nrcb2_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00004_nrcb3/jw02767002001_02103_00004_nrcb3_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00005_nrcb3/jw02767002001_02103_00005_nrcb3_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00004_nrcb4/jw02767002001_02103_00004_nrcb4_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00008_nrcb2/jw02767002001_02103_00008_nrcb2_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00007_nrcb4/jw02767002001_02103_00007_nrcb4_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00008_nrcb4/jw02767002001_02103_00008_nrcb4_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00003_nrcb2/jw02767002001_02103_00003_nrcb2_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00006_nrcb4/jw02767002001_02103_00006_nrcb4_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00002_nrcb3/jw02767002001_02103_00002_nrcb3_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00003_nrcb4/jw02767002001_02103_00003_nrcb4_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00001_nrcb3/jw02767002001_02103_00001_nrcb3_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00003_nrcb1/jw02767002001_02103_00003_nrcb1_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00005_nrcb4/jw02767002001_02103_00005_nrcb4_cal.fits with expected size 117573120. [astroquery.query]
INFO: Found cached file ./mastDownload/JWST/jw02767002001_02103_00002_nrcb4/jw02767002001_02103_00002_nrcb4_cal.fits with expected size 117573120. [astroquery.query]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:JWST/product/jw02767-o002_t001_nircam_clear-f150w_i2d.fits to ./mastDownload/JWST/jw02767-o002_t001_nircam_clear-f150w/jw02767-o002_t001_nircam_clear-f150w_i2d.fits ... [Done]
JWST files: 32
JWST aperture photometry
obs_jwst = space_phot.observation2(jwst_files)
# Example: use JWST aperture correction by EE (preferred)
obs_jwst.aperture_photometry(
sn_jwst,
encircled_energy="70",
)
print("JWST calibrated aperture photometry:")
print(obs_jwst.aperture_result.phot_cal_table)
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T10:18:28.305' from MJD-BEG.
Set DATE-AVG to '2022-10-06T10:23:45.039' from MJD-AVG.
Set DATE-END to '2022-10-06T10:29:01.774' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 4.937494 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.545121 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233352946.798 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T10:29:44.720' from MJD-BEG.
Set DATE-AVG to '2022-10-06T10:35:01.454' from MJD-AVG.
Set DATE-END to '2022-10-06T10:40:18.189' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 4.954836 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.552944 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233357129.869 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T10:41:44.080' from MJD-BEG.
Set DATE-AVG to '2022-10-06T10:47:00.814' from MJD-AVG.
Set DATE-END to '2022-10-06T10:52:17.549' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 4.973283 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.561260 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233361611.708 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T10:53:00.495' from MJD-BEG.
Set DATE-AVG to '2022-10-06T10:58:17.229' from MJD-AVG.
Set DATE-END to '2022-10-06T11:03:33.964' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 4.990631 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.569078 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233365857.162 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T11:04:59.855' from MJD-BEG.
Set DATE-AVG to '2022-10-06T11:10:16.589' from MJD-AVG.
Set DATE-END to '2022-10-06T11:15:33.324' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 5.009083 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.577389 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233370405.449 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T11:16:16.270' from MJD-BEG.
Set DATE-AVG to '2022-10-06T11:21:33.004' from MJD-AVG.
Set DATE-END to '2022-10-06T11:26:49.739' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 5.026435 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.585203 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233374713.411 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T11:28:15.629' from MJD-BEG.
Set DATE-AVG to '2022-10-06T11:33:32.363' from MJD-AVG.
Set DATE-END to '2022-10-06T11:38:49.098' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 5.044893 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.593510 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233379328.081 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T11:28:15.693' from MJD-BEG.
Set DATE-AVG to '2022-10-06T11:33:32.428' from MJD-AVG.
Set DATE-END to '2022-10-06T11:38:49.162' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 5.044894 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.593510 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233379328.493 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T11:39:32.044' from MJD-BEG.
Set DATE-AVG to '2022-10-06T11:44:48.778' from MJD-AVG.
Set DATE-END to '2022-10-06T11:50:05.513' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 5.062250 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.601318 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233383698.495 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T11:39:32.108' from MJD-BEG.
Set DATE-AVG to '2022-10-06T11:44:48.843' from MJD-AVG.
Set DATE-END to '2022-10-06T11:50:05.577' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 5.062252 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.601319 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233383698.910 from OBSGEO-[XYZ]'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/stats/sigma_clipping.py:400: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically clipped.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/stats/sigma_clipping.py:400: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically clipped.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/stats/sigma_clipping.py:400: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically clipped.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/stats/sigma_clipping.py:400: AstropyUserWarning: Input data contains invalid values (NaNs or infs), which were automatically clipped.
warnings.warn(
JWST calibrated aperture photometry:
flux fluxerr ... mjd
--------------------- ---------------------- ... ------------------
nan nan ... 59858.4331601794
nan nan ... 59858.4331601794
6.517576507507144e-13 1.0929850951571815e-14 ... 59858.4331601794
nan nan ... 59858.4331601794
nan nan ... 59858.44098905671
nan nan ... 59858.44098905671
6.37487762745444e-13 1.12331815381951e-14 ... 59858.44098905671
nan nan ... 59858.44098905671
nan nan ... 59858.44931498264
nan nan ... 59858.44931498264
... ... ... ...
6.481764149230344e-13 1.1234180362055577e-14 ... 59858.47329866319
nan nan ... 59858.47329866319
nan nan ... 59858.481624577544
nan nan ... 59858.481624577544
6.745328359152624e-13 1.124209681893188e-14 ... 59858.481624577544
nan nan ... 59858.48162531829
nan nan ... 59858.48945345486
nan nan ... 59858.48945345486
6.202523613983137e-13 1.0998334121016685e-14 ... 59858.48945345486
nan nan ... 59858.4894541956
Length = 32 rows
Level 3 HST aperture photometry (drz/drc)
Level 3 HST products are typically drizzled: *_drz.fits or *_drc.fits.
hst_lvl3_files = sorted(glob.glob("mastDownload/HST/*/*dr?.fits"))
hst_lvl3_files = [x for x in hst_lvl3_files if 'skycell' not in x]
# glob pattern *dr?.fits matches *drz.fits and *drc.fits
if len(hst_lvl3_files) == 0:
raise RuntimeError(
"No HST Level 3 (*_drz.fits or *_drc.fits) found. "
"Pre-download Level 3 products or disable with SPACE_PHOT_DOCS_LEVEL3=0."
)
print(f"HST Level 3 files: {len(hst_lvl3_files)}")
obs3_hst = space_phot.observation3(hst_lvl3_files[0])
obs3_hst.aperture_photometry(
sn_hst,
radius=3,
skyan_in=5,
skyan_out=7,
)
print("HST Level 3 calibrated aperture photometry:")
print(obs3_hst.aperture_result.phot_cal_table)
HST Level 3 files: 2
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/checkouts/latest/space_phot/photometry.py:638: RuntimeWarning: divide by zero encountered in divide
self.err = 1./np.sqrt(self.fits['WHT',1].data)
Cannot create flux_units from header...assuming electrons/s
HST Level 3 calibrated aperture photometry:
flux fluxerr ... mjd
----------------- ------------------- ... ---
7.639487889108437 0.18076863317776534 ... nan
Level 3 JWST aperture photometry (i2d)
jwst_i2d_files = sorted(glob.glob("mastDownload/JWST/*/*i2d.fits"))
if len(jwst_i2d_files) == 0:
raise RuntimeError(
"No JWST Level 3 (*_i2d.fits) found. "
"Pre-download Level 3 products or disable with SPACE_PHOT_DOCS_LEVEL3=0."
)
print(f"JWST Level 3 files: {len(jwst_i2d_files)}")
obs3_jwst = space_phot.observation3(jwst_i2d_files[0])
# Keep the interface consistent: use EE-based aperture correction
obs3_jwst.aperture_photometry(
sn_jwst,
encircled_energy="70",
)
print("JWST Level 3 calibrated aperture photometry:")
print(obs3_jwst.aperture_result.phot_cal_table)
JWST Level 3 files: 1
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'datfix' made the change 'Set DATE-BEG to '2022-10-06T10:18:28.305' from MJD-BEG.
Set DATE-AVG to '2022-10-06T11:04:16.913' from MJD-AVG.
Set DATE-END to '2022-10-06T11:50:05.577' from MJD-END'.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/space-phot/envs/latest/lib/python3.11/site-packages/astropy/wcs/wcs.py:918: FITSFixedWarning: 'obsfix' made the change 'Set OBSGEO-L to 4.937494 from OBSGEO-[XYZ].
Set OBSGEO-B to 20.545121 from OBSGEO-[XYZ].
Set OBSGEO-H to 1233352946.798 from OBSGEO-[XYZ]'.
warnings.warn(
JWST Level 3 calibrated aperture photometry:
flux fluxerr ... mjd
-------------------- ---------------------- ... -----------------
6.42207153958038e-13 3.8602661822936444e-15 ... 59858.46130686632
Total running time of the script: (1 minutes 50.216 seconds)