Skip to content

Commit

Permalink
Add option to use maude to fetch AACCCDPT (and fetch 7 instead of 30 …
Browse files Browse the repository at this point in the history
…days)
  • Loading branch information
jeanconn committed Jun 3, 2019
1 parent 634e798 commit 8eb5b23
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
22 changes: 14 additions & 8 deletions starcheck/calc_ccd_temps.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get_options():

def get_ccd_temps(oflsdir, outdir='out',
json_obsids=sys.stdin,
model_spec=None, char_file=None, orlist=None,
model_spec=None, char_file=None, orlist=None, use_maude=0,
verbose=1, **kwargs):
"""
Using the cmds and cmd_states sybase databases, available telemetry, and
Expand All @@ -112,23 +112,30 @@ def get_ccd_temps(oflsdir, outdir='out',
:param json_obsids: file-like object or string containing JSON of
starcheck Obsid objects
:param model_spec: xija ACA model specification
:param use_maude: if 1, use maude to fetch recent AACCCDPT data
:param verbose: Verbosity (0=quiet, 1=normal, 2=debug)
:returns: JSON dictionary of labeled dwell intervals with max temperatures
"""
if not os.path.exists(outdir):
os.mkdir(outdir)

if use_maude == 1:
fetch.data_source.set('maude allow_subset=False')

config_logging(outdir, verbose)

# Store info relevant to processing for use in outputs
proc = {'run_user': os.environ['USER'],
'run_time': time.ctime(),
'errors': []}
'errors': [],
'use_maude': use_maude,
}
logger.info('##############################'
'#######################################')
logger.info('# %s run at %s by %s'
% (TASK_NAME, proc['run_time'], proc['run_user']))
logger.info('# {} version = {}'.format(TASK_NAME, VERSION))
logger.info('# Fetch data sources set to {}'.format(fetch.data_source.sources()))
logger.info('###############################'
'######################################\n')

Expand All @@ -153,10 +160,10 @@ def get_ccd_temps(oflsdir, outdir='out',
proc['datestart'] = DateTime(tstart).date
proc['datestop'] = DateTime(tstop).date

# Get temperature telemetry for 30 days prior to min(tstart, NOW)
# Get temperature telemetry for 7 days prior to min(tstart, NOW)
tlm = get_telem_values(min(tstart, tnow),
['aacccdpt', 'pitch'],
days=30)
['aacccdpt'],
days=7)

states = get_week_states(tstart, tstop, bs_cmds, tlm)
# if the last obsid interval extends over the end of states
Expand Down Expand Up @@ -368,8 +375,7 @@ def mock_telem_predict(states):

tlm = fetch.MSIDset(['aacccdpt'],
states[0]['tstart'],
states[-1]['tstart'],
stat='5min')
states[-1]['tstart'])
temps = {'aca': tlm['aacccdpt'].vals}
return tlm['aacccdpt'].times, tlm['aacccdpt'].vals

Expand Down Expand Up @@ -404,7 +410,7 @@ def get_telem_values(tstart, msids, days=7, name_map={}):
start = DateTime(tstart - days * 86400).date
stop = DateTime(tstart).date
logger.info('Fetching telemetry between %s and %s' % (start, stop))
msidset = fetch.MSIDset(msids, start, stop, stat='5min')
msidset = fetch.MSIDset(msids, start, stop)
start = max(x.times[0] for x in msidset.values())
stop = min(x.times[-1] for x in msidset.values())
msidset.interpolate(328.0, start, stop + 1) # 328 for '5min' stat
Expand Down
9 changes: 7 additions & 2 deletions starcheck/src/starcheck.pl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
html => 1,
text => 1,
yaml => 1,
maude => 0,
agasc_file => "${SKA}/data/agasc/agasc1p7.h5",
config_file => "characteristics.yaml",
fid_char => "fid_CHARACTERISTICS",
Expand All @@ -137,6 +138,7 @@
'dir=s',
'out=s',
'plot!',
'maude!',
'html!',
'text!',
'yaml!',
Expand Down Expand Up @@ -596,6 +598,7 @@ sub json_obsids{
model_spec => "$Starcheck_Data/aca_spec.json",
char_file => "$Starcheck_Data/characteristics.yaml",
orlist => $or_file,
use_maude => $par{maude},
});
# convert back from JSON outside
$obsid_temps = JSON::from_json($json_obsid_temps);
Expand Down Expand Up @@ -1311,12 +1314,14 @@ =head1 OPTIONS
Specify directory which contains starcheck data files including agasc.bad and fid characteristics. Default is SKA/data/starcheck.
Specify YAML configuration file in starcheck data directory. Default is SKA/data/starcheck/characteristics.yaml
=item B<-config_file <config file>>
Specify YAML configuration file in starcheck data directory. Default is SKA/data/starcheck/characteristics.yaml
=item B<-maude>
Set to use MAUDE (instead of CXC Eng Archive) to fetch recent AACCCDPT data for ACA thermal model run
=back
=head1 DESCRIPTION
Expand Down

0 comments on commit 8eb5b23

Please sign in to comment.