conducted_emissions_mpylab.ce¶
This is the conducted_emission.ce module.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class conducted_emission_mpylab.ce.Stdout_Logger[source]¶
Bases:
objectStdout_Logger class.
Simply prints the message to stdout.
- class conducted_emission_mpylab.ce.File_Logger(logger)[source]¶
Bases:
objectFile_Logger class.
A logger intended to log to file.
- levels = {'critical': 50, 'debug': 10, 'error': 40, 'info': 20, 'warning': 30}¶
- class conducted_emission_mpylab.ce.ConductedEmission(description: str | None = None, log_fn: Callable[[str], None] | None = None, export_pre_fn: Callable[[None], None] | None = None, export_fin_fn: Callable[[None], None] | None = None, output_path: str | None = None, prefix_prescan: str | None = None, finscan_prefix: str | None = None)[source]¶
Bases:
objectConducted Emission class
Used to perform conducted emission EMC measurements using an EMC-Receiver and a Line-Impedance Stabilized Network (LISN)
- __init__(description: str | None = None, log_fn: Callable[[str], None] | None = None, export_pre_fn: Callable[[None], None] | None = None, export_fin_fn: Callable[[None], None] | None = None, output_path: str | None = None, prefix_prescan: str | None = None, finscan_prefix: str | None = None) None[source]¶
Constructor
- Parameters:
description – str; general description of the measurement
log_fn – callback for logging messages
export_pre_fn – callback for exporting conducted emission prescan measurements
export_fin_fn – callback for exporting conducted emission final measurements
output_path – file save path if internal export functions are used
prefix_prescan – file prefix for prescan measurements if internal export functions are used
finscan_prefix – file prefix for finscan measurements if internal export functions are used
- prepare_scan(dot: str | TextIO, names: dict | None = None, searchpaths: Iterable[str] | None = None, paths: Iterable[str] | None = None, freqs: Iterable[float] | None = None, limitline: limitline = None, dut_description: str | None = None) None[source]¶
Prepare the graph and initialize the measurement devices.
Parameters¶
- dotstr or file-like
Measurement graph input.
- namesdict, optional
Graph names for receiver, LISN and EUT.
- searchpathsiterable of str, optional
Configuration search paths; defaults to the current directory.
- pathsiterable of str, optional
LISN paths; defaults to L and N.
- freqsiterable of float, optional
Frequencies in Hz; defaults to an empty sequence.
- limitlinecallable, optional
Limit in dBµV for a frequency in Hz.
- dut_descriptionstr
Non-empty description used in export filenames.
Raises¶
- ValueError
The DUT description is empty.
- RuntimeError
Device initialization returns an error status.
Notes¶
Call
quitafter use, including after a failed preparation. The GUI worker performs this cleanup automatically.
- uniquify(path)[source]¶
Method to uniquify a path: append three digit counter until unique filemame is sanitized first.
- Parameters:
path – str: full path to uniquify
- Returns:
str: uniquified path
- do_pre_scan(paths: Iterable[str] | None = None, detector: str = 'PEAK', should_stop: Callable[[], bool] | None = None, wait_if_paused: Callable[[], bool] | None = None, progress: Callable[[object], None] | None = None)[source]¶
Measure corrected prescan voltages over the requested paths.
Parameters¶
- pathsiterable of str, optional
LISN paths; defaults to the prepared paths.
- detectorstr, optional
Receiver detector, normally PEAK or AVERAGE.
- should_stopcallable, optional
Predicate checked before paths and points; defaults to False.
- wait_if_pausedcallable, optional
Wait until measurement may proceed; False requests cancellation. The default proceeds immediately.
- progresscallable, optional
Receives path, f (Hz), data (voltage quantity), and pre_or_final.
Raises¶
- RuntimeError
The receiver returns an error status; that sample is not stored.
- init_prescan(detector: str = 'PEAK') None[source]¶
Setup pre-scan
- Parameters:
detector – str; either ‘PEAK’ or ‘AVERAGE’
- Returns:
None
- pre_scan_set_path(path: str) None[source]¶
Set measurement path for pre scan
- Parameters:
path – str; in ‘(‘L’, ‘N’)’, or ‘(‘L1’, ‘L2’, ‘L3’, ‘N’)
- Returns:
None
- pre_scan_do_freq(freq: float) Quantity[source]¶
Measure and store one corrected prescan voltage.
Parameters¶
- freqfloat
Frequency in Hz.
Returns¶
- Quantity
Path-corrected voltage magnitude in V.
Raises¶
- RuntimeError
The receiver returns a nonzero error status.
- do_final_scan(paths: Iterable[str] | None = None, margin: float = 6, detector: str | None = None, should_stop: Callable[[], bool] | None = None, wait_if_paused: Callable[[], bool] | None = None, progress: Callable[[object], None] | None = None) None[source]¶
Measure final-detector candidates selected from the prescan.
Parameters¶
- pathsiterable of str, optional
LISN paths; defaults to the prepared paths.
- marginfloat, optional
Screening margin below the limit in dB. Equality triggers a reading.
- detectorstr, optional
Final detector; defaults to QPEAK.
- should_stopcallable, optional
Predicate checked before paths and points; defaults to False.
- wait_if_pausedcallable, optional
Wait until measurement may proceed; False requests cancellation. The default proceeds immediately.
- progresscallable, optional
Receives path, f (Hz), data (voltage quantity), and pre_or_final.
Raises¶
- RuntimeError
The receiver returns an error status; that sample is not stored.
Notes¶
Missing, nonfinite or non-applicable limits do not trigger a reading. Unmeasured frequencies have no final-scan sample.
- init_finscan(margin: float = 6, detector: str | None = None) None[source]¶
Setup final conducted emission measurement
- Parameters:
margin – float; dB value below limit
- Returns:
None
- finscan_set_path(path: str) None[source]¶
Set measurement path for final conducted emission
- Parameters:
path – str; e.g. from [‘L’, ‘N’]
- Returns:
None
- finscan_do_freq(freq: float) tuple[Quantity | None, Quantity | None][source]¶
Measure a candidate at or above the screening threshold.
Parameters¶
- freqfloat
Frequency in Hz, present in the current path’s prescan.
Returns¶
- tuple of Quantity or None
Corrected voltage and limit in V. A below-threshold point returns
(None, limit); an unassessable limit returns(None, None).
Raises¶
- RuntimeError
The receiver returns a nonzero error status.
- quit(log: Callable[[str], None] | None = None) None[source]¶
Close devices belonging to the prepared measurement graph.
Parameters¶
- logcallable, optional
Receives the cleanup message. No-op when omitted.
Notes¶
Safe before a graph has been created. Device cleanup errors propagate to the caller; the GUI worker logs them and still signals completion.
- class conducted_emission_mpylab.ce.ce_plot(paths: Iterable[str] | None = None, limit_dct: dict | None = None, limit_legend: str | None = None, unit: str | None = None, margin: float = 6, fmin: float | None = None, fmax: float | None = None)[source]¶
Bases:
objectClass providing plot facilities for Conducted Emission Measurement
- __init__(paths: Iterable[str] | None = None, limit_dct: dict | None = None, limit_legend: str | None = None, unit: str | None = None, margin: float = 6, fmin: float | None = None, fmax: float | None = None) None[source]¶
Constructor for class ce_plot
- Parameters:
paths – list or tuple; e.g. [‘L’, ‘N’]
limit_dct – dictionary with keys ‘freq’ and ‘limit’; both are lists (limit is a dB value)
limit_legend – str; provides the legend for the limit
unit – str; provides the unit of measurement
margin – float; dB value below limit
- update_data_plot(typ: str, path: str, freqs: Iterable[float], data: Iterable[float]) None[source]¶
Update the plot with (freq, data) tuples for all freq in freqs
- Parameters:
typ – str; ‘pre’ or ‘fin’ to indicate pre scan or final scan
path – str; e.g. ‘L’ or ‘N’
freqs – iterable; the frequencies
data – iterable; the data (dB values)
- Returns:
None