mpylab.env.msc.MSC module¶
This is mpylab.env.msc.MSC.
Provides
mpylab.env.msc.MSCfor EMC measurements in MSC
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.env.msc.MSC.MSC(SearchPaths=None)
Bases:
MeasurePerform measurements in a mode-stirred chamber.
The class stores the complete measurement history in separate raw and processed data dictionaries for main calibration, EUT calibration, autocorrelation, immunity, and emission measurements.
- Parameters:
SearchPaths (sequence of path-like, optional) – Directories searched for DOT graphs, device INI files, and data files.
- CalculateLoading_EUTCal(empty_cal='empty', eut_cal='EUT', freqs=None, interpolation='linxliny')
Calculate chamber loading from main and EUT calibrations.
- Parameters:
empty_cal (str, optional) – Empty-chamber main-calibration description.
eut_cal (str, optional) – EUT-calibration description.
freqs (sequence of float, optional) – Output frequencies in hertz. Frequencies from
empty_calare used by default.interpolation (str, optional) – Interpolation policy for nonmatching frequency grids.
- Returns:
Zero on success or
-1when a calibration is unavailable.- Return type:
int
- CalculateLoading_MainCal(empty_cal='empty', loaded_cal='loaded', freqs=None, interpolation='linxliny')
Calculate chamber loading from two main calibrations.
- Parameters:
empty_cal (str, optional) – Empty-chamber main-calibration description.
loaded_cal (str, optional) – Loaded-chamber main-calibration description.
freqs (sequence of float, optional) – Output frequencies in hertz. Frequencies from
empty_calare used by default.interpolation (str, optional) – Interpolation policy for nonmatching frequency grids.
- Returns:
Zero on success or
-1when a calibration is unavailable.- Return type:
int
- Evaluate_AutoCorr(description='empty', lag=None, alpha=0.05, rho=0.44, rho0=None, skip=None, every=1, offset=0)
Evaluate autocorrelation, independence, and field statistics.
- Parameters:
description (str, optional) – Raw autocorrelation description key.
lag (int or callable, optional) – Maximum autocorrelation lag, either constant or frequency dependent.
alpha (float, optional) – Significance level used for the critical correlation coefficient.
rho (float, optional) – Correlation coefficient used to derive its distribution.
rho0 (float or mapping, optional) – Critical correlation coefficient, either as a scalar or indexed by
alpha. If omitted, it is calculated from the coefficient distribution whenever an independence threshold is needed.skip (sequence of str, optional) – Evaluation blocks to omit.
every (int, optional) – Evaluate every nth frequency.
offset (int, optional) – Starting index for frequency subsampling.
- Returns:
Zero on success or
-1if the description is unavailable.- Return type:
int
- Evaluate_EUTCal(description='EUT', calibration='empty')
Evaluate an EUT calibration against a main calibration.
- Parameters:
description (str, optional) – Raw EUT-calibration description key.
calibration (str, optional) – Processed main-calibration description used as reference.
- Returns:
Zero on success or
-1when required input data is missing.- Return type:
int
- Evaluate_Emission(description='EUT', empty_cal='empty', loaded_cal='loaded', EUT_cal='EUT', interpolation='linxliny', distance=10, directivity=1.7, hg=0.8, RH=(0.8, 0.8), isoats=None)
Evaluate emission data using chamber and EUT calibrations.
- Parameters:
description (str, optional) – Raw emission description key.
empty_cal (str, optional) – Empty-chamber main-calibration description.
loaded_cal (str, optional) – Loaded-chamber main-calibration description.
EUT_cal (str, optional) – EUT-calibration description.
interpolation (str, optional) – Interpolation policy for calibration data.
distance (float, optional) – Extrapolation distance in metres.
directivity (float or callable, optional) – Assumed EUT directivity, constant or frequency dependent.
hg (float, optional) – EUT height above the ground plane in metres.
RH (tuple of float, optional) – Horizontal and vertical receive-antenna heights in metres.
isoats (bool, optional) – Use the OATS propagation model instead of the FAR model.
- Returns:
Zero on success or
-1when required input data is missing.- Return type:
int
- Evaluate_Immunity(description='EUT', empty_cal='empty', loaded_cal='loaded', EUT_cal='EUT', EUT_OK=None, interpolation='linxliny', performance_criterion=None)
Evaluate immunity measurements and derive failure thresholds.
- Parameters:
description (str, optional) – Raw immunity description key.
empty_cal (str, optional) – Empty-chamber main-calibration description.
loaded_cal (str, optional) – Loaded-chamber main-calibration description.
EUT_cal (str, optional) – EUT-calibration description. A loading factor of one is used when it is unavailable.
EUT_OK (callable, optional) – Predicate returning whether a recorded EUT status is acceptable.
interpolation (str, optional) – Interpolation policy for calibration data.
performance_criterion (str or None, optional) – EMC criterion
A,B, orC.Noneuses the criterion recorded byMeasure_Immunity().
- Returns:
Zero on success or
-1when required input data is missing.- Return type:
int
- Evaluate_MainCal(description='empty', standard=None, freqs=None)
Evaluate raw main-calibration data.
- Parameters:
description (str, optional) – Raw main-calibration description key.
standard (str, optional) – Evaluation standard or alias. The configured default is used when omitted.
freqs (list of float, optional) – Frequencies in hertz to evaluate. By default all measured frequencies are used. The supplied list is sorted in place.
- Returns:
Zero on success or
-1if the description is unavailable.- Return type:
int
- GetAllTPos(description)
Return all tuner-position combinations in a main calibration.
- Parameters:
description (str) – Main-calibration description key.
- Returns:
Cartesian product of the tuner positions, or an empty list when the description has no suitable data.
- Return type:
list
- GetFreqs_MainCal(description)
Return frequencies for a raw main calibration.
- Parameters:
description (str) – Main-calibration description key.
- Returns:
Sorted frequencies in hertz, or an empty list if not found.
- Return type:
list of float
- GetKeys_MainCal()
Return available processed main-calibration description keys.
- Returns:
Description keys in insertion order.
- Return type:
list of str
- MaxtoAvET2()
Create the maximum-to-average squared-field interpolation.
- Returns:
Interpolator mapping the number of tuner positions to the conversion factor.
- Return type:
scipy.interpolate.interp1d
- Measure_Autocorrelation(description='empty', dotfile='testgr.dot', delay=1.0, SGLevel=-20, leveling=None, freqs=None, toffsets=None, ntunerpos=None, SearchPaths=None, names=None)
Measure field autocorrelation over tuner positions.
- Parameters:
description (str, optional) – Key under which the raw measurement is stored.
dotfile (path-like, optional) – Measurement graph configuration.
delay (float, optional) – Settling time in seconds before each acquisition.
SGLevel (float or scuq.Quantity, optional) – Initial signal-generator output level.
leveling (sequence of mapping, optional) – Conditional leveling configurations.
freqs (sequence of float, optional) – Measurement frequencies in hertz.
toffsets (sequence of float, optional) – Position increment for each tuner.
ntunerpos (sequence of int, optional) – Number of positions for each tuner.
SearchPaths (sequence of path-like, optional) – Additional configuration search paths.
names (mapping, optional) – Logical-to-graph device-name mapping.
- Returns:
Final device status; zero indicates success.
- Return type:
int
- Measure_EUTCal(description='EUT', dotfile='msc-calibration.dot', delay=1.0, freqs=None, SGLevel=-20, leveling=None, calibration='empty', SearchPaths=None, names=None)
Perform an EUT loading calibration according to IEC 61000-4-21.
- Parameters:
description (str, optional) – Key under which the EUT-calibration data is stored.
dotfile (path-like, optional) – Measurement graph configuration.
delay (float, optional) – Settling time in seconds before each acquisition.
freqs (sequence of float, optional) – Measurement frequencies in hertz.
SGLevel (float or scuq.Quantity, optional) – Initial signal-generator output level.
leveling (sequence of mapping, optional) – Conditional leveling configurations.
calibration (str, optional) – Main-calibration description used for tuner positions.
SearchPaths (sequence of path-like, optional) – Additional configuration search paths.
names (mapping, optional) – Logical-to-graph device-name mapping.
- Returns:
Final device status; zero indicates success.
- Return type:
int
- Measure_Emission(description='EUT', dotfile='msc-emission.dot', calibration='empty', delay=1.0, freqs=None, receiverconf=None, SearchPaths=None, names=None)
Perform an emission measurement according to IEC 61000-4-21.
- Parameters:
description (str, optional) – Key under which the emission measurement is stored.
dotfile (path-like, optional) – Measurement graph configuration.
calibration (str, optional) – Main-calibration description used for tuner positions.
delay (float, optional) – Settling time in seconds before each acquisition.
freqs (sequence of float, optional) – Measurement frequencies in hertz.
receiverconf (mapping, optional) – Frequency-dependent receiver command configuration.
SearchPaths (sequence of path-like, optional) – Additional configuration search paths.
names (mapping, optional) – Logical-to-graph device-name mapping.
- Returns:
Final device status; zero indicates success.
- Return type:
int
- Measure_Immunity(description='EUT', dotfile='msc-immunity.dot', calibration='empty', kernel=(None, None), leveling=None, freqs=None, eut_monitor=None, manual_eut_monitor=None, eut_event_policy=None, performance_criterion='A', post_exposure_timeout=None, SearchPaths=None, names=None)
Perform an immunity measurement according to IEC 61000-4-21.
- Parameters:
description (str, optional) – Key under which the immunity measurement is stored.
dotfile (path-like, optional) – Measurement graph configuration.
calibration (str, optional) – Main-calibration description used for tuner positions.
kernel (tuple, optional) –
(kernel_class, parameters)controlling the test sequence.ImmunityThresholdKernelperforms a stepped susceptibility-threshold search and acceptsfield_levels,backtrack_levels,dwell, and optional EUT monitors.leveling (sequence of mapping, optional) – Conditional leveling configurations.
freqs (sequence of float, optional) – Test frequencies in hertz.
eut_monitor (EUTMonitor or sequence of EUTMonitor, optional) – Additional automatic EUT monitors. Manual intervention remains available independently.
manual_eut_monitor (ManualEUTMonitor, optional) – Manual operator monitor, for example one owned by a GUI.
eut_event_policy (mapping, optional) – Actions for degraded, failed, and unevaluable EUT observations.
performance_criterion (str, optional) – EMC performance criterion
A,B, orC.post_exposure_timeout (float or None, optional) – Optional EUT observation time after RF has been switched off.
SearchPaths (sequence of path-like, optional) – Additional configuration search paths.
names (mapping, optional) – Logical-to-graph device-name mapping.
- Returns:
Final device status; zero indicates success.
- Return type:
int
- Measure_MainCal(description='empty', dotfile='msc-calibration.dot', delay=1.0, LUF=250000000.0, FStart=150000000.0, FStop=1000000000.0, InputLevel=None, leveler=None, leveler_par=None, ftab=None, nftab=None, ntuntab=None, tofftab=None, nprbpostab=None, nrefantpostab=None, SearchPaths=None, names=None)
Perform a main chamber calibration according to IEC 61000-4-21.
- Parameters:
description (str, optional) – Key under which the raw measurement is stored.
dotfile (path-like, optional) – Measurement graph configuration.
delay (float, optional) – Settling time in seconds before each acquisition.
LUF (float, optional) – Lowest usable frequency in hertz; scales the entries in
ftab.FStart (float, optional) – Lower and upper measurement frequencies in hertz.
FStop (float, optional) – Lower and upper measurement frequencies in hertz.
InputLevel (scuq.Quantity, optional) – Initial forward-power target. The default is 1 mW.
leveler (type, optional) – Leveler implementation. Defaults to
mgraph.Leveler.leveler_par (mapping, optional) – Keyword arguments used to construct the leveler.
ftab (sequence of float, optional) – Frequency-region boundaries relative to
LUF.nftab (sequence of int, optional) – Number of frequencies in each frequency region.
ntuntab (sequence of sequence of int, optional) – Number of positions for each tuner and frequency region.
tofftab (sequence of sequence of float, optional) – Tuner-position increments for each frequency region.
nprbpostab (sequence of int, optional) – Number of field-probe positions in each frequency region.
nrefantpostab (sequence of int, optional) – Number of reference-antenna positions in each frequency region.
SearchPaths (sequence of path-like, optional) – Additional configuration search paths.
names (mapping, optional) – Logical-to-graph device-name mapping.
- Returns:
Final device status; zero indicates success.
- Return type:
int
- OutputProcessedData_AutoCorr(description=None, what=None, fname=None)
Print or write processed autocorrelation data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- OutputProcessedData_EUTCal(description=None, what=None, fname=None)
Print or write processed EUT-calibration data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- OutputProcessedData_Emission(description=None, what=None, fname=None)
Print or write processed emission data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- OutputProcessedData_Immunity(description=None, what=None, fname=None)
Print or write processed immunity data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- OutputProcessedData_MainCal(description=None, what=None, fname=None)
Print or write processed main-calibration data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- OutputRawData_AutoCorr(description=None, what=None, fname=None)
Print or write raw autocorrelation data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- OutputRawData_EUTCal(description=None, what=None, fname=None)
Print or write raw EUT-calibration data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- OutputRawData_Emission(description=None, what=None, fname=None)
Print or write raw emission data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- OutputRawData_Immunity(description=None, what=None, fname=None)
Print or write raw immunity data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- OutputRawData_MainCal(description=None, what=None, fname=None)
Print or write raw main-calibration data.
- Parameters:
description (str or sequence of str, optional) – Description key or keys to include. By default all are included.
what (str or sequence of str, optional) – Data fields to include. By default all fields are included.
fname (path-like, optional) – Output file. If omitted, write to standard output.
- UseTunerPos(description, f, t)
Check whether a tuner position applies at a frequency.
- Parameters:
description (str) – Main-calibration description key.
f (float) – Frequency in hertz.
t (sequence) – Combined tuner position.
- Returns:
Trueif the position occurs in the applicable calibration frequency region.- Return type:
bool
- getMaxE(mg, names, f, etest, rfac=None)
Estimate the maximum usable field from graph safety limits.
- Parameters:
mg (mpylab.tools.mgraph.MGraph) – Active measurement graph whose
MaxSafevalue limits the source.names (mapping) – Logical device-name mapping. Retained for API compatibility.
f (float) – Frequency in hertz.
etest (callable) – Converter accepting
(frequency, forward_power)and returning electric field strength.rfac (float, optional) – Additional linear reduction factor. The default, 0.891, corresponds approximately to 1 dB.
- Returns:
Reduced maximum electric field strength.
- Return type:
scuq.Quantity
- getStandard(s=None)
Normalize a standard name or alias.
- Parameters:
s (str, optional) – Standard name or recognizable alias. The instance default is used when omitted.
- Returns:
Canonical standard name, or the configured default for an unknown alias.
- Return type:
str
- static stdTPosCmp(t1, t2)
Compare tuner positions by the sum of their coordinates.
- Parameters:
t1 (sequence or str) – Tuner positions. Strings must contain Python list or tuple literals, for example
"[0, 5, 10]".t2 (sequence or str) – Tuner positions. Strings must contain Python list or tuple literals, for example
"[0, 5, 10]".
- Returns:
-1,0, or1according to the ordering.- Return type:
int
- stdUserInterruptHandler(dct, ignorelist='')
Handle an operator interrupt during an MSC measurement.
- Parameters:
dct (mapping) – Local measurement-loop state used for resuming devices and levels.
ignorelist (str or sequence of str, optional) – Commands that the shared interrupt handler must ignore.
- Returns:
Result returned by the shared interrupt handler.
- Return type:
object
- class mpylab.env.msc.MSC.TestField(instance, maincal='empty', eutcal=None)
Bases:
objectConvert forward power to expected electric field strength.
- Parameters:
instance (MSC) – Measurement instance containing processed calibration data.
maincal (str, optional) – Main-calibration description.
eutcal (str, optional) – EUT-calibration description. If omitted or unavailable, no EUT loading correction is applied.
- class mpylab.env.msc.MSC.TestPower(instance, maincal='empty', eutcal=None)
Bases:
objectConvert target electric field strength to required forward power.
- Parameters:
instance (MSC) – Measurement instance containing processed calibration data.
maincal (str, optional) – Main-calibration description.
eutcal (str, optional) – EUT-calibration description. If omitted or unavailable, no EUT loading correction is applied.
- class mpylab.env.msc.MSC.stdImmunityKernel(field, tp, messenger, poll_key=None, completed_frequencies=None, dwell=1, keylist='sS', eut_monitor=None, manual_eut_monitor=None, eut_event_policy=None, post_exposure_timeout=None)
Bases:
objectGenerate commands for a standard immunity test sequence.
- Parameters:
field (scuq.Quantity) – Target electric field strength.
tp (mapping) – Tuner positions indexed by frequency.
messenger (callable) – User-message callback.
poll_key (callable, optional) – Non-blocking callback returning an operator key code while dwelling.
completed_frequencies (collection of float, optional) – Frequencies already completed by an earlier autosave run. These frequencies are omitted from the generated test plan.
dwell (float, optional) – Exposure duration in seconds at each tuner position.
keylist (str, optional) – Operator keys that mark an EUT event.
eut_monitor (EUTMonitor or sequence of EUTMonitor, optional) – Additional automatic EUT monitors.
manual_eut_monitor (ManualEUTMonitor, optional) – Mandatory manual monitor. A keyboard-backed instance is created when omitted.
eut_event_policy (mapping, optional) – Actions for degraded, failed, and unevaluable EUT observations.
post_exposure_timeout (float or None, optional) – Optional EUT observation time after RF has been switched off.
- close()
Stop and close all EUT monitors without accessing RF hardware.
- test(stat)
Return the next command in the test plan.
- Parameters:
stat (object) – Status of the preceding command.
"AmplifierProtectionError"skips the remainder of the current frequency block.- Returns:
(command, message, parameters)for the measurement loop.- Return type:
tuple