Skip to main content

mpylab

pipeline status coverage PyPI version Python versions documentation

Overview

mpylab is a Python framework for developing reproducible and traceable laboratory measurement applications. It combines instrument drivers, configurable RF measurement paths, measurement procedures, uncertainty-aware physical quantities, hardware-independent test configurations, and user interfaces.

The framework is used for electromagnetic compatibility measurements such as TEM/GTEM emission and immunity tests, mode verification, amplifier characterization, and mode-stirred chamber measurements. Measurement applications can use real instruments or virtual drivers without changing their measurement logic.

A typical mpylab setup consists of:

  • Python measurement logic defining the measurement sequence;
  • a DOT file describing instruments and signal paths;
  • INI files configuring individual devices and channels;
  • DAT files containing frequency-dependent correction and calibration data;
  • a pickle history containing measurement configuration, raw data, evaluated results, and the information required to resume interrupted measurements.

Core architecture

Device drivers

mpylab.device.driver.DRIVER provides the common foundation for instrument drivers. It handles device configuration, communication setup, command execution, error reporting, and virtual operation. Device-type base classes such as SIGNALGENERATOR, POWERMETER, RECEIVER, FIELDPROBE, and NPORT define the interfaces expected by measurement applications.

Concrete drivers implement these interfaces for particular instruments. Communication backends include VISA/GPIB, Prologix adapters, serial and network-based devices, as well as debug and virtual drivers for tests without laboratory hardware.

Measurement graphs

mpylab.tools.mgraph.MGraph turns a DOT configuration into an executable measurement setup. Graph nodes represent active or passive devices, while edges describe the signal paths and their frequency-dependent corrections.

MGraph creates and initializes devices, evaluates conditional paths, applies N-port corrections, switches active signal paths, controls RF state, and provides common leveling and amplifier-protection functions. Measurement code therefore works with logical device roles instead of hard-coding a particular laboratory setup.

Measurement environments

mpylab.env.Measure.Measure provides shared measurement infrastructure such as logging, UI adapters, autosave and resume support, user interruption, device initialization and fail-safe shutdown, protected signal-generator control, and common leveling operations.

Specialized environments build on this foundation. Examples include TEMCell for TEM/GTEM measurements, MSC for mode-stirred chamber measurements, and AmplifierTest for amplifier characterization. Measurement scripts combine these environments with a configuration and preserve the complete measurement history in pickle files.

Physical quantities and uncertainty

mpylab uses SCUQ consistently for physical measurement values and derived results. A SCUQ Quantity combines a numerical value, its uncertainty, and its physical unit. Unit conversion, uncertainty propagation, interpolation, path correction, evaluation, and result export can therefore retain the metrological meaning of a value instead of reducing it prematurely to a plain float.

This is particularly important for EMC measurements, where values routinely move between linear and logarithmic representations and where calibration, path loss, field strength, power, voltage, and uncertainty must remain traceable.

This software is distributed under the GPL-3.0-or-later license. See LICENSE for details.

Installation

Install the current release from PyPI:

python -m pip install mpylab

Alternatively, install directly from GitLab:

python -m pip install git+https://gitlab.hrz.tu-chemnitz.de/chair-of-electromagnetic-theory-and-compatibility-at-tu-dresden/mpylab/mpylab.git

This requires git. Append a branch or tag to the URL to select a particular revision, for example @main or @v1.0.9.

Optional dependency groups can be installed from PyPI as needed:

# Tests, coverage, formatting, and linting
python -m pip install "mpylab[dev]"

# Build the Sphinx documentation
python -m pip install "mpylab[docs]"

# Build and check release artifacts
python -m pip install "mpylab[release]"

Extras can be combined:

python -m pip install "mpylab[dev,docs,release]"

They also work with a direct GitLab installation:

python -m pip install "mpylab[dev,docs] @ git+https://gitlab.hrz.tu-chemnitz.de/chair-of-electromagnetic-theory-and-compatibility-at-tu-dresden/mpylab/mpylab.git@main"

For an editable development installation from a local checkout:

python -m pip install -e ".[dev,docs]"

Command-line tools

Installing mpylab provides configuration-maintenance commands and a modular TEM report generator:

# Migrate legacy f condition identifiers in one DOT file or a directory.
mpylab-dot-migrate --write local-config.dot
mpylab-dot-migrate --check --recursive path/to/configurations

# Migrate legacy NPORT interpolation settings.
mpylab-nport-migrate --write local-cable.ini
mpylab-nport-migrate --check --recursive path/to/configurations

# Check NPORT coverage, sampling and interpolation quality.
mpylab-nport-check --recursive path/to/configurations \
    --json-report nport-quality.json

# Discover and report all supported sections in a TEMCell history pickle.
mpylab-tem-report measurement-history.p --list-sections
mpylab-tem-report measurement-history.p --output tem-report \
    --formats pdf html svg \
    --profile script/conf/tem-report-profile.toml \
    --profile script/conf/tem-report-measurement.toml

Both migration commands perform a dry run and show a diff unless --write or --check is selected. Use --no-diff to suppress diff output. The DOT tool can additionally validate selected signal paths with --path, --frequency-range, --path-mode and --context. Run any command with --help for its complete option list. Detailed usage is available in the documentation.

The TEM report generator reads the complete pickle history and automatically includes every supported data set. Report modules currently cover TEM-mode verification, measured e0y field-factor data, evaluated emission data, and evaluated immunity data including EUT performance assessments. The top-level HTML and PDF reports include a cross-section traceability overview, and traceability.tsv provides the same information for machine processing. It shows frequency coverage, referenced source data sets, unresolved dependencies, completeness, and warnings without recalculating measurement results.

Measurement content and traceability are kept separate from report styling. This allows later report profiles to add laboratory identity, measurement date, environmental conditions, free text, logos, colors, and page layout without changing the stored measurement history.

The commented examples script/conf/tem-report-profile.toml and script/conf/tem-report-measurement.toml separate global laboratory and presentation settings from measurement-specific values. --profile may be repeated; files are merged in command-line order and later values override only the same keys. Profile values with their source files, generated values, defaults, and missing fields are distinguished in the top-level report-metadata.tsv file.

MSC virtual workflows

The MSC scripts can be run with virtual device configurations below script/conf. The pickle files written by these scripts are history containers: a new measurement loads an existing MSC instance, appends new measurement and evaluation data, and writes a new pickle containing the full previous history.

Typical sequences are:

maincal -> eutcal -> immunity
maincal -> eutcal -> emission
maincal -> eutcal -> immunity -> emission

Example from the script directory:

python msc-maincal.py conf/msc-immunity-virtual/conf.py
python msc-eutcal.py conf/msc-immunity-virtual/conf-eutcal.py
python msc-immunity.py conf/msc-immunity-virtual/conf-immunity.py
python msc-emission.py conf/msc-emission-virtual/conf-after-immunity.py

GTEM virtual workflows

The current TEM/GTEM scripts focus on one-port GTEM cells. The virtual workflow follows the traceable pickle-history model used by the MSC scripts:

e0y -> emission

Example from the script directory:

python tem-e0y.py conf/tem-gtem-e0y-virtual/conf.py
python tem-emission.py conf/tem-gtem-emission-virtual/conf.py

The measurement and evaluation workflow is based on IEC 61000-4-20:2010, especially Annex A.3.2.3 for one-port GTEM emission correlation and Annex A.3.2.3.3 for the e0y field factor.

Immunity result interchange

mpylab.env.immunity_result provides an optional, disturbance-neutral JSON exchange format for immunity results. It is currently used by TEMField when exporting measurement tables. Native TEMCell and MSC measurement histories remain stored in pickle files; the modular TEM report generator produces HTML, PDF, TSV, and graphical output.

SCUQ quantities are serialized as value, uncertainty, and unit. Details and examples are available in the documentation.

License

GPL-3 or higher

Repository

https://gitlab.hrz.tu-chemnitz.de/chair-of-electromagnetic-theory-and-compatibility-at-tu-dresden/mpylab/mpylab.git

The documentation is also available from the gitlab server of TU Chemnitz:

https://mpylab-75fcff.gp.hrz.tu-chemnitz.de/

Contact

Prof. Dr. Hans Georg Krauthäuser (hgk@ieee.org)
Chair for Electromagnetic Theory and Compatibility
Technische Universität Dresden, Dresden, Germany

Release files for mpylab 1.0.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpylab 1.0.24
File Size Uploaded
mpylab-1.0.24.tar.gz 28.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for mpylab 1.0.24
File Interpreter ABI Platform
mpylab-1.0.24-py3-none-any.whl Python 3 none any Details

Total release size: 29.7 MB

Release files / mpylab-1.0.24.tar.gz

Download URL mpylab-1.0.24.tar.gz
Size 28.8 MB
Tags Source
SHA-256 checksum
How to use checksums
c51d3dad93efb4b5cda715534f38a2baa98586eaae14871f1b444ab341d4ecdb
BLAKE2b-256 checksum
How to use checksums
4e98c1ad3a842be41e84d6c0d9e0d623620098742bd33411a097cf8af034114d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / mpylab-1.0.24-py3-none-any.whl

Download URL mpylab-1.0.24-py3-none-any.whl
Size 884.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
116b4d0e9a2fa325cdb87266e322935d9b4edc8ddbe7908318201768800adb9d
BLAKE2b-256 checksum
How to use checksums
828999b4d72defdd4959786a49239851c79d23d808a1f917b92a43731e0255f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release history Release notifications | RSS feed

1.0.28

2 release files

1.0.27

2 release files

1.0.26

2 release files

1.0.25

2 release files

This release

1.0.24 This release

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page