Skip to content

Commit

Permalink
Factor out c26202 magnitude calculation for easier re-use.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Dec 16, 2024
1 parent 0a50021 commit fd428bd
Showing 1 changed file with 60 additions and 23 deletions.
83 changes: 60 additions & 23 deletions python/lsst/the/monster/measure_colorterms.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,37 @@ def apply_c26202_calibration(self, stars):
if len(i1) == 0:
raise RuntimeError("Could not find C26202 in catalog.")

target_info = self.TargetCatInfoClass()
bands = target_info.bands

c26202_mags = self.compute_target_c26202_magnitudes()

orig_data_mags = np.zeros(len(bands))
final_data_mags = np.zeros(len(bands))
for i, band in enumerate(bands):
orig_data_mags[i] = stars[f"comcam_{band}_flux"][i1].quantity.to_value(units.ABmag)[0]

ratio = stars[f"comcam_{band}_flux"][i1] / c26202_mags[i].to_value(units.nJy)
stars[f"comcam_{band}_flux"] /= ratio

final_data_mags[i] = stars[f"comcam_{band}_flux"][i1].quantity.to_value(units.ABmag)[0]

print("C2602 (ComCam)")
print("Band CalSpec Original Corrected")
for i, band in enumerate(bands):
print(f"{band} "
f"{c26202_mags[i].value:0.5} "
f"{orig_data_mags[i]:0.5} "
f"{final_data_mags[i]:0.5}")

def compute_target_c26202_magnitudes(self):
"""Compute C26202 magnitudes for target catalog.
Returns
-------
c26202_abmags : `np.ndarray`
Array of c26202 AB magnitudes, one for each target band.
"""
spec_file = os.path.join(
getPackageDir("the_monster"),
"data",
Expand All @@ -557,17 +588,29 @@ def apply_c26202_calibration(self, stars):
1.0e23*spec["flux"]*spec["wavelength"]*spec["wavelength"]*1e-10/299792458.0,
)

bands = self.TargetCatInfoClass().bands
target_info = self.TargetCatInfoClass()

bands = target_info.bands
c26202_mags = np.zeros(len(bands))

throughputs = {}

if target_info.NAME == "ComCam":
for band in bands:
throughput_file = os.path.join(
getPackageDir("the_monster"),
"data",
"throughputs",
f"total_comcam_{band}.ecsv",
)
throughput = Table.read(throughput_file)

throughputs[band] = throughput
else:
raise NotImplementedError(f"Absolute calibration of C26202 for {target_info.NAME} not supported.")

for i, band in enumerate(bands):
throughput_file = os.path.join(
getPackageDir("the_monster"),
"data",
"throughputs",
f"total_comcam_{band}.ecsv",
)
throughput = Table.read(throughput_file)
throughput = throughputs[band]

wavelengths = throughput["wavelength"].quantity.to_value(units.Angstrom)

Expand All @@ -584,23 +627,17 @@ def apply_c26202_calibration(self, stars):

c26202_mags *= units.ABmag

orig_data_mags = np.zeros(len(bands))
final_data_mags = np.zeros(len(bands))
for i, band in enumerate(bands):
orig_data_mags[i] = stars[f"comcam_{band}_flux"][i1].quantity.to_value(units.ABmag)[0]

ratio = stars[f"comcam_{band}_flux"][i1] / c26202_mags[i].to_value(units.nJy)
stars[f"comcam_{band}_flux"] /= ratio
return c26202_mags

final_data_mags[i] = stars[f"comcam_{band}_flux"][i1].quantity.to_value(units.ABmag)[0]
def check_c26202_calibration(self, stars):
"""Check the C26202 absolute calibration.
print("C2602 (ComCam)")
print("Band CalSpec Original Corrected")
for i, band in enumerate(bands):
print(f"{band} "
f"{c26202_mags[i].value:0.5} "
f"{orig_data_mags[i]:0.5} "
f"{final_data_mags[i]:0.5}")
Parameters
----------
stars : `astropy.table.Table`
Catalog to compute absolute calibration for.
"""
pass

@property
def do_fit_flux_offset(self):
Expand Down

0 comments on commit fd428bd

Please sign in to comment.