The obspy.wav package contains methods in order to read and write seismogram files in the WAV(audio) format. The data are squeezed to audible frequencies.
|copyright:||The ObsPy Development Team (email@example.com)|
|license:||GNU Lesser General Public License, Version 3 (http://www.gnu.org/copyleft/lesser.html)|
Importing WAV files is done similar to reading any other waveform data format within ObsPy by using the read() method of the obspy.core module. Examples seismograms files may be found at http://examples.obspy.org.
>>> from obspy import read >>> st = read("/path/to/3cssan.near.8.1.RNON.wav") >>> print(st) 1 Trace(s) in Stream: ... | 1970-01-01T00:00:00.000000Z - 1970-01-01T00:00:00.371143Z | 7000.0 Hz, 2599 samples
The format will be determined automatically. As WAV files can contain only one data trace (as opposed to Mini-SEED or GSE2), the length of ‘st’ will be one. ‘st’ will have a stats attribute containing the essential meta information of the WAV file.
>>> print(st.stats) network: station: location: channel: starttime: 1970-01-01T00:00:00.000000Z endtime: 1970-01-01T00:00:00.371143Z sampling_rate: 7000.0 delta: 0.000142857142857 npts: 2599 calib: 1.0 _format: WAV
The data is stored in the data attribute.
>>> st.data array([ 64, 78, 99, ..., 106, 103, 102], dtype=uint8)
is also straight forward.
>>> st.write('myfile.wave', format='WAV', framerate=7000)
The framerate specifies the framerate to which the seismogram should be squeezed. Using the original sampling_rate results in an WAV file with frequencies which cannot be heard by a human, therefore it makes sense to set the framerate to a high value.