obspy.clients.filesystem.tsindex.Client
- class Client(database, datapath_replace=None, loglevel=None)[source]
Bases:
object
Time series extraction client for IRIS tsindex database schema.
Public Methods
Get a list of tuples [(network, station, location, channel, starttime, endtime),...] containing data availability info for time series included in the tsindex database. |
|
Get a list of tuples [(network, station, location, channel, earliest, latest)] containing data extent info for time series included in the tsindex database. |
|
Get percentage of available data. |
|
Get a list of tuples [(net, sta, loc, cha),...] containing information on what streams are included in the tsindex database. |
|
Query tsindex database and read miniSEED data from local indexed directory tree. |
|
Query tsindex database and read miniSEED data from local indexed directory tree using a bulk request. |
|
Return whether there is data for a specified network, station, location, channel, starttime, and endtime combination. |
Private Methods
Warning
Private methods are mainly for internal/developer use and their API might change without notice.
- Client._are_timespans_adjacent(ts1, ts2, sample_rate, tolerance=0.5)[source]
Checks whether or not two time span named tuples (e.g. NameTuple(earliest, latest)) are adjacent within a given tolerance.
- Client._create_avail_tuple(network, station, location, channel, earliest, latest, sr=None)[source]
Returns a tuple representing available waveform data.
- Parameters
network (str) – Network code of requested data (e.g. “IU”). Wildcards ‘*’ and ‘?’ are supported.
station (str) – Station code of requested data (e.g. “ANMO”). Wildcards ‘*’ and ‘?’ are supported.
location (str) – Location code of requested data (e.g. “”). Wildcards ‘*’ and ‘?’ are supported.
channel (str) – Channel code of requested data (e.g. “HHZ”). Wildcards ‘*’ and ‘?’ are supported.
earliest (
UTCDateTime
) – Earliest date of timespan.latest (
UTCDateTime
) – Latest date of timespan.sr (float) – Sensor sample rate (optional).
- Client._create_timespan(earliest, latest)[source]
Create a
TimeSpan
named tuple object given a earliest and latest date.- Parameters
earliest – Earliest date of timespan.
latest – Latest date of timespan.
- Client._create_timespans_list(raw_timespans)[source]
Given a timespans string from the database, return a list of named tuples.
- Parameters
raw_timespans (str) – timespans field from tsindex database table.
- Client._do_timespans_overlap(ts1, ts2)[source]
Checks whether or not two time span named tuples (e.g. NameTuple(earliest, latest)) intersect with one another.
- Parameters
ts1 (
collections.namedtuple
) – Earliest timespan.ts2 (
collections.namedtuple
) – Latest timespan.
- Client._get_availability_from_timespans(network, station, location, channel, samplerates, include_sample_rate, merge_overlap, timespans, _sncl_joined_avail_tuples=None)[source]
Recurse over a list of timespans, joining adjacent timespans, and merging if merge_overlaps is
True
.Returns a list of tuples (network, station, location, channel, earliest, latest) representing available data.
- Parameters
network (str) – Network code of requested data (e.g. “IU”). Wildcards ‘*’ and ‘?’ are supported.
station (str) – Station code of requested data (e.g. “ANMO”). Wildcards ‘*’ and ‘?’ are supported.
location (str) – Location code of requested data (e.g. “”). Wildcards ‘*’ and ‘?’ are supported.
channel (str) – Channel code of requested data (e.g. “HHZ”). Wildcards ‘*’ and ‘?’ are supported.
starttime (
UTCDateTime
) – Start of requested time window.endtime (
UTCDateTime
) – End of requested time window.timespans (list) – List of timespan tuples.
- Client._get_summary_rows(network, station, location, channel, starttime, endtime)[source]
Return a list of tuples [(net, sta, loc, cha, earliest, latest),…] containing information found in the tsindex_summary table.
Information about the tsindex_summary schema may be found in the mseedindex wiki.
- Parameters
network (str) – Network code of requested data (e.g. “IU”). Wildcards ‘*’ and ‘?’ are supported.
station (str) – Station code of requested data (e.g. “ANMO”). Wildcards ‘*’ and ‘?’ are supported.
location (str) – Location code of requested data (e.g. “”). Wildcards ‘*’ and ‘?’ are supported.
channel (str) – Channel code of requested data (e.g. “HHZ”). Wildcards ‘*’ and ‘?’ are supported.
starttime (
UTCDateTime
) – Start of requested time window.
- Client._get_tsindex_rows(network, station, location, channel, starttime, endtime)[source]
Return a list of tuples [(net, sta, loc, cha, quality… etc.),…] containing information found in the tsindex table.
Information about the tsindex schema may be found in the mseedindex wiki schema.
- Parameters
network (str) – Network code of requested data (e.g. “IU”). Wildcards ‘*’ and ‘?’ are supported.
station (str) – Station code of requested data (e.g. “ANMO”). Wildcards ‘*’ and ‘?’ are supported.
location (str) – Location code of requested data (e.g. “”). Wildcards ‘*’ and ‘?’ are supported.
channel (str) – Channel code of requested data (e.g. “HHZ”). Wildcards ‘*’ and ‘?’ are supported.
starttime (
UTCDateTime
) – Start of requested time window.endtime (
UTCDateTime
) – End of requested time window.
- Client._get_waveforms(query_rows, merge=- 1)[source]
Query tsindex database and read miniSEED data from local indexed directory tree using a bulk request and return a
Stream
object containing the requested timeseries data.- Parameters
query_rows (list(tuple(str, str, str, str,
UTCDateTime
,UTCDateTime
))) – A list of tuples [(net, sta, loc, cha, starttime, endtime),…] containing information on what timeseries should be returned from the indexed archive. Wildcards ‘*’ and ‘?’ are supported.merge (int or None) – Specifies, which merge operation should be performed on the stream before returning the data. Default (
-1
) means only a conservative cleanup merge is performed to merge seamless traces (e.g. when reading across day boundaries). SeeStream.merge()
for details. If set toNone
(orFalse
) no merge operation at all will be performed.
Special Methods
- Client.__delattr__(name, /)
Implement delattr(self, name).
- Client.__dir__()
Default dir() implementation.
- Client.__eq__(value, /)
Return self==value.
- Client.__format__(format_spec, /)
Default object formatter.
- Client.__ge__(value, /)
Return self>=value.
- Client.__getattribute__(name, /)
Return getattr(self, name).
- Client.__gt__(value, /)
Return self>value.
- Client.__hash__()
Return hash(self).
- Client.__init__(database, datapath_replace=None, loglevel=None)[source]
Initializes the client.
- Parameters
database (str or
TSIndexDatabaseHandler
) – Path to SQLite tsindex database or a TSIndexDatabaseHandler objectdatapath_replace (tuple(str, str)) – A
tuple(str, str)
, where any occurrence of the first value will be replaced with the second value in filename paths from the index.
- Client.__init_subclass__()
This method is called when a class is subclassed.
The default implementation does nothing. It may be overridden to extend subclasses.
- Client.__le__(value, /)
Return self<=value.
- Client.__lt__(value, /)
Return self<value.
- Client.__ne__(value, /)
Return self!=value.
- Client.__new__(**kwargs)
- Client.__reduce__()
Helper for pickle.
- Client.__reduce_ex__(protocol, /)
Helper for pickle.
- Client.__repr__()
Return repr(self).
- Client.__setattr__(name, value, /)
Implement setattr(self, name, value).
- Client.__sizeof__()
Size of object in memory, in bytes.
- Client.__str__()
Return str(self).
- Client.__subclasshook__()
Abstract classes can override this to customize issubclass().
This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).