Skip to content

Commit

Permalink
Merge pull request #28 from jzuhone/refactor_limits_etc
Browse files Browse the repository at this point in the history
Add customizations to support checking +12 degC/0 FEPs violations, other minor updates
  • Loading branch information
jzuhone authored Jan 5, 2021
2 parents 45cd2d3 + 92de464 commit 82c1d64
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 4 deletions.
58 changes: 58 additions & 0 deletions dpa_check/dpa_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,64 @@ def __init__(self):
super(DPACheck, self).__init__("1dpamzt", "dpa", valid_limits,
hist_limit)

def custom_prediction_plots(self, plots):
"""
Customization of prediction plots.
Parameters
----------
plots : dict of dicts
Contains the hooks to the plot figures, axes, and filenames
and can be used to customize plots before they are written,
e.g. add limit lines, etc.
"""
plots[self.name]['ax'].axhline(self.zero_feps_limit, linestyle='--',
color='dodgerblue', label="Zero FEPs",
linewidth=2.0)

def custom_prediction_viols(self, times, temp, viols, load_start):
"""
Custom handling of limit violations. This is for checking the
+12 degC violation if all FEPs are off.
Parameters
----------
times : NumPy array
The times for the predicted temperatures
temp : NumPy array
The predicted temperatures
viols : dict
Dictionary of violations information to add to
load_start : float
The start time of the load, used so that we only report
violations for times later than this time for the model
run.
"""
# Only check this violation when all FEPs are off
mask = self.predict_model.comp['fep_count'].dvals == 0
zf_viols = self._make_prediction_viols(times, temp, load_start,
self.zero_feps_limit,
"zero-feps", "min",
mask=mask)
viols["zero_feps"] = {"name": f"Zero FEPs ({self.zero_feps_limit} C)",
"type": "Min",
"values": zf_viols}

def custom_validation_plots(self, plots):
"""
Customization of validation plots.
Parameters
----------
plots : dict of dicts
Contains the hooks to the plot figures, axes, and filenames
and can be used to customize plots before they are written,
e.g. add limit lines, etc.
"""
plots[0]['lines']['ax'].axhline(self.zero_feps_limit, linestyle='--',
color='dodgerblue', zorder=-8,
linewidth=2, label="Zero FEPs")

def _calc_model_supp(self, model, state_times, states, ephem, state0):
"""
Update to initialize the dpa0 pseudo-node. If 1dpamzt
Expand Down
11 changes: 8 additions & 3 deletions dpa_check/tests/answers/JUL3018A_viol.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
],
"run_start": "2018:205:00:42:38.816",
"limits": {
"yellow_hi": 37.2,
"plan_limit_hi": 35.2
}
"yellow_hi_limit": 37.2,
"plan_hi_limit": 35.2
},
"duration": [
"3.94",
"5.25",
"3.94"
]
}
2 changes: 1 addition & 1 deletion dpa_check/tests/dpa_test_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
0.7
],
"eclipse_comp": "eclipse",
"epoch": "2018:003",
"epoch": "2018:003:12:00:00",
"pitch_comp": "pitch",
"simz_comp": "sim_z",
"var_func": "linear"
Expand Down

0 comments on commit 82c1d64

Please sign in to comment.