sot / kadi

Chandra commands and events
https://sot.github.io/kadi
BSD 3-Clause "New" or "Revised" License
5 stars 3 forks source link

CommandTable get_rltt needs docs and looks to only work on from-backstop cmds #306

Closed jeanconn closed 7 months ago

jeanconn commented 7 months ago

CommandTable get_rltt needs docs and looks to only work on from-backstop cmds

I thought it could perhaps be used to fetch arbitrary rltt in archived commands.


In [1]: from kadi.commands import get_cmds

In [2]: cmds = get_cmds('2023:009', '2023:010')

In [3]: cmds.get_rltt()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[3], line 1
----> 1 cmds.get_rltt()

File ~/miniconda3/envs/ska3/lib/python3.10/site-packages/kadi/commands/core.py:557, in CommandTable.get_rltt(self)
    552 def get_rltt(self):
    553     # Find the RLTT, which should be near the start of the table.
    554     for cmd in self:
    555         if (
    556             cmd["type"] == "LOAD_EVENT"
--> 557             and cmd["params"]["event_type"] == "RUNNING_LOAD_TERMINATION_TIME"
    558         ):
    559             return cmd["date"]
    561     return None

KeyError: 'event_type'

In [4]: cmds.fetch_params()

In [5]: cmds.get_rltt()
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[5], line 1
----> 1 cmds.get_rltt()

File ~/miniconda3/envs/ska3/lib/python3.10/site-packages/kadi/commands/core.py:557, in CommandTable.get_rltt(self)
    552 def get_rltt(self):
    553     # Find the RLTT, which should be near the start of the table.
    554     for cmd in self:
    555         if (
    556             cmd["type"] == "LOAD_EVENT"
--> 557             and cmd["params"]["event_type"] == "RUNNING_LOAD_TERMINATION_TIME"
    558         ):
    559             return cmd["date"]
    561     return None

KeyError: 'event_type'

In [6]: cmds[(cmds['type'] == 'LOAD_EVENT') & (cmds['tlmsid'] != 'OBS')]
Out[6]: 
 idx            date            type    tlmsid scs step      time      source  vcdu                  params                 
------ --------------------- ---------- ------ --- ---- ------------- -------- ---- ----------------------------------------
207386 2023:009:04:14:00.000 LOAD_EVENT   None   0    0 789624909.184 DEC2622A    0           event_type=SCHEDULED_STOP_TIME
207385 2023:009:04:14:00.000 LOAD_EVENT   None   0    0 789624909.184 JAN0923A    0 event_type=RUNNING_LOAD_TERMINATION_TIME

In [7]: