pisces.io.waveforms#
Raw waveform sample-vector reading, dispatched by wfdisc.datatype.
This module reads the samples from files already described by a waveform
record; it does not import file-header metadata into database tables. For
SAC or miniSEED header import, use pisces.io.sac or
pisces.io.mseed, respectively. Files remain in place: callers provide
the path and offset stored by their waveform record.
Plain NumPy-compatible binary layouts (NPTYPE below) are read generically
by read_numpy, keyed only by their NumPy dtype string – no registration
needed. Everything else (data requiring a real decoder: miniSEED, SEGY,
compressed formats, etc.) is read by a function registered in
WAVEFORM_READERS, keyed by its wfdisc.datatype string.
WAVEFORM_READERS is a plain pisces.io.util.Registry, so new datatypes can be added from user code without editing pisces, e.g.:
from pisces.io.waveforms import WAVEFORM_READERS
@WAVEFORM_READERS('my_dtype')
def read_my_dtype(path, byteoffset=0, nsamp=None):
...
Note that 'sd' (miniSEED/SEED) and 'sc' (SAC), as well as the numeric
NumPy types, are not official KB Core wfdisc.datatype values – they’re
pisces conveniences, and the files they point to may hold header metadata
that’s stale relative to the database tables. 'sc' in particular is
mostly redundant with the plain float NumPy types (SAC’s own on-disk sample
array is just a big/little-endian f4 vector at a known byte offset);
it’s kept here only as a convenience for reading a standalone SAC file
wholesale through ObsPy, ignoring byteoffset/nsamp.
- pisces.io.waveforms.read_e1(DATAFILE, BYTEOFFSET, NUM)[source]#
Read an ‘e1’-compressed datatype. Requires the ‘e1’ package.
- pisces.io.waveforms.read_numpy(DATAFILE, BYTEOFFSET, NUM, PERMISSION, DTYPE)[source]#
Read NumPy-compatible binary data.
Modeled after MatSeis function read_file in util/waveread.m.
- pisces.io.waveforms.read_s3(DATAFILE, BYTEOFFSET, NUM)[source]#
Read signed big-endian 3-byte integers into a 4-byte native NumPy array.
- pisces.io.waveforms.read_sac(DATAFILE, BYTEOFFSET=0, NUM=None)[source]#
Read a standalone SAC file’s data through ObsPy, ignoring BYTEOFFSET/NUM.
See the module docstring – ‘sc’ is a pisces convenience, redundant with the plain float NumPy datatypes for most purposes.
- pisces.io.waveforms.read_seed(DATAFILE, BYTEOFFSET=0, NUM=None)[source]#
Read a SEED or miniSEED ‘sd’ datatype.
- pisces.io.waveforms.read_segy(DATAFILE, BYTEOFFSET=0, NUM=None)[source]#
Read a standalone SEGY file’s data through ObsPy.
- pisces.io.waveforms.read_waveform(DATAFILE, DATATYPE, BYTEOFFSET, NUM)[source]#
Read a data vector of a certain data type.
- Parameters:
- DATAFILEstring
Path and name of data file.
- DATATYPEstring
- {‘f4’, ‘i1’, ‘i2’, ‘i4’, ‘p4’, ‘t8’, ‘s2’, ‘p8’, ‘s4’, ‘f8’, ‘u4’, ‘t4’,
‘s1’, ‘sd’, ‘e1’, ‘sc’, ‘sy’, ‘s3’, …}
Data type string (from wfdisc.datatype). ‘sd’, ‘sc’, and ‘sy’ are SEED/miniSEED, SAC, and SEGY (pisces conveniences, not official KB Core values – see module docstring). ‘e1’ requires installation of the “e1” python module. Additional datatypes can be registered via
WAVEFORM_READERS.- BYTEOFFSETint
Number of bytes from beginning of file.
- NUMint
Number of samples to read.
- Returns:
- datanumpy.array
Vector of NUM samples of type DATATYPE.
- Raises:
- ValueError
Unrecognized DATATYPE.
- IOError
DATAFILE does not exist.
Notes
If the file has a header and you want it, you’ll have to read it manually with obspy.core.read or something else.