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
//! Minimal utilities for reading and writing ASAM MDF 4 files.
//!
//! The crate exposes a high level API under [`api`] to inspect existing
//! recordings as well as a [`writer::MdfWriter`] to generate new files. Only a
//! fraction of the MDF 4 specification is implemented.
/// File-cutting utilities (native only; not available on `wasm32-unknown-unknown`).
/// File-merging utilities (native only; not available on `wasm32-unknown-unknown`).
// Python bindings module
// Re-export the Python module when building as an extension
use *;
/// Python bindings for the ``mf4-rs`` crate: a minimal reader/writer for
/// ASAM MDF 4 measurement files.
///
/// Everything is addressed by **name** — channel-group and channel names —
/// never by numeric index.
///
/// Quick tour
/// ----------
///
/// Read — ``read`` returns a ``pandas.Series`` (values indexed by the master
/// time axis); ``values`` returns a plain numpy array::
///
/// import mf4_rs
/// mdf = mf4_rs.Mdf("recording.mf4")
/// for g in mdf.groups:
/// print(g.name, g.record_count, g.channel_names)
/// speed = mdf["Speed"] # pandas Series, datetime index
/// rpm = mdf.read("RPM", group="Engine")
/// raw = mdf.values("Speed") # numpy.ndarray[float64], no index
///
/// Write::
///
/// w = mf4_rs.MdfWriter("out.mf4")
/// w.init_mdf_file()
/// cg = w.add_channel_group("Engine")
/// t = w.add_time_channel(cg, "Time")
/// y = w.add_float_channel(cg, "Speed")
/// w.start_data_block(cg)
/// w.write_record(cg, [
/// mf4_rs.create_float_value(0.0),
/// mf4_rs.create_float_value(123.4),
/// ])
/// w.finish_data_block(cg)
/// w.finalize()
///
/// Index (HTTP-friendly random access) — the index remembers its source and
/// reads lazily (range requests happen on ``read``/``values``, not at build)::
///
/// idx = mf4_rs.MdfIndex.from_url("https://host/recording.mf4") # only metadata fetched
/// speed = idx.read("Speed") # pandas Series; range request happens now
/// idx.save("recording.idx.json")
/// idx = mf4_rs.MdfIndex.load("recording.idx.json")
/// idx.source = "recording.mf4" # re-attach a source after load
/// raw = idx.values("Speed") # numpy, lazy
///
/// Other utilities: :func:`merge_files`, :func:`cut_mdf_by_time`,
/// :func:`cut_mdf_by_utc`, and the :class:`FileLayout` block-layout
/// inspector.
///
/// All errors raised by this module are subclasses of :class:`MdfException`.