From 965e411aa2fed3c59885e603802e0895a92175c3 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Wed, 31 May 2023 14:31:00 -0400 Subject: [PATCH] Update for new ska_helpers.chandra_models --- ska_sun/sun.py | 13 ++++++++++--- ska_sun/tests/test_sun.py | 21 ++++++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ska_sun/sun.py b/ska_sun/sun.py index a7776b0..ca55c6d 100755 --- a/ska_sun/sun.py +++ b/ska_sun/sun.py @@ -10,16 +10,23 @@ from Chandra.Time import DateTime from chandra_aca.transform import radec_to_eci from Quaternion import Quat -from ska_helpers.utils import LazyVal from ska_helpers import chandra_models - +from ska_helpers.utils import LazyVal CHANDRA_MODELS_PITCH_ROLL_FILE = "chandra_models/pitch_roll/pitch_roll_constraint.csv" def load_roll_table(): """Load the pitch/roll table from the chandra_models repo.""" - dat = chandra_models.get_data(CHANDRA_MODELS_PITCH_ROLL_FILE, read_func=Table.read) + + def read_func(filename): + return Table.read(filename), filename + + dat, info = chandra_models.get_data( + CHANDRA_MODELS_PITCH_ROLL_FILE, read_func=read_func + ) + dat.meta.update(info) + # Sanity check that the pitch values are monotonically increasing. assert np.all(np.diff(dat["pitch"]) > 0) diff --git a/ska_sun/tests/test_sun.py b/ska_sun/tests/test_sun.py index a42cb01..565ff36 100644 --- a/ska_sun/tests/test_sun.py +++ b/ska_sun/tests/test_sun.py @@ -4,15 +4,15 @@ import pytest from Quaternion import Quat -from ..sun import ( +from ska_sun.sun import ( allowed_rolldev, apply_sun_pitch_yaw, get_sun_pitch_yaw, nominal_roll, off_nominal_roll, ) -from ..sun import pitch as sun_pitch -from ..sun import position +from ska_sun.sun import pitch as sun_pitch +from ska_sun.sun import position # Expected pitch, rolldev pairs exp_pitch_rolldev = np.array( @@ -117,3 +117,18 @@ def test_get_sun_pitch_yaw(): assert np.allclose((pitch, yaw), (92.405603, 210.56582)) pitch, yaw = get_sun_pitch_yaw(338, -9.1, time="2021:242") assert np.allclose((pitch, yaw), (179.417797, 259.703451)) + + +def test_roll_table_meta(): + from ska_sun.sun import ROLL_TABLE + + # A sampling of args from the roll table meta + exp = { + "file_path": "chandra_models/pitch_roll/pitch_roll_constraint.csv", + "version": None, + "repo_path": "None", + "require_latest_version": False, + "timeout": 5, + } + for key, val in exp.items(): + assert ROLL_TABLE.val.meta["call_args"][key] == val