pile

class Pile[source]

Waveform archive lookup, data loading and caching infrastructure.

chopper(tmin=None, tmax=None, tinc=None, tpad=0.0, group_selector=None, trace_selector=None, want_incomplete=True, degap=True, maxgap=5, maxlap=None, keep_current_files_open=False, accessor_id=None, snap=(<built-in function round>, <built-in function round>), include_last=False, load_data=True, style=None)[source]

Get iterator for shifting window wise data extraction from waveform archive.

Parameters
  • tmin – start time (default uses start time of available data)

  • tmax – end time (default uses end time of available data)

  • tinc – time increment (window shift time) (default uses tmax-tmin)

  • tpad – padding time appended on either side of the data windows (window overlap is 2*tpad)

  • group_selector – filter callback taking TracesGroup objects

  • trace_selector – filter callback taking pyrocko.trace.Trace objects

  • want_incomplete – if set to False, gappy/incomplete traces are discarded from the results

  • degap – whether to try to connect traces and to remove gaps and overlaps

  • maxgap – maximum gap size in samples which is filled with interpolated samples when degap is True

  • maxlap – maximum overlap size in samples which is removed when degap is True

  • keep_current_files_open – whether to keep cached trace data in memory after the iterator has ended

  • accessor_id – if given, used as a key to identify different points of extraction for the decision of when to release cached trace data (should be used when data is alternately extracted from more than one region / selection)

  • snap – replaces Python’s round() function which is used to determine indices where to start and end the trace data array

  • include_last – whether to include last sample

  • load_data – whether to load the waveform data. If set to False, traces with no data samples, but with correct meta-information are returned

  • style – set to 'batch' to yield waveforms and information about the chopper state as Batch objects. By default lists of pyrocko.trace.Trace objects are yielded.

Returns

iterator providing extracted waveforms for each extracted window. See style argument for details.

all(*args, **kwargs)[source]

Shortcut to aggregate chopper() output into a single list.

iter_traces(load_data=False, return_abspath=False, group_selector=None, trace_selector=None)[source]

Iterate over all traces in pile.

Parameters
  • load_data – whether to load the waveform data, by default empty traces are yielded

  • return_abspath – if True yield tuples containing absolute file path and pyrocko.trace.Trace objects

  • group_selector – filter callback taking TracesGroup objects

  • trace_selector – filter callback taking pyrocko.trace.Trace objects

Example; yields only traces, where the station code is ‘HH1’:

test_pile = pile.make_pile('/local/test_trace_directory')
for t in test_pile.iter_traces(
        trace_selector=lambda tr: tr.station=='HH1'):

    print t
snuffle(**kwargs)[source]

Visualize it.

Parameters
  • stations – list of pyrocko.model.Station objects or None

  • events – list of pyrocko.model.Event objects or None

  • markers – list of pyrocko.gui.snuffler.marker.Marker objects or None

  • ntracks – float, number of tracks to be shown initially (default: 12)

  • follow – time interval (in seconds) for real time follow mode or None

  • controls – bool, whether to show the main controls (default: True)

  • opengl – bool, whether to use opengl (default: False)

class Batch(tmin, tmax, i, n, traces)[source]

Batch of waveforms from window wise data extraction.

Encapsulates state and results yielded for each window in window wise waveform extraction with the Pile.chopper() method (when the style=’batch’ keyword argument set).

Attributes:

tmin

Start of this time window.

tmax

End of this time window.

i

Index of this time window in sequence.

n

Total number of time windows in sequence.

traces

Extracted waveforms for this time window.

make_pile(paths=None, selector=None, regex=None, fileformat='mseed', cachedirname=None, show_progress=True)[source]

Create pile from given file and directory names.

Parameters
  • paths – filenames and/or directories to look for traces. If paths is None sys.argv[1:] is used.

  • selector – lambda expression taking group dict of regex match object as a single argument and which returns true or false to keep or reject a file

  • regex – regular expression which filenames have to match

  • fileformat – format of the files (‘mseed’, ‘sac’, ‘kan’, ‘from_extension’, ‘detect’)

  • cachedirname – loader cache is stored under this directory. It is created as neccessary.

  • show_progress – show progress bar and other progress information