Welcome to parse_cm’s documentation!

The parse_cm package provides functions to read, and in some cases write, various configured files that are used in Chandra mission planning.

Backstop

parse_cm.backstop.read_backstop(content)[source]

Read commands from backstop file or backstop-formatted string.

This function is DEPRECATED for new code. Instead use kadi.commands.read_backstop.

Note that the BackstopTable object returned by this function has a cmds property that can be used to convert to a kadi.commands.CommandTable.

Returns a BackstopTable object (derived from astropy Table) which has a row for each backstop command.

Example:

>>> ####################################################################################
>>> # THIS FUNCTION IS DEPRECATED for new code, use kadi.commands.read_backstop instead.
>>> ####################################################################################
>>>
>>> from parse_cm import read_backstop
>>> backstop_lines = [' 2009:035:04:32:22.516 | 8941534 0 | SIMTRANS | POS= 89824, SCS= 128, STEP= 2244']
>>> read_backstop(backstop_lines)
<BackstopTable masked=False length=1>
        date           vcdu     type    tlmsid   scs   step                  params
    string168        int64   string64 string32 int64 int64                  object
--------------------- -------- -------- -------- ----- ----- ----------------------------------------
2009:035:04:32:22.516 89415340 SIMTRANS     None   128  2244 {'step': 2244, 'pos': 89824, 'scs': 128}
Content:

Backstop file name or a list of backstop lines

Returns:

BackstopTable

parse_cm.backstop.read_backstop_as_list(content, inline_params=True)[source]

Read commands from backstop file or backstop-formatted string.

This function is DEPRECATED. Use read_backstop(content).cmds.as_list_of_dict() or kadi.commands.read_backstop(content).as_list_of_dict() instead.

Returns a list of dict objects with keys as follows for each command. Here params is the dict of key=val pairs corresponding to the command description and parameters.

Example:

>>> from parse_cm import read_backstop_as_list
>>> backstop_lines = [' 2009:035:04:32:22.516 | 8941534 0 | SIMTRANS | POS= 89824, SCS= 128, STEP= 2244']
>>> read_backstop_as_list(backstop_lines)
[{'pos': 89824,
'scs': 128,
'step': 2244,
'date': '2009:035:04:32:22.516',
'type': 'SIMTRANS',
'vcdu': 89415340}]

>>> read_backstop_as_list(backstop_lines, inline_params=False)
[{'date': '2009:035:04:32:22.516',
'params': {'pos': 89824, 'scs': 128, 'step': 2244},
'scs': 128,
'step': 2244,
'tlmsid': 'None',
'type': 'SIMTRANS',
'vcdu': 89415340}]
Content:

Backstop file name or a list of backstop lines

Inline_params:

Put params into output dict, otherwise bundle in params (default=True)

Returns:

list of dict for each command

parse_cm.backstop.replace_starcat_backstop(bs, cats)[source]

Replace catalog(s) in bs structure (Table or list of dict).

The cats arg must be a dict of catalogs keyed by obsid, where each catalog is in the mica.starcheck Table format with the following columns: ‘slot’, ‘type’ (e.g. ‘GUI’, ‘BOT’), ‘yang’, ‘zang’, ‘sz’ (e.g. ‘4x4’), ‘halfw’, ‘mag’.

Parameters:
  • bs – backstop Table or list of dict

  • cats – dict of replacement catalogs

Returns:

updated backstop

parse_cm.backstop.write_backstop(content, filename)[source]

Write backstop content (Table or list of dict) to file or file-like object. Note that for the list of dict option one must use inline_params=False when reading.

The example below shows providing the input backstop content as a list of dict (one dict per command). Each command dict must have the following keys: ‘date’, ‘type’, ‘vcdu’, ‘params’. The ‘params’ value is itself a dict with each of the command parameters. The example below should make this clear.

Example:

>>> from parse_cm import write_backstop
>>> bs = [ {'date': '2018:182:08:05:08.332', 'type': 'ORBPOINT', 'vcdu': 1148116,
            'params': {'type': 'EEF1000', 'scs': 0, 'step': 0}
        },
        {'date': '2018:182:08:08:00.257', 'type': 'COMMAND_SW', 'vcdu': 1148820,
            'params': {'tlmsid': 'AONM2NPE', 'hex': '8030601', 'msid': 'AONM2NPE',
                    'scs': 130, 'step': 6}
        },
        ]
>>> write_backstop(bs, 'new.backstop')
>>> !cat new.backstop
2018:182:08:05:08.332 |  1148116 0 | ORBPOINT         | TYPE= EEF1000, SCS= 0, STEP= 0
2018:182:08:08:00.257 |  1148820 0 | COMMAND_SW       | TLMSID= AONM2NPE, HEX= 8030601, ...

In lieu of outputting a file to disk, write_backstop can output to a file-like object instead, as demonstrated in the example below.

Example:

>>> import io
>>> out = io.StringIO()
>>> write_backstop(bs, filename=out)
>>> print(out.getvalue())
2018:182:08:05:08.332 |  1148116 0 | ORBPOINT         | TYPE= EEF1000, SCS= 0, STEP= 0
2018:182:08:08:00.257 |  1148820 0 | COMMAND_SW       | TLMSID= AONM2NPE, HEX= 8030601, ...
Content:

Backstop (Table or list of dict (with Dot file name or a list of dot lines

Filename:

Output filename or file-like object

Characteristics

parse_cm.characteristics.read_characteristics(content='CHARACTERIS_12OCT15', item=None, raw=False)[source]

Read OFLS ODB CHARACTERISTICS file.

If item is supplied then only that item is returns.

By default any available transformation routines will be applied. Transform routines are any function named transform_<item>. This can be disabled by setting raw=True to get raw values.

Parameters:
  • content – OFLS ODB characteristics file name or lines

  • item – return only the item characteristic

  • raw – return raw values instead of transforming where possible

Returns:

dictionary of characteristic values

DOT

parse_cm.dot.read_dot(content)[source]

Read commands from dot file or dot-formatted string.

Returns an astropy Table object which has a row for each dot command. Any DOT comments are stored in the Table meta['comments'] location.

Example:

>>> from parse_cm import read_dot
>>> lines = [
... "ATS,MANVR,Q1=-0.462147874359,Q2=-0.632450473022,Q3=0.228874621726,    EP06040002",
... "MANSTART=000:00:00:00.000,CHANGE_RATE='FALSE',HW='RWA',FSS='OUT',     EP06040002",
... "TIME=2017:007:23:45:36.709                                            EP06040002"]
>>> dot = read_dot(lines)
>>> dot.colnames
['type', 'name', 'dot_id', 'params']
>>> dot['params'][0].keys()
dict_keys(['Q1', 'Q2', 'Q3', 'MANSTART', 'CHANGE_RATE', 'HW', 'FSS', 'TIME'])
Content:

Dot file name or a list of dot lines

Returns:

Table

parse_cm.dot.read_dot_as_list(content)[source]

Read commands from dot file or dot-formatted string.

Returns a list of dict objects with keys as follows for each command. Here params is the dict of key=val pairs corresponding to the command description and parameters. Any DOT comments are stored in the comments attribute of the returned list.

Handles all available DOT files:

>>> from glob import glob
>>> from parse_cm.dot import read_dot_as_list
>>> for filedot in glob("/data/mpcrit1/mplogs/[12]???/???????/ofls/*dot"):
        try:
            dot = read_dot_as_list(filedot)
        except:
            print(filedot)

User warning regarding multiple DOT_IDs will be displayed.

Example:

>>> from parse_cm import read_dot_as_list
>>> lines = ['ATS,MANVR,Q1=-0.462147874359,Q2=-0.632450473022,Q3=0.228874621726,    EP06040002',
            "MANSTART=000:00:00:00.000,CHANGE_RATE='FALSE',HW='RWA',FSS='OUT',     EP06040002",
            "MECH_MOVE='FALSE',DURATION=000:00:25:24.750,                          EP06040002",
            "TIME=2017:007:23:45:36.709                                            EP06040002"]
>>> read_dot_as_list(lines)
[{'name': 'MANVR',
'params': {'CHANGE_RATE': 'FALSE',
            'DOT_ID': 'EP06040002',
            'DURATION': '000:00:25:24.750',
            'FSS': 'OUT',
            'HW': 'RWA',
            'MANSTART': '000:00:00:00.000',
            'MECH_MOVE': 'FALSE',
            'Q1': -0.462147874359,
            'Q2': -0.632450473022,
            'Q3': 0.228874621726,
            'TIME': '2017:007:23:45:36.709'},
'type': 'ATS'}]
Content:

Dot file name or a list of dot lines

Returns:

list of dict for each command

parse_cm.dot.replace_starcat_dot(dot, cats)[source]

Replace the star catalog for obsid with cat.

Functional testing is done in proseco.

The cats arg must be a dict of catalogs keyed by obsid, where each catalog is in the mica.starcheck Table format with the following columns: ‘slot’, ‘type’ (e.g. ‘GUI’, ‘BOT’), ‘yang’, ‘zang’, ‘sz’ (e.g. ‘4x4’), ‘halfw’, ‘mag’.

Parameters:
  • guide_summ – guide summary from read_guide_summary

  • cats – dict of replacement catalogs

  • date – optional date for star proper motion

Returns:

updated DOT

parse_cm.dot.write_dot(content, filename, orviewer_hrc_bug=False)[source]

Write DOT content (Table or list of dict) to file.

Example:

>>> from parse_cm import read_dot, write_dot
>>> lines = ['ATS,MANVR,Q1=-0.462147874359,Q2=-0.632450473022,Q3=0.228874621726,    EP06040002',
            "MANSTART=000:00:00:00.000,CHANGE_RATE='FALSE',HW='RWA',FSS='OUT',     EP06040002",
            "TIME=2017:007:23:45:36.709                                            EP06040002"]
>>> dot = read_dot(lines)
>>> write_dot(dot, 'new.dot')
Content:

DOT (as Table or list of dict)

Filename:

Output filename

Orviewer_hrc_bug:

Replicate bug in ORviewer DOT output format for HRC params

DOT / FOT request cmd gen

The parse_cm.csd module implements an interpreter for the OP-19 Command Sequence Definition language. It is used to translate a Detailed Operations Timeline (DOT) or a FOT request into backstop commands. Some Caveats apply, but for most commanding the translation is accurate and well-tested.

By default this uses the configured ATS and RTS product files on OCCweb, but you can optionally use local versions of those files.

Examples

Translate a DOT to a backstop CommandTable

In this example we translate the DOT from MAR2122A into a kadi CommandTable with the corresponding backstop commands.

First we need to get the DOT file:

>>> from kadi.occweb import get_occweb_page
>>> mar2122a = 'FOT/mission_planning/PRODUCTS/APPR_LOADS/2022/MAR/MAR2122A'
>>> dot = get_occweb_page(f'{mar2122a}/mps/mdMAR2122A.dot', cache=True)
>>> print(dot[:400])
!Schedule generated by MATLAB Tools at: 2022:073:16:05:24.432

ATS,ACQ,MANEUVER='TRUE',NUMENT=12,AQIM1=0,AQY1=-0.00375441,           O23840M001
AQZ1=-0.00453566,AQMBRT1=6.00000000,AQMFNT1=8.00000000,AQRES1='H',    O23840M001
AQBOX1=1,AQSIZE1=2,AQFLG1=3,AQIM2=1,AQY2=0.01037522,AQZ2=0.00470447,  O23840M001
AQMBRT2=6.00000000,AQMFNT2=8.00000000,AQRES2='H',AQBOX2=1,AQSIZE2=2,  O23840M001
AQFLG2=3,AQIM

In order to translate the DOT correctly, we need to set continuity. In typical flight planning these values are managed in ORviewer and provided to CMAN, but in this case we do this manually.

>>> from parse_cm.csd import get_initial_globals_from_trp
>>> trp = get_occweb_page(f'{mar2122a}/C079_2001.trp', cache=True)
>>> initial_globals = get_initial_globals_from_trp(trp)
>>> initial_globals
{'G_ACQFLG': 'FALSE',
'G_MANFLG': 'TRUE',
'G_SUNPOSMON': 'ENAB',
'G_TLM_FMT': 2,
'PREV_HRC_DETECTOR': 'HRC-I',
'SHUTTERS_HOME': 'TRUE',
'PREV_HRC_DEF_SETTINGS': 'FALSE',
'HRC_DOOR_OPEN': 'TRUE',
'G_MSFILTER': 'DISA',
'G_IU_ID': 'A',
'G_GRATING_STAT': 'NONE',
'G_98_STATE': 'ENAB'}

We need any FOT requests that were included:

>>> fot_request = get_occweb_page(f'{mar2122a}/fot/MAR2122A_RAD_DM.fot', cache=True)

And finally get the backstop commands from the DOT:

>>> from parse_cm.csd import csd_cmd_gen
>>> cmds = csd_cmd_gen(dot, initial_globals=initial_globals,
...                    fot_requests=[fot_request])
>>> cmds
        date            type     tlmsid  scs           params
--------------------- ---------- -------- --- -------------------------
2022:079:20:30:44.820 COMMAND_SW AOACRSTD 128             MSID=AOACRSTD
2022:079:20:31:44.820 COMMAND_SW AOFUNCDS 128 AOPCADSD=21 MSID=AOFUNCDS
2022:079:20:32:44.820 COMMAND_SW AOFUNCDS 128 AOPCADSD=32 MSID=AOFUNCDS
2022:079:20:33:44.820 COMMAND_SW AONMMODE 128             MSID=AONMMODE
2022:079:20:33:44.820   ORBPOINT     None 131                 POS=91254
                ...        ...      ... ...                       ...
2022:086:22:30:01.285 COMMAND_HW   CTXAOF 128               MSID=CTXAOF
2022:086:22:30:01.542 COMMAND_HW   CTXBOF 128               MSID=CTXBOF
2022:086:22:30:01.799 COMMAND_HW   CPAAOF 128               MSID=CPAAOF
2022:086:22:30:02.056 COMMAND_HW   CPABOF 128               MSID=CPABOF
2022:086:22:30:02.313 COMMAND_SW OFMTSNRM 128             MSID=OFMTSNRM
Length = 1416 rows

Translate a FOT request to commands

>>> from parse_cm.csd import csd_cmd_gen
>>> fot_req = '''
... RTSLOAD,A_QUP,SCS_NUM=214,
... Q1=0.70546907,
... Q2=0.32988307,
... Q3=0.53440900
... '''
>>> cmds = csd_cmd_gen(fot_req, date='2021:001')
>>> print(cmds)
         date             type     tlmsid  scs                         params
--------------------- ----------- -------- --- ------------------------------------------------------
2021:001:00:00:00.000 MP_TARGQUAT AOUPTARQ 214 Q1=0.70546907 Q2=0.32988307 Q3=0.534409 Q4=0.328477658

Caveats

This command generation does not get to the level of CMAN, for instead the SCS is fixed to either 128, 131, or the specified SCS number, and the command “step” number is not generated. However, the key command parameters do match.

ACA hardware commanding via the AAC1CCSC command is not generated correctly. Instead you will see commands like AAC1CAL, AAC1INT, AAC1HDR, and/or AAC1IU.

By default, the ATS and RTS files which get used in the translation are the current flight configured products on OCCweb. These are downloaded from OCCweb as needed. If you translate an older DOT then problems may occur, either outright failures or command outputs that do not match the actual backstop commands at the time of original translation. In most cases, apart from regression testing, this is not an issue. The csd_dir option of csd_cmd_gen() provides a pathway to use a fixed or archived set of ATS / RTS products.

Testing

Testing of this module has included running the command generation for dozens of historical DOT files and comparing the generated commands to the flight backstop. Current regression testing uses MAR2122A, MAR1422A, MAR0722A, FEB2822A, and FEB2122A.

API docs

ACIS Tables

parse_cm.acis_tables.get_acis_tables(cfg_file=None, dat_file=None)[source]

Parse the ACIS tables (.cfg and .dat files) and retrieve the following information:

From the configuration (.cfg) file: dictionary of SIMODES which contains the number of ACIS command packets, the specific packets used, and the delay times in seconds after each command.

From the data (.dat) file: dictionary of ACIS command packets with word_length, command_opcode, slot_id, file_format, packet_duration, and binary_data.

Looks first for an environment variable $ACIS_TABLES_DIR for the location of the tables, and failing that, looks in $SKA/data/acis_tables.

Parameters

cfg_filestring or Path object, optional

The ACIS tables CFG file to use. Default is “current.cfg.”

dat_filestring or Path object, optional

The ACIS tables CFG file to use. Default is “current.dat.”

Returns

Two Python dictionaries containing the .cfg and .dat table information, in that order.

Examples

>>> from parse_cm import get_acis_tables
>>> tab_cfg, tab_dat = get_acis_tables()
>>> print(tab_cfg["TE_007AC"])
{
    'cmd_cnt': 6,
    'packets': [
        'WSVIDALLDN',
        'WSPOW0CF3F',
        'WT007AD024',
        'XTZ0000005',
        'RS_0000001',
        'RH_0000001'
    ],
    'delays': [18, 63, 4, 4, 4, 23]
}
>>> print(tab_dat["WSPOW0CF3F"])
{
    'word_length': 7,
    'cmd_type': '',
    'slot_id': '',
    'file_format': '2',
    'packet_duration': 0,
    'binary_data': [1792, 26369, 8192, 0, 52992, 256, 16128]
}

Translate a DOT or FOT request into backstop commands.

This module implements an interpreter for the OP-19 Command Sequence Definition language. It is used to translate a Detailed Operations Timeline (DOT) or FOT request into backstop commands.

parse_cm.csd.csd.csd_cmd_gen(csd, *, date=None, fot_requests=None, csd_dir=None, debug=False, initial_globals=None, use_default_globals=False)[source]

Parse DOT or FOT request and return a table of commands.

If the input is a FOT request then the date should be supplied as the starting date of the commands (defaults to 2000:001).

Example:

>>> from parse_cm import csd
>>> fot_req = '''
... RTSLOAD,A_QUP,SCS_NUM=214,
... Q1=0.70546907,
... Q2=0.32988307,
... Q3=0.53440900
... '''
>>> cmds = csd.csd_cmd_gen(fot_req, date='2021:001')
>>> print(cmds)
         date             type     tlmsid  scs                         params
--------------------- ----------- -------- --- ------------------------------------------------------
2021:001:00:00:00.000 MP_TARGQUAT AOUPTARQ 214 Q1=0.70546907 Q2=0.32988307 Q3=0.534409 Q4=0.328477658
Parameters:
  • csd – str, Path Input file name or text of DOT/FOT request to generate commands.

  • date – str, optional Starting date of the commands for a FOT request.

  • fot_requests – list of str, optional Optional list of FOT requests which are prepended to a DOT

  • csd_dir – str, optional Directory to look for CSD files (with subdirs ATS/ and/or RTS/). If not set or the file is not found then fall back to OCCweb. This parameter is handy for testing or for locally modified CSD files.

  • debug – bool If True, print debugging information.

  • initial_globals – dict Dictionary of initial global symbols.

  • use_default_globals – bool If True, use default global symbols.

Returns:

CommandTable

parse_cm.csd.csd.get_initial_globals_from_trp(trp)[source]

Get initial globals from command load gen Translation Report (TRP) file.

Params trp:

str Text of translation report file.

Returns:

dict Dict of initial globals defined in the TRP file.

parse_cm.csd.csd.run_csd(csd, *, date=None, fot_requests=None, csd_dir=None, debug=False, initial_globals=None, use_default_globals=False, trace=None, vehicle_only=False, parse_only=False, write_tables=False, yacc_kwargs=None)[source]

Low level function to run a CSD file. This is NOT recommended for most users and you should use csd_cmd_gen() instead.

NOTE: use_default_globals default should be set to False for production.

Example:

>>> from parse_cm import csd
>>> from pathlib import Path
>>> small_dot = Path(csd.__file__).parent / 'tests' / 'small.dot'
>>> bs = csd.run_csd(small_dot, use_default_globals=True)
>>> csd.print(backstop)
2012:310:02:59:57.056 COMMAND    SCS=128 TLMSID=AOACRSTD MSID=AOACRSTD
2012:310:03:02:57.056 COMMAND    SCS=128 TLMSID=AONMMODE MSID=AONMMODE
2012:310:03:02:57.313 COMMAND    SCS=128 TLMSID=AONM2NPE MSID=AONM2NPE
...
2012:310:04:28:50.889 COMMAND    SCS=128 TLMSID=AOFUNCEN AOPCADSE=21 MSID=AOFUNCEN
2012:310:05:40:01.285 COMMAND    SCS=128 TLMSID=CTXAOF MSID=CTXAOF
2012:310:05:40:01.542 COMMAND    SCS=128 TLMSID=CTXBOF MSID=CTXBOF
2012:310:05:40:01.799 COMMAND    SCS=128 TLMSID=CPAAOF MSID=CPAAOF
2012:310:05:40:02.056 COMMAND    SCS=128 TLMSID=CPABOF MSID=CPABOF
2012:310:05:40:02.313 COMMAND    SCS=128 TLMSID=OFMTSNRM MSID=OFMTSNRM
Parameters:
  • csd – str, Path Input file name or text of DOT/FOT request to generate commands.

  • date – str, optional Starting date of the commands for a FOT request.

  • fot_requests – list of str, optional Optional list of FOT requests which are prepended to a DOT

  • csd_dir – str, optional Directory to look for CSD files (with subdirs ATS/ and/or RTS/). If not set or expected file is not found then fall through to OCCweb. This parameter is handy for testing or for locally modified CSD files.

  • debug – bool If True, print debugging information and write “parser.out” file into the source directory. Probably can be used only in development repo.

  • initial_globals – dict Dictionary of initial global symbols.

  • use_default_globals – bool If True, use default global symbols.

  • trace – list, optional List of symbols to trace.

  • vehicle_only – bool If True, only generate vehicle commands.

  • parse_only – bool If True, only parse the CSD file instead of generating commands.

  • write_tables – bool If True, write out the “parsetab.py” parser file. This is only needed when developing the parser as it writes into the source directory.

  • yacc_kwargs – dict Additional keyword arguments to pass to the yacc parser.

Returns:

list of BaseCommand objects

Guide Summary

Read and write a series of PROCESSING REQUEST blocks in the SAUSAGE (formerly OFLS) guide star summary file.

HEADER stuff
...

**** PROCESSING REQUEST ****
    ID:         49159  (49159)
    X-AXIS RA:  260.676014 DEG.
    X-AXIS DEC:  -6.693566 DEG.

X-AXIS ROLL (DEG): 226.5501

STARS/FIDUCIAL LIGHTS                                 AC COORDINATES (RAD)
TYPE           ID   RA(DEG)  DEC(DEG)      MAG       Y-ANGLE       Z-ANGLE
**************************************************************************
BOT     665584672  260.3963   -7.0911    8.892   8.36903E-03   1.25645E-03  a2g1
BOT     665715152  260.6428   -6.9459    9.914   3.59573E-03   2.60999E-03  a2g3
BOT     665715344  261.1431   -6.9607    8.648  -2.17797E-03   9.08459E-03  a2g2
BOT     665716160  260.7685   -7.1046    6.983   4.10718E-03   6.10107E-03  a1g1
BOT     665717192  260.8468   -6.0276    8.869  -1.04755E-02  -5.83994E-03  a2g3
BOT     665718480  261.4977   -6.5818    7.249  -1.12048E-02   9.01141E-03  a1g1
BOT     665718576  260.6758   -6.3313    8.203  -4.57547E-03  -4.34249E-03  a1g1
GUI     665715088  260.9592   -7.2511    9.931   3.69483E-03   1.02524E-02  g3
ACQ     665717320  261.0946   -6.5372    9.419  -6.97051E-03   3.39567E-03  a2
parse_cm.guide_summary.read_guide_summary(content)[source]

Parse guide summary into a dict with header lines, footer lines, and a list of dict with star catalog tables. This is not a complete parsing but enough to modify and/or rewrite the file.

Parameters:

content – filename or list of lines

Returns:

dict

parse_cm.guide_summary.replace_starcat_guide_summary(guide_summ, cats, date=None)[source]

Replace the star catalog for obsid with cat. The date parameter is used for proper motion in stars. If not supplied then a reasonably-close date is scraped from the guide summary processing time.

The cats arg must be a dict of catalogs keyed by obsid, where each catalog is in the mica.starcheck Table format with the following columns: ‘slot’, ‘type’ (e.g. ‘GUI’, ‘BOT’), ‘yang’, ‘zang’, ‘sz’ (e.g. ‘4x4’), ‘halfw’, ‘mag’.

Parameters:
  • guide_summ – guide summary from read_guide_summary

  • cats – dict of replacement catalogs

  • date – optional date for star proper motion

Returns:

updated guide summary structure

parse_cm.guide_summary.write_guide_summary(guide_summ, filename)[source]

Write guide_summ dict from read_guide_summary back to filename.

Parameters:
  • guide_summ – dict

  • filename – output filename

Maneuver Summary

parse_cm.maneuver.read_maneuver_summary(content, structured=False)[source]

Read maneuver summary content.

Parse maneuver content from the OFLS manuever summary file. This works for MPS MMAN VERSION = 9.40 through 11.0 (from late 2002 onward). By default the initial and final maneuver values (e.g. q1, ra etc) are denoted with a trailing _0 or _1, respectively:

>>> ms = read_maneuver_summary(manvr_summ_file)
>>> ms['q1_0']  # initial quaternion element 1
0.123132322

Howevever, if the structured arg is set to True then the values are collected into sub-dicts initial and final:

>>> ms = read_maneuver_summary(manvr_summ_file, structured=True)
>>> ms['initial']['q1']  # initial quaternion element 1
0.123132322
Parameters:
  • filename – Maneuver summary file name

  • structured – create initial/final sub-dicts (default=False)

Return type:

list of dict for each maneuver

OR List

parse_cm.or_list.get_zero_offset_table(content)[source]

Extract zero offset table from OR filename or OR text as list of strings

Parameters:

content – OR list filename or OR list as list of strings

Returns:

table of zero offset entries

parse_cm.or_list.read_or_list(content, asdict=False)[source]

Read an OR list file or content (DEPRECATED, use read_or_list_full instead)

This uses a legacy parser which is incomplete and does not parse all OR parameters or arguments. The parameter names are adhoc.

An example output is:

{
    "chip_id": 7,
    "chipx": 200.7,
    "chipy": 476.9,
    "cycle": 17,
    "detector": "ACIS-S",
    "dither_on": "ON",
    "dither_y_amp": 0.002222,
    "dither_y_freq": 0.36,
    "dither_y_phase": 0.0,
    "dither_z_amp": 0.002222,
    "dither_z_freq": 0.5091,
    "dither_z_phase": 0.0,
    "duration": 25000.0,
    "grating": "HETG",
    "mon_dec": -7.735581,
    "mon_ra": 111.463705,
    "obsid": 18799,
    "priority": 5,
    "si": "ACIS-S",
    "si_mode": "TE_0088E",
    "sim_offset_x": 0,
    "sim_offset_z": 0,
    "target_dec": 65.719444,
    "target_name": "Mkn 876",
    "target_offset_y": 0.0,
    "target_offset_z": 0.0,
    "target_ra": 243.488333,
}
Parameters:
  • content – OR list file name or lines

  • asdict – return dict instead of list

Returns:

list of dict ORs or dict of ORs keyed by obsid (if asdict is True)

parse_cm.or_list.read_or_list_full(content)[source]

Read an OR list file or list of lines for an OR.

This returns a nested dict of parameter values keyed by obsid. Parameters that have multiple arguments are represented as a dict. An example output is:

{
    "aca_mode": "DEFAULT",
    "comment": "The proposed observation is an ACIS-HETG observation.",
    "dither": {
        "status": "ON",
        "y_amp": 0.002222,
        "y_freq": 0.36,
        "y_phase": 0.0,
        "z_amp": 0.002222,
        "z_freq": 0.5091,
        "z_phase": 0.0,
    },
    "duration": {"nominal": 25000.0},
    "grating": "HETG",
    "id": 18799,
    "min_acq": 1,
    "min_guide": 1,
    "preceding": {"reqid": 18798},
    "priority": 5,
    "roll": {"roll_angle": 105.0, "roll_tolerance": 0.0},
    "segment": {"max_number": 1, "min_duration": 22800.0},
    "si": "ACIS-S",
    "si_mode": "TE_0088E",
    "sim_offset": {"focus_offset": 0, "trans_offset": 0},
    "star": {"dec": -7.735581, "mag": 9.0, "ra": 111.463705, "type": "MON"},
    "target": {"dec": 65.719444, "name": "Mkn 876", "ra": 243.488333},
    "target_offset": {"y_offset": 0.0, "z_offset": 0.0},
    "window": {
        "window_end_time": "2016:067:01:47:50.562",
        "window_start_time": "2016:067:00:08:52.887",
    },
    "zero_offset": {
        "chip_id": 7,
        "chipx": 200.7,
        "chipy": 476.9,
        "cycle": 17,
        "date": "2016-03-05",
        "detector": "ACIS-S",
    },
}

In addition to the formal OR parameters, this function puts additional values into the dict for each OR:

  • ‘comment’: OR comment if available

  • ‘info’: dict of key/value pairs from OR comment if it conforms to the OR list

    machine-readable comments specification.

  • ‘zero_offset’: dict of zero_offset values from the zero-offsets table

The second return value is a list of the comments in the OR list that have ID=49999.

Parameters:

content – OR list file name or list of lines

Returns:

(dict, list) Dict of ORs keyed by obsid, list of comments (ID=49999)

Indices and tables