diff --git a/sparkles/core.py b/sparkles/core.py index 584940e..51c31ee 100644 --- a/sparkles/core.py +++ b/sparkles/core.py @@ -20,6 +20,7 @@ from astropy.table import Column, Table from chandra_aca.star_probs import guide_count from chandra_aca.transform import mag_to_count_rate, snr_mag_for_t_ccd, yagzag_to_pixels +from cxotime import CxoTime from jinja2 import Template from proseco.catalog import ACATable from proseco.core import MetaAttribute @@ -1173,6 +1174,7 @@ def check_catalog(self): self.check_dither() self.check_fid_count() self.check_include_exclude() + self.check_t_ccd_acq() def check_guide_overlap(self): """ @@ -1351,6 +1353,27 @@ def check_include_exclude(self): self.add_message("info", msg) + def check_t_ccd_acq(self): + """ + Check that the fid lights are in the current search boxes by a check on t_ccd_acq. + These tolerances apply to observations after the 2022:294 safe mode. + """ + if self.is_ER or CxoTime(self.date).date < "2022:294": + return + + t_ccd_acq = self.fids.t_ccd_acq + + if t_ccd_acq <= -14.0: + self.add_message( + "critical", + f"Fid lights outside boxes (t_ccd_acq {t_ccd_acq:.1f} <= -14.0)", + ) + elif t_ccd_acq <= -13.5: + self.add_message( + "caution", + f"Fid lights near box edge (t_ccd_acq {t_ccd_acq:.1f} <= -13.5)", + ) + def check_guide_count(self): """ Check for sufficient guide star fractional count. diff --git a/sparkles/tests/test_checks.py b/sparkles/tests/test_checks.py index 0e4134a..2807b5e 100644 --- a/sparkles/tests/test_checks.py +++ b/sparkles/tests/test_checks.py @@ -80,6 +80,52 @@ def test_n_guide_check_not_enough_stars(): ] +@pytest.mark.parametrize( + "obsid, t_ccd_acq, date, expected_messages", + [ + (5000, -5, "2023:001", []), + (5000, -19, "2019:001", []), + ( + 5000, + -13.62312, + "2023:001", + [ + { + "text": "Fid lights near box edge (t_ccd_acq -13.6 <= -13.5)", + "category": "caution", + } + ], + ), + ( + 5000, + -14.1, + "2023:001", + [ + { + "text": "Fid lights outside boxes (t_ccd_acq -14.1 <= -14.0)", + "category": "critical", + } + ], + ), + (40000, -15, "2023:001", []), + ], +) +def test_too_cold(obsid, t_ccd_acq, date, expected_messages): + """Test check_t_ccd_acq""" + + stars = StarsTable.empty() + stars.add_fake_constellation(n_stars=5, mag=8.5) + aca = get_aca_catalog( + **mod_std_info(n_fid=3, n_guide=5, obsid=obsid, t_ccd_acq=t_ccd_acq, date=date), + stars=stars, + dark=DARK40, + raise_exc=True + ) + acar = ACAReviewTable(aca) + acar.check_t_ccd_acq() + assert acar.messages == expected_messages + + def test_guide_is_candidate(): """Test the check that guide star meets candidate star requirements