Created
November 3, 2016 14:50
-
-
Save jkmacc-LANL/1a1d672c73bbdaee1b04d3cab9caa5c8 to your computer and use it in GitHub Desktop.
miniseed to css wfdisc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import glob | |
from obspy import read | |
from pisces.tables.css3 import Wfdisc | |
with open('wfdiscfile.wfdisc', 'w') as wfdiscfile: | |
for ifile in glob.glob('*.mseed'): | |
pathname, ext = os.path.splitext(ifile) | |
newname = pathname + '.w' | |
idir, idfile = os.path.split(newname) | |
tr = read(ifile)[0] | |
with open(newname, 'wb') as f: | |
tr.data.astype('<i4').tofile(f) | |
wf = Wfdisc(sta=tr.stats.station, chan=tr.stats.channel, samprate=tr.stats.sampling_rate, | |
nsamp=tr.stats.npts, time=tr.stats.starttime.timestamp, foff=0, dir=idir, | |
dfile=idfile, endtime=tr.stats.endtime.timestamp, datatype='i4') | |
wfdiscfile.write(str(wf) + os.linesep) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment