obspy_compat
¶
This module provides basic compatibility between ObsPy and Pyrocko.
The functions defined here can be used to translate back and forth some of the
basic objects in Pyrocko and ObsPy. It also provides shortcuts to quickly look
at ObsPy waveforms with the Pyrocko’s Snuffler
application (snuffle()
, fiddle()
).
With pyrocko.obspy_compat.plant()
several new methods are attached to
Pyrocko and ObsPy classes.
Example, visualize ObsPy stream object with Snuffler:
import obspy
from pyrocko import obspy_compat
obspy_compat.plant()
stream = obspy.read() # returns some example data
stream.snuffle()
– With best wishes to the ObsPy Team from the Pyrocko Developers!
Note
This is an experimental module, the interface may still be changed. Feedback and discussion welcome!
- to_pyrocko_trace(trace)[source]¶
Convert ObsPy trace object to Pyrocko trace object.
- Parameters
trace –
obspy.Trace
object- Returns
pyrocko.trace.Trace
object
- to_pyrocko_traces(stream)[source]¶
Convert ObsPy stream object to list of Pyrocko trace objects.
- Parameters
stream –
obspy.Stream
object- Returns
list of
pyrocko.trace.Trace
objects
- to_pyrocko_events(catalog)[source]¶
Convert ObsPy catalog object to list of Pyrocko event objects.
- Parameters
catalog –
obspy.Catalog
object- Returns
list of
pyrocko.model.Event
objects orNone
if catalog isNone
- to_pyrocko_stations(inventory)[source]¶
Convert ObsPy inventory to list of Pyrocko traces.
- Parameters
inventory –
obspy.Inventory
object- Returns
list of
pyrocko.model.Station
objects orNone
if inventory isNone
- to_obspy_stream(pile)[source]¶
Convert Pyrocko pile to ObsPy stream.
- Parameters
pile –
pyrocko.pile.Pile
object- Returns
obspy.Stream
object
- to_obspy_trace(trace)[source]¶
Convert Pyrocko trace to ObsPy trace.
- Parameters
trace –
pyrocko.trace.Trace
- snuffle(stream_or_trace, inventory=None, catalog=None, **kwargs)[source]¶
Explore ObsPy data with Snuffler.
- Parameters
stream_or_trace –
obspy.Stream
orobspy.Trace
objectinventory –
obspy.Inventory
objectcatalog –
obspy.Catalog
objectkwargs – extra arguments passed to
pyrocko.trace.Trace.snuffle()
.
- Returns
(return_tag, markers)
, wherereturn_tag
is the a string to flag how the Snuffler window has been closed andmarkers
is a list ofpyrocko.gui.marker.Marker
objects.
This function displays an ObsPy stream object in Snuffler. It returns to the caller once the window has been closed. The
return_tag
returned by the function can be used as a primitive way to communicate a user decision to the calling script. By default it returns the key pressed to close the window (if any), either'q'
or'x'
, but the value could be customized when the exit is triggered from within a Snuffling.See also
fiddle()
for a variant of this function returning an interactively modified ObsPy stream object.
- fiddle(stream_or_trace, inventory=None, catalog=None, **kwargs)[source]¶
Manipulate ObsPy stream object interactively.
- Parameters
stream_or_trace –
obspy.Stream
orobspy.Trace
objectinventory –
obspy.Inventory
objectcatalog –
obspy.Catalog
objectkwargs – extra arguments passed to
pyrocko.trace.Trace.snuffle()
.
- Returns
obspy.Stream
object with changes applied interactively (orobspy.Trace
if called with a trace as first argument).
This function displays an ObsPy stream object in Snuffler like
snuffle()
, but additionally adds a Snuffling panel to apply some basic ObsPy signal processing to the contained traces. The applied changes are handed back to the caller as a modified copy of the stream object.import obspy from pyrocko import obspy_compat obspy_compat.plant() stream = obspy.read() stream_filtered = stream.fiddle() # returns once window has been # closed