sot / chandra_aca

Chandra Aspect Camera Tools
https://sot.github.io/chandra_aca
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Support fid drift times before 2012:001 #160

Closed jeanconn closed 10 months ago

jeanconn commented 10 months ago

Description

Support fid drift times before 2012:001. This is handled by just clipping the times to the range of the aimpoint drift model.

This may not be needed even for old regression loads, but without a change, the fid offset code would do this:

In [2]: get_fid_offset('2010:001', -14)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 get_fid_offset('2010:001', -14)

File ~/git/chandra_aca/chandra_aca/drift.py:205, in get_fid_offset(time, t_ccd)
    200 drift_z = AcaDriftModel(**DRIFT_PARS["dz"])
    202 # Compute the predicted asol DY/DZ based on time and ACA CCD temperature
    203 # via the predictive model calibrated in the fit_aimpoint_drift notebook
    204 # in this repo.  And flip the signs.
--> 205 dy_pred = -1.0 * drift_y.calc(time, t_ccd)
    206 dz_pred = -1.0 * drift_z.calc(time, t_ccd)
    208 # Apply internal offset that places the fid lights at ~zero position
    209 # offset during the 2022:094 to 2023:044.

File ~/git/chandra_aca/chandra_aca/drift.py:153, in AcaDriftModel.calc(self, times, t_ccd)
    150     raise ValueError("times arg must be monotonically increasing")
    152 if times[0] < DateTime("2012:001:12:00:00").secs:
--> 153     raise ValueError("model is not applicable before 2012")
    155 # Years from model `year0`
    156 dyears = DateTime(times, format="secs").frac_year - self.year0

ValueError: model is not applicable before 2012

Interface impacts

Testing

Unit tests

Independent check of unit tests by [REVIEWER NAME]

Functional tests

Unit tests added and simple functional test is fine.

In [1]: from chandra_aca.drift import get_fid_offset
In [2]: get_fid_offset('2010:001', -14)
Out[2]: (-12.334006738845702, -3.3898347868921164)
In [3]: get_fid_offset('2012:001', -14)
Out[3]: (-12.334006738845702, -3.3898347868921164)
jeanconn commented 10 months ago

Functional and unit tests redone after f4eb544 .