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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpylab-1.0.21.tar.gz (28.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mpylab-1.0.21-py3-none-any.whl (843.6 kB view details)

Uploaded Python 3

File details

Details for the file mpylab-1.0.21.tar.gz.

File metadata

  • Download URL: mpylab-1.0.21.tar.gz
  • Upload date:
  • Size: 28.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for mpylab-1.0.21.tar.gz
Algorithm Hash digest
SHA256 50504a8044d41308b643e6c5821f1dd2324feed3f0e83b85bf8b8d664d53ce34
MD5 4d36540b9d6ebeb9da6fa3ef55d63181
BLAKE2b-256 8ea3ab44f448955094ec2648f6ba262c732d3c277bca17e2ed95f338aa538a85

See more details on using hashes here.

File details

Details for the file mpylab-1.0.21-py3-none-any.whl.

File metadata

  • Download URL: mpylab-1.0.21-py3-none-any.whl
  • Upload date:
  • Size: 843.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.5

File hashes

Hashes for mpylab-1.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 838cbc2ab96e2469ba7487df6e714c9779c44667f0398486689a01df18668324
MD5 ead475c75e419cdc7cc0c1938eba67c7
BLAKE2b-256 b3aeb3d16c2621e4c7c9248d3cedcb8f8a3f7d3ccedf3cff8ed45a8ff45f2078

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.23

2 files

1.0.22

2 files

This release

1.0.21 This release

2 files

1.0.20

2 files

1.0.19

2 files

1.0.18

2 files

1.0.17

2 files

1.0.16

2 files

1.0.15

2 files

1.0.14

2 files

1.0.13

2 files

1.0.12

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.9.5

2 files

0.9.4

2 files

0.9.3

2 files

0.9.2

2 files

0.9.1

2 files

0.9

2 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