LALFrame has no support for FrProcData tRange
It seems like there's no support for the tRange
attribute of an FrProcData
when writing data with LALFrame. Consider the following code:
import numpy
from LDAStools import frameCPP
import lal
import lalframe
def create_timeseries():
"""Create a `REAL8TimeSeries`
"""
data = numpy.arange(10, dtype=float)
ts = lal.CreateREAL8TimeSeries(
"data",
lal.LIGOTimeGPS(0),
0,
1., # dt
"m",
data.size,
)
ts.data.data = data
return ts
def write_gwf_lalframe(data, target):
"""Write a REAL8TimeSeries to GWF using LALFrame
"""
frame = lalframe.FrameNew(
data.epoch,
data.deltaT * data.data.length,
data.name,
0, # run
0, # frame number
0, # detectors
)
lalframe.FrameAddREAL8TimeSeriesProcData(
frame,
data,
)
return lalframe.FrameWrite(frame, target)
def read_gwf_framecpp(target, name):
"""Read an FrProcData from a GWF using frameCPP
"""
stream = frameCPP.IFrameFStream(target)
return stream.ReadFrProcData(0, name)
if __name__ == "__main__":
outfile = "test.gwf"
ts = create_timeseries()
duration = ts.deltaT * ts.data.length
write_gwf_lalframe(ts, outfile)
tRange = read_gwf_framecpp(outfile, ts.name).GetTRange()
assert duration == tRange, \
"tRange {} doesn't match duration {}".format(tRange, duration)
When executed this results in the following
AssertionError: tRange 0.0 doesn't match duration 10.0
GWpy relies on the tRange to determine with an FrProcData
structure contains data inside a requested interval, so GWF files created using LALFrame are unreadable using the latest version of GWpy (when GWpy itself uses frameCPP as the backend).
Can an interface for this parameter be added, and it automatically set inside XLALFrameAdd<type>TimeSeriesProcData
?
Edited by Duncan Macleod