Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jzuhone committed Mar 22, 2024
1 parent 0100b4e commit 4f7c496
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions acis_thermal_check/apps/acisfp_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,16 @@ def make_prediction_plots(
load_start=load_start,
)
plots[name].ax.set_title(self.msid.upper(), loc="left", pad=10)
# Draw the planning limit line on the plot (broken up
# according to condition)
upper_limit.plot(
fig_ax=(plots[name].fig, plots[name].ax),
lw=3,
zorder=2,
use_colors=True,
show_changes=False,
)
# Draw the yellow limit line on the plot
plots[name].add_limit_line(self.limits["yellow_hi"], lw=3)
# Get the width of this plot to make the widths of all the
# prediction plots the same
Expand Down Expand Up @@ -280,14 +283,18 @@ def make_prediction_viols(self, temps, states, load_start):
- science_viols
"""
# Extract the prediction violations and the limit objects
viols, upper_limit, lower_limit = super().make_prediction_viols(
temps, states, load_start
)

# Store the obsid table
obs_table = self.limit_object.acis_obs_info.as_table()
# use only the obsids after the load start
idxs = np.where(CxoTime(obs_table["start_science"]).secs > load_start)[0]
self.acis_and_ecs_obs = obs_table[idxs]
# for each violation, add the exposure time to the violation
# so we can record it on the page
for v in viols["hi"]:
idx = np.where(self.acis_and_ecs_obs["obsid"] == v["obsid"])[0]
if idx.size == 0:
Expand Down
13 changes: 13 additions & 0 deletions acis_thermal_check/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,21 +515,25 @@ def make_prediction_viols(self, temps, states, load_start):
"""
mylog.info("Checking for limit violations")

# Get the upper planning limit line
upper_limit = self.limit_object.get_limit_line(
states,
which="high",
)
# Check the violations for the upper planning limit
viols = {
"hi": upper_limit.check_violations(
self.predict_model,
start_time=load_start,
),
}
if self._flag_cold_viols:
# Get the lower planning limit line
lower_limit = self.limit_object.get_limit_line(
states,
which="low",
)
# Check the violations for the lower planning limit
viols["lo"] = lower_limit.check_violations(
self.predict_model,
start_time=load_start,
Expand Down Expand Up @@ -841,11 +845,13 @@ def make_validation_plots(self, tlm, model_spec, outdir):

self.validate_model = model

# get the upper planning limit
upper_limit = self.limit_object.get_limit_line(
states,
which="high",
)
if self._flag_cold_viols:
# get the lower planning limit
lower_limit = self.limit_object.get_limit_line(
states,
which="low",
Expand Down Expand Up @@ -960,6 +966,7 @@ def make_validation_plots(self, tlm, model_spec, outdir):
# lines by adjusting ymin/ymax accordingly.
if self.msid == msid:
ymin, ymax = ax.get_ylim()
# Plot the upper planning limit
upper_limit.plot(
fig_ax=(fig, ax),
lw=3,
Expand All @@ -968,6 +975,7 @@ def make_validation_plots(self, tlm, model_spec, outdir):
show_changes=False,
)
if lower_limit is not None:
# Plot the lower planning limit
lower_limit.plot(
fig_ax=(fig, ax),
lw=3,
Expand All @@ -990,6 +998,9 @@ def make_validation_plots(self, tlm, model_spec, outdir):
)
# Set label to None so we don't repeat it
label = None
# ymin and ymax for plots have to be at least
# above/below their yellow limits or the data
# extremes
ymax = max(self.limits[key]["value"] + 1, ymax)
ymin = min(self.limits[key]["value"] - 1, ymin)
ax.set_ylim(ymin, ymax)
Expand Down Expand Up @@ -1230,6 +1241,7 @@ def rst_to_html(self, outdir):
stylesheet_path = str(outdir / "acis_thermal_check.css")
prefixes = ["index"]
if self.msid == "fptemp":
# For the ACIS FP limit we write out an obsid table
prefixes.append("obsid_table")
for prefix in prefixes:
infile = str(outdir / f"{prefix}.rst")
Expand Down Expand Up @@ -1275,6 +1287,7 @@ def write_index_rst(self, outdir, context):
with open(outfile, "w") as fout:
fout.write(template.render(**context))
if self.msid == "fptemp":
# For the ACIS FP limit we write out an obsid table
context["acis_obs"] = self.acis_and_ecs_obs
template_path = (
TASK_DATA / "acis_thermal_check/templates/obsid_template.rst"
Expand Down

0 comments on commit 4f7c496

Please sign in to comment.