Commit 6615ee98 authored by Javier Quinteros's avatar Javier Quinteros

Add parameter channels to TDMS and give priority to the channel selection

parent 9673997a
......@@ -49,7 +49,7 @@ class TDMS(object):
return self
# TODO Add parameter to accept a list with channel numbers
def __init__(self, filename, directory='.', chstart=0, chstop=None, chstep=1,
def __init__(self, filename, directory='.', chstart=0, chstop=None, chstep=1, channels=None,
starttime=None, endtime=None, iterate='D', decimate=1, firfilter='fir235',
"""Initialize the TDMS object selecting the data, channels and decimation
......@@ -64,6 +64,8 @@ class TDMS(object):
:type chstop: int
:param chstep: Step between channels in the selection
:type chstep: int
:param channels: Selection of channels to work with (list of integers)
:type channels: list
:param starttime: Start of the selected time window
:type starttime: datetime.datetime
:param endtime: End of the selected time window
......@@ -88,11 +90,19 @@ class TDMS(object):
# Decimation factor
self.__decimate = decimate
# Channel from and to
# self.__chstart = chstart
# self.__chstop = chstop
# self.__chstep = chstep
self.__channels = list(range(chstart, chstop+1, chstep))
# Selection of channels
# channels has priority. Otherwise, chstart, chstop and chstep are used
if channels is not None:
if isinstance(channels, list):
self.__channels = channels
raise TypeError('"channels" must be a list')
self.__channels = list(range(chstart, chstop+1, chstep))
# List of channels cannot be empty
if not len(self.__channels):
raise Exception('Channel list is empty!')
# Time window selection
self.__twstart = starttime
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