ldparser icon indicating copy to clipboard operation
ldparser copied to clipboard

Question - Feature request on the ldChan class

Open j-antunes opened this issue 5 years ago • 4 comments

Hello!

Thank you for the update on the repo.

I have a question for you. In the new version it's possible to access the data as: l.channs[0].data or l.channs[1].data, etc.

This is not very practical because I need to check every time the name. Would it be possible for this to be a dictionary instead of a list? That way it would be more convenient to get data based on the channel name.

What I would suggest is to be able to get the data as l.channs['Beacon'].data

Let me know what you think.

j-antunes avatar Oct 21 '20 13:10 j-antunes

Hi, I guess this actually already exists. Try

l = ldData.fromfile('sample.ld')
l['Beacon'].data

Does this work for you?


Offtopic: Just to finish up on your earlier question, even though it's probably too late, and I don't have an answer ^^ I don't know any book or resource on decoding. The only things I used were pydoc about struct and a hexeditor, plus general knowledge and 'an eye' for binary data from previous work ... I don't know how other people approach this kind of work, or if there is a better way to go. I just started with an idea and went from there ;) Also, I'm glad that this code seems to be useful to you!

gotzl avatar Oct 21 '20 18:10 gotzl

Hey @gotzl thank you for getting back to me! I've tried to call the data as you suggest, but it didn't work for me at that time. I'll try it again and let you know! It's very helpful, I use motec files all the time, and just being able to read them really helps me to streamline all my data! Thank you for putting it here!

I also don't know how people would approach it, but your approach seems really good! I really like how you modified the code to use "pointers" so that we avoid memory overflow! Thank you for your feedback!

j-antunes avatar Nov 03 '20 22:11 j-antunes

I just tested and it's working, maybe I did a mistake before. Thank you!

j-antunes avatar Nov 06 '20 23:11 j-antunes

In my application I use the following: ' l = ldData.fromfile(file_path) self._header, self._channels = l.head, l.channs ' When used like this the l.channs is a list, and for that reason I can't do self._channels['Channel_name']. Would it be possile to change the channel from a list to a dict? Hence my commit.

j-antunes avatar Nov 07 '20 11:11 j-antunes