1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: E501, F401
r"""
A single MDF block discovered while walking the file's link graph.
Attributes
----------
offset, end_offset, size : int
On-disk byte range of the block.
block_type : str
Four-character MDF block tag (e.g. ``"##HD"``, ``"##CN"``).
description : str
Short human-readable summary (e.g. ``"channel 'Speed' [f64@0..8]"``).
links : list[LinkInfo]
Outbound links to other blocks.
extra : Optional[str]
Block-type-specific extra information, when applicable.
"""
:
:
:
:
:
:
:
...
r"""
Read-only metadata describing a single channel.
Found on :py:attr:`GroupInfo.channels`, and returned by
:py:meth:`Mdf.channel` / :py:meth:`MdfIndex.channel`.
Attributes
----------
name : Optional[str]
Channel name from the ``##TX`` block, or ``None`` if not set.
unit : Optional[str]
Engineering unit string, or ``None``.
comment : Optional[str]
Free-form comment, or ``None``. Always ``None`` when obtained via the
index (not stored in `IndexedChannel`).
data_type : DataType
The MDF data type of the raw samples.
bit_count : int
Width of the raw value in bits (e.g. 32 for f32, 64 for f64/u64).
"""
:
:
:
:
:
:
:
...
...
r"""
MDF channel data type descriptor.
Wraps the on-disk MDF 4 data type code (`cn_data_type`) together with a
human-readable name. Use the ``create_data_type_*`` helper functions to
construct one for the writer API.
Attributes
----------
name : str
Symbolic name, e.g. ``"FloatLE"``, ``"UnsignedIntegerLE"``.
value : int
The MDF spec numeric code (0-16, or 255 for unknown).
"""
:
:
...
...
r"""
Full structural layout of an MDF file: blocks, links, and gaps.
Build one with :py:meth:`from_file` or :py:meth:`Mdf.file_layout`. Use
it to debug file structure, audit storage efficiency, or render a
human-readable map of an MDF.
"""
:
:
:
r"""
Build a layout by parsing an MDF file from disk.
Parameters
----------
path : str
"""
...
r"""
Render the layout as a flat, sorted text listing.
Each line is ``offset .. end_offset block_type description``,
including link targets — easy to ``grep`` / diff.
"""
...
r"""
Render the link graph as an indented tree rooted at ``##ID``.
"""
...
r"""
Serialize the layout to a pretty-printed JSON string.
"""
...
r"""
Write the flat text listing (see :py:meth:`to_text`) to ``path``.
"""
...
r"""
Write the indented tree view (see :py:meth:`to_tree`) to ``path``.
"""
...
r"""
Write the JSON representation (see :py:meth:`to_json`) to ``path``.
"""
...
...
r"""
A range of bytes in the file not covered by any visited block.
Gaps usually represent alignment padding, abandoned scratch space, or
(rarely) blocks that aren't reachable from the link graph.
Attributes
----------
start, end, size : int
"""
:
:
:
...
r"""
Read-only metadata describing a channel group (``##CG`` block).
Returned by :py:attr:`Mdf.groups` / :py:attr:`MdfIndex.groups`.
Attributes
----------
name : Optional[str]
Group / acquisition name (often ``None`` for files written by mf4-rs).
comment : Optional[str]
Free-form comment.
channel_count : int
Number of channels in this group.
record_count : int
Number of records (cycles) recorded for this group.
"""
:
:
:
:
:
:
r"""
Find a channel in this group by name (first match), or ``None``.
"""
...
...
...
r"""
A single outbound link from a block to another block.
Attributes
----------
name : str
Link's role inside the source block (e.g. ``"first_dg_addr"``).
target : int
Absolute file offset of the target block (0 means null link).
target_type : Optional[str]
Block type at the target offset, when known (e.g. ``"##DG"``).
"""
:
:
:
...
r"""
Read-only handle to an MDF 4 file, backed by a memory-mapped buffer.
Metadata (block tree, channel names, conversions) is parsed up front, but
sample data is only decoded when you call :py:meth:`read`, :py:meth:`read_raw`
or :py:meth:`series`. Navigate by group / channel **name** — there are no
numeric indices in the public API.
Example
-------
>>> import mf4_rs
>>> mdf = mf4_rs.Mdf("recording.mf4")
>>> for group in mdf.groups:
... print(group.name, group.record_count, group.channel_names)
>>> speed = mdf["Speed"] # numpy float64 array
>>> rpm = mdf.read("RPM", group="Engine")
>>> s = mdf.series("Speed") # pandas Series, datetime index
"""
:
:
:
...
r"""
A flat catalog of every channel as ``(source, group, channel)`` tuples.
``source`` is this file's path (same for every row). ``group`` /
``channel`` are ``None`` if unnamed. Metadata only — no samples decoded.
Returns
-------
list[tuple[str, Optional[str], Optional[str]]]
"""
...
r"""
Find a channel group by name (first match), or ``None``.
"""
...
r"""
Find a channel by name across all groups (first match), or ``None``.
"""
...
r"""
Read a channel as a ``pandas.Series`` of values indexed by timestamps.
This is the primary read: the channel's samples (with all conversions
applied) are the data, and the group's master/time channel is the index
— a ``DatetimeIndex`` when the file has a start time, otherwise the raw
master seconds. If there is no master, or the requested channel *is* the
master, a default integer index is used.
Parameters
----------
name : str
Channel name (case-sensitive).
group : Optional[str]
Restrict the search to a single group by name. Use this when the
same channel name (e.g. ``"Time"``) appears in several groups.
Raises
------
MdfException
If no matching channel exists or pandas is not installed.
"""
...
r"""
Read a numeric channel by name as a plain numpy ``float64`` array.
The fast, pandas-free path — just the values, no timestamp index.
Invalid / non-numeric samples are ``NaN``. Use :py:meth:`read` when you
want the timestamp-indexed Series and faithful (text / table) conversions.
Parameters
----------
name : str
group : Optional[str]
"""
...
r"""
``mdf["Speed"]`` — shorthand for :py:meth:`read` (timestamp-indexed Series).
Pass a ``(name, group)`` tuple to disambiguate a channel name shared by
several groups, e.g. ``mdf["Speed", "Engine"]``.
"""
...
r"""
Build a :class:`FileLayout` describing every block in this file.
Useful for debugging or analysing on-disk structure: offset, size,
type, link targets and unreferenced gaps for each MDF block.
"""
...
r"""
Lightweight, self-contained index over an MDF 4 file.
An index records the byte ranges of each channel, fully resolves every
conversion block, and serialises to JSON. Navigate it by **name**
(:py:attr:`groups`, :py:meth:`group`, :py:meth:`channel`). It also remembers
its data :py:attr:`source` (file path or URL); reading is lazy — the
byte-range request happens on :py:meth:`read` / :py:meth:`values`, never at
build time.
**Limitation:** compressed (``##DZ``) data blocks are not supported.
Example
-------
>>> idx = mf4_rs.MdfIndex.from_url("https://host/recording.mf4") # only metadata fetched
>>> speed = idx.read("Speed") # pandas Series; range request happens now
>>> rpm = idx.values("RPM") # numpy float64, no timestamp index
>>> idx.save("recording.idx.json")
>>> idx = mf4_rs.MdfIndex.load("recording.idx.json")
>>> idx.source = "recording.mf4" # re-attach a source after load
>>> t = idx.read("Speed")
"""
:
:
:
:
r"""
Build a fresh index by parsing an MDF file from disk.
All conversions are resolved during construction so the index is fully
self-contained afterwards.
Parameters
----------
path : str
Path to a ``.mf4`` file.
"""
...
r"""
Load a previously saved JSON index (companion to :py:meth:`save`).
The original MDF file is only needed later, when you actually read
values via :py:meth:`open`.
"""
...
r"""
Build an index from an MDF file served over HTTP / S3 using range
requests, without downloading the whole file.
Issues range reads only for metadata blocks; sample data is never
fetched. With the default 1 MiB read-ahead chunk a typical file
collapses to a handful of HTTP requests regardless of size.
Parameters
----------
url : str
``http://`` / ``https://`` URL honouring ``Range`` requests.
chunk_size : int, optional
Metadata read-ahead chunk size in bytes (default 1 MiB).
"""
...
r"""
Serialize the index to JSON at ``path`` (dependency-free).
"""
...
r"""
Find a channel group by name (first match), or ``None``.
"""
...
r"""
Find a channel by name across all groups (first match), or ``None``.
"""
...
r"""
Names of the groups that contain a channel called ``name``.
Use this to disambiguate a channel name shared by several groups, then
pass the chosen group to :py:meth:`read` / :py:meth:`values`.
"""
...
r"""
Byte ranges ``[(offset, length), ...]`` occupied by a channel.
Accounts for the channel's record-layout position and data-block
splitting. Power-user entry point for issuing your own partial reads.
Parameters
----------
name : str
group : Optional[str]
Disambiguate by group when the name is not unique.
"""
...
r"""
Byte ranges covering a record window ``[start, start+count)``.
"""
...
r"""
Inspect the conversion attached to a channel (by name).
Returns ``None`` if the channel has no conversion, otherwise a dict
describing it (``conversion_type``, ``values``, ``resolved_texts``,
``formula`` …).
"""
...
r"""
A flat catalog of every channel as ``(source, group, channel)`` tuples.
``source`` is this index's attached source (file path or URL) — the same
for every row, so catalogs from several indexes concatenate cleanly.
Built from metadata only; no sample data is read (cheap even for a
URL-backed index). ``group`` / ``channel`` are ``None`` if unnamed.
Returns
-------
list[tuple[Optional[str], Optional[str], Optional[str]]]
"""
...
...
r"""
Attach (or clear) the data source used by :py:meth:`read` / :py:meth:`values`.
A value starting with ``http://`` or ``https://`` is treated as a URL;
anything else as a local file path. Pass ``None`` to clear.
"""
...
r"""
Read a channel as a ``pandas.Series`` of values indexed by timestamps.
**Lazy:** the byte-range request to the attached source happens now, not
when the index was built. Values carry all conversions; the index is the
group master converted to a ``DatetimeIndex`` (or raw seconds / default
index when there is no start time / master).
Parameters
----------
name : str
group : Optional[str]
Disambiguate by group when the channel name is not unique.
Raises
------
MdfException
If no source is attached, the channel is missing, or pandas is absent.
"""
...
r"""
Read a numeric channel by name as a plain numpy ``float64`` array.
Lazy fast path — just the values, no timestamp index, pandas-free.
Invalid / non-numeric samples are ``NaN``.
Parameters
----------
name : str
group : Optional[str]
"""
...
r"""
``index["Speed"]`` — shorthand for :py:meth:`read` (timestamp-indexed Series).
Pass a ``(name, group)`` tuple to disambiguate a channel name shared by
several groups, e.g. ``index["Speed", "Engine"]``.
"""
...
r"""
Streaming writer for MDF 4 files.
Build an MDF file in five logical steps:
1. ``writer = mf4_rs.MdfWriter("out.mf4")``
2. ``writer.init_mdf_file()`` — write ``##ID`` and ``##HD``.
3. Define structure: :py:meth:`add_channel_group`, then any combination of
:py:meth:`add_time_channel`, :py:meth:`add_float_channel`,
:py:meth:`add_float32_channel`, :py:meth:`add_int_channel`, or the
generic :py:meth:`add_channel`.
4. Write data: :py:meth:`start_data_block`, then either
:py:meth:`write_record` (one record at a time, ergonomic) or
:py:meth:`write_columns_f64` / :py:meth:`write_columns` (bulk numpy,
much faster), then :py:meth:`finish_data_block`.
5. :py:meth:`finalize` — flushes and closes the file. The writer is
unusable after this; calling any other method raises ``MdfException``.
All identifiers (``cg_*`` for groups, ``ch_*`` for channels) are *opaque
strings* — pass them back to subsequent methods, but don't try to parse
them. Channels are auto-linked into a per-group linked list in the order
they were added.
Example
-------
>>> w = mf4_rs.MdfWriter("demo.mf4")
>>> w.init_mdf_file()
>>> cg = w.add_channel_group("group_0")
>>> t = w.add_time_channel(cg, "Time")
>>> y = w.add_float_channel(cg, "Speed")
>>> w.start_data_block(cg)
>>> for i in range(100):
... w.write_record(cg, [
... mf4_rs.create_float_value(i * 0.01),
... mf4_rs.create_float_value(i * 1.5),
... ])
>>> w.finish_data_block(cg)
>>> w.finalize()
"""
...
r"""
Write the MDF identification (``##ID``) and header (``##HD``) blocks.
Must be called exactly once, before adding any channel group.
"""
...
r"""
Append a new channel group (``##CG``) to the file.
Parameters
----------
name : Optional[str]
Group acquisition name. Written as a ``##TX`` block referenced
from the new ``##CG`` via ``acq_name_addr``. Pass ``None`` to
leave it unset.
Returns
-------
str
Opaque group ID (e.g. ``"cg_0"``) — pass to subsequent
``add_channel`` / ``write_record`` / ``finish_data_block`` calls.
"""
...
r"""
Attach a comment / description to a channel group.
Writes a ``##TX`` block holding ``comment`` and links it from the
group's ``comment_addr`` field.
"""
...
r"""
Add a generic channel to a channel group, using the data type's
natural bit width.
The new channel is linked after the most recently added channel in
the same group, and inherits its byte offset from the running record
layout. For float channels this defaults to **32 bits** — use
:py:meth:`add_float_channel` if you want 64-bit precision.
Parameters
----------
group_id : str
ID returned by :py:meth:`add_channel_group`.
name : str
Channel name (written as a ``##TX`` block).
data_type : DataType
One of the values from the ``create_data_type_*`` helpers.
Returns
-------
str
Opaque channel ID (e.g. ``"ch_3"``).
"""
...
r"""
Add a 64-bit little-endian float channel and mark it as the group's
master / time channel.
Equivalent to :py:meth:`add_float_channel` followed by
:py:meth:`set_time_channel`. Should typically be the **first** channel
added to a group — subsequent channels will be linked after it.
Parameters
----------
group_id : str
name : str
Usually ``"Time"`` or ``"t"``.
Returns
-------
str
Channel ID.
"""
...
r"""
Add a 64-bit little-endian float (``f64``) data channel.
Recommended default for scientific / numeric data. Use
:py:meth:`add_float32_channel` when 32-bit precision is enough and
file size matters.
"""
...
r"""
Add a 32-bit little-endian float (``f32``) data channel.
Halves the per-record size compared to :py:meth:`add_float_channel`
at the cost of precision (~7 decimal digits).
"""
...
r"""
Add a 64-bit little-endian unsigned integer (``u64``) data channel.
Values must be created with ``create_uint_value``. For signed
integers use :py:meth:`add_sint_channel` (writing a negative
``create_int_value`` into an unsigned channel raises).
"""
...
r"""
Add a 64-bit little-endian signed integer (``i64``) data channel.
Values must be created with ``create_int_value``.
"""
...
r"""
Add a variable-length (VLSD) UTF-8 string data channel.
Each record stores an offset into a ``##SD`` block that the writer
maintains automatically; pass values created with
``create_string_value`` to :py:meth:`write_record`. This is the only
way to write string data — fixed-length string channels are not
supported by the writer.
"""
...
r"""
Mark an existing channel as the group's master / time channel.
Sets ``channel_type = 2`` and ``sync_type = 1`` on the underlying
``##CN`` block. Most users should prefer :py:meth:`add_time_channel`,
which combines channel creation with this call.
Parameters
----------
channel_id : str
ID returned by one of the ``add_*_channel`` methods.
"""
...
r"""
Open a fresh ``##DT`` data block for a channel group.
Must be called once after all channels have been added, before any
:py:meth:`write_record` / :py:meth:`write_columns_f64` /
:py:meth:`write_columns` for that group. The writer will
automatically split into multiple ``##DT`` fragments at the 4 MB
boundary, joined by a ``##DL`` block when you call
:py:meth:`finish_data_block`.
"""
...
r"""
Append a single record (one sample for each channel in the group).
``values`` must contain exactly one entry per channel, in the same
order channels were added — typically the master channel first, then
data channels. Each value is encoded according to its channel's data
type (the variant of :class:`DecodedValue` is *not* re-checked, so
passing the wrong variant will produce nonsense bytes).
This call has Python-level overhead per value; for bulk numeric data,
prefer :py:meth:`write_columns_f64` or :py:meth:`write_columns`.
"""
...
r"""
Close the open ``##DT`` block for a channel group.
If the group's data exceeded the 4 MB block size and was split
across multiple ``##DT`` fragments, this also writes the ``##DL``
(data list) block linking them together. Call once per group after
all records have been written, and before :py:meth:`finalize`.
"""
...
r"""
Bulk-write all channels of a group from numpy ``float64`` arrays.
Equivalent to writing every record in row order, but ~10× faster than
looping over :py:meth:`write_record` because it avoids per-value
Python-Rust crossings and ``DecodedValue`` boxing.
Parameters
----------
group_id : str
columns : list[numpy.ndarray]
One contiguous 1-D ``float64`` array per channel, in channel
order. **All arrays must have identical length** — that length
becomes the record count. The float values are converted to each
channel's declared data type before encoding.
Raises
------
MdfException
If an array is not contiguous, not ``float64``, or lengths
mismatch.
"""
...
r"""
Bulk-write all channels of a group from heterogeneous numpy arrays.
Like :py:meth:`write_columns_f64` but accepts a per-column dtype, so
integer / single-precision channels are written without an
intermediate ``float64`` round-trip.
Parameters
----------
group_id : str
columns : list[numpy.ndarray]
One contiguous 1-D array per channel, all of identical length.
dtypes : list[str]
One entry per column, matching ``columns``. Allowed values:
``"f64"``, ``"f32"``, ``"u64"``, ``"i64"``.
Raises
------
MdfException
If the dtype string is not one of the supported values, the
numpy array's element type doesn't match the dtype string, the
two list lengths differ, or any array is non-contiguous.
"""
...
r"""
Flush all buffered bytes to disk and close the file.
After this returns, the writer is consumed: any subsequent method
call raises ``MdfException``. Calling :py:meth:`finalize` more than
once also raises.
"""
...
r"""
A single decoded channel sample, tagged with its underlying type.
Returned by ``create_*_value`` helpers and consumed by
:py:meth:`MdfWriter.write_record`. When *reading*, most APIs return native
Python objects (``float`` / ``int`` / ``str`` / ``bytes``) directly, so you
usually only construct ``DecodedValue`` to feed back into the writer.
Variants carry a single ``value`` field (use the ``value`` getter to
retrieve the inner native Python value):
- ``Float(value: float)``
- ``UnsignedInteger(value: int)``
- ``SignedInteger(value: int)``
- ``String(value: str)``
- ``ByteArray(value: bytes)``
- ``Unknown()`` — undecodable / not yet supported
"""
=
=
=
=
=
=
r"""
Return the :class:`DataType` for little-endian IEEE-754 floats.
Pair with :py:meth:`MdfWriter.add_channel`. Defaults to 32 bits when
passed to ``add_channel`` — for f64 use :py:meth:`MdfWriter.add_float_channel`.
"""
...
r"""
Return the :class:`DataType` for little-endian signed integers.
Pair with :py:meth:`MdfWriter.add_channel` when you need a signed
integer channel of non-default width (otherwise see
:py:meth:`MdfWriter.add_sint_channel`).
"""
...
r"""
Return the :class:`DataType` for UTF-8 encoded string channels.
"""
...
r"""
Return the :class:`DataType` for little-endian unsigned integers.
Pair with :py:meth:`MdfWriter.add_channel` when you need an unsigned
integer channel of non-default width (otherwise see
:py:meth:`MdfWriter.add_int_channel`).
"""
...
r"""
Wrap a Python ``float`` in a :class:`DecodedValue` of variant ``Float``.
Use this to feed values into :py:meth:`MdfWriter.write_record` for any
floating-point channel (32- or 64-bit; the value is truncated to the
channel's declared bit width on encode).
"""
...
r"""
Wrap a Python ``int`` in a ``SignedInteger`` :class:`DecodedValue`.
"""
...
r"""
Wrap a Python ``str`` in a ``String`` :class:`DecodedValue`.
For string channels (``StringUtf8`` etc.). Encoding into the file is
done according to the channel's declared string data type.
"""
...
r"""
Wrap a Python ``int`` in a ``UnsignedInteger`` :class:`DecodedValue`.
Suitable for any unsigned integer channel; the value is truncated to the
channel's bit width on encode.
"""
...
r"""
Cut an MDF file by time, copying only records whose master channel value
falls within the inclusive `[start_time, end_time]` window.
The output preserves fixed-length numeric, string, and byte-array
channels, per-record invalidation bytes, and VLSD ("signal-based")
channels (a fresh ##SD chain is written for each kept VLSD channel).
Per-channel conversion, source, unit and comment blocks are cloned
recursively into the output, so cut channels keep their physical
scaling and metadata.
Parameters
----------
input_path : str
Path to the source MF4 file.
output_path : str
Destination path for the trimmed file.
start_time : float
Start of the window in seconds (inclusive).
end_time : float
End of the window in seconds (inclusive).
"""
...
r"""
Cut an MDF file by absolute UTC time. Accepts ISO 8601 strings (e.g.
`"2024-01-15T12:34:56Z"`), `datetime.datetime` objects (naive values are
assumed to be UTC), or numeric UNIX timestamps in seconds.
The window is inclusive on both ends. The source file must record a
non-zero `HD.abs_time` (set by the writer / asammdf when creating the
file) — without it the relative offset cannot be computed and an
`MdfException` is raised.
Other behaviour matches [`cut_mdf_by_time`]: VLSD payloads, byte-array
channels, and per-record invalidation bytes are preserved verbatim.
"""
...
r"""
Build a :class:`FileLayout` from an MDF file on disk.
Functional alias for :py:meth:`FileLayout.from_file`.
Parameters
----------
path : str
Returns
-------
FileLayout
"""
...
r"""
Merge two MDF files into a new file at ``output``.
Channel groups whose layouts (record-id length and channel list — names,
data types, bit/byte offsets, bit count, channel type, VLSD flag) match
are concatenated; non-matching groups are appended as separate groups.
Supports normal numeric, fixed ``ByteArray``, and VLSD signal channels
(variable-length strings and byte arrays stored in ``##SD`` blocks).
Parameters
----------
output : str
Destination path for the merged file.
first, second : str
Source file paths. Must be uncompressed MDF 4.10+ files.
"""
...