pyrocko.io¶
Low-level input and output of seismic waveforms, metadata and earthquake catalogs.
Input and output (IO) for various different file formats is implemented in the
submodules of pyrocko.io
. pyrocko.io
itself provides a
simple unified interface to load and save seismic waveforms to a few different
file formats. For a higher-level approach to accessing seismic data see
Squirrel - Data access infrastructure.
Seismic waveform IO
The data model used for the Trace
objects in Pyrocko
is most closely matched by the Mini-SEED file format. However, a difference is,
that Mini-SEED limits the length of the network, station, location, and channel
codes to 2, 5, 2, and 3 characters, respectively.
format |
format identifier |
load |
save |
note |
---|---|---|---|---|
Mini-SEED |
mseed |
yes |
yes |
|
SAC |
sac |
yes |
yes |
|
SEG Y rev1 |
segy |
some |
||
SEISAN |
seisan, seisan.l, seisan.b |
yes |
||
KAN |
kan |
yes |
||
YAFF |
yaff |
yes |
yes |
|
ASCII Table |
text |
yes |
||
GSE1 |
gse1 |
some |
||
GSE2 |
gse2 |
some |
||
DATACUBE |
datacube |
yes |
||
SUDS |
suds |
some |
||
CSS |
css |
yes |
||
TDMS iDAS |
tdms_idas |
yes |
||
HDF5 iDAS |
hdf5_idas |
yes |
Notes
Modules
Reader of CSS wfdisc waveform data. |
|
Reader for DiGOS DATA-CUBE³ raw data. |
|
Reader for enhanced SAC pole-zero files. |
|
Event data access interface (deprecated). |
|
Reader for the Güralp GCF format. |
|
Reader for GSE1 files. |
|
Reader for GSE2.0 (IMS) waveform files. |
|
Reader for Silixia iDAS HDF5 files. |
|
Read and write GSE2.0, GSE2.1, and IMS1.0 files. |
|
IO related exception definitions and utilities. |
|
Reader for KAN files. |
|
Read/write MiniSEED files (wraps libmseed). |
|
QuakeML 1.2 input, output, and data model. |
|
Access to SEED volumes by interfacing rdseed (deprecated). |
|
Reader for RESP files. |
|
SAC waveform file input, output and data model. |
|
Reader for SEGY files. |
|
Read instrument responses from SEISAN files. |
|
Read seismic waveforms from SEISAN files. |
|
FDSN StationXML input, output and data model. |
|
Reader for SUDS waveforms and station information. |
|
Reader for Silixia iDAS TDMS files. |
|
File IO module for SICK traces format. |
Functions
|
Load traces from file (iterator version). |
|
Load traces from file. |
|
Save traces to file(s). |
- load(filename, format='mseed', getdata=True, substitutions=None)[source]¶
Load traces from file.
- Parameters:
format – format of the file (
'detect'
,'from_extension'
,'mseed'
,'sac'
,'segy'
,'seisan'
,'seisan.l'
,'seisan.b'
,'kan'
,'yaff'
,'gse1'
,'gse2'
,'gcf'
,'datacube'
,'suds'
,'css'
,'tdms_idas'
,'hdf5_idas'
)getdata – if
True
(the default), read data, otherwise only read traces metadatasubstitutions – dict with substitutions to be applied to the traces metadata
- Returns:
list of loaded traces
When format is set to
'detect'
, the file type is guessed from the first 512 bytes of the file. Only Mini-SEED, SAC, GSE1, and YAFF format are detected. When format is set to'from_extension'
, the filename extension is used to decide what format should be assumed. The filename extensions considered are (matching is case insensitive):'.sac'
,'.kan'
,'.sgy'
,'.segy'
,'.yaff'
, everything else is assumed to be in Mini-SEED format.This function calls
iload()
and aggregates the loaded traces in a list.
- iload(filename, format='mseed', getdata=True, substitutions=None)[source]¶
Load traces from file (iterator version).
This function works like
load()
, but returns an iterator which yields the loaded traces.
- save(traces, filename_template, format='mseed', additional={}, stations=None, overwrite=True, append=False, check_append=False, check_append_merge=False, check_append_hook=None, **kwargs)[source]¶
Save traces to file(s).
- Parameters:
traces – a trace or an iterable of traces to store
filename_template – filename template with placeholders for trace metadata. Uses normal python ‘%(placeholder)s’ string templates. The following placeholders are considered:
network
,station
,location
,channel
,tmin
(time of first sample),tmax
(time of last sample),tmin_ms
,tmax_ms
,tmin_us
,tmax_us
. The versions with ‘_ms’ include milliseconds, the versions with ‘_us’ include microseconds.format –
'mseed'
,'sac'
,'text'
,'yaff'
,'gse2'
additional – dict with custom template placeholder fillins.
overwrite' – if
False
, raise an exception if file existsappend' – append traces to the file if the file exists
check_append' – ensure that appended traces do not overlap with traces already present in the file
check_append_merge' – try to merge traces with already stored traces where check_append finds a conflict.
append
andcheck_append
must be set to use this option.check_append_hook – callback queried for permission to append to an existing file (for example to prevent overwriting files which existed prior to the application start but to allow appending to files created in the current run). The callback takes a single argument, the current filename. If it returns
False
the save will either fail (if overwrite isFalse
) or truncate the file (if overwrite is True). If the hook returnsTrue
or if no hook is installed, appending is allowed.
- Returns:
list of generated filenames
Note
Network, station, location, and channel codes may be silently truncated to file format specific maximum lengthes.