Skip to content

Commit

Permalink
Merge pull request #21 from jzuhone/atc3.0
Browse files Browse the repository at this point in the history
update dpa_check for acis_thermal_check 3.0
  • Loading branch information
jzuhone authored Apr 13, 2020
2 parents 2ef8bcf + 434016d commit 0eddba6
Show file tree
Hide file tree
Showing 48 changed files with 27,693 additions and 60 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include dpa_check/dpa_model_spec.json
include dpa_check/dpa_model_spec.json
include dpa_check/dpa_check/tests/answers/*
1 change: 1 addition & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from acis_thermal_check.conftest import *
11 changes: 10 additions & 1 deletion dpa_check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,14 @@
__version__ = ska_helpers.get_version(__package__)

from .dpa_check import \
calc_model
DPACheck, main, \
model_path


def test(*args, **kwargs):
"""
Run py.test unit tests.
"""
import testr
return testr.test(*args, **kwargs)

77 changes: 32 additions & 45 deletions dpa_check/dpa_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,76 +10,63 @@
plots comparing predicted values to telemetry for the previous three
weeks.
"""
from __future__ import print_function

# Matplotlib setup
# Use Agg backend for command-line (non-interactive) operation
# Matplotlib setup
# Use Agg backend for command-line (non-interactive) operation
import matplotlib
matplotlib.use('Agg')

import numpy as np
import xija
import sys
from acis_thermal_check import \
ACISThermalCheck, \
calc_off_nom_rolls, \
get_options
import os

model_path = os.path.abspath(os.path.dirname(__file__))

VALIDATION_LIMITS = {'1DPAMZT': [(1, 2.0), (50, 1.0), (99, 2.0)],
'PITCH': [(1, 3.0), (99, 3.0)],
'TSCPOS': [(1, 2.5), (99, 2.5)]
}

HIST_LIMIT = [20.]
class DPACheck(ACISThermalCheck):
def __init__(self):
valid_limits = {'1DPAMZT': [(1, 2.0), (50, 1.0), (99, 2.0)],
'PITCH': [(1, 3.0), (99, 3.0)],
'TSCPOS': [(1, 2.5), (99, 2.5)]
}
hist_limit = [20.0]
super(DPACheck, self).__init__("1dpamzt", "dpa", valid_limits,
hist_limit)

def calc_model(model_spec, states, start, stop, T_dpa=None, T_dpa_times=None,
dh_heater=None, dh_heater_times=None):
model = xija.ThermalModel('dpa', start=start, stop=stop,
model_spec=model_spec)
times = np.array([states['tstart'], states['tstop']])
model.comp['sim_z'].set_data(states['simpos'], times)
model.comp['eclipse'].set_data(False)
model.comp['1dpamzt'].set_data(T_dpa, T_dpa_times)
def _calc_model_supp(self, model, state_times, states, ephem, state0):
"""
Update to initialize the dpa0 pseudo-node. If 1dpamzt
has an initial value (T_dpa) - which it does at
prediction time (gets it from state0), then T_dpa0
is set to that. If we are running the validation,
T_dpa is set to None so we use the dvals in model.comp
# Update to initialize the dpa0 pseudo-node. If 1dpamzt
# has an initial value (T_dpa) - which it does at
# prediction time (gets it from state0), then T_dpa0
# is set to that. If we are running the validation,
# T_dpa is set to None so we use the dvals in model.comp
#
# NOTE: If you change the name of the dpa0 pseudo node you
# have to edit the new name into the if statement
# below.
if 'dpa0' in model.comp:
if T_dpa is None:
T_dpa0 = model.comp["1dpamzt"].dvals
else:
T_dpa0 = T_dpa
model.comp['dpa0'].set_data(T_dpa0, T_dpa_times)

model.comp['roll'].set_data(calc_off_nom_rolls(states), times)
for name in ('ccd_count', 'fep_count', 'vid_board', 'clocking', 'pitch'):
model.comp[name].set_data(states[name], times)
NOTE: If you change the name of the dpa0 pseudo node you
have to edit the new name into the if statement
below.
"""
if 'dpa0' in model.comp:
if state0 is None:
T_dpa0 = model.comp["1dpamzt"].dvals
else:
T_dpa0 = state0["1dpamzt"]
model.comp['dpa0'].set_data(T_dpa0, model.times)

model.make()
model.calc()
return model

def main():
args = get_options("dpa", model_path)
dpa_check = ACISThermalCheck("1dpamzt", "dpa", VALIDATION_LIMITS,
HIST_LIMIT, calc_model, args)
dpa_check = DPACheck()
try:
dpa_check.run()
dpa_check.run(args)
except Exception as msg:
if args.traceback:
raise
else:
print("ERROR:", msg)
sys.exit(1)


if __name__ == '__main__':
main()
main()
Loading

0 comments on commit 0eddba6

Please sign in to comment.