Skip to content

Commit

Permalink
Merge pull request #292 from sot/add-spm-vadliation
Browse files Browse the repository at this point in the history
Add validator for sun position monitor
  • Loading branch information
taldcroft authored Aug 19, 2023
2 parents 7fe0dd5 + aeb8ff0 commit 761efd0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kadi/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def add_figure_regions(
def convert_state_code_to_raw_val(state_vals, state_codes):
raw_vals = np.zeros(len(state_vals), dtype=int)
for raw_val, state_code in state_codes:
ok = state_vals == state_code
ok = np.char.strip(state_vals) == state_code
raw_vals[ok] = raw_val
return raw_vals

Expand Down
24 changes: 24 additions & 0 deletions kadi/commands/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,30 @@ class ValidateHETG(ValidateGrating):
plot_attrs = PlotAttrs(title="HETG", ylabel="HETG")


class ValidateSunPosMon(ValidateStateCode):
state_name = "sun_pos_mon"
msids = ["aopssupm"]
plot_attrs = PlotAttrs(title="Sun position monitor", ylabel="Sun position monitor")
min_violation_duration = 300

def add_exclude_intervals(self):
super().add_exclude_intervals()
self.exclude_ofp_intervals_except(["NRML"])

@functools.cached_property
def state_vals(self):
"""Convert ENAB (commanded states) to ACT (telemetry).
The "ENAB" is an artifact of the backstop history sun position monitor states.
This method is otherwise equivalent to the ValidateStateCode method.
"""
states_interp = interpolate_states(self.states, self.tlm["time"])
state_vals = states_interp[self.state_name]
state_vals[state_vals == "ENAB"] = "ACT"
state_vals_raw = convert_state_code_to_raw_val(state_vals, self.state_codes)
return state_vals_raw


def get_overlap_mask(times: np.ndarray, intervals: Table):
"""Return a bool mask of ``times`` that are within any of the ``intervals``.
Expand Down

0 comments on commit 761efd0

Please sign in to comment.