Closed gr1nk0 closed 6 years ago
Hi, Version 0.2.2 is rather old so I would strongly advise you to test it with latest version. Anyway, I will try to investigate with 0.2.2 but in the mean time, when doing .getChannelData(channel), does it returns raw data or converted data ?
Anyway I got another issue: Can I do a resampling for the data with an interpolation which sticks to the last value until a new value is recognized for that signal?
So if I have signals which are represented by integers I would only that int-values. For example if I have a signal with values as 0, 1 and 2, I only want those values. Not 0.5 or 0.75 to a time point between the raising from 0 to 1.
Is this kind of interpolation available?
You could use something similar with the interp method from the Signal class here:
https://github.com/danielhrisca/asammdf/blob/master/asammdf/signal.py
Another simple way could be to replace numpy.interp by scipy.interpolate.interp1d in resample method of mdfreader and specify kind='nearest' (many others are also available). Can be an improvement. Daniel's implementation will give another result (step between the points compared to at points) What is your preference, I guess depends of your data ?
My rational was that most of the times integer channel are some flags, codes or states, and that when interpolating you should take the previous value.
If the signal represents something physical, you cannot know when is the transition or step between 2 points so stepping at left, right or middle point does not matter. But I agree with you, most channels recording in mdf are representing logic variables so your approach makes sense --> I Will add your approach as default option in resample when I have some spare time.
Obviously this approach does not fit all cases, but in this context of automotive oriented measurement files I think it's the better/safer way.
In the mean time gr1nk0, did you solve your issue with raw data and .getChannelData() ? Or should we change title into somehting related to interpolation ?
New interpolation code from Daniel was implemented in last commit, can you check it ?
No feedback since a while, I guess issue solved.
Hello, I have a problem with the mdfreader. I want to read in a mdf-file, resample it and then export it into a mat-file. All steps are working, but I receive only raw values for my data.
If I have a look at the mdf-file with CANape all the files are shown in a correct way. But if I have a look at the exported mat-file, I get all the data in raw format. Normally there should be values with an included calculated factor and offset. But this part doesn't work even if I use the 'convertAfterRead'-flag...
An example for the used code: yop = mdfreader.mdf(mdf_path1, convertAfterRead=True)
I tried a lot of different things and read through the documentation for the mdfreader, but I wasn't successful.
I hope you can help me with this problem. Thank you in advance!
PS: I work with mdf-files of version 4.10 (compressed), Python 3 and mdfreader version 0.2.2