[Python] Using the asammdf library to resample a signal with linear interpolation

Discussão em 'Python' iniciado por Stack, Novembro 21, 2024.

  1. Stack

    Stack Membro Participativo

    I use the asammdf python library to read files in MDF4 format and export them to CSV format :

    from asammdf import MDF
    mdf = MDF("C:/Users/haonf/Downloads/RecordFile_24-11-12_22_11_10_237.mf4")
    mdf_cut = mdf.cut(start=0.0,stop=1.0)
    mdf_resample = mdf_cut.resample(raster=0.001)
    mdf_resample.configure(float_interpolation=1)
    mdf_resample.export(fmt='csv',filename='C:/Users/haonf/Downloads/ResampledRecordFile.csv')


    The MDF4 file that I want to export contains a signal corresponding to a temperature sampled at 250 Hz (1 sample every 4 ms). I want to export the signal by oversampling to 1 kHz (1 sample every 1ms). The figure below presents the results obtained :

    Linear interpolation obtained

    Without interpolation, the samples are repeated well to obtain a period of 1ms. With linear interpolation, the samples created are not placed on a line separating two samples of the input signal. I expect to get the results below :

    Expected linear interpolation

    The results were obtained with version 8.0.1 of the asammdf library. Have I misunderstood how this option works or maybe I'm using it wrong? Thank you in advance for your answers!

    Continue reading...

Compartilhe esta Página