sot / kadi

Chandra commands and events
https://sot.github.io/kadi
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

Improve SPM eclipse enable state #291

Closed taldcroft closed 10 months ago

taldcroft commented 11 months ago

Description

This refactors the handling for the sun_pos_mon state into three separate states. This was needed in order to ensure that continuity is correct for any state query start time.

Fixes #289

Interface impacts

Adds new states battery_connect and eclipse_enable_spm.

Testing

Unit tests

Independent check of unit tests by Jean

Functional tests

Created (in a notebook) a new validator class:

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"])

    @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

With this the SPM transitions for a 200 day span are mostly OK:

>>> vp = ValidateSunPosMon("2023:200", days=200)
>>> viols = vp.get_violations()
>>> print(viols)
        start                  stop        
--------------------- ---------------------
2023:045:04:46:49.525 2023:045:04:52:17.525  # Safe mode
2023:049:03:38:31.067 2023:049:04:12:08.267  # Safe mode
2023:056:21:59:54.110 2023:056:22:06:11.310  # Real diff between expected penumbra exit and actual?
jeanconn commented 11 months ago

Related to "With this the SPM transitions for a 200 day span are mostly OK" -- what knobs would we have to twiddle to in the command google sheet if we ended up with a mismatch or wanted to fix a "mostly ok" that wasn't based on the code being incorrect?

jeanconn commented 11 months ago

Oh, and I guess I shouldn't have Approved with an outstanding Flake 8 issue and it still probably should have that comment fixed.

taldcroft commented 10 months ago

Related to "With this the SPM transitions for a 200 day span are mostly OK" -- what knobs would we have to twiddle to in the command google sheet if we ended up with a mismatch or wanted to fix a "mostly ok" that wasn't based on the code being incorrect?

In the Exclude Intervals sheet of the Chandra Command events spreadsheet, we would add interval(s) to exclude with the key sun_pos_mon.

taldcroft commented 10 months ago

@jeanconn - I think I addressed your comments.