Skip to content

`TimeSeriesDict.find` bug when querying from multiple IFOs

Created by: EthanMarx

Using gwpy=3.0.5 the following code snippet

channels = ["H1:DCS-CALIB_STRAIN_CLEAN_C01", "L1:DCS-CALIB_STRAIN_CLEAN_C01"]
start = 1240764591
stop = 1240764592
TimeSeriesDict.find(channels, start, stop, frametype_match=".*HOFT_C01")

leads to a missing segments RuntimeError:

RuntimeError: Missing segments: 
[1240764591 ... 1240764592)

Although data does exist during this interval for both IFOs

gw_data_find -o L -s 1240764591 -e 1240764592 -t L1_HOFT_C01
gw_data_find -o H -s 1240764591 -e 1240764592 -t H1_HOFT_C01

It looks like the bug lies here. observatory is initially None, so in the first iteration of the loop it is being set to "H". When the second iteration happens to query Livingston, observatory is set to "H", and thus gwdatafind.find_urls is called with frametype="L1_HOFT_C01" but observatory="H" leading to the missing segment error.

Wondering if querying from different IFOs is a misuse of the API, or if this is a bug. In any case some sort of warning would be usefl.

Easy fix would be to do something like

if observatory is None:
    try:
        obs = ''.join(
            sorted(set(c.ifo[0] for c in channellist)))
    except TypeError as exc:
        exc.args = "Cannot parse list of IFOs from channel names",
        raise
else:
   obs = observatory
...   
gwdatafind.find_urls(
    obs,
    frametype,
    start,
    end,
    on_gaps="error" if pad is None else "warn",
)