pyrocko.pile¶
Waveform archive lookup, data loading and caching infrastructure.
Note
This module has been superseded by squirrel but will
remain available for backwards compatibility.
Functions
|
Get global TracesFileCache object for given directory. |
|
Create pile from given file and directory names. |
Classes
|
Batch of waveforms from window wise data extraction. |
|
This is needed to make traces without an actual disc file to be inserted into a Pile. |
|
Waveform archive lookup, data loading and caching infrastructure. |
|
Manages trace metainformation cache. |
|
Trace container base class. |
- class TracesFileCache(cachedir)[source]¶
Bases:
objectManages trace metainformation cache.
For each directory with files containing traces, one cache file is maintained to hold the trace metainformation of all files which are contained in the directory.
- get(abspath)[source]¶
Try to get an item from the cache.
- Parameters:
abspath – absolute path of the object to retrieve
- Returns:
a stored object is returned or None if nothing could be found.
- class TracesGroup(parent)[source]¶
Bases:
objectTrace container base class.
Base class for Pile, SubPile, and TracesFile, i.e. anything containing a collection of several traces. A TracesGroup object maintains lookup sets of some of the traces meta-information, as well as a combined time-range of its contents.
- add(content)[source]¶
Add content to traces group and update indices.
Accepts
pyrocko.trace.Traceobjects andpyrocko.pile.TracesGroupobjects.
- relevant(tmin, tmax, group_selector=None, trace_selector=None)[source]¶
Return list of
pyrocko.trace.Traceobjects where given argumentstminandtmaxmatch.- Parameters:
tmin – start time
tmax – end time
group_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 (default:
None)trace_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 (default:
None)
- class MemTracesFile(parent, traces)[source]¶
Bases:
TracesGroupThis is needed to make traces without an actual disc file to be inserted into a Pile.
- class Batch(tmin, tmax, i, n, traces)[source]¶
Bases:
objectBatch 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.
- class Pile[source]¶
Bases:
TracesGroupWaveform 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
TracesGroupobjectstrace_selector – filter callback taking
pyrocko.trace.Traceobjectswant_incomplete – if set to
False, gappy/incomplete traces are discarded from the resultsdegap – 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
degapisTruemaxlap – maximum overlap size in samples which is removed when
degapisTruekeep_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 arrayinclude_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 returnedstyle – set to
'batch'to yield waveforms and information about the chopper state asBatchobjects. By default lists ofpyrocko.trace.Traceobjects are yielded.
- Returns:
iterator providing extracted waveforms for each extracted window. See
styleargument for details.
- 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
Trueyield tuples containing absolute file path andpyrocko.trace.Traceobjectsgroup_selector – filter callback taking
TracesGroupobjectstrace_selector – filter callback taking
pyrocko.trace.Traceobjects
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.Stationobjects orNoneevents – list of
pyrocko.model.event.Eventobjects orNonemarkers – list of
pyrocko.gui.snuffler.marker.Markerobjects orNonentracks – float, number of tracks to be shown initially (default: 12)
follow – time interval (in seconds) for real time follow mode or
Nonecontrols – bool, whether to show the main controls (default:
True)opengl – bool, whether to use opengl (default:
False)
- 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
Nonesys.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