09-18-2019 04:11 AM
I have an issue with reading tdms files with nptdms module, I seem to use it correctly looking at the examples but the python output differs from expected.
Here is my code:
group_name_mV = 'max_sampling_test'
Test_number = 2
file_path = r"c:\daq_logs\test_max_sampling.tdms"
if Test_number == 0:
group_fullname_mV = group_name_mV
group_fullname_mA = group_name_mA
else:
group_fullname_mV = group_name_mV + ' ' + '#' + str(Test_number)
group_fullname_mA = group_name_mA + ' ' + '#' + str(Test_number)
Channel_name = ch[0]
'''import data, time from file'''
tdms_file = TdmsFile(file_path)
print('tdms_file.object(group_fullname_mV).as_dataframe()')
print(tdms_file.object(group_fullname_mV).as_dataframe())
Here is my result with python
Dev2/ai0 Dev2/ai1 Dev2/ai2
0 -0.000751 0.002774 0.085045
1 -0.000631 0.002774 0.040465
2 -0.000831 0.002774 0.023281
3 -0.000631 0.002774 0.014590
4 -0.000671 0.002774 0.005377
5 -0.000631 0.002774 0.025204
6 -0.000871 0.002774 -0.002714
7 -0.000711 0.002774 -0.005197
8 -0.000831 0.002774 0.005497
Here is tdms file opened with excel
Dev2/ai0 | Dev2/ai1 | Dev2/ai2 |
-0.000751191 | 0.085044911 | 0.105352391 |
-0.000631029 | 0.040464584 | 0.073389138 |
-0.0008313 | 0.023281331 | 0.047994774 |
-0.000631029 | 0.014589569 | 0.042627511 |
-0.000671083 | 0.005377102 | 0.027326806 |
-0.000631029 | 0.025203933 | 0.024442903 |
-0.000871354 | -0.002713847 | 0.019796615 |
-0.000711137 | -0.005197208 | 0.010664257 |
-0.0008313 | 0.005497265 | 0.018234501 |
I don't know why my ai1 data in tdms data is moved to ai2 in python??
Any ideas what I'm doing wrong here?
05-19-2020 02:15 AM
Hi, may you please share the tdms file you are tying to open?
05-19-2020 08:44 AM
Your columns don't line up anyway, so to presume you are seeing the second signal's data in the 3rd column isn't valid in the first place.
That 0.002774 value looks like a time delta to me. Are you sampling at 360 Hz (1/0.002774)? Perhaps that is just its way of returning XY data (similar to right-clicking a graph in LabVIEW and exporting to Excel -- it returns XY data for all plots even though for most situations the X values are all the same).
Just a thought. I don't really do python 😋