ratal / mdfreader

Read Measurement Data Format (MDF) versions 3.x and 4.x file formats in python
Other
169 stars 74 forks source link

Time has more samples than signal. #146

Closed MontyTHall closed 5 years ago

MontyTHall commented 6 years ago

Pyhton version

Please write here the output of printing sys.version '2.7.15 (v2.7.15:ca079a3ea3, Apr 30 2018, 16:30:26) [MSC v.1500 64 bit (AMD64)]'

Platform information

Please write here the output of printing platform.platform() 'Windows-7-6.1.7601-SP1'

Numpy version

Please write here the output of printing numpy.__version__ '1.14.3'

mdfreader version

Please write here the output of printing mdfreader.__version__ '2.7.5' `

Description

Please describe the issue here and eventually script used to use mdfreader

base = "cross_traffic3"
fileName = "C:\\Users\\xzcjml\\Documents\\dSPACE\\ControlDeskNG\\5.3\\Project_001\\Experiment_001\\Measurement Data\\" + base + ".mf4"
name_cav_id = "Model Root/slave/LCM_ProcessInputs/LCM_Read/LCM Slave/LCM_Subscribers/LCM Subscribers 40ms/CAV/cav_id"
name_cav_x = "Model Root/slave/LCM_ProcessInputs/LCM_Read/LCM Slave/LCM_Subscribers/LCM Subscribers 40ms/CAV/cav_x"
name_cav_y = "Model Root/slave/LCM_ProcessInputs/LCM_Read/LCM Slave/LCM_Subscribers/LCM Subscribers 40ms/CAV/cav_y"
name_rltvLaneTOS = "Model Root/slave/Control/TSTR/TSTR Component/Relative Lane/VaTSTR_e_RltvLaneTOS"

mdf = mdfreader.mdf(fileName)
cav_id = mdf.getChannelData(name_cav_id)
cav_x = mdf.getChannelData(name_cav_x)
cav_y = mdf.getChannelData(name_cav_y)
rltvLaneTOS = mdf.getChannelData(name_rltvLaneTOS)
print(len(cav_id))
print(len((mdf.getChannelData(masterName))))
exit(0)
masterName = list(mdf.masterChannelList.keys())[0]
for i, t in enumerate(mdf.getChannelData(masterName)):
    delta = t - lastTime
    if delta > win.DT:
        text.reset()
        win.reset()
        iz = cav_id[i]  <-- this fails because i > 1095
        xs = cav_x[i]
        ys = cav_y[i]

cav_id has 1095 rows master has 1128 rows. Should they be the same?

The mf4 file was generated with dSPACE control desk. "for i, t in enumerate(mdf.getChannelData(masterName)): " should iterate over the time stamps right? Why do I have 1128 time stamps, yet my signal "cav_id", "cav_x" and "cav_y" all have 1095 rows?

Thanks,

M

Also mentionning version of mdf file will be helpfull (using mdfvalidator or mdfreader if functionnal for reading)

print of issue related variables at the errors location and eventually mdfvalidator screenshots can help troubleshooting complicated issues

cristi-neagu commented 6 years ago

It's kinda hard following the code if it's not formatted properly using the Insert code feature. Also, where do you get masterName from? Are you using, for example, mdf.getChannelMaster(cav_id)?

MontyTHall commented 6 years ago

Looks like the following change works:

for i, t in enumerate(mdf.getChannelData(mdf.getChannelMaster(name_cav_id))):

cristi-neagu commented 6 years ago

As far as i can tell, that's the correct way to get the time vector associated with a certain data channel.

MontyTHall commented 6 years ago

Is there a forum of some type for this channel for basic q&a?

cristi-neagu commented 6 years ago

Not as far as i know. Would be nice to have a forum. Would be even nicer if GitHub had a conversation page for each repo.

MontyTHall commented 6 years ago

Sounds like I need to purchase the spec if I need to have questions answered. Because I thought there was only 1 timer. I had no idea that I needed to get a "master" for my channel.

cristi-neagu commented 6 years ago

No need to purchase any spec. You can get it for free from ASAM. Also, if you use MDF Validator from Vector you can understand some things about the structure of the file. You can also ask questions here, i think.

ratal commented 6 years ago

Hi, Thanks Cristi for supporting, I was bit out of sight for some time. There is a documentation going along with the package but I must admit this auto generated pdf is bit difficult to get in. Otherwise, if you look at the readme, major examples are there. I would advise you to use the attribute .masterChannelList as much as possible. It will help you understand your file data structure, especially the rasters, just print it for instance in an interactive session like ipython. For each dataGroup you have a time channel, however, the channels could be absent or ommitted --> that is why you could have more time channels than actual data channels. Otherwise, like mentionned Cristi, you could open your file with MDFValidator. If you still have questions, please ask

ratal commented 5 years ago

I guess questions were answered, long time