def _read_recarray(f, *args, **kwargs): # handle multiprocessing nproc = kwargs.pop('nproc', 1) if nproc > 1: kwargs['format'] = strip(table_.tableName) return read_cache(file_list(f), GWRecArray, nproc, None, *args, **kwargs) # set up keyword arguments reckwargs = { 'on_attributeerror': 'raise', 'get_as_columns': False } for key in reckwargs: if key in kwargs: reckwargs[key] = kwargs.pop(key) reckwargs['columns'] = kwargs.get('columns', None) # read from LIGO_LW return table_from_file(f, table_.tableName, *args, **kwargs).to_recarray(**reckwargs)
return read_cache(file_list(f), GWRecArray, nproc, None, *args, **kwargs) # set up keyword arguments reckwargs = { 'on_attributeerror': 'raise', 'get_as_columns': False } for key in reckwargs: if key in kwargs: reckwargs[key] = kwargs.pop(key) reckwargs['columns'] = kwargs.get('columns', None) # read from LIGO_LW return table_from_file(f, table_.tableName, *args, **kwargs).to_recarray(**reckwargs) return _read_ligolw, _read_recarray # register reader and auto-id for LIGO_LW for table in TableByName.itervalues(): tablename = strip(table.tableName) llwfunc, recfunc = read_table_factory(table) # register generic reader and table-specific reader for LIGO_LW registry.register_reader('ligolw', table, llwfunc) registry.register_reader(tablename, table, llwfunc) registry.register_identifier('ligolw', table, identify_ligolw) # register table-specific reader for GWRecArray registry.register_reader(tablename, GWRecArray, recfunc)
"""Read LIGO_LW documents into glue.ligolw.table.Table objects. """ from glue.ligolw.table import StripTableName as strip from glue.ligolw.lsctables import TableByName from ...io import registry from ...io.ligolw import (table_from_file, identify_ligolw) __author__ = 'Duncan Macleod <*****@*****.**>' __all__ = [] def read_table_factory(table_): """Define a custom function to read this table from a LIGO_LW file. """ def _read(f, *args, **kwargs): return table_from_file(f, table_.tableName, *args, **kwargs) return _read # register reader and auto-id for LIGO_LW for table in TableByName.itervalues(): tablename = strip(table.tableName) func = read_table_factory(table) # register generic reader and table-specific reader registry.register_reader('ligolw', table, func) registry.register_reader(tablename, table, func) registry.register_identifier('ligolw', table, identify_ligolw)