Commit 9a5693ae authored by Javier Quinteros's avatar Javier Quinteros

Reduce decimate choices (1, 5) and treat it inside the TDMS class

parent f61a7ec3
......@@ -80,9 +80,9 @@ def main():
parser.add_argument('--chstep', type=int,
help='Step between channels in the selection',
default=1)
parser.add_argument('--decimate', type=int, choices=range(1, 17),
parser.add_argument('--decimate', type=int, choices=[1, 5],
help='Factor by which the sampling rate is lowered by decimation.',
default=5)
default=1)
parser.add_argument('--metadata', action='store_true', default=False,
help='Read and display the metadata from the TDMS files')
parser.add_argument('-V', '--version', action='version', version='dasconv v%s' % version)
......@@ -107,7 +107,7 @@ def main():
td = TDMS(args.filename, directory=args.directory, iterate='M' if args.metadata else 'D',
chstart=args.chstart, chstop=args.chstop, chstep=args.chstep,
starttime=dtstart, endtime=dtend)
starttime=dtstart, endtime=dtend, decimate=args.decimate)
with td:
curstream = None
......@@ -121,18 +121,9 @@ def main():
if curstream != '%s.%s.%s.%s' % (data[1]['network'], data[1]['station'], data[1]['location'], data[1]['channel']):
# Save the previous Stream completely
if curstream is not None:
with open('%s.mseed' % (curstream), 'wb') as fout:
# Do not call the decimate method if it is not needed
# 1: no decimation
if args.decimate > 1:
tr0.decimate(args.decimate)
# Use the headers from the decimated Trace
tr1 = Trace(data=tr0.data.astype(td.datatype), header=tr0.stats)
st = Stream([tr1])
logs.info('Storing channel %s' % curstream)
st.write(fout, format='MSEED')
st = Stream([tr0])
logs.info('Storing channel %s' % curstream)
st.write('%s.mseed' % curstream, format='MSEED')
# Update which stream is being processed
curstream = '%s.%s.%s.%s' % (data[1]['network'], data[1]['station'], data[1]['location'], data[1]['channel'])
......@@ -142,18 +133,9 @@ def main():
tr0 += Trace(data=data[0], header=data[1])
else:
if not args.metadata:
with open('%s.mseed' % (curstream), 'wb') as fout:
# Do not call the decimate method if it is not needed
# 1: no decimation
if args.decimate > 1:
tr0.decimate(args.decimate)
# Use the headers from the decimated Trace
tr1 = Trace(data=tr0.data.astype(td.datatype), header=tr0.stats)
st = Stream([tr1])
logs.info('Storing channel %s' % curstream)
st.write(fout, format='MSEED')
st = Stream([tr0])
logs.info('Storing channel %s' % curstream)
st.write('%s.mseed' % curstream, format='MSEED')
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