Skip to content

Instantly share code, notes, and snippets.

@jkmacc-LANL
Created November 3, 2016 14:50
Show Gist options
  • Save jkmacc-LANL/1a1d672c73bbdaee1b04d3cab9caa5c8 to your computer and use it in GitHub Desktop.
Save jkmacc-LANL/1a1d672c73bbdaee1b04d3cab9caa5c8 to your computer and use it in GitHub Desktop.
miniseed to css wfdisc
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