Skip to content

Commit

Permalink
Merge pull request #20 from jzuhone/atc3.0
Browse files Browse the repository at this point in the history
update psmc_check for acis_thermal_check 3.0
  • Loading branch information
jzuhone authored Apr 13, 2020
2 parents 747eb9d + 1a585ee commit ee21e02
Show file tree
Hide file tree
Showing 48 changed files with 27,824 additions and 56 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include psmc_check/psmc_model_spec.json
include psmc_check/psmc_model_spec.json
include psmc_check/psmc_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 *
12 changes: 11 additions & 1 deletion psmc_check/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,14 @@
__version__ = ska_helpers.get_version(__package__)

from .psmc_check import \
calc_model
PSMCCheck, main, \
model_path


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

65 changes: 26 additions & 39 deletions psmc_check/psmc_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,68 +10,55 @@
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
from acis_thermal_check import \
ACISThermalCheck, \
calc_off_nom_rolls, \
get_options, mylog
get_options
import os
import sys

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

VALIDATION_LIMITS = {'1PDEAAT': [(1, 2.5), (50, 1.0), (99, 5.5)],
'PITCH': [(1, 3.0), (99, 3.0)],
'TSCPOS': [(1, 2.5), (99, 2.5)]
}
HIST_LIMIT = [30., 40.]

def calc_model(model_spec, states, start, stop, T_psmc=None, T_psmc_times=None,
dh_heater=None, dh_heater_times=None):
model = xija.XijaModel('psmc', 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['1pdeaat'].set_data(T_psmc, T_psmc_times)
# 1PIN1AT is broken, so we set its initial condition
# using an offset, which makes sense based on historical
# data
if T_psmc is None:
T_pin1at = model.comp["1pdeaat"].dvals - 10.0
else:
T_pin1at = T_psmc - 10.0
model.comp['pin1at'].set_data(T_pin1at,T_psmc_times)
model.comp['roll'].set_data(calc_off_nom_rolls(states), times)
model.comp['eclipse'].set_data(False)
for name in ('ccd_count', 'fep_count', 'vid_board', 'clocking', 'pitch'):
model.comp[name].set_data(states[name], times)
model.comp['dh_heater'].set_data(dh_heater, dh_heater_times)
model.make()
model.calc()
return model
class PSMCCheck(ACISThermalCheck):
def __init__(self):
valid_limits = {'1PDEAAT': [(1, 2.5), (50, 1.0), (99, 5.5)],
'PITCH': [(1, 3.0), (99, 3.0)],
'TSCPOS': [(1, 2.5), (99, 2.5)]
}
hist_limit = [30., 40.]
super(PSMCCheck, self).__init__("1pdeaat", "psmc", valid_limits,
hist_limit, other_telem=['1dahtbon'],
other_map={'1dahtbon': 'dh_heater'})

def _calc_model_supp(self, model, state_times, states, ephem, state0):
# 1PIN1AT is broken, so we set its initial condition
# using an offset, which makes sense based on historical
# data
if state0 is None:
T_pin1at = model.comp["1pdeaat"].dvals - 10.0
else:
T_pin1at = state0["1pdeaat"] - 10.0
model.comp['pin1at'].set_data(T_pin1at, model.times)


def main():
args = get_options("psmc", model_path)
psmc_check = ACISThermalCheck("1pdeaat", "psmc", VALIDATION_LIMITS, HIST_LIMIT,
calc_model, args, other_telem=['1dahtbon'],
other_map={'1dahtbon': 'dh_heater'})
psmc_check = PSMCCheck()
try:
psmc_check.run()
psmc_check.run(args)
except Exception as msg:
if args.traceback:
raise
else:
print("ERROR:", msg)
sys.exit(1)


if __name__ == '__main__':
main()
665 changes: 665 additions & 0 deletions psmc_check/tests/answers/APR0217B/states.dat

Large diffs are not rendered by default.

Loading

0 comments on commit ee21e02

Please sign in to comment.