Chandra.cmd_states

See also the cmd_states task.

Functions

Chandra.cmd_states.cmd_set(name, *args)

Return a predefined cmd_set name generated with *args.

Parameters:
  • name – cmd set name (manvr|scs107|nsm)
  • *args – optional args
Returns:

cmd set

Chandra.cmd_states.decode_power(mnem)

Decode number of chips and feps from a ACIS power command Return a dictionary with the number of chips and their identifiers

Example:

>>> decode_power("WSPOW08F3E")
{'ccd_count': 5,
 'ccds': 'I0 I1 I2 I3 S3 ',
 'fep_count': 5,
 'feps': '1 2 3 4 5 '}
Parameters:mnem – power command string
Chandra.cmd_states.generate_cmds(time, cmd_set)

Generate a set of commands based on the supplied cmd_set starting from the specified time.

The cmd_set is a list of command definitions like the output of read_backstop() but with an optional ‘dur’ key in each command and no absolute time values. This key specifies the duration of that command in seconds. Normally this routine is used with the predefined CMD_SET values.

Parameters:
  • cmd_set – list of command definitions
  • time – starting time for command set
Returns:

list of command dicts ala read_backstop()

Chandra.cmd_states.get_states(state0, cmds, exclude=None)

Get states resulting from the spacecraft commands cmds starting from an initial state0.

State keys in the exclude list or set will be excluded from causing a transition. This is useful if a state parameter (e.g. simfa_pos) is not of interest. An excluding parameter will have incorrect values in the returned states.

A state is a dict with key values corresponding to the following database schema:

Name Type Size
datestart varchar 21
datestop varchar 21
obsid int 4
power_cmd varchar 11
si_mode varchar 8
pcad_mode varchar 6
vid_board bit 1
clocking bit 1
fep_count int 4
ccd_count int 4
simpos int 4
simfa_pos int 4
pitch float 8
ra float 8
dec float 8
roll float 8
q1 float 8
q2 float 8
q3 float 8
q4 float 8
trans_keys varchar 60
letg varchar 4
hetg varchar 4
dither varchar 4

The input commands must be a list of dicts including keys date, vcdu, cmd, params, time. See also Ska.ParseCM.read_backstop().

Parameters:
  • state0 – initial state.
  • cmds – list of commands
  • ignore – list or set of state keys to ignore
Returns:

recarray of states starting with state0 (which might be modified)

Chandra.cmd_states.get_state0(date=None, db=None, date_margin=10, datepar='datestop')

From the cmd_states table get the last state with datepar before date.

It is assumed that the cmd_states database table is populated and accurate (definitive) at times more than date_margin days before the present time. The conservative default value of date_margin=10 allows for processing downtime. The table is accessed via the db object.
Parameters:
  • db – Ska.DBI.DBI object. Created automatically if not supplied.
  • date – date cutoff for state0 (Chandra.Time ‘date’ string)
  • date_margin – days before current time for definitive values
  • datepar – table parameter for select (datestop|datestart)
Returns:

state0

Return type:

dict

Chandra.cmd_states.get_cmds(datestart='1998:001:00:00:00.000', datestop='2099:001:00:00:00.000', db=None, update_db=None, timeline_loads=None, mp_dir='/data/mpcrit1/mplogs')

Get all commands with datestart < date <= datestop using DBI object db. This includes both commands already in the database and new commands. If update_db is True then update the database cmds table to reflect new and/or deleted commands.

Use datestart < date instead of <= because in typical ussage datestart is the start date of a state and one wants commands after those that generated the original state transition.

The timeline_loads table is relied upon as the final authority of which commands were (will be) run on-board. The timeline_load values can change in the database in the event of an autonomous or ground-commanded load segment interrupt. The strategy is to regenerate the list of commands that were (will be) run on-board using commands already in the database supplemented by backstop commands found in the SOTMP repository of load products.

Parameters:
  • datestart – start date (Chandra.Time ‘date’ str) (default=1998:001)
  • datestop – stop date (default=2099:001)
  • db – Ska.DBI.DBI object (required)
  • update_db – update the ‘cmds’ table
Returns:

cmds

Return type:

list of dicts

Chandra.cmd_states.insert_cmds_db(cmds, timeline_id, db)

Insert the cmds into the db table ‘cmds’ with timeline_id. Command parameters are also inserted into ‘cmd_intpars’ and ‘cmd_fltpars’ tables. timeline_id can be None to indicate non-load commands (from ground or autonomous).

Each command must be dict with at least the following keys:

date char
time float
cmd char

Optional keys are:

params dict
paramstr char
tlmsid char
msid char
vcdu int
step int
scs int

The input cmds are used to populate three tables:

cmds

name type length
id (PK) int 4
timeline_id int 4
date char 21
time float 8,
cmd varchar 12
tlmsid varchar 10
msid varchar 8
vcdu int 4
step int 4
scs int 4

cmd_intpars and cmd_fltpars

name type length
cmd_id (FK) int 4
timeline_id (FK) int 4
name varchar 15
value int/float 8
Parameters:
  • cmds – list of command dicts, e.g. from Ska.ParseCM.read_backstop()
  • db – Ska.DBI.DBI object
  • timeline_id – id of timeline load segment that contains commands
Returns:

None

Chandra.cmd_states.interpolate_states(states, times)

Interpolate states np.recarray at given times.

Parameters:
  • states – states (np.recarray)
  • times – times (np.array or list)
Returns:

states view at times

Chandra.cmd_states.interrupt_loads(datestop, db, observing_only=False, current_only=False)

Interrupt the timelines with db.datestop > datestop by updating the table datestop accordingly. Use DBI handle db to access tables. If current_only is set then only update the load that actually contains datestop.

Parameters:
  • datestop – load stop date
  • db – Ska.DBI.DBI object
  • observing_only – only interrupt ‘observing’ slots (131,132,133)
  • current_only – only stop the load containing datestop
Returns:

None

Chandra.cmd_states.reduce_states(states, cols, allow_identical=True)

Reduce the input states so that only transitions in the cols columns are noticed.

Parameters:
  • states – numpy recarray of states
  • cols – notice transitions in this list of columns
  • allow_identical – allow null transitions between apparently identical states
Returns:

numpy recarray of reduced states

Table Of Contents

Previous topic

Ska python documentation

Next topic

Chandra.ECF