asammdf.channels_db
channels_dbはクラスasammdf.blocks.mdf_v4.MDF4のアトリビュートの1つとしてドキュメントには記載されています。
下記のサンプルプログラムからも分かる通り、channel_dbは信号名を引数として与えると、引数として設定された信号のGroup IndexとChannel Indexを返してくれます。
先日紹介したgroups.channels.nameがGroup IndexとChannel Indexを引数として与えると、対応する信号名が得られるのとちょうど逆向きの動作となります。
from asammdf import MDF
def mdfGroups(mdfFile):
with MDF(mdfFile) as mdf_file: # mdf_fileとしてMF4ファイルを開く
groups = mdf_file.groups # get_group()の引数で設定したindexのDataFrameがgroupsに渡される
lenGroups = len(groups)
for i in range(lenGroups):
lenSubChannel = len(groups[i].channels)
for n in range(lenSubChannel):
signalName = groups[i].channels[n].name # Groups内のデータを順番にアクセスして信号名を取り出す
gr_idx, ch_idx = mdf_file.channels_db[signalName][0] # 信号名からGroupのIndex, CHannelのIndexを取り出す
print("signal Name = ", signalName)
print("ID = ", gr_idx, "Channel = ", ch_idx)/* Your code... */
class asammdf.blocks.mdf_v4.MDF4(name: BufferedReader | BytesIO | StrPathType | None = None, version: str = ‘4.10’, channels: list[str] | None = None, **kwargs)
The header attibute is a HeaderBlock.
The groups attribute is a list of dicts, each one with the following keys:
• data_group – DataGroup object
• channel_group – ChannelGroup object
• channels – list of Channel objects with the same order as found in the mdf file
• channel_dependencies – list of ChannelArrayBlock in case of channel arrays; list of Channel objects in case of structure channel composition
• data_block – address of data block
• data_location- integer code for data location (original file, temporary file or memory)
• data_block_addr – list of raw samples starting addresses
• data_block_type – list of codes for data block type
• data_block_size – list of raw samples block size
• sorted – sorted indicator flag
• record_size – dict that maps record ID’s to record sizes in bytes (including invalidation bytes)
• param – row size used for transposition, in case of transposed zipped blocks
Parameters
name
[string] mdf file name (if provided it must be a real file name) or file-like object
version
[string] mdf file version (‘4.00’, ‘4.10’, ‘4.11’, ‘4.20’); default ‘4.10’
kwargs
use_display_names (True)
[bool] keyword only argument: for MDF4 files parse the XML channel comment to search
for the display name; XML parsing is quite expensive so setting this to False can decrease the loading times very much; default True
remove_source_from_channel_names (True)
[bool]
copy_on_get (True)
[bool] copy channel values (np.array) to avoid high memory usage
compact_vlsd (False)
[bool] use slower method to save the exact sample size for VLSD channels
column_storage (True)
[bool] use column storage for MDF version >= 4.20
password
[bytes | str] use this password to decode encrypted attachments
Attributes
attachments
[list] list of file attachments
channels_db
[dict] used for fast channel access by name; for each name key the value is a list of (group index, channel index) tuples
events
[list] list event blocks
file_comment
[TextBlock] file comment TextBlock
file_history
[list] list of (FileHistory, TextBlock) pairs
groups
[list] list of data group dicts
header
[HeaderBlock] mdf file header
identification
[FileIdentificationBlock] mdf file start block
last_call_info
[dict | None] a dict to hold information about the last called method.
New in version 5.12.0.
masters_db
[dict]
used for fast master channel access; for each group index key the value
is the master channel index
name
[string] mdf file name
version
[str] mdf version
最近のコメント