def register_gwf_api(library):
<EOL>try:<EOL><INDENT>lib = import_gwf_library(library)<EOL><DEDENT>except ImportError:<EOL><INDENT>pass  <EOL><DEDENT>else:<EOL><INDENT>libread_ = lib.read<EOL>libwrite_ = lib.write<EOL><DEDENT>fmt = '<STR_LIT>' % library<EOL>def read_timeseriesdict(source, channels, start=None, end=None,<EOL>dtype=None, resample=None,<EOL>gap=None, pad=None, nproc=<NUM_LIT:1>,<EOL>series_class=TimeSeries, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>import_gwf_library(library)<EOL>if start:<EOL><INDENT>start = to_gps(start)<EOL><DEDENT>if end:<EOL><INDENT>end = to_gps(end)<EOL><DEDENT>if resample is not None:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>DeprecationWarning)<EOL><DEDENT>if not isinstance(resample, dict):<EOL><INDENT>resample = dict((c, resample) for c in channels)<EOL><DEDENT>if dtype is not None:<EOL><INDENT>warnings.warn('<STR_LIT>'<EOL>'<STR_LIT>',<EOL>DeprecationWarning)<EOL><DEDENT>if not isinstance(dtype, dict):<EOL><INDENT>dtype = dict((c, dtype) for c in channels)<EOL><DEDENT>if gap is None and pad is not None:<EOL><INDENT>gap = '<STR_LIT>'<EOL><DEDENT>elif gap is None:<EOL><INDENT>gap = '<STR_LIT>'<EOL><DEDENT>if (isinstance(source, string_types) and<EOL>source.endswith(('<STR_LIT>', '<STR_LIT>'))) or (<EOL>isinstance(source, io_cache.FILE_LIKE) and<EOL>source.name.endswith(('<STR_LIT>', '<STR_LIT>'))):<EOL><INDENT>source = io_cache.read_cache(source)<EOL><DEDENT>if io_cache.is_cache(source):<EOL><INDENT>if start is not None and end is not None:<EOL><INDENT>source = io_cache.sieve(source, segment=Segment(start, end))<EOL><DEDENT>source = list(io_cache.find_contiguous(source))<EOL><DEDENT>if not isinstance(source, (list, tuple)):<EOL><INDENT>source = [source]<EOL><DEDENT>out = series_class.DictClass()<EOL>for i, src in enumerate(source):<EOL><INDENT>if i == <NUM_LIT:1>:  <EOL><INDENT>for name in out:<EOL><INDENT>out[name] = numpy.require(out[name], requirements=['<STR_LIT:O>'])<EOL><DEDENT><DEDENT>out.append(libread_(src, channels, start=start, end=end,<EOL>series_class=series_class, **kwargs),<EOL>gap=gap, pad=pad, copy=False)<EOL><DEDENT>for name in out:<EOL><INDENT>if (resample.get(name) and<EOL>resample[name] != out[name].sample_rate.value):<EOL><INDENT>out[name] = out[name].resample(resample[name])<EOL><DEDENT>if dtype.get(name) is not None and (<EOL>numpy.dtype(dtype[name]) != out[name].dtype):<EOL><INDENT>out[name] = out[name].astype(dtype[name])<EOL><DEDENT><DEDENT>return out<EOL><DEDENT>def read_timeseries(source, channel, *args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>return read_timeseriesdict(source, [channel], *args, **kwargs)[channel]<EOL><DEDENT>def read_statevector(source, channel, *args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>bits = kwargs.pop('<STR_LIT>', None)<EOL>kwargs.setdefault('<STR_LIT>', StateVector)<EOL>statevector = read_timeseries(source, channel, *args, **kwargs)<EOL>statevector.bits = bits<EOL>return statevector<EOL><DEDENT>def read_statevectordict(source, channels, *args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>bitss = channel_dict_kwarg(kwargs.pop('<STR_LIT>', {}), channels)<EOL>kwargs.setdefault('<STR_LIT>', StateVector)<EOL>svd = StateVectorDict(<EOL>read_timeseriesdict(source, channels, *args, **kwargs))<EOL>for (channel, bits) in bitss.items():<EOL><INDENT>svd[channel].bits = bits<EOL><DEDENT>return svd<EOL><DEDENT>def write_timeseriesdict(data, outfile, start=None, end=None,<EOL>name='<STR_LIT>', run=<NUM_LIT:0>):<EOL><INDENT>"""<STR_LIT>"""<EOL>import_gwf_library(library)<EOL>return libwrite_(data, outfile, start=start, end=end,<EOL>name=name, run=run)<EOL><DEDENT>def write_timeseries(series, *args, **kwargs):<EOL><INDENT>"""<STR_LIT>"""<EOL>return write_timeseriesdict({None: series}, *args, **kwargs)<EOL><DEDENT>register_reader(fmt, TimeSeriesDict, read_timeseriesdict)<EOL>register_reader(fmt, TimeSeries, read_timeseries)<EOL>register_reader(fmt, StateVectorDict, read_statevectordict)<EOL>register_reader(fmt, StateVector, read_statevector)<EOL>register_writer(fmt, TimeSeriesDict, write_timeseriesdict)<EOL>register_writer(fmt, TimeSeries, write_timeseries)<EOL>register_writer(fmt, StateVectorDict, write_timeseriesdict)<EOL>register_writer(fmt, StateVector, write_timeseries)<EOL>
Register a full set of GWF I/O methods for the given library

    The given frame library must define the following methods

    - `read` : which receives one of more frame files which can be assumed
               to be contiguous, and should return a `TimeSeriesDict`
    - `write` : which receives an output frame file path an a `TimeSeriesDict`
                and does all of the work

    Additionally, the library must store the name of the third-party
    dependency using the ``FRAME_LIBRARY`` variable.