Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'convertAfterRead' does not work #90

Closed
gr1nk0 opened this issue Sep 29, 2017 · 10 comments
Closed

'convertAfterRead' does not work #90

gr1nk0 opened this issue Sep 29, 2017 · 10 comments

Comments

@gr1nk0
Copy link

gr1nk0 commented Sep 29, 2017

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

@ratal
Copy link
Owner

ratal commented Oct 2, 2017

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 ?

@gr1nk0
Copy link
Author

gr1nk0 commented Oct 11, 2017

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?

@danielhrisca
Copy link
Contributor

You could use something similar with the interp method from the Signal class here:

https://github.com/danielhrisca/asammdf/blob/master/asammdf/signal.py

@ratal
Copy link
Owner

ratal commented Oct 11, 2017

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 ?

@danielhrisca
Copy link
Contributor

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.

@ratal
Copy link
Owner

ratal commented Oct 11, 2017

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.

@danielhrisca
Copy link
Contributor

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.

@ratal
Copy link
Owner

ratal commented Oct 19, 2017

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 ?

@ratal
Copy link
Owner

ratal commented Nov 8, 2017

New interpolation code from Daniel was implemented in last commit, can you check it ?

@ratal
Copy link
Owner

ratal commented Dec 15, 2017

No feedback since a while, I guess issue solved.

@ratal ratal closed this as completed Dec 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants