Commit 5b6754dc authored by Javier Quinteros's avatar Javier Quinteros

Write to MiniSEED using Obspy.

parent 6186ba20
......@@ -24,6 +24,9 @@ import datetime
import numpy as np
from math import floor
from math import ceil
from obspy import UTCDateTime
from obspy import Trace
from obspy import Stream
class TDMS(object):
......@@ -294,9 +297,10 @@ class TDMS(object):
# Loop through channels
for ch in range(self.__chstart, self.__chstop+1, self.__chstep):
data = self.__readdata(channel=ch)
stats = {'network': 'XX', 'station': 'XXXX', 'location': '',
'channel': str(ch), 'npts': len(data),
'sampling_rate': self.sampling_rate}
stats = {'network': 'XX', 'station': '%05d' % ch, 'location': '',
'channel': 'FH1', 'npts': len(data),
'sampling_rate': self.sampling_rate,
'starttime': UTCDateTime(self.__twstart)}
yield (data, stats)
def __iter_metadata__(self):
......@@ -454,10 +458,21 @@ def main():
starttime=dtstart, endtime=dtend)
with td:
print(td.starttime, td.endtime)
if td.datatype.endswith('i2'):
enc = 1
elif td.datatype.endswith('f4'):
enc = 4
raise Exception('Encoding type not supported to export in MiniSEED!')
for data, stats in td:
st = Stream([Trace(data=data, header=stats)])
st.write('%s.%s.%s.%s.mseed' % (stats['network'], stats['station'],
stats['location'], stats['channel']),
if __name__ == '__main__':
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment