Skip to content

Commit

Permalink
Merge pull request #75 from acisops/fp_hrc_dep
Browse files Browse the repository at this point in the history
Update acisfp_check to allow for HRC dependence in the ACIS FP model
  • Loading branch information
jzuhone authored Dec 9, 2024
2 parents e56ebbc + 33a1f02 commit f9f2438
Show file tree
Hide file tree
Showing 18 changed files with 11,143 additions and 13 deletions.
12 changes: 9 additions & 3 deletions acis_thermal_check/apps/acisfp_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def _calc_model_supp(self, model, state_times, states, ephem, state0):
model.comp["1cbat"].set_data(-53.0)
model.comp["sim_px"].set_data(-120.0)

if "215pcast_off" in model.comp:
# Set the HRC 15 volt state
# NOTE: Because of an error in AP, the correct state is 215PCAST=OFF,
# which indicates that the HRC 15V is ON.
model.comp["215pcast_off"].set_data(states["hrc_15v"] == "ON", state_times)

def make_prediction_plots(
self, outdir, states, temps, load_start, upper_limit, lower_limit
):
Expand Down Expand Up @@ -253,11 +259,11 @@ def make_prediction_plots(

# Now write all the plots after possible
# customizations have been made
for key in plots:
for key, plot in plots.items():
if key != self.msid:
outfile = outdir / plots[key].filename
outfile = outdir / plot.filename
mylog.info("Writing plot file %s", outfile)
plots[key].fig.savefig(outfile)
plot.fig.savefig(outfile)

return plots

Expand Down
1 change: 1 addition & 0 deletions acis_thermal_check/apps/dpa_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
plots comparing predicted values to telemetry for the previous three
weeks.
"""

import sys

import matplotlib
Expand Down
1 change: 1 addition & 0 deletions acis_thermal_check/apps/dpamyt_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
plots comparing predicted values to telemetry for the previous three
weeks.
"""

import sys

import matplotlib
Expand Down
1 change: 1 addition & 0 deletions acis_thermal_check/apps/psmc_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
plots comparing predicted values to telemetry for the previous three
weeks.
"""

import sys

import matplotlib
Expand Down
8 changes: 4 additions & 4 deletions acis_thermal_check/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def run(self, args, override_limits=None):
# Record the selected state builder in the class attributes
# If there is no "state_builder" command line argument assume
# kadi
hrc_states = self.name in ["cea"]
hrc_states = any(p["comp_name"] == "215pcast_off" for p in model_spec["pars"])
state_builder = getattr(args, "state_builder", "kadi")
mylog.info(f"ACISThermalCheck is using the '{state_builder}' state builder.")
self.state_builder = make_state_builder(
Expand Down Expand Up @@ -774,11 +774,11 @@ def make_prediction_plots(

# Now write all of the plots after possible
# customizations have been made
for key in plots:
for key, plot in plots.items():
if key != self.msid:
outfile = outdir / plots[key].filename
outfile = outdir / plot.filename
mylog.debug("Writing plot file %s" % outfile)
plots[key].fig.savefig(outfile)
plot.fig.savefig(outfile)

return plots

Expand Down
13 changes: 8 additions & 5 deletions acis_thermal_check/state_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ class StateBuilder:
should not be used by itself, but subclassed.
"""

def __init__(self, logger=None):
def __init__(self, logger=None, hrc_states=False):
if logger is None:
# Make a logger but with no output
logger = logging.getLogger("statebuilder-no-logger")
self.logger = logger
self.state_keys = STATE_KEYS.copy()
if hrc_states:
self.state_keys += ["hrc_15v", "hrc_24v", "hrc_i", "hrc_s"]

def get_prediction_states(self, tlm):
"""
Expand Down Expand Up @@ -132,9 +134,7 @@ def __init__(
hrc_states : boolean, optional
Whether to add HRC-specific states. Default: False
"""
super().__init__(logger=logger)
if hrc_states:
self.state_keys += ["hrc_15v", "hrc_24v", "hrc_i", "hrc_s"]
super().__init__(logger=logger, hrc_states=hrc_states)

# Note: `interrupt` is ignored in this class. This concept is not needed
# since backstop 6.9, which provides the RUNNING_LOAD_TERMINATION_TIME
Expand Down Expand Up @@ -247,6 +247,7 @@ def __init__(
outdir=None,
verbose=2,
logger=None,
hrc_states=False,
):
"""
Give the ACISStateBuilder arguments that were passed in
Expand All @@ -270,6 +271,8 @@ def __init__(
- obtained from the model invocation command line arguments.
logger : Logger object, optional
The Python Logger object to be used when logging.
hrc_states : boolean, optional
Whether to add HRC-specific states. Default: False
"""
# Import the BackstopHistory class
from backstop_history import BackstopHistory
Expand All @@ -284,7 +287,7 @@ def __init__(
outdir,
verbose,
)
super().__init__()
super().__init__(hrc_states=hrc_states)

# Save some arguments to class attributes
self.interrupt = interrupt
Expand Down
Loading

0 comments on commit f9f2438

Please sign in to comment.