Comments (6)
Would you have an example file (as small as possible) that we can look into?
from nptdms.
I uploaded the file to https://github.com/boiler42/npTDMS
My code is:
from nptdms import TdmsFile
tdms_file = TdmsFile('data.tdms')
a = tdms_file.object('Test Group', 'Channel A')
b = tdms_file.object('Test Group', 'Channel B')
print(a.time_track(absolute_time=True))
print(b.time_track(absolute_time=True))
print(a.time_track())
print(b.time_track())
b should lag a by 3 seconds. Absolute time is correct. Relative time is not correct
from nptdms.
I think it's best that @adamreeve looks at this. My knowledge of TDMS files is kinda bad :-)
from nptdms.
Your file has offsets of zero for each channel but has different absolute start times. The output from tdmsinfo looks like:
/
properties:
name: Test TDMS data
/'Test Group'
/'Test Group'/'Channel A'
data type: tdsTypeDoubleFloat
properties:
wf_start_time: 2015-11-20 20:13:43.596313
wf_start_offset: 0.0
wf_increment: 1.0
wf_samples: 10
/'Test Group'/'Channel B'
data type: tdsTypeDoubleFloat
properties:
wf_start_time: 2015-11-20 20:13:46.596614
wf_start_offset: 0.0
wf_increment: 1.0
wf_samples: 10
So when you want to plot the data you could plot each channel against an absolute time or calculate the offset based on the absolute times. If you want to get a time track with absolute times for your channel you can set absolute_time
to true in the time_track
method, eg. t = tdms_obj.time_track(absolute_time=True)
.
from nptdms.
Understood. For the real work, I am getting absolute time for each channel and then relativizing them by subtracting the min across all channels. I think your current code is correct and this is more of a peculiarity of the file I am using. It would be nice to print a warning if you get relative times from channels with unequal "true start times", which I am considering to be equal to wf_start_time + wf_start_offset. It would be even better if the extra functionality I described above were built in, basically a third option for time which would be something like "global_relative".
Thanks for the quick replies and the helpful library! I am a python guy but where I work all test data is NI/TDMS so nptdms is perfect.
from nptdms.
Hmm so re-reading NI's documentation on wf_start_offset
, they say "This property is used for the LabVIEW Express Dynamic Data Type. Frequency-domain data and histogram results will use this value as the first value on the x-axis."
So this is probably always zero for time-series data. It's just that the time_track
method can also be used to get an array of x-axis data for non time-series data, so needs to account for this attribute if it's present. This is kind of an unfortunate naming choice, and maybe this method should have just been named "independent_axis_values" or something.
I will update the documentation to clarify what these parameters mean, and note that wf_start_offset
will be zero for time series data, and the start time should be used to align time-series data.
from nptdms.
Related Issues (20)
- not able to read heavily fragmented TDMS (v1.6.0) HOT 2
- Reading TDMs Files HOT 2
- Printing the values of all tdms files in the same directory using the for loop in python
- Read data with specific numpy floating dtype
- Numpy Deprecation Warning HOT 1
- read error UTF8 HOT 5
- Problem with reading SpooledTemporaryFile HOT 2
- Error in loading image files HOT 2
- Deprecation warning for setup.py HOT 1
- [Bug] read version from import lib HOT 1
- Type Hints/Annotations HOT 1
- struct.error: unpack requires a buffer of 4 bytes HOT 3
- Group Properties Not Reading HOT 14
- Error encountered when writing DAQmx data with scale information HOT 1
- [Feature] Add number of samples to read per chunk HOT 3
- API Reference HOT 2
- [Feature] Option to return Dataframe as PyArrow dtype HOT 1
- How to ignore `warning` in read function? HOT 3
- Missing 8 rquired positional arguments when trying to create ChannelObject HOT 1
- Inconsistent Behaviour With Truncated Files HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nptdms.