mpylab.env.tem.calibration_geometry module¶
Geometry helpers for TEM/GTEM calibration and verification planes.
- class mpylab.env.tem.calibration_geometry.CalibrationPlane(name: str, z: Quantity, h: Quantity, points: tuple[CalibrationPoint, ...] = (), width: Quantity | None = None, height: Quantity | None = None, center: CalibrationPoint | None = None)
Bases:
objectCalibration or verification x-y plane at a fixed cell position.
- Parameters:
name (str) – Stable identifier used in measurement history and selection output.
z (Quantity) – Longitudinal cell coordinate in meters.
h (Quantity) – Septum height at
zin meters.points (tuple of CalibrationPoint, optional) – Ordered measurement positions in the x-y plane.
width (Quantity, optional) – Full dimensions of a generated uniform area.
height (Quantity, optional) – Full dimensions of a generated uniform area.
center (CalibrationPoint, optional) – Geometric center of a generated uniform area.
Notes
heightis the vertical size of the plane, whereashis the septum height used to locate the plane in the GTEM cell.- center: CalibrationPoint | None = None
- classmethod from_h(name, h, geometry, points=())
Create a plane at a specified septum height.
- Parameters:
name (str) – Stable plane identifier.
h (float or Quantity) – Septum height in meters.
geometry (GTEMGeometry) – Fixed cell geometry used to derive longitudinal coordinate
z.points (iterable, optional) –
CalibrationPointobjects or(x, y)and(x, y, label)tuples. Numeric coordinates denote meters.
- Returns:
Immutable plane with normalized coordinates.
- Return type:
CalibrationPlane
- classmethod from_uniform_area_h(name, h, width, height, geometry, center=(0, 0))
Create a uniform-area plane from its size according to IEC 61000-4-20.
widthandheightare the full dimensions of the uniform area, not the point spacing. Areas up to 0.5 m x 0.5 m use four corners plus the center point. Larger or non-tabulated areas use the smallest 0.5 m grid that covers the area.- Parameters:
name (str) – Stable plane identifier.
h (float or Quantity) – Septum height locating the plane, in meters.
width (float or Quantity) – Full horizontal and vertical dimensions of the uniform area.
height (float or Quantity) – Full horizontal and vertical dimensions of the uniform area.
geometry (GTEMGeometry) – Fixed cell geometry used to derive longitudinal coordinate
z.center (CalibrationPoint or tuple, optional) – Area center as a point or
(x, y)coordinates in meters.
- Returns:
Plane containing the generated ordered measurement points.
- Return type:
CalibrationPlane
- Raises:
ValueError – If either area dimension is not positive.
- classmethod from_uniform_area_z(name, z, width, height, geometry, center=(0, 0))
Create a uniform-area plane at a longitudinal coordinate.
- Parameters:
name (str) – Stable plane identifier.
z (float or Quantity) – Longitudinal coordinate locating the plane, in meters.
width (float or Quantity) – Full horizontal and vertical dimensions of the uniform area.
height (float or Quantity) – Full horizontal and vertical dimensions of the uniform area.
geometry (GTEMGeometry) – Fixed cell geometry used to derive septum height
h.center (CalibrationPoint or tuple, optional) – Area center as a point or
(x, y)coordinates in meters.
- Returns:
Plane containing the generated ordered measurement points.
- Return type:
CalibrationPlane
- Raises:
ValueError – If either area dimension is not positive.
- classmethod from_z(name, z, geometry, points=())
Create a plane at a longitudinal coordinate.
- Parameters:
name (str) – Stable plane identifier.
z (float or Quantity) – Longitudinal coordinate in meters.
geometry (GTEMGeometry) – Fixed cell geometry used to derive septum height
h.points (iterable, optional) –
CalibrationPointobjects or(x, y)and(x, y, label)tuples. Numeric coordinates denote meters.
- Returns:
Immutable plane with normalized coordinates.
- Return type:
CalibrationPlane
- h: Quantity
- height: Quantity | None = None
- name: str
- points: tuple[CalibrationPoint, ...] = ()
- width: Quantity | None = None
- z: Quantity
- class mpylab.env.tem.calibration_geometry.CalibrationPlaneSelection(mode: str, target_h: Quantity, plane: CalibrationPlane | None = None, lower: CalibrationPlane | None = None, upper: CalibrationPlane | None = None, fraction: float | None = None)
Bases:
objectResult of selecting calibration data for a target height.
- Parameters:
mode (str) – One of
exact,nearest, orinterpolate.target_h (Quantity) – Requested septum height in meters.
plane (CalibrationPlane, optional) – Selected plane for exact or nearest selection.
lower (CalibrationPlane, optional) – Bracketing planes for interpolation.
upper (CalibrationPlane, optional) – Bracketing planes for interpolation.
fraction (float, optional) – Linear height fraction from
lowertoupper.
- fraction: float | None = None
- lower: CalibrationPlane | None = None
- mode: str
- plane: CalibrationPlane | None = None
- target_h: Quantity
- upper: CalibrationPlane | None = None
- class mpylab.env.tem.calibration_geometry.CalibrationPoint(x: Quantity, y: Quantity, label: str | None = None)
Bases:
objectLabeled point in a calibration or verification x-y plane.
- Parameters:
x (Quantity) – Coordinates in the plane, expressed as lengths.
y (Quantity) – Coordinates in the plane, expressed as lengths.
label (str, optional) – Stable human-readable point identifier.
- classmethod from_values(x, y, label=None)
Create a point and normalize its coordinates to meters.
- Parameters:
x (float or Quantity) – Plane coordinates. Numeric values are interpreted in meters.
y (float or Quantity) – Plane coordinates. Numeric values are interpreted in meters.
label (str, optional) – Stable point identifier.
- Returns:
Normalized immutable point.
- Return type:
CalibrationPoint
- label: str | None = None
- x: Quantity
- y: Quantity
- class mpylab.env.tem.calibration_geometry.GTEMGeometry(height_per_z: float, width_per_z: float | None = None, gap_per_z: float | None = None, characteristic_impedance: float = 50, max_height: Quantity | None = None, type_designation: str | None = None, geometry_heights: tuple[Quantity, ...] = (), geometry_z_positions: tuple[Quantity, ...] = (), delta_z: Quantity | None = None, first_index: int | None = None)
Bases:
objectFixed linear GTEM geometry using
h = height_per_z * z.- Parameters:
height_per_z (float or dimensionless Quantity) – Ratio between septum height
hand longitudinal coordinatez.width_per_z (float or dimensionless Quantity, optional) – Ratio between cell width
aandzused by analytical e0y.gap_per_z (float or dimensionless Quantity, optional) – Ratio between septum gap
gandzused by analytical e0y.characteristic_impedance (float or Quantity, optional) – Cell impedance; its numeric expectation is stored as a float in ohms. The default is 50.
max_height (Quantity, optional) – Maximum septum height, stored in meters.
type_designation (str, optional) – Human-readable cell designation such as
"GTEM 1750".geometry_heights (tuple of Quantity, optional) – Heights used to establish the fixed geometry. They do not define calibration or verification planes.
geometry_z_positions (tuple of Quantity, optional) – Positions derived from
h / height_per_zforgeometry_heights.delta_z (Quantity, optional) – Measured spacing between successive geometry-height stations.
first_index (int, optional) – Index metadata for the first measured station. It does not define an absolute first
zcoordinate and does not enter the slope fit.
- a_from_z(z)
Calculate cell width from a longitudinal coordinate.
- Parameters:
z (float or Quantity) – Longitudinal coordinate. Numeric input is interpreted in meters.
- Returns:
Width
a = width_per_z * zin meters.- Return type:
scuq.quantities.Quantity
- Raises:
ValueError – If
width_per_zis not defined.
- characteristic_impedance: float = 50
- delta_z: Quantity | None = None
- first_index: int | None = None
- classmethod from_height_series(h_max, heights, delta_z, first_index=1, relative_tolerance=0.02, type_designation=None, width_per_z=None, gap_per_z=None, characteristic_impedance=50)
Create GTEM geometry from measured heights at equidistant z positions.
The height series defines the fixed cell geometry only. It does not define calibration or verification planes. For GTEM cells this helper constructs the zero-offset model
h = k * zwhile derivingkonly from measured height differences at the known spacing.- Parameters:
h_max (float, Quantity, or str) – Maximum height in meters, or a GTEM type designation whose numeric component specifies millimeters.
heights (sequence of float or Quantity) – At least two positive, strictly increasing measured heights.
delta_z (float or Quantity) – Fixed measured distance between successive height stations.
first_index (int, optional) – Index metadata for the first station. It does not establish an absolute
zorigin or contribute to the fitted slope.relative_tolerance (float, optional) – Maximum relative deviation of each adjacent height-difference slope from their mean.
type_designation (str, optional) – Human-readable cell designation. It defaults to
h_maxwhen that argument is a string.width_per_z (float or dimensionless Quantity, optional) – Cell-width to longitudinal-position ratio.
gap_per_z (float or dimensionless Quantity, optional) – Septum-gap to longitudinal-position ratio.
characteristic_impedance (float or Quantity, optional) – Characteristic impedance. Numeric input is interpreted in ohms; a quantity must have an electrical-resistance dimension.
- Returns:
Geometry whose
height_per_zis the mean of the adjacent height differences divided bydelta_z.- Return type:
GTEMGeometry
- Raises:
ValueError – If spacing, indices, heights, or adjacent slopes are invalid.
- classmethod from_max_height(max_height, z_at_max_height, type_designation=None, width_per_z=None, gap_per_z=None, characteristic_impedance=50)
Create geometry from maximum height and its longitudinal position.
- Parameters:
max_height (float or Quantity) – Maximum septum height. Numeric input is interpreted in meters.
z_at_max_height (float or Quantity) – Longitudinal coordinate at
max_height, in meters.type_designation (str, optional) – Human-readable GTEM designation.
width_per_z (float or dimensionless Quantity, optional) – Cell-width to longitudinal-position ratio.
gap_per_z (float or dimensionless Quantity, optional) – Septum-gap to longitudinal-position ratio.
characteristic_impedance (float or Quantity, optional) – Characteristic impedance. Numeric input is interpreted in ohms; a quantity must have an electrical-resistance dimension.
- Returns:
Geometry with
height_per_z = max_height / z_at_max_height.- Return type:
GTEMGeometry
- Raises:
ValueError – If
z_at_max_heightis zero.
- classmethod from_type_designation(type_designation, z_at_max_height, width_per_z=None, gap_per_z=None, characteristic_impedance=50)
Create geometry using a maximum height encoded in its designation.
- Parameters:
type_designation (str) – Designation such as
"GTEM 1750"; its numeric part is treated as the maximum height in millimeters.z_at_max_height (float or Quantity) – Longitudinal coordinate at maximum height, in meters.
width_per_z (float or dimensionless Quantity, optional) – Cell-width to longitudinal-position ratio.
gap_per_z (float or dimensionless Quantity, optional) – Septum-gap to longitudinal-position ratio.
characteristic_impedance (float or Quantity, optional) – Characteristic impedance. Numeric input is interpreted in ohms; a quantity must have an electrical-resistance dimension.
- Returns:
Geometry derived from the parsed maximum height.
- Return type:
GTEMGeometry
- g_from_z(z)
Calculate septum gap from a longitudinal coordinate.
- Parameters:
z (float or Quantity) – Longitudinal coordinate. Numeric input is interpreted in meters.
- Returns:
Gap
g = gap_per_z * zin meters.- Return type:
scuq.quantities.Quantity
- Raises:
ValueError – If
gap_per_zis not defined.
- gap_per_z: float | None = None
- geometry_heights: tuple[Quantity, ...] = ()
- geometry_z_positions: tuple[Quantity, ...] = ()
- h_from_z(z)
Calculate septum height from a longitudinal coordinate.
- Parameters:
z (float or Quantity) – Longitudinal coordinate. Numeric input is interpreted in meters.
- Returns:
Height
h = height_per_z * zin meters.- Return type:
scuq.quantities.Quantity
- height_per_z: float
- max_height: Quantity | None = None
- type_designation: str | None = None
- width_per_z: float | None = None
- z_from_h(h)
Calculate longitudinal coordinate from septum height.
- Parameters:
h (float or Quantity) – Septum height. Numeric input is interpreted in meters.
- Returns:
Coordinate
z = h / height_per_zin meters.- Return type:
scuq.quantities.Quantity
- Raises:
ValueError – If
height_per_zis zero.
- mpylab.env.tem.calibration_geometry.gtem_geometry_from_config(config)
Create a
GTEMGeometryfrom script configuration data.- Parameters:
config (GTEMGeometry or dict) – Existing geometry or mapping using one of three representations:
heightswithdelta_z,z_at_max_heightwith a maximum height, or the direct ratioheight_per_z. Optional analytical parameters arewidth_per_z,gap_per_z, andcharacteristic_impedance.- Returns:
Normalized fixed geometry.
- Return type:
GTEMGeometry
- Raises:
TypeError – If
configis neither a geometry nor a mapping.ValueError – If the geometry kind or required representation fields are invalid.
- mpylab.env.tem.calibration_geometry.parse_gtem_max_height(type_designation)
Parse the maximum height from a GTEM type designation.
"GTEM 1750"is interpreted as a maximum height of 1750 mm.- Parameters:
type_designation (str) – Designation containing a numeric maximum height in millimeters.
- Returns:
Maximum cell height reduced to meters.
- Return type:
scuq.quantities.Quantity
- Raises:
ValueError – If the designation contains no numeric value.
- mpylab.env.tem.calibration_geometry.same_calibration_plane(left, right, tolerance=1e-09)
Compare two named calibration-plane definitions.
- Parameters:
left (CalibrationPlane) – Plane definitions to compare.
right (CalibrationPlane) – Plane definitions to compare.
tolerance (float, optional) – Absolute tolerance in meters for positions and dimensions.
- Returns:
True when names, positions, dimensions, centers, and ordered labeled points agree within
tolerance.- Return type:
bool
- mpylab.env.tem.calibration_geometry.same_gtem_geometry(left, right, tolerance=1e-09)
Compare the physical parameters of two fixed GTEM geometries.
- Parameters:
left (GTEMGeometry or dict) – Geometries or accepted configuration mappings to compare.
right (GTEMGeometry or dict) – Geometries or accepted configuration mappings to compare.
tolerance (float, optional) – Absolute comparison tolerance. Lengths use meters; ratios and characteristic impedance use their stored numeric values.
- Returns:
True when height, width and gap ratios, characteristic impedance, and maximum height agree within
tolerance.- Return type:
bool
Notes
Descriptive metadata and the original height-series samples are not part of this physical-equivalence comparison.
- mpylab.env.tem.calibration_geometry.select_calibration_plane(planes: Iterable[CalibrationPlane], target_h, on_missing='error', tolerance=1e-09)
Select or bracket a calibration plane for a requested height.
on_missingcontrols behavior when no plane at exactlytarget_his available:"error"raisesValueError."nearest"returns the closest plane."interpolate"returns lower/upper planes and the linear fraction between them.
- Parameters:
planes (iterable of CalibrationPlane) – Available planes. Input order is irrelevant; selection sorts by
h.target_h (float or Quantity) – Requested septum height. Numeric input is interpreted in meters.
on_missing ({"error", "nearest", "interpolate"}, optional) – Policy used when no plane matches
target_hwithintolerance.tolerance (float, optional) – Absolute height tolerance in meters for an exact match.
- Returns:
Exact or nearest selection, or bracketing planes and interpolation fraction. This function selects geometry only; it does not interpolate measured values itself.
- Return type:
CalibrationPlaneSelection
- Raises:
ValueError – If no planes exist, exact selection is required but unavailable, the policy is unsupported, or interpolation would extrapolate beyond the available height range.
- mpylab.env.tem.calibration_geometry.uniform_area_from_config(config, geometry)
Create a norm-oriented uniform-area plane from configuration data.
- Parameters:
config (CalibrationPlane or dict) – Existing plane or mapping containing
name, fullwidthandheight, and exactly one position key,horz. Numeric lengths are interpreted in meters.centerdefaults to(0, 0).geometry (GTEMGeometry) – Fixed cell geometry used to convert between
handz.
- Returns:
Plane populated with the norm-oriented uniform-area points.
- Return type:
CalibrationPlane
- Raises:
TypeError – If
configis neither a plane nor a mapping.ValueError – If required dimensions, the name, or the plane position are missing.