Commit eb6bddaa authored by Javier Quinteros's avatar Javier Quinteros

Bugfix: Avoid calling decimation if not needed

Even calling decimation with parameter 1 gave some small differences in
amplitude.
Limit the values that the decimation parameter can receive.
parent 2fd81f4a
......@@ -28,7 +28,7 @@ from obspy import UTCDateTime
from obspy import Trace
from obspy import Stream
version = '0.1b2'
version = '0.1b4'
class TDMS(object):
......@@ -459,6 +459,11 @@ def str2date(dStr):
dateParts = dStr.replace('-', ' ').replace('T', ' ')
dateParts = dateParts.replace(':', ' ').replace('.', ' ')
dateParts = dateParts.replace('Z', '').split()
# Consider the case in which just the first digits of microseconds
# are given and complete with 0's to have 6 digits
if len(dateParts) == 7:
dateParts[6] = dateParts[6] + '0' * (6 - len(dateParts[6]))
return datetime.datetime(*map(int, dateParts))
......@@ -489,7 +494,7 @@ def main():
parser.add_argument('--chstep', type=int,
help='Step between channels in the selection',
default=1)
parser.add_argument('--decimate', type=int,
parser.add_argument('--decimate', type=int, choices=range(1, 17),
help='Factor by which the sampling rate is lowered by decimation.',
default=5)
parser.add_argument('--metadata', action='store_true', default=False,
......@@ -523,7 +528,11 @@ def main():
logs.info(data)
else:
tr0 = Trace(data=data[0], header=data[1])
tr0.decimate(args.decimate)
# 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)
......
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