obsplus.interfaces module

Some common interfaces for event/client types.

Note: These are used instead of the ones in obspy.clients.base so the subclass hooks can be used.

class obsplus.interfaces.BankType(*args, **kwargs)[source]

Bases: Protocol

an object that looks like a bank

abstract read_index(*args, **kwargs)[source]

A method which must return a dataframe of index contents.

Return type:

DataFrame

class obsplus.interfaces.EventClient(*args, **kwargs)[source]

Bases: Protocol

Abstract Base Class defining the event client interface.

Any object which has a get_events method implements the interface and is either an instance or subclass of EventClient.

Examples

>>> import obsplus
>>> import obspy
>>> # EventBank is a subclass of EventClient
>>> assert issubclass(obsplus.EventBank, EventClient)
>>> # A string has no `get_events` so it is not a subclass/instance
>>> assert not issubclass(str, EventClient)
>>> assert not isinstance('string', EventClient)
>>> # this works on any class with a get_events method
>>> class NewEventClientThing:
...     def get_events(self, *args, **kwargs):
...         pass
>>> assert issubclass(NewEventClientThing, EventClient)
abstract get_events(*args, **kwargs)[source]

A method which must return events as obspy.Catalog object.

Return type:

Catalog

class obsplus.interfaces.ProgressBar(*args, **kwargs)[source]

Bases: Protocol

A class that behaves like the progressbar2.ProgressBar class.

abstract finish(**kwargs)[source]

Puts the progress bar in the finished state.

abstract update(value=None, force=False, **kwargs)[source]

Called when updating the progress bar.

class obsplus.interfaces.StationClient(*args, **kwargs)[source]

Bases: Protocol

Abstract Base Class defining the station client interface.

Any object which has a get_stations method implements the interface and is either an instance or subclass of StationClient.

Examples

>>> import obsplus
>>> import obspy
>>> # Inventory is a subclass of StationClient
>>> assert issubclass(obspy.Inventory, StationClient)
>>> assert isinstance(obspy.read_inventory(), StationClient)
>>> # A string has no `get_stations` so it is not a subclass/instance
>>> assert not issubclass(str, StationClient)
>>> assert not isinstance('string', StationClient)
>>> # this works on any class with a get_waveforms method
>>> class NewStationClientThing:
...     def get_stations(self, *args, **kwargs):
...         pass
>>> assert issubclass(NewStationClientThing, StationClient)
abstract get_stations(*args, **kwargs)[source]

A method which must return an inventory object.

Return type:

Inventory

class obsplus.interfaces.WaveformClient(*args, **kwargs)[source]

Bases: Protocol

Abstract Base Class defining the waveform client interface.

Any object which has a get_waveforms method implements the interface and is either an instance or subclass of WaveformClient.

Examples

>>> import obsplus
>>> import obspy
>>> # WaveBank/Stream are subclasses of WaveformClient
>>> assert issubclass(obsplus.WaveBank, WaveformClient)
>>> # A string has no `get_waveforms` so it is not a subclass/instance
>>> assert not issubclass(str, WaveformClient)
>>> assert not isinstance('string', WaveformClient)
>>> # this works on any class with a get_waveforms method
>>> class NewWaveformClientThing:
...     def get_waveforms(self, *args, **kwargs):
...         pass
>>> assert issubclass(NewWaveformClientThing, WaveformClient)
abstract get_waveforms(network, station, location, channel, starttime, endtime)[source]

A method which must return waveforms as an obspy.Stream.

Return type:

Stream