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

Update for new ska_helpers.chandra_models #31

Merged
merged 1 commit into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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