Pool coverage boundaries issue with multiple references
Currently, the SpicePool.coverage()
function returns the max(start)
and the min(end)
times for the kernels present in the pool for a given spice reference (see src):
starts, ends = cls.windows(*refs, fmt='ET').T
start, stop = np.max(starts), np.min(ends)
The temporal coverage windows are computed for each kernel and for each reference to get an array of time coverage as min(ets)
and max(ets)
values per reference and per files (see src):
for kernel in kernels:
for ref in refs:
if ets := cov(kernel, ref):
windows.append([np.min(ets), np.max(ets)]) # Coverage per file
Description of the issue
This behavior does not provide the correct coverage windows like the one provided by the spice brief
tool:
brief juice_plan.tm -t -a
BRIEF -- Version 4.1.0, September 17, 2021 -- Toolkit Version N0067
Summary for all files.
Bodies Start of Interval (ET) End of Interval (ET)
------- ----------------------------- -----------------------------
-28 JUICE 2023 APR 05 12:41:33.336 2035 OCT 05 01:58:58.683
Step to reproduce
>>> from planetary_coverage import SpicePool
>>> SpicePool.add([
'lsk/naif0012.tls',
'spk/jup365_19900101_20500101.bsp',
'spk/juice_crema_5_1_150lb_v01.bsp',
'spk/juice_orbc_000010_230414_310721_v03.bsp',
], purge=True)
Current behavior:
>>> SpicePool.windows('JUICE')
array([['1990-01-01T00:00:00.000', '2050-01-01T06:00:00.000'], # Ganymede in jup365_19900101_20500101.bsp
['2023-04-05T12:40:24.151', '2035-10-05T01:57:49.501'], # Juice in juice_crema_5_1_150lb_v01.bsp
['2023-04-14T12:40:06.151', '2031-07-21T22:51:23.047']], # Juice in juice_orbc_000010_230414_310721_v03.bsp
dtype='datetime64[ms]')
>>> SpicePool.coverage('JUICE')
(numpy.datetime64('2023-04-14T12:40:06.151'), numpy.datetime64('2031-07-21T22:51:23.047'))
Expected behavior:
>>> SpicePool.windows('JUICE')
{
'GANYMEDE': [
['1990-01-01T00:00:00.000', '2050-01-01T06:00:00.000'], # in jup365_19900101_20500101.bsp
],
'JUICE': [
['2023-04-05T12:40:24.151', '2035-10-05T01:57:49.501'], # in juice_crema_5_1_150lb_v01.bsp
['2023-04-14T12:40:06.151', '2031-07-21T22:51:23.047'], # in juice_orbc_000010_230414_310721_v03.bsp
],
}
>>> SpicePool.coverage('JUICE')
(numpy.datetime64('2023-04-05T12:40:24.151'), numpy.datetime64('2035-10-05T01:57:49.501'))
Suggestion fix
The intervals should be computed per reference (stacked intervals per file) then intersected by references.
The dict
return here is for illustration purposes to group the intervals. It might be implemented differently.