Commit ebcdedc4 authored by Javier Quinteros's avatar Javier Quinteros
Browse files

Bugfix: Remove hardcoded decimation factor

parent 526ef99f
......@@ -617,11 +617,12 @@ class TDMS(object):
# Flush outbuf?
if ch in outbuf:
leftover = len(nodecimation[ch]) % 5
leftover = len(nodecimation[ch]) % self.__decimate
# outbuf[ch]['stats']['starttime'] += 1/outbuf[ch]['stats']['sampling_rate']
outbuf[ch]['stats']['npts'] = 1
yield nodecimation[ch][-leftover::5], outbuf[ch]['stats']
logs.debug('Flushing: %s %s' % (nodecimation[ch][-leftover::5], outbuf[ch]['stats']))
yield nodecimation[ch][-leftover::self.__decimate], outbuf[ch]['stats']
logs.debug('Flushing: %s %s' % (nodecimation[ch][-leftover::self.__decimate],
outbuf[ch]['stats']))
del outbuf[ch]
# self.__buffer[ch] = None
del expectedtime[ch]
......@@ -650,8 +651,8 @@ class TDMS(object):
startofchunk = False
# Change the headers to reflect the decimation
# FIXME Decimation factor is hardcoded
outbuf[ch]['stats']['sampling_rate'] = stats['sampling_rate']/5
# Reduce the sampling rate by the decimation factor
outbuf[ch]['stats']['sampling_rate'] = stats['sampling_rate']/self.__decimate
# print('outbuf new: %s' % outbuf[ch]['stats'])
# If there are not enough components move to the next chunk
......@@ -667,23 +668,23 @@ class TDMS(object):
logs.debug('filtered[%d][-11:] %s' % (ch, nodecimation[ch][-11:]))
# Check if we can copy as many components as a multiple of the decimation factor
# FIXME Decimation factor is hardcoded
leftover = len(nodecimation[ch]) % 5
leftover = len(nodecimation[ch]) % self.__decimate
logs.debug('filtered: leave %d components for next iteration %s' % (leftover, nodecimation[ch][-leftover:]))
if leftover:
if 'data' not in outbuf[ch]:
# FIXME Decimation factor is hardcoded
outbuf[ch]['data'] = nodecimation[ch][:-leftover][::5]
# Take samples each "self.__decimate" components
outbuf[ch]['data'] = nodecimation[ch][:-leftover][::self.__decimate]
else:
# FIXME Decimation factor is hardcoded
outbuf[ch]['data'] = np.append(outbuf[ch]['data'], nodecimation[ch][:-leftover][::5])
# Add samples each "self.__decimate" components
outbuf[ch]['data'] = np.append(outbuf[ch]['data'],
nodecimation[ch][:-leftover][::self.__decimate])
else:
if 'data' not in outbuf[ch]:
# FIXME Decimation factor is hardcoded
outbuf[ch]['data'] = nodecimation[ch][::5]
# Take samples each "self.__decimate" components
outbuf[ch]['data'] = nodecimation[ch][::self.__decimate]
else:
# FIXME Decimation factor is hardcoded
outbuf[ch]['data'] = np.append(outbuf[ch]['data'], nodecimation[ch][::5])
# Add samples each "self.__decimate" components
outbuf[ch]['data'] = np.append(outbuf[ch]['data'], nodecimation[ch][::self.__decimate])
logs.debug('outbuf[%d][:11] %s' % (ch, outbuf[ch]['data'][:11]))
logs.debug('outbuf[%d][-11:] %s' % (ch, outbuf[ch]['data'][-11:]))
......
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