How to use the gwpy.io.registry.register_identifier function in gwpy

To help you get started, we’ve selected a few gwpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gwpy / gwpy / gwpy / timeseries / io / wav.py View on Github external
finally:
            fileobj.seek(loc)
    elif filepath is not None:
        return filepath.endswith(('.wav', '.wave'))
    else:
        try:
            wave.open(args[0])
        except (wave.Error, AttributeError):
            return False
        else:
            return True


io_registry.register_reader('wav', TimeSeries, read)
io_registry.register_writer('wav', TimeSeries, write)
io_registry.register_identifier('wav', TimeSeries, is_wav)
github gwpy / gwpy / gwpy / detector / io / clf.py View on Github external
except configparser.NoOptionError:
            out.set(group, 'channels', '\n%s' % entry)
        else:
            out.set(group, 'channels', clist + '\n%s' % entry)
    if isinstance(fobj, FILE_LIKE):
        close = False
    else:
        fobj = open(fobj, 'w')
        close = True
    out.write(fobj)
    if close:
        fobj.close()


registry.register_reader('ini', ChannelList, read_channel_list_file)
registry.register_identifier('ini', ChannelList,
                             identify_factory('.ini', '.clf'))
registry.register_writer('ini', ChannelList, write_channel_list_file)
github gwpy / gwpy / gwpy / table / io / ligolw.py View on Github external
llwtable = table_to_ligolw(table, tablename, ilwdchar_compat=True)
        except Exception:
            raise exc
    return write_ligolw_tables(target, [llwtable], **kwargs)


# -- register -----------------------------------------------------------------

for table_ in LIGOLW_TABLES:
    # register conversion from LIGO_LW to astropy Table
    table_.__astropy_table__ = to_astropy_table

for table_class in (Table, EventTable):
    registry.register_reader('ligolw', table_class, read_table)
    registry.register_writer('ligolw', table_class, write_table)
    registry.register_identifier('ligolw', table_class, is_ligolw)
github gwpy / gwpy / gwpy / types / io / hdf5.py View on Github external
"""Registry read() and write() methods for the HDF5 format
    """
    def from_hdf5(*args, **kwargs):
        """Read an array from HDF5
        """
        kwargs.setdefault('array_type', array_type)
        return read_hdf5_array(*args, **kwargs)

    io_registry.register_reader(format, array_type, from_hdf5)
    if issubclass(array_type, Series):
        io_registry.register_writer(format, array_type, write_hdf5_series)
    else:
        io_registry.register_writer(format, array_type, write_hdf5_array)

    if identify:
        io_registry.register_identifier(format, array_type,
                                        io_hdf5.identify_hdf5)
github gwpy / gwpy / gwpy / segments / io / hdf5.py View on Github external
for i, seg in enumerate(seglist):
        start, end = map(LIGOTimeGPS, seg)
        data[i, :] = (start.gpsSeconds, start.gpsNanoSeconds,
                      end.gpsSeconds, end.gpsNanoSeconds)
    segtable = Table(data, names=['start_time', 'start_time_ns',
                                  'end_time', 'end_time_ns'])

    # write table to HDF5
    return segtable.write(output, path=path, format='hdf5', **kwargs)


# -- register -----------------------------------------------------------------

register_reader('hdf5', SegmentList, read_hdf5_segmentlist)
register_writer('hdf5', SegmentList, write_hdf5_segmentlist)
register_identifier('hdf5', SegmentList, io_hdf5.identify_hdf5)

register_reader('hdf5', DataQualityFlag, read_hdf5_flag)
register_writer('hdf5', DataQualityFlag, write_hdf5_flag)
register_identifier('hdf5', DataQualityFlag, io_hdf5.identify_hdf5)

register_reader('hdf5', DataQualityDict, read_hdf5_dict)
register_writer('hdf5', DataQualityDict, write_hdf5_dict)
register_identifier('hdf5', DataQualityDict, io_hdf5.identify_hdf5)