temfield_mpylab.TestSusceptibility

temfield_mpylab.TestSusceptibility.am_headroom_factor(modulation_depth_percent)[source]

Return the peak-to-carrier field factor for sinusoidal AM.

modulation_depth_percent is expressed in percent. For the usual 80 % modulation depth, the returned factor is 1.8.

temfield_mpylab.TestSusceptibility.format_probe_orientation_preflight(graph_name, orientation, source='default')[source]

Return a readable preflight summary for one probe orientation.

Parameters:
  • graph_name (str) – Physical field-probe node name.

  • orientation (mapping, str, or None) – Orientation accepted by parse_probe_orientation().

  • source (str, optional) – Configuration source shown in the summary.

Returns:

Multiline orientation and cell-from-probe matrix summary.

Return type:

str

temfield_mpylab.TestSusceptibility.map_probe_field_vector(data, orientation=None, *, data_kind='signed_vector')[source]

Map a three-axis field reading into cell coordinates.

Parameters:
  • data (sequence of Quantity or float) – Probe x-, y-, and z-axis field components.

  • orientation (mapping, str, or None, optional) – Probe orientation accepted by parse_probe_orientation().

  • data_kind ({"signed_vector", "component_magnitudes"}, optional) – signed_vector applies the complete rotation matrix. For component_magnitudes only an axis permutation is physically identifiable; signs are ignored and general rotations are rejected.

Returns:

cell_x, cell_y, and cell_z field quantities.

Return type:

dict

temfield_mpylab.TestSusceptibility.parse_probe_axis_map(axis_map=None)[source]

Parse a complete signed mapping from probe axes to cell axes.

Parameters:

axis_map (mapping of str to str, optional) – Mapping for cell_x, cell_y, and cell_z. Values use signed probe-axis expressions such as +probe_y or -probe_x.

Returns:

Parsed probe-axis index, sign, and normalized expression for every cell axis.

Return type:

dict

temfield_mpylab.TestSusceptibility.parse_probe_orientation(orientation=None)[source]

Parse a field-probe orientation into a cell-from-probe matrix.

Parameters:

orientation (mapping, str, or None, optional) – Signed axis map, rotation matrix, or fixed-cell-axis rotation angles. None selects DEFAULT_PROBE_AXIS_MAP.

Returns:

Rotation matrix, an axis_map when the rotation is a signed permutation, and its normalized representation.

Return type:

dict

temfield_mpylab.TestSusceptibility.resolve_probe_orientation(measurement_graph, graph_name, config_probe_orientations=None)[source]

Resolve one physical field probe’s orientation and source.

Parameters:
  • measurement_graph (mpylab.tools.mgraph.MGraph or compatible object) – Graph containing the field-probe node, DOT attributes, and parsed INI sections.

  • graph_name (str) – Physical field-probe node name.

  • config_probe_orientations (mapping, optional) – Per-node or direct orientation supplied by the application.

Returns:

orientation contains the normalized mapping or matrix, source identifies the selected source, and candidates retains all agreeing explicit definitions.

Return type:

dict

Raises:

ProbeOrientationConflictError – If explicit sources define different normalized orientations.

temfield_mpylab.TestSusceptibility.dBm2W(inp)
class temfield_mpylab.TestSusceptibility.Measure(SearchPaths=None)[source]

Bases: object

Base class for measurements.

Parameters:

SearchPaths (iterable of path-like, optional) – Directories searched for measurement configuration files. The current working directory is used by default.

__init__(SearchPaths=None)[source]

constructor

set_autosave_resume(measurement, method, description, parameter_source='current_configuration')[source]

Store a structured restart instruction alongside ascmd.

Parameters:
  • measurement (str) – Stable measurement-family identifier.

  • method (str) – Method used to continue the measurement.

  • description (str) – Data-set description to resume.

  • parameter_source (str, optional) – Source from which restart parameters must be reconstructed.

Returns:

Pickle-friendly structured restart instruction.

Return type:

dict

wait(delay, dct, uitester, intervall=0.1)[source]

Wait while repeatedly polling an interrupt callback.

Parameters:
  • delay (float) – Number of seconds to wait.

  • dct (mapping) – Namespace passed to legacy callbacks accepting one argument.

  • uitester (callable) – Interrupt callback accepting either dct or no arguments.

  • intervall (float, optional) – Delay in seconds between callback invocations.

out(item)[source]

Print a nested object recursively on one line.

Parameters:

item (object) – Mapping, sequence, or scalar value to print.

set_autosave_interval(interval)[source]

Set the minimum interval between automatic saves.

Parameters:

interval (float) – Minimum interval in seconds.

stdlogger(block, *args)[source]

The standard method to write messages to log file.

Print block to self.logfile or to stdout (if self.logfile is None). If block has attribute keys (i.e. is a dict), the elements are processed with the local function out_block(). Else, the block is printed directly.

Parameters:
  • block (object) – Mapping or scalar message to log.

  • *args (object) – Additional positional values retained for callback compatibility; they are ignored by the standard logger.

stdUserMessenger(msg: str = 'Are you ready?', but: list[str] | None = None, level: str = '', dct: dict[Any, Any] | None = None) int[source]

Present a message and optionally wait for a button selection.

Parameters:
  • msg (str, optional) – Message shown to the operator.

  • but (list of str, optional) – Button labels selectable by their initial character.

  • level (str, optional) – Message category; "email" enables the legacy email path.

  • dct (mapping, optional) – Supplemental message data, including legacy email fields.

Returns:

Selected button index, or -1 when no buttons are supplied.

Return type:

int

static stdUserInterruptTester() int | None[source]

Poll the standard keyboard source for a user interrupt.

Returns:

Key code from mpylab.tools.keyboard.anykeyevent(), or None when no key is available.

Return type:

int or None

set_logfile(name)[source]

Open or replace the append-only measurement log file.

Parameters:

name (path-like) – Requested log-file path. The filename component is sanitized.

set_logger(logger=None)[source]

Configure the callbacks receiving measurement log messages.

Parameters:

logger (callable or iterable of callable, optional) – Logger callbacks. stdlogger() is used by default.

set_messenger(messenger)[source]

Configure the callback used for user-facing messages.

Parameters:

messenger (callable) – Messenger compatible with stdUserMessenger().

set_ui_adapter(adapter)[source]

Replace the complete measurement UI adapter.

Parameters:

adapter (UIAdapter) – Adapter providing messaging, logging, and interaction hooks.

set_user_interrupt_tester(tester)[source]

Configure the non-blocking user-interrupt callback.

Parameters:

tester (callable) – Callback compatible with stdUserInterruptTester().

set_user_interrupt_Tester(tester)[source]

Call set_user_interrupt_tester() for legacy clients.

Parameters:

tester (callable) – Non-blocking user-interrupt callback.

set_pre_user_event(event_cb)[source]

Configure the callback run before user-facing interactions.

Parameters:

event_cb (callable) – Callback invoked before an interaction begins.

set_post_user_event(event_cb)[source]

Configure the callback run after user-facing interactions.

Parameters:

event_cb (callable) – Callback invoked after an interaction finishes.

set_interactive_runner(runner)[source]

Configure the callback used for interactive sessions.

Parameters:

runner (callable) – Callback starting an interactive session.

set_autosave(name)[source]

Set the autosave filename used by do_autosave().

Parameters:

name (path-like or None) – Autosave destination, or None to disable file output.

do_autosave(name_or_obj=None, depth=None, prefixes=None)[source]

Serialize the measurement state using pickle.

Assuming a calling sequence like so:

script -> method of measurement class -> do_autosave

depth=1 stores the command issued in the script as self.ascmd. If the requested depth is too large, the outermost command is used.

Measurement methods may additionally set self.autosave_resume to a structured restart description. ascmd remains available as the human-readable and legacy restart instruction.

Parameters:
  • name_or_obj (str or binary file-like, optional) – Path-like destination or writable binary stream. self.asname is used by default. Path destinations are replaced atomically; caller-owned streams remain open.

  • depth (int, optional) – Number of caller frames used to derive ascmd.

  • prefixes (iterable of str, optional) – Command prefixes considered when deriving the restart command.

static stdPreUserEvent()[source]

stdPreUserEvent method.

static stdPostUserEvent()[source]

stdPostUserEvent method.

static stdInteractiveSession(obj, banner)[source]

Start the default terminal-based interactive session.

Parameters:
  • obj (object) – Object exposed to the interactive session.

  • banner (str) – Introductory text shown by the interactive console.

set_level(mg, l, leveler=None)[source]

Set the signal-generator level, optionally respecting a leveler.

Parameters:
  • mg (MGraph) – Active measurement graph containing the signal generator.

  • l (Quantity or float) – Requested power. Numeric values are interpreted as dBm.

  • leveler (Leveler, optional) – Leveler whose MaxSafe value limits the request.

Returns:

Level reported as applied by the signal generator.

Return type:

Quantity

set_level_protected(mg, level, output=None, actor=None, leveler=None, reason=None)[source]

Set a signal-generator level without exceeding graph safety limits.

If output is given, MGraph.AmplifierProtect() is used as the hard safety check. Unsafe requests are clipped to MGraph.MaxSafeLevel(); the level is still applied and metadata is returned so measurement code can record that the requested target was unreachable due to amplifier protection.

Parameters:
  • mg (MGraph) – Active measurement graph.

  • level (Quantity or float) – Requested power. Numeric values are interpreted as dBm.

  • output (str, optional) – End node of the path checked for amplifier protection.

  • actor (str, optional) – Signal-generator node. The graph’s sg name is used by default.

  • leveler (Leveler, optional) – Leveler providing an additional MaxSafe constraint.

  • reason (str, optional) – Operation recorded when protection limits the request.

Returns:

Applied level and protection metadata. max_safe_level contains the strictest effective limit when multiple protection sources are active.

Return type:

tuple of (Quantity, dict)

setLevel(mg, level_or_names, level_or_leveler=None)[source]

Backward-compatible wrapper for legacy callers.

Supported call shapes: - setLevel(mg, level_dBm) - setLevel(mg, level_dBm, leveler) - setLevel(mg, names_dict, level_dBm) (legacy TEM/Univers code)

Parameters:
  • mg (MGraph) – Active measurement graph.

  • level_or_names (Quantity, float, or mapping) – Requested level, or a legacy names mapping.

  • level_or_leveler (Quantity, float, or Leveler, optional) – Legacy level argument or leveler instance.

Returns:

Applied signal-generator level returned by set_level().

Return type:

Quantity

doLeveling(leveling, mg, names, dct)[source]

Backward-compatible no-op stub for removed legacy leveling API.

The legacy callers expect this method to exist and to return either a new level or None. Current code path keeps behavior by returning None.

Parameters:
  • leveling (object) – Unused legacy leveling configuration.

  • mg (MGraph) – Unused measurement graph.

  • names (mapping) – Unused instrumentation names.

  • dct (mapping) – Unused legacy evaluation context.

do_leveling(leveling, mg, names, dct)[source]

Call the compatibility doLeveling() implementation.

Parameters:
  • leveling (object) – Legacy leveling configuration.

  • mg (MGraph) – Active measurement graph.

  • names (mapping) – Instrumentation names.

  • dct (mapping) – Legacy evaluation context.

Returns:

The removed legacy implementation is intentionally a no-op.

Return type:

None

make_deslist(thedata, description)[source]

Select available data-set descriptions.

Parameters:
  • thedata (mapping) – Data indexed by description.

  • description (str, iterable of str, or None) – Requested descriptions, or None for all available entries.

Returns:

Requested descriptions that exist in thedata.

Return type:

list

MakeDeslist(thedata, description)[source]

Call make_deslist() for legacy clients.

Parameters:
  • thedata (mapping) – Data indexed by description.

  • description (str, iterable of str, or None) – Requested descriptions.

Returns:

Available requested descriptions.

Return type:

list

make_whatlist(thedata, what)[source]

Select available result-channel names.

Parameters:
  • thedata (mapping) – Data sets containing channel mappings.

  • what (str, iterable of str, or None) – Requested channels, or None for all available channels.

Returns:

Requested channels present in the data.

Return type:

list

MakeWhatlist(thedata, what)[source]

Call make_whatlist() for legacy clients.

Parameters:
  • thedata (mapping) – Data sets containing channel mappings.

  • what (str, iterable of str, or None) – Requested channels.

Returns:

Available requested channels.

Return type:

list

static stdEutStatusChecker(status)[source]

Return whether a legacy EUT status denotes normal operation.

Parameters:

status (object) – Legacy EUT status value.

Returns:

True only for "ok" or "OK".

Return type:

bool

static std_eut_status_checker(status)[source]

Call stdEutStatusChecker() using the snake-case name.

Parameters:

status (object) – Legacy EUT status value.

Returns:

Whether the status denotes normal operation.

Return type:

bool

class temfield_mpylab.TestSusceptibility.TestSusceptibility(parent=None)[source]

Bases: Measure

__init__(parent=None)[source]

constructor

Init(names=None, datafunc=None, pin=None, dwell_time=None, e_target=None, dotfile=None, SearchPath=None, leveler_par=None, adjust_to_setting=None, probe_orientations=None)[source]

Configure the susceptibility measurement.

Raw field-probe readings are mapped once from probe coordinates into the final (Ex, Ey, Ez) cell-coordinate order. Component selection and custom datafunc callbacks operate on that mapped vector.

Parameters:
  • names (mapping, optional) – Measurement-graph role to node-name mapping.

  • datafunc (callable, optional) – Custom observer function receiving an already ordered three-axis field vector. By default, adjust_to_setting selects the value.

  • pin (iterable of float, optional) – Initial signal-generator levels in dBm.

  • dwell_time (float, optional) – Exposure time in seconds; defaults to one second.

  • e_target (float, optional) – Requested carrier field strength in volts per metre.

  • dotfile (path-like, optional) – Measurement-graph DOT file.

  • SearchPath (iterable of path-like, optional) – Search paths used to resolve graph configuration files.

  • leveler_par (mapping, optional) – Explicit mpylab leveler parameters.

  • adjust_to_setting ({"x", "y", "z", "mag", "largest"}, optional) – Field value used for leveling. Missing and legacy "auto" values select "y".

  • probe_orientations (mapping, optional) – Direct or per-probe orientation configuration. Graph-node and field-probe INI metadata are used when this is omitted.

init_measurement(am)[source]

Initialize devices and AM configuration while keeping RF off.

reset_to_safe_actor_level()[source]

Reset the generator to its lowest configured level with RF off.

rf_on()[source]
rf_off()[source]
am_on()[source]
am_off()[source]
adjust_level(target_field=None)[source]

Level to the target field and return the full probe field vector.

The structured mpylab.tools.mgraph.LevelingResult is retained in last_leveling_result. Callers must only expose the EUT to the test field when that result has status converged.

prepare_am_waveform_validation(modulation_depth_percent)[source]

Level only to the safe CW starting field for in-loop AM validation.

Parameters:

modulation_depth_percent (float) – Sinusoidal AM depth from 0 through 100 percent. It determines the peak-to-carrier factor used to keep the initial AM peak at or below the requested carrier field.

Returns:

Three-axis probe field at e_target / (1 + modulation_depth).

Return type:

list of scuq.quantities.Quantity

Notes

TEMField deliberately does not approach factor * e_target as CW: the EUT is already in the test volume. Amplifier linearity is assessed later from the actual AM waveform while its level is increased from this safe starting point.

set_am_ramp_level(actor_level)[source]

Apply one protected signal-generator level during the AM ramp.

read_field()[source]

Return the current mapped three-axis field-probe reading.

leveling_succeeded()[source]

Return whether the most recent leveling operation converged.

get_waveform()[source]
do_measurement(f)[source]
quit_measurement()[source]
stdUserInterruptHandler(dct, ignorelist='')[source]