Skip to content

Commit

Permalink
Merge pull request #31 from sot/chandra-models-update
Browse files Browse the repository at this point in the history
Update for new ska_helpers.chandra_models
  • Loading branch information
taldcroft authored Jun 1, 2023
2 parents e43f1e1 + 965e411 commit 3112cac
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
13 changes: 10 additions & 3 deletions ska_sun/sun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
21 changes: 18 additions & 3 deletions ska_sun/tests/test_sun.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

0 comments on commit 3112cac

Please sign in to comment.