Transfer recording data into an array using Python

Discussion in 'X4M03' started by Kyle, Jul 3, 2018.

  1. Kyle

    Kyle New Member

    Using an X4M03 module, I recorded data using the example XEP_plot_record_playback. It saved an output file as xethru_recording_date_time.dat and a meta file. How can I see use Python to obtain the float data in the .dat file and put it into an array.
    I understand it is supposed to be float data types but I cannot view the data as floats either.

    Thank you
     
  2. Aksel Johnsby

    Aksel Johnsby Moderator Staff Member

    Hi Kyle,
    To see the data recorded with XEP you can use the playback class. This can be done with the same example you used for recording, XEP_plot_record_playback.py. There are several ways of storing the data. I would not recomend storing all the data in an array due to the sheer amount of data you will receive in a short time, but writing the data to a .txt file or a .csv file will allow for a easy access and "limitless" storing capacity. For example:

    import numpy as np
    import csv

    outfile=open('Float_recording.csv','wb')

    while(1)
    d = xep.read_message_data_float()
    frame =np.array(d.data) #this is how you put float_datatype in arrays
    outfile.write(repr(frame)
    outfile.write('\n')

    Have a great day :)
    --
    Aksel
     
  3. Kyle

    Kyle New Member

    Thanks for your response.
    I tried running your code but I get an error saying NameError: name 'xep' is undefined
    How so?
     
  4. Aksel Johnsby

    Aksel Johnsby Moderator Staff Member

    XEP and other classes can be imported through pymoduleconnector:
    import pymoduleconnector

    The code I sent in the previous post is just a crude example on how to store data to csv, not a complete script. I suggest you implement this method(or something similar) in the XEP_plot_record_playback.py example to get what you are looking for.

    If you haven't already I suggest you take a look at the "XeThru Sensors Introduction" application note.
    https://www.xethru.com/community/resources/xethru-sensors-introduction.111/

    Have a great day!
    --
    Aksel