API¶
- class nitdms.reader.TdmsFile(file)¶
TDMS file object containing all groups, channels, properties and data
Upon instantiation, the class loads the TDMS file into memory and discovers all of the file, group and channel objects and respective properties. These objects and properties are dynamically instantiated as attributes allowing easy access from within an interactive session with tab completion such as Jupyter.
- file¶
TDMS file to read
- Type
str
Example
>>> from nitdms import TdmsFile >>> tf = TdmsFile(<file>) >>> data = tf.<group>.<channel>.data >>> data array([...])
- __str__()¶
Tree view of the groups, channels and properties
- property groups¶
Groups in file
- property info¶
names of all the groups, channels and properties in the file
- Type
dict
- property name¶
File name
- class waveformDT.waveform.WaveformDT(Y, dt, t0)¶
Python implementation of LabVIEW’s waveform data type
LabVIEW’s waveform data type has three required attributes: t0, dt, and Y. Additional attributes can be set and are included in the returned WaveformDT. WaveformDT has the function to_xy() that will generate the x-axis array from the t0, dt and number of samples in the Y array.
- Y¶
data
- Type
array-like
- dt¶
wf_increment
- Type
float
- t0¶
wf_start_time
- Type
float or datetime
Example
>>> data = WaveformDT([1,2,3], 1, 0) >>> x, y = data.to_xy() >>> x array([0., 1., 2.]) >>> y array([1, 2, 3])
WaveformDT supports a variety of workflows with and without units where unit support is provided by the Unyt library.
>>> data.xunit = "s" >>> data.yunit = "V" >>> x, y = data.to_xy() >>> x unyt_array([0., 1., 2.], 's') >>> y unyt_array([0, 1, 2], 'V')
WaveformDT supports Matplotlib and its labeled data interface:
>>> import matplotlib.pyplot as plt >>> waveform = WaveformDT([1,2,3], 1, 0) >>> plt.plot('x', 'y', 'r-', data=waveform) [<matplotlib.lines.Line2D object ... >] >>> plt.show()
Note
The x-axis array will be relative time by default. For absolute time, set the relative parameter to False.
- head(n=5)¶
Return first n samples of the waveform
- Parameters
n (int) – number of samples to return
- Returns
first n samples
- Return type
- property max¶
maximum value
- Type
(float)
- property min¶
minimum value
- Type
(float)
- set_attributes(**kwargs)¶
Set waveform attributes
- property size¶
Return the number of elements in Y
- property std¶
standard deviation
- Type
(float)
- tail(n=5)¶
Return the last n samples of the waveform
- Parameters
n (int) – number of samples to return
- Returns
last n samples
- Return type
- to_xy(relative=True, inunits=True)¶
Generate the (x, y) tuple
- Parameters
relative (bool) – y is relative time if True, absolute if False
inunits (bool) – convert arrays to unyt_array if yunit and xunit are defined
- Returns
x, y arrays
- Return type
tuple
- property xunit¶
X-axis unit, based on dt
- Type
units (str, Unit)
- property yunit¶
Y-axis unit
- Type
units (str, Unit)
- class nitdms.common.TdmsObject¶
Base class for the three TDMS object types: File, Group and Channel
TdmsObject is a container whose elements are attributes that are dynamically instantiated during discovery of the tdms file metadata. The class, and derivatives, support both attribute dot access and dict-like item access. The container is immutable and supports iteration through the attributes.
TdmsObject is not intended to be instantiated in application code.
- class nitdms.common.Group(name)¶
Group object for group properties and channel objects
Not intended to be instantiated in application code.
- __str__()¶
Tree view of this group’s channels and properties
- class nitdms.common.Channel(name)¶
Channel object for channel properties and data
Not intended to be instantiated in application code.
- __str__()¶
Tree view of this channel’s properties and data
- property data¶
the channel data
- Type
ndarray or WaveformDT
- property name¶
Return name of channel