sot / chandra_cmd_states

Interface for creation and maintenance of the Chandra commanded states database.
https://sot.github.io/cmd_states
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Set interrupt_loads to shorten timelines only as short as zero length #61

Closed jeanconn closed 3 years ago

jeanconn commented 3 years ago

Description

Set interrupt_loads to shorten timelines only as short as zero length. This sets the timelines to not have negative duration. This should prevent recurrence of https://github.com/sot/timelines/issues/24 without any side-effects.

Testing

I tested just with sqlite and confirmed expected datestop values by eye, with an interrupt time set to '2020:266:14:48:29.000' in full interrupt and observing_only modes.

Current real database

sqlite> select * from timelines where datestart > '2020:260';
426104399|426104272|/2020/SEP1220/oflsa/|2020:261:23:14:59.959|2020:264:06:44:08.275|0|0|0
426104400|426104273|/2020/SEP1220/oflsa/|2020:261:23:14:59.959|2020:264:06:44:08.275|0|0|0
426104401|426104274|/2020/SEP2120/oflsa/|2020:264:06:42:00.000|2020:267:05:04:01.816|0|0|0
426104402|426104275|/2020/SEP2120/oflsa/|2020:264:06:42:00.000|2020:267:05:04:01.816|0|0|0
426104403|426104276|/2020/SEP2120/oflsa/|2020:267:05:46:01.272|2020:270:03:15:02.313|0|0|0
426104404|426104277|/2020/SEP2120/oflsa/|2020:267:05:46:01.272|2020:270:03:15:02.313|0|0|0
426104405|426104278|/2020/SEP2120/oflsa/|2020:270:08:32:29.334|2020:272:05:01:47.549|0|0|0
426104406|426104279|/2020/SEP2120/oflsa/|2020:270:08:32:29.334|2020:272:05:01:47.549|0|0|0

Doing a full interrupt

sqlite> select * from timelines where datestart > '2020:260';
426104399|426104272|/2020/SEP1220/oflsa/|2020:261:23:14:59.959|2020:264:06:44:08.275|0|0|0
426104400|426104273|/2020/SEP1220/oflsa/|2020:261:23:14:59.959|2020:264:06:44:08.275|0|0|0
426104401|426104274|/2020/SEP2120/oflsa/|2020:264:06:42:00.000|2020:266:14:48:29.000|0|0|0
426104402|426104275|/2020/SEP2120/oflsa/|2020:264:06:42:00.000|2020:266:14:48:29.000|0|0|0
426104403|426104276|/2020/SEP2120/oflsa/|2020:267:05:46:01.272|2020:267:05:46:01.272|0|0|0
426104404|426104277|/2020/SEP2120/oflsa/|2020:267:05:46:01.272|2020:267:05:46:01.272|0|0|0
426104405|426104278|/2020/SEP2120/oflsa/|2020:270:08:32:29.334|2020:270:08:32:29.334|0|0|0
426104406|426104279|/2020/SEP2120/oflsa/|2020:270:08:32:29.334|2020:270:08:32:29.334|0|0|0

Observing-only

sqlite> select * from timelines where datestart > '2020:260';
426104399|426104272|/2020/SEP1220/oflsa/|2020:261:23:14:59.959|2020:264:06:44:08.275|0|0|0
426104400|426104273|/2020/SEP1220/oflsa/|2020:261:23:14:59.959|2020:264:06:44:08.275|0|0|0
426104401|426104274|/2020/SEP2120/oflsa/|2020:264:06:42:00.000|2020:267:05:04:01.816|0|0|0
426104402|426104275|/2020/SEP2120/oflsa/|2020:264:06:42:00.000|2020:266:14:48:29.000|0|0|0
426104403|426104276|/2020/SEP2120/oflsa/|2020:267:05:46:01.272|2020:270:03:15:02.313|0|0|0
426104404|426104277|/2020/SEP2120/oflsa/|2020:267:05:46:01.272|2020:267:05:46:01.272|0|0|0
426104405|426104278|/2020/SEP2120/oflsa/|2020:270:08:32:29.334|2020:272:05:01:47.549|0|0|0
426104406|426104279|/2020/SEP2120/oflsa/|2020:270:08:32:29.334|2020:270:08:32:29.334|0|0|0

Fixes https://github.com/sot/timelines/issues/24

jeanconn commented 3 years ago

Are we thinking about backports to ska2? I suppose I also need to test and update the scs107 directions to use ska3 (whinch may be shiny... not sure about our promotion plan).

jeanconn commented 3 years ago

Good point about the ternary. I think here I don't mind seeing more lines of code because it does deserve a bit of attention.

taldcroft commented 2 years ago

This should prevent recurrence of sot/timelines#24 without any side-effects.

Not completely without any side effects. :smile:

Kadi.commands uses the following to select commands within timeline segments:

        # Only store commands for this timeline (match SCS and date)
        bs_cmds = [x for x in bs_cmds
                   if tl['datestart'] <= x['date'] <= tl['datestop']
                   and x['scs'] == tl['scs']]

So if there is a command that is exactly at tl['datestart'] and tl['datestop'] then it gets accepted. This happens for some AOACRSTD in real life (e.g. the 2021:296 NSM interrupt).

Question: is the datestop supposed to be inclusive? Should I write if tl['datestart'] <= x['date'] < tl['datestop'] or should we clip datestop (for an interrupt) to 1 ms earlier?

ANSWER: Yes, it is inclusive (from examining some loads and the corresponding timelines). So we may need to clip to 1 ms earlier.