danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
633 stars 224 forks source link

how to get the signal value for different channel #966

Closed CSG2019 closed 9 months ago

CSG2019 commented 9 months ago

Hello,

I've just started using this library. now I have a test data, this data contains 2 different channels ,but the 2 signal names are same, how to get the value separately. thank you. below is the screenshot from CANape

image
CSG2019 commented 9 months ago

I suspect I need to use the groups method to differentiate, but I still don't know exactly how to implement it.

danielhrisca commented 9 months ago

Is not possible to use mdf.get("L1.Supply.voltage") ?

CSG2019 commented 9 months ago

I tried below code: import asammdf

file_path = "D:\test.mdf"

mdf = asammdf.MDF(file_path) L1_signal_voltage = mdf.get("L1.Supply.voltage")

It will report :

raise MdfException(f'Channel "{name}" not found') asammdf.blocks.utils.MdfException: Channel "L1.Supply.voltage" not found

danielhrisca commented 9 months ago

Then you should play around with this method https://asammdf.readthedocs.io/en/latest/api.html#asammdf.mdf.MDF.whereis L1 and L2 should be found for one of its arguments

CSG2019 commented 9 months ago

Then you should play around with this method https://asammdf.readthedocs.io/en/latest/api.html#asammdf.mdf.MDF.whereis L1 and L2 should be found for one of its arguments

Thank you for your help.

I tried to use whereis method to get the signals position as below, and get the result is : ((5, 1), (6, 1)), but it seems that I still can't confirm which one is L1. The other question is , once I got this tuple, how to plot/read this "L1.Supply.voltage" signal

mdf = asammdf.MDF(file_path) signal_position = mdf.whereis('Supply.voltage') print(signal_position)

morbult commented 9 months ago

Try sig = mdf.get(group=5, index=1), that returns a Signal object. Get samples with sig.samples and plot with sig.plot()

CSG2019 commented 9 months ago

Try sig = mdf.get(group=5, index=1), that returns a Signal object. Get samples with sig.samples and plot with sig.plot()

thank you. it can work.