Asammdf初次接触



Asammdf 官方地址

  • asammdf是ASAM(自动化和测量系统的标准化协会)MDF(测量数据格式)文件的快速解析器/编辑器。

  • asammdf支持MDF版本2(.dat),3(.mdf)和4(.mf4)。

  • asammdf可在Python> = 3.6上运行(对于Python 2.7、3.4和3.5,请参见4.xy版本)

注: 学习这个是因为工作需要, 主要用于数据提取和可视化展示, 使用起来相当的方便.

  1. 构件环境

    1. 首先需要确定你所使用的PYTHON 环境符合你的要求,

    2. 当前asammdf要求python版本不低于3.6, 如果版本过低请注意更换版本

    3. 使用pip 安装asammdf包

      • pip install asammdf
    4. 也可以使用gui进行安装

      • pip install asammdf[gui]
    5. 或者使用anaconda进行安装

      • conda install -c conda-forge asammdf
  1. 初次使用

    from asammdf import MDF
    m = MDF('001.MF4')

    打开一个MF4文件

  2. 基础代码示例

    from asammdf import MDF, Signal
    >>> import numpy as np
    >>> t = np.arange(5)
    >>> s = np.ones(5)
    >>> mdf = MDF(version='4.10')
    >>> for i in range(4):
    ...     sigs = [Signal(s*(i*10+j), t, name='Sig') for j in range(1, 4)]
    ...     mdf.append(sigs)
    ...
    >>> # first group and channel index of the specified channel name
    ...
    >>> mdf.get('Sig')
    UserWarning: Multiple occurances for channel "Sig". Using first occurance from data group 4. Provide both "group" and "index" arguments to select another data group
    <Signal Sig:
            samples=[ 1.  1.  1.  1.  1.]
            timestamps=[0 1 2 3 4]
            unit=""
            info=None
            comment="">
    >>> # first channel index in the specified group
    ...
    >>> mdf.get('Sig', 1)
    <Signal Sig:
            samples=[ 11.  11.  11.  11.  11.]
            timestamps=[0 1 2 3 4]
            unit=""
            info=None
            comment="">
    >>> # channel named Sig from group 1 channel index 2
    ...
    >>> mdf.get('Sig', 1, 2)
    <Signal Sig:
            samples=[ 12.  12.  12.  12.  12.]
            timestamps=[0 1 2 3 4]
            unit=""
            info=None
            comment="">
    >>> # channel index 1 or group 2
    ...
    >>> mdf.get(None, 2, 1)
    <Signal Sig:
            samples=[ 21.  21.  21.  21.  21.]
            timestamps=[0 1 2 3 4]
            unit=""
            info=None
            comment="">
    >>> mdf.get(group=2, index=1)
    <Signal Sig:
            samples=[ 21.  21.  21.  21.  21.]
            timestamps=[0 1 2 3 4]
            unit=""
            info=None
            comment="">
    >>> # validation using source name
    ...
    >>> mdf.get('Sig', source='VN7060')
    <Signal Sig:
            samples=[ 12.  12.  12.  12.  12.]
            timestamps=[0 1 2 3 4]
            unit=""
            info=None
            comment="">
全部评论

相关推荐

Dream_coding:你是不是只投大厂了
点赞 评论 收藏
分享
刚开始投简历好慌
MindbniM:我也是一个用C++20改造的sylar服务器,还有一个即时通讯系统
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务