danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
611 stars 216 forks source link

timestamp reading problem #1027

Closed HuixuanGan closed 1 week ago

HuixuanGan commented 1 month ago

Could anyone tell me how to extrace all the timestamps as epoch form inside of the dataframe?

My current reading of timestamps from channel groups using: mdf.channels_db only include results like this: {'Timestamp': ((0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (10, 0), (12, 0), (14, 0), (16, 0), (17, 0), (18, 0), (19, 0), (20, 0), (21, 0), (22, 0), (23, 0), (24, 0), (25, 0), (26, 0), (27, 0), (28, 0), (29, 0), (31, 0), (33, 0), (35, 0), (37, 0), (38, 0), (39, 0)} that may determine where have the timestamp, not the timestamp itself.

Also the iter_groups() doesn't have timestamp as a column.

Thank you!

danielhrisca commented 1 month ago
from asammdf import MDF

m = MDF(r'c:\ASAP2_Demo_V171.mf4')

for i, df in enumerate(m.iter_groups()):
    print(df)
    print(df.index)
            ASAM_[15].M.MATRIX_DIM_16.UBYTE.IDENTICAL  ASAM.M.SCALAR.UBYTE.FORM_X_PLUS_4
timestamps                                                                              
0.000000                                          244                               29.0
0.010000                                          247                               32.0
0.020000                                          250                               34.0
0.030000                                          253                               37.0
0.040000                                            0                               39.0
...                                               ...                                ...
12.350015                                         229                              166.0
12.360015                                         230                              164.0
12.370015                                         230                              163.0
12.380015                                         230                              161.0
12.390015                                         230                              159.0

[1240 rows x 2 columns]
Index([                 0.0, 0.009999999999990905,  0.01999999999998181,
        0.03000000000002956, 0.040000000000020464,  0.05000000000001137,
       0.060000000000002274,  0.06999999999999318,  0.07999999999998408,
        0.09000000000003183,
       ...
         12.300015452548678,   12.310015442978454,   12.320015433372419,
         12.330015423730401,   12.340015414052516,   12.350015404338649,
         12.360015394588913,   12.370015384803253,   12.380015374981667,
         12.390015365124214],
      dtype='float64', name='timestamps', length=1240)

the timestamps are found in the dataframe index

HuixuanGan commented 1 week ago

Thanks!