Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fid offset support to drift #157

Merged
merged 6 commits into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions chandra_aca/drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,31 @@ def calc(self, times, t_ccd):
return out[0] if is_scalar else out


def get_fid_offset(time, t_ccd):
jeanconn marked this conversation as resolved.
Show resolved Hide resolved
"""
Compute the fid light offset values for the provided inputs.
The y_offset and z_offset values in this function were calibrated against the
jeanconn marked this conversation as resolved.
Show resolved Hide resolved
2022-11 aimpoint drift model and the FEB07 fid characteristics.
See https://github.com/sot/fid_drift_mon/blob/master/fid_offset_coeff.ipynb
"""
jeanconn marked this conversation as resolved.
Show resolved Hide resolved

# Define model instances using calibrated parameters
drift_y = AcaDriftModel(**DRIFT_PARS["dy"])
drift_z = AcaDriftModel(**DRIFT_PARS["dz"])

# Compute the predicted asol DY/DZ based on time and ACA CCD temperature
# via the predictive model calibrated in the fit_aimpoint_drift notebook
# in this repo. And flip the signs.
dy_pred = -1.0 * drift_y.calc(time, t_ccd)
dz_pred = -1.0 * drift_z.calc(time, t_ccd)

# Apply internal offset that places the fid lights at ~zero position
# offset during the 2022:094 to 2023:044.
y_offset = 20.3
z_offset = 20.3
return dy_pred + y_offset, dz_pred + z_offset


def get_aca_offsets(detector, chip_id, chipx, chipy, time, t_ccd):
"""
Compute the dynamical ACA offset values for the provided inputs.
Expand Down
28 changes: 28 additions & 0 deletions chandra_aca/tests/test_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,31 @@ def test_get_aca_offsets(kwargs, monkeypatch):
# 3.9 arcsec/C. Also up to 0.005 arcsec error in the stored aca_offset_y/z values.
assert abs(dy) < 0.03
assert abs(dz) < 0.02


def test_get_fid_offset():
"""
Test that the get_fid_offset function returns expected values for a few inputs.
"""

# Show that the offsets are reasonable for a few inputs in the different epochs
# of the drift model. Dates picked to be before and after jumps
t1 = "2018:284"
t2 = "2018:286"
t3 = "2022:293"
t4 = "2022:295"

t_ccd = -10

expected_dy_1, expected_dz_1 = drift.get_fid_offset(t1, t_ccd)
expected_dy_2, expected_dz_2 = drift.get_fid_offset(t2, t_ccd)
expected_dy_3, expected_dz_3 = drift.get_fid_offset(t3, t_ccd)
expected_dy_4, expected_dz_4 = drift.get_fid_offset(t4, t_ccd)

assert np.isclose(expected_dy_1, -6.79, atol=0.01)
assert np.isclose(expected_dy_2 - expected_dy_1, 12.5, atol=0.1)
assert np.isclose(expected_dy_4 - expected_dy_3, 7.97, atol=0.1)

assert np.isclose(expected_dz_1, -5.10, atol=0.01)
assert np.isclose(expected_dz_2 - expected_dz_1, 6.05, atol=0.1)
assert np.isclose(expected_dz_4 - expected_dz_3, 1.51, atol=0.1)