Skip to content

LIGO_LW tables should read ASCII/CSV with unified I/O read() method

The LIGO_LW format tables imported from glue should be able to read space-, tab-, and comma-separated text files using the standard unified read() method.

The following simple example works fine for reading CSV and is easily adaptable for other delimiters:

import numpy
from gwpy.table.lsctables import (New, SnglBurstTable)
from gwpy.time import LIGOTimeGPS
trigs = New(SnglBurstTable, columns=['peak_time', 'peak_time_ns', 'snr', 'central_freq'])
for t, f, snr in numpy.loadtxt('mytrigs.csv', delimiter=','):
    row = trigs.RowType()
    row.set_peak(LIGOTimeGPS(float(t)))
    row.central_freq = f
    row.snr = snr
    trigs.append(row)