Skip to content

Commit

Permalink
Add tests for comcam color measurements.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Dec 16, 2024
1 parent 508f612 commit 9f91d4b
Show file tree
Hide file tree
Showing 5 changed files with 2,687 additions and 14 deletions.
39 changes: 26 additions & 13 deletions python/lsst/the/monster/measure_colorterms.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def measure_spline_fit(
np.array([cat_stars[cat_info.get_flux_field(band_2)][c26202_cat_index]]),
np.array([cat_stars[cat_info.get_flux_field(band)][c26202_cat_index]]),
)
mag_target_corr0 = float((flux_target_corr0*units.nJy).to_value(units.ABmag))
mag_target_corr0 = float((flux_target_corr0*units.nJy).to_value(units.ABmag)[0])

ratio = flux_target_corr0 / c26202_absmags[band_index].to_value(units.nJy)

Expand All @@ -366,7 +366,7 @@ def measure_spline_fit(
np.array([cat_stars[cat_info.get_flux_field(band_2)][c26202_cat_index]]),
np.array([cat_stars[cat_info.get_flux_field(band)][c26202_cat_index]]),
)
mag_target_corr1 = float((flux_target_corr1*units.nJy).to_value(units.ABmag))
mag_target_corr1 = float((flux_target_corr1*units.nJy).to_value(units.ABmag)[0])

c26202_message += f"{band} "
c26202_message += f"{c26202_absmags[band_index].value:0.3f} "
Expand Down Expand Up @@ -515,7 +515,7 @@ def compute_target_c26202_magnitudes(self):

throughputs = {}

if target_info.NAME == "ComCam":
if target_info.NAME in ("ComCam", "TestComCam"):
for band in bands:
throughput_file = os.path.join(
getPackageDir("the_monster"),
Expand Down Expand Up @@ -627,17 +627,30 @@ def custom_target_catalog_reader(self):
catalog : `astropy.Table`
Astropy table catalog.
"""
from lsst.daf.butler import Butler
if self.testing_mode:
target_info = self.TargetCatInfoClass()
fgcm_stars = Table.read(
os.path.join(
target_info.PATH,
"comcam_test_stars.fits",
),
)

butler = Butler(
"embargo",
instrument="LSSTComCam",
collections=["LSSTComCam/runs/DRP/20241101_20241211/w_2024_50/DM-48128"],
)
bands = ["u", "g", "r", "i", "z", "y"]
else:
from lsst.daf.butler import Butler

fgcm_stars = butler.get("fgcm_Cycle5_StandardStars")
md = fgcm_stars.metadata
fgcm_stars = fgcm_stars.asAstropy()
butler = Butler(
"embargo",
instrument="LSSTComCam",
collections=["LSSTComCam/runs/DRP/20241101_20241211/w_2024_50/DM-48128"],
)

fgcm_stars = butler.get("fgcm_Cycle5_StandardStars")
md = fgcm_stars.metadata
fgcm_stars = fgcm_stars.asAstropy()

bands = md.getArray("BANDS")

fgcm_stars["coord_ra"].convert_unit_to(units.degree)
fgcm_stars["coord_dec"].convert_unit_to(units.degree)
Expand All @@ -650,7 +663,7 @@ def custom_target_catalog_reader(self):
},
)

for i, band in enumerate(md.getArray("BANDS")):
for i, band in enumerate(bands):
flux = (fgcm_stars["mag_std_noabs"][:, i]*units.ABmag).to_value(units.nJy)
flux[fgcm_stars["ngood"][:, i] < 2] = np.nan
flux_err = (np.log(10)/2.5) * np.asarray(fgcm_stars["magErr_std"][:, i]) * flux
Expand Down
Loading

0 comments on commit 9f91d4b

Please sign in to comment.