Closed jeanconn closed 1 month ago
Here are a couple of other continuity failures (these look like obsid = None problems more than attitude = unknown ones).
In [1]: from kadi.commands import states
In [2]: states.get_continuity(743506575.506)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[2], line 1
----> 1 states.get_continuity(743506575.506)
File /proj/sot/ska3/flight/lib/python3.11/site-packages/kadi/commands/states.py:2305, in get_continuity(date, state_keys, lookbacks, scenario)
2294 # Get available commanded states for this particular state_key.
2295 # This may return state values for many more keys (e.g.
2296 # PCAD-related), and some or all of these might be None if the
2297 # relevant command never happened. Fill in continuity as possible
2298 # from last state (corresponding to the state after the last command
2299 # in cmds).
2300 try:
2301 # Note that we need to specify start and stop to ensure that the
2302 # states span the required time range. Without this the time
2303 # range of cmds is used which can give unexpected outputs if
2304 # ``date``` is within a maneuver.
-> 2305 states = get_states(
2306 state_keys=state_key,
2307 cmds=cmds,
2308 start=start,
2309 stop=stop,
2310 continuity={},
2311 reduce=False,
2312 scenario=scenario,
2313 )
2314 except NoTransitionsError:
2315 # No transitions within `cmds` for state_key, continue with other keys
2316 continue
File /proj/sot/ska3/flight/lib/python3.11/site-packages/kadi/commands/states.py:2111, in get_states(start, stop, state_keys, cmds, continuity, reduce, merge_identical, scenario)
2106 for key, value in transition.items():
2107 if callable(value):
2108 # Special case of a functional transition that calls a function
2109 # instead of directly updating the state. The function might itself
2110 # update the state or it might generate downstream transitions.
-> 2111 value(date, transitions, state, idx)
2112 elif key != "date":
2113 # Normal case of just updating current state
2114 state[key] = value
File /proj/sot/ska3/flight/lib/python3.11/site-packages/kadi/commands/states.py:1658, in ACISTransition.simode_callback(tlmsid, date, transitions, state, idx)
1655 si_mode = NIL_SIMODES[tlmsid]
1656 # Value of SIMODE in some cases depends on whether obsid is
1657 # an odd or even number
-> 1658 if si_mode.startswith("HIE") and state["obsid"] % 2 != 0:
1659 si_mode = si_mode.replace("HIE", "HIO")
1661 # All other SI modes: this logic uses the PBLK command to
1662 # determine the SI mode hex string, which depends in part on
1663 # whether a bias is being (re)computed.
TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'
In [3]: states.get_continuity(743506575.506)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 states.get_continuity(743506575.506)
File /proj/sot/ska3/flight/lib/python3.11/site-packages/kadi/commands/states.py:2305, in get_continuity(date, state_keys, lookbacks, scenario)
2294 # Get available commanded states for this particular state_key.
2295 # This may return state values for many more keys (e.g.
2296 # PCAD-related), and some or all of these might be None if the
2297 # relevant command never happened. Fill in continuity as possible
2298 # from last state (corresponding to the state after the last command
2299 # in cmds).
2300 try:
2301 # Note that we need to specify start and stop to ensure that the
2302 # states span the required time range. Without this the time
2303 # range of cmds is used which can give unexpected outputs if
2304 # ``date``` is within a maneuver.
-> 2305 states = get_states(
2306 state_keys=state_key,
2307 cmds=cmds,
2308 start=start,
2309 stop=stop,
2310 continuity={},
2311 reduce=False,
2312 scenario=scenario,
2313 )
2314 except NoTransitionsError:
2315 # No transitions within `cmds` for state_key, continue with other keys
2316 continue
File /proj/sot/ska3/flight/lib/python3.11/site-packages/kadi/commands/states.py:2111, in get_states(start, stop, state_keys, cmds, continuity, reduce, merge_identical, scenario)
2106 for key, value in transition.items():
2107 if callable(value):
2108 # Special case of a functional transition that calls a function
2109 # instead of directly updating the state. The function might itself
2110 # update the state or it might generate downstream transitions.
-> 2111 value(date, transitions, state, idx)
2112 elif key != "date":
2113 # Normal case of just updating current state
2114 state[key] = value
File /proj/sot/ska3/flight/lib/python3.11/site-packages/kadi/commands/states.py:1658, in ACISTransition.simode_callback(tlmsid, date, transitions, state, idx)
1655 si_mode = NIL_SIMODES[tlmsid]
1656 # Value of SIMODE in some cases depends on whether obsid is
1657 # an odd or even number
-> 1658 if si_mode.startswith("HIE") and state["obsid"] % 2 != 0:
1659 si_mode = si_mode.replace("HIE", "HIO")
1661 # All other SI modes: this logic uses the PBLK command to
1662 # determine the SI mode hex string, which depends in part on
1663 # whether a bias is being (re)computed.
TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'
Those examples in the recent past are more concerning, thanks for documenting this. I mostly understand this as the ACIS state wanting obsid for continuity but it isn't available at the time of a callback. I found one hack that fixed it but I need to dig more to be sure there isn't a bigger problem of chicken-and-egg happening.
Thanks! This came up when I remembered I hadn't stuck that quick "observing fraction" notebook anywhere. I just put it in skanb and added a try-except to get through the couple of times that it was breaking out of get_continuity.
https://github.com/sot/skanb/blob/ddd50a1ae8155fdae4008a39dbc8ccdb03b459d5/misc/observing.ipynb
states.get_continuity('2003:071:11:57:07.899') fails