{"id":4884,"library":"asammdf","title":"ASAM MDF measurement data file parser","description":"asammdf is a Python library for parsing and manipulating ASAM MDF (Measurement Data Format) files. It supports MDF versions 3 and 4, providing robust tools for reading, writing, and modifying measurement data. The library is currently at version 8.8.1 and maintains a frequent release cadence, often pushing several bug fix releases per month.","status":"active","version":"8.8.1","language":"en","source_language":"en","source_url":"https://github.com/danielhrisca/asammdf","tags":["data parsing","automotive","MDF","measurement","ASAM"],"install":[{"cmd":"pip install asammdf","lang":"bash","label":"Core library"},{"cmd":"pip install \"asammdf[plot]\"","lang":"bash","label":"With plotting capabilities (Matplotlib)"},{"cmd":"pip install \"asammdf[gui]\"","lang":"bash","label":"With graphical user interface (PySide6/PyQt6, pyqtgraph)"}],"dependencies":[{"reason":"Core dependency for numerical data handling.","package":"numpy"},{"reason":"Required for plotting functionalities (`asammdf[plot]`).","package":"matplotlib","optional":true},{"reason":"Required for GUI and advanced plotting (`asammdf[gui]`).","package":"pyqtgraph","optional":true},{"reason":"Primary Qt binding for GUI (`asammdf[gui]`). PyQt6 can also be used.","package":"PySide6","optional":true}],"imports":[{"symbol":"MDF","correct":"from asammdf import MDF"},{"symbol":"Signal","correct":"from asammdf import Signal"}],"quickstart":{"code":"import numpy as np\nfrom asammdf import MDF, Signal\nimport os\n\n# Create a dummy MDF file for demonstration\nfile_name = \"example.mdf\"\n\n# Ensure clean slate for quickstart run\nif os.path.exists(file_name):\n    os.remove(file_name)\n\n# 1. Create some dummy signals\ntime_stamps = np.arange(0, 10, 0.1)\nsignal1_data = np.sin(time_stamps)\nsignal2_data = np.cos(time_stamps)\n\ns1 = Signal(samples=signal1_data, timestamps=time_stamps, name='Engine_Speed', unit='rpm')\ns2 = Signal(samples=signal2_data, timestamps=time_stamps, name='Vehicle_Speed', unit='km/h')\n\n# 2. Write signals to a new MDF file (using context manager)\nwith MDF(version='4.10') as mdf_writer:\n    mdf_writer.append([s1, s2], comment='Basic measurement data')\n    mdf_writer.save(file_name, overwrite=True)\n\nprint(f\"Dummy MDF file '{file_name}' created successfully.\\n\")\n\n# 3. Read the MDF file back\nwith MDF(file_name) as mdf_reader:\n    print(f\"File version: {mdf_reader.version}\")\n    print(f\"Available channels: {mdf_reader.channels}\")\n\n    # 4. Access a specific signal by name\n    engine_speed_signal = mdf_reader.get('Engine_Speed')\n\n    if engine_speed_signal:\n        print(f\"\\nSignal 'Engine_Speed' unit: {engine_speed_signal.unit}\")\n        print(f\"Signal 'Engine_Speed' samples (first 5): {engine_speed_signal.samples[:5]}\")\n        print(f\"Signal 'Engine_Speed' timestamps (first 5): {engine_speed_signal.timestamps[:5]}\")\n\n    # 5. Select multiple signals\n    selected_signals = mdf_reader.select(channels=['Engine_Speed', 'Vehicle_Speed'])\n    print(f\"\\nSelected signals count: {len(selected_signals)}\")\n\n# Clean up the dummy file\nif os.path.exists(file_name):\n    os.remove(file_name)\nprint(f\"\\nDummy MDF file '{file_name}' cleaned up.\")\n","lang":"python","description":"This quickstart demonstrates how to create an MDF file with sample data, save it, and then load it to retrieve signal information. It uses `MDF` as a context manager for proper file handling and showcases basic signal creation and access by name."},"warnings":[{"fix":"Migrate to the current API: use `mdf.get(channel_name)` for single signals and `mdf.select(channels=[...])` for multiple signals. Use `mdf.iter_groups()` for iterating over channel groups.","message":"The API for accessing signals and channel groups has undergone significant changes in versions leading up to 7.x and beyond. Older patterns, such as direct dictionary-style access to `mdf.channels` or different `get` method signatures, may no longer work or behave as expected.","severity":"breaking","affected_versions":"< 7.0.0"},{"fix":"For large files, utilize methods like `mdf.iter_get_channels()` to process data in chunks or specify `MDF(file_path, memory='low')` to hint at lower memory usage, which might involve more disk I/O. Use slicing on signals to read only parts of the data (e.g., `signal.samples[start:end]`).","message":"Loading extremely large MDF files (multiple gigabytes) entirely into memory using `MDF(file_path)` can lead to `MemoryError` and slow performance. The library reads the entire file by default if not specified otherwise.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install `asammdf` with the appropriate extras: `pip install \"asammdf[plot]\"` for plotting or `pip install \"asammdf[gui]\"` for the GUI, which also includes plotting dependencies.","message":"Plotting and GUI functionalities are not included in the base `asammdf` installation. Attempting to use `mdf.plot()` or `mdf.gui()` without installing the extra dependencies will result in `ImportError` or `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade your Python environment to version 3.10 or newer. Check the `requires_python` metadata on PyPI for the exact minimum version.","message":"As of recent versions (e.g., 8.x), `asammdf` requires Python 3.10 or newer. Users attempting to install or run `asammdf` on older Python versions (e.g., 3.9 or below) will encounter dependency resolution errors or runtime failures.","severity":"breaking","affected_versions":">= 8.0.0"},{"fix":"Be aware of the MDF file version you are working with. When writing files, specify `MDF(version='4.10')` to leverage v4 features. When reading, understand that some metadata might not be available or structured differently in v3 files.","message":"While `asammdf` supports both MDF v3 and v4, certain features or metadata structures are exclusive to specific versions. For instance, detailed bus logging (CAN/LIN) metadata and some complex block structures are primarily a v4 feature.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}