From f39da1eb06bbd66a427f0ba25c95c45bad6adbf2 Mon Sep 17 00:00:00 2001 From: Jean Connelly Date: Tue, 17 Oct 2023 17:48:46 -0400 Subject: [PATCH] Update to use new get_fid_offset function in chandra_aca --- proseco/fid.py | 18 +++++++++--------- proseco/tests/conftest.py | 2 +- proseco/tests/test_fid.py | 14 ++++---------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/proseco/fid.py b/proseco/fid.py index 59230de9..4ac6c0d4 100644 --- a/proseco/fid.py +++ b/proseco/fid.py @@ -9,7 +9,7 @@ import weakref import numpy as np -from chandra_aca.fid_drift import get_drift +from chandra_aca.drift import get_fid_offset from chandra_aca.transform import yagzag_to_pixels from cxotime import CxoTime @@ -521,21 +521,21 @@ def get_fid_positions(detector, focus_offset, sim_offset, t_ccd_acq=None, date=N yang, zang = np.degrees(yfid) * 3600, np.degrees(zfid) * 3600 - # Apply fid drift - enable_fid_drift_env = os.environ.get("PROSECO_ENABLE_FID_DRIFT", "True") - if enable_fid_drift_env not in ("True", "False"): + # Apply fid offset + enable_fid_offset_env = os.environ.get("PROSECO_ENABLE_FID_OFFSET", "True") + if enable_fid_offset_env not in ("True", "False"): raise ValueError( - f'PROSECO_ENABLE_FID_DRIFT env var must be either "True" or "False" ' - f"got {enable_fid_drift}" + f'PROSECO_ENABLE_FID_OFFSET env var must be either "True" or "False" ' + f"got {enable_fid_offset_env}" ) # The env var is still just a string so do a string equals on it - if enable_fid_drift_env == "True": + if enable_fid_offset_env == "True": if t_ccd_acq is None or date is None: raise ValueError( - "t_ccd_acq and date must be provided if fid drift is enabled" + "t_ccd_acq and date must be provided if fid offset is enabled" ) - dy, dz = get_drift(date, t_ccd_acq) + dy, dz = get_fid_offset(date, t_ccd_acq) yang += dy zang += dz diff --git a/proseco/tests/conftest.py b/proseco/tests/conftest.py index 3a56dcea..769fedbd 100644 --- a/proseco/tests/conftest.py +++ b/proseco/tests/conftest.py @@ -9,7 +9,7 @@ def use_fixed_chandra_models(monkeypatch): @pytest.fixture(autouse=True) def disable_fid_drift(monkeypatch): - monkeypatch.setenv("PROSECO_ENABLE_FID_DRIFT", "False") + monkeypatch.setenv("PROSECO_ENABLE_FID_OFFSET", "False") # By default test with the latest AGASC version available including release candidates diff --git a/proseco/tests/test_fid.py b/proseco/tests/test_fid.py index a03c47e6..4785a1f5 100644 --- a/proseco/tests/test_fid.py +++ b/proseco/tests/test_fid.py @@ -12,7 +12,7 @@ # Reference fid positions for spoiling tests. Because this is done outside # a test the fixture to generally disable fid drift is not in effect. -os.environ["PROSECO_ENABLE_FID_DRIFT"] = "False" +os.environ["PROSECO_ENABLE_FID_OFFSET"] = "False" FIDS = get_fid_catalog(stars=StarsTable.empty(), **STD_INFO) # Do not use the AGASC supplement in testing by default since mags can change @@ -51,18 +51,12 @@ def test_get_fid_position(monkeypatch): assert np.allclose(zang[fidset], [-468, -460, 561], rtol=0, atol=1.1) yang1, zang1 = get_fid_positions("ACIS-S", focus_offset=0.0, sim_offset=0.0) - monkeypatch.setenv("CHANDRA_MODELS_DEFAULT_VERSION", "fid-drift") - monkeypatch.setenv("PROSECO_ENABLE_FID_DRIFT", "True") + monkeypatch.setenv("PROSECO_ENABLE_FID_OFFSET", "True") yang2, zang2 = get_fid_positions( "ACIS-S", focus_offset=0.0, sim_offset=0.0, date="2023:235", t_ccd_acq=-13.65 ) - yang3, zang3 = get_fid_positions( - "ACIS-S", focus_offset=0.0, sim_offset=0.0, date="2019:001", t_ccd_acq=-13.65 - ) - assert np.allclose(yang1, yang3, rtol=0, atol=0.1) - assert np.allclose(zang1, zang3, rtol=0, atol=0.1) - assert np.allclose(yang1 - yang2, -36.35, rtol=0, atol=0.1) - assert np.allclose(zang1 - zang2, -11.83, rtol=0, atol=0.1) + assert np.allclose(yang1 - yang2, -33.16, rtol=0, atol=0.1) + assert np.allclose(zang1 - zang2, -9.83, rtol=0, atol=0.1) def test_get_initial_catalog():