class Restrictions(starttime, endtime, station_starttime=None, station_endtime=None, chunklength_in_sec=None, network=None, station=None, location=None, channel=None, exclude_networks=(), exclude_stations=(), limit_stations_to_inventory=None, reject_channels_with_gaps=True, minimum_length=0.9, sanitize=True, minimum_interstation_distance_in_m=1000, channel_priorities=('HH[ZNE12]', 'BH[ZNE12]', 'MH[ZNE12]', 'EH[ZNE12]', 'LH[ZNE12]', 'HL[ZNE12]', 'BL[ZNE12]', 'ML[ZNE12]', 'EL[ZNE12]', 'LL[ZNE12]', 'SH[ZNE12]'), location_priorities=('', '00', '10'))[source]

Bases: builtins.object

Class storing non-domain restrictions for a query. This is best explained with two examples. See the list below for a more detailed explanation of the parameters. The first set of restrictions is useful for event based earthquake set queries.

>>> import obspy
>>> restrictions = Restrictions(
...     # Get data from 5 minutes before the event to one hour after the
...     # event.
...     starttime=obspy.UTCDateTime(2012, 1, 1),
...     endtime=obspy.UTCDateTime(2012, 1, 2),
...     # You might not want to deal with gaps in the data.
...     reject_channels_with_gaps=True,
...     # And you might only want waveforms that have data for at least
...     # 95 % of the requested time span.
...     minimum_length=0.95,
...     # No two stations should be closer than 10 km to each other.
...     minimum_interstation_distance_in_m=10E3,
...     # Only HH or BH channels. If a station has HH channels,
...     # those will be downloaded, otherwise the BH. Nothing will be
...     channel_priorities=["HH[ZNE]", "BH[ZNE]"],
...     # Location codes are arbitrary and there is no rule as to which
...     # location is best.
...     location_priorities=["", "00", "10"])


>>> import obspy
>>> restrictions = Restrictions(
...     # Get data for a whole year.
...     starttime=obspy.UTCDateTime(2012, 1, 1),
...     endtime=obspy.UTCDateTime(2013, 1, 1),
...     # Chunk it to have one file per day.
...     chunklength_in_sec=86400,
...     # Considering the enormous amount of data associated with
...     # continuous requests, you might want to limit the data based on
...     # SEED identifiers. If the location code is specified, the
...     # location priority list is not used; the same is true for the
...     # channel argument and priority list.
...     network="BW", station="A*", location="", channel="BH*",
...     # The typical use case for such a data set are noise correlations
...     # where gaps are dealt with at a later stage.
...     reject_channels_with_gaps=False,
...     # Same is true with the minimum length. Any data during a day
...     # might be useful.
...     minimum_length=0.0,
...     # Sanitize makes sure that each MiniSEED file also has an
...     # associated StationXML file, otherwise the MiniSEED files will
...     # be deleted afterwards. This is not desirable for large noise
...     # data sets.
...     sanitize=False,
...     # Guard against the same station having different names.
...     minimum_interstation_distance_in_m=100.0)


The network, station, location, and channel codes are directly passed to the station service of each fdsn-ws implementation and can thus take comma separated string lists as arguments, i.e.

restrictions = Restrictions(
...
network="BW,G?", station="A*,B*",
...
)


Not all fdsn-ws implementations support the direct exclusion of network or station codes. The exclude_networks and exclude_stations arguments should thus be used for that purpose to ensure compatibility across all data providers, e.g.

restrictions = Restrictions(
...
network="B*,G*", station="A*, B*",
exclude_networks=["BW", "GR"],
exclude_stations=["AL??", "*O"],
...
)


It is also possible to restrict the downloaded stations to stations part of an existing inventory object which can originate from a StationXML file or from other sources. It will only keep stations that are part of the inventory object. Channels are still selected dynamically based on the other restrictions. Keep in mind that all other restrictions still apply - passing an inventory will just further restrict the possibly downloaded data.

restrictions = Restrictions(
...
limit_stations_to_inventory=inv,
...
)


Attributes

 __dict__ __doc__ str(object=’‘) -> str __hash__ __module__ str(object=’‘) -> str __weakref__ list of weak references to the object (if defined)

Special Methods

 __dir__ default dir() implementation __eq__ __format__ default object formatter __init__ __iter__ Iterator yielding time intervals based on the chunklength and __ne__ __new__ Create and return a new object. __reduce__ helper for pickle __reduce_ex__ helper for pickle __sizeof__ size of object in memory, in bytes __subclasshook__ Abstract classes can override this to customize issubclass().