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.Protocol[source]¶
Bases:
GenericBase class for protocol classes.
Protocol classes are defined as:
class Proto(Protocol): def meth(self) -> int: ...
Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing).
For example:
class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check
See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:
class GenProto[T](Protocol): def meth(self) -> T: ...
- class conducted_emission_mpylab.ce.TextIO[source]¶
-
Typed version of the return of open() in text mode.
- class conducted_emission_mpylab.ce.Any(*args, **kwargs)[source]¶
Bases:
objectSpecial type indicating an unconstrained type.
Any is compatible with every type.
Any assumed to have all methods.
All values assumed to be instances of Any.
Note that all the above statements are true from the point of view of static type checkers. At runtime, Any should not be used with instance checks.
- conducted_emission_mpylab.ce.from_quantity(tounit, obj)[source]¶
Backward-compatible convenience wrapper around UConv.from_quantity.
- class conducted_emission_mpylab.ce.MGraph(fname_or_data=None, themap=None, SearchPaths=None)[source]¶
Bases:
GraphMeasurement graph class based of
Graph. See there for the argument of the__init__()method.- get_gname(name: str) str | None[source]¶
Tries to get the name of the device name in the dot file. Returns self.map[name] if name is key. Returns name if name is in self.bimap. Else returns None.
- get_path_correction(start, end, unit=None)[source]¶
Get the correction (S21) from start to end. If unit is None, an AMPLITUDERATIO is returned. unit has to be AMPLITUDERATIO or POWERRATIO (from mpylab.tools.aunits)
- get_path_corrections(start, end, unit=None)[source]¶
Returns a dict with the corrections for all edges from start to end. unit can be
mpylab.tools.aunits.AMPLITUDERATIOormpylab.tools.aunits.POWERRATIO. If unit is None,mpylab.tools.aunits.AMPLITUDERATIOis used.The key ‘total’ gives the total correction.
All corrections are
scuq.quantities.Quantityobjects.
- EvaluateConditions(doAction=True)[source]¶
Set key isActice in nodes argument depending on the condition given in the graph.
If doAction is True an action act defined in the edge attributed is executed using exec str(act) if the condition evaluates to True.
The condition may refer to variables in the callers namespace, e.g. ‘f’.
- CreateDevices()[source]¶
Create instances of the devices found in the graph. Should be called once after creating the graph instance.
Sets attribute active = True for all nodes and edges
Reads the ini-file (if ini atrib is present)
Creates the device instances of all nodes and save the variable in the nodes dict (nodes[key][‘inst’])
Returns a dict with keys from the graphs nodes names and val are the device instances Can be used to create local references like so:
for k,v in ddict.items(): globals()['k']=v
- NBTrigger(lst)[source]¶
Triggers all devices in list if possible (node exists, has dev instance, is active, and has Trigger method).
Returns dict: keys->list items, vals->None or return val from Trigger method
- CmdDevices(IgnoreInactive, cmd, *args)[source]¶
Tries to send cmd(*arg) to all devices in graph.
If IgnoreInactice is True, only active devices are used.
Returns the sum of all status codes returned from the called methods, i.e. a return value of zero indicates success.
Return error codes for all devices are stored in self.nodes[str(n)][‘ret’] and self.nodes[str(n)][‘err’].
- Init_Devices(IgnoreInactive=False)[source]¶
Initialize all device.
Raises
UserWarningif a device fails to initialize.If IgnoreInactive = False (default), all devices are initialized, else only active devices are initialized.
- Quit_Devices(IgnoreInactive=False)[source]¶
Quit all devices using
CmdDevices().Input: IgnoreInactive=False
Return: return val of
CmdDevices()
- SetFreq_Devices(freq, IgnoreInactive=True)[source]¶
Set frequency on all (optionally active) devices and return min/max.
- ConfReceivers(conf, IgnoreInactive=True)[source]¶
Configures all SA/Receivers in Graph.
Input:
conf: a dict with keys from
(‘rbw’, ‘vbw’, ‘att’, ‘preamp’, ‘reflevel’, ‘detector’, ‘tracemode’, ‘sweeptime’, ‘sweepcount’, ‘span’)
and values for these parameters.
If a key, val pair exists in conf, we try to set this parameter. If the a key is not in conf, or if the value is missing (None), we try to read the val from the instrument.
IgnoreInactive: flag to ignore devices marked as inactive
Return:
rdict: a dict of dicts with rdict[node][key] = val mapping
- Zero_Devices(IgnoreInactive=True)[source]¶
Zero all devices using CmdDevices Input: IgnoreInactive=True Return: return val of CmdDevices
- RFOn_Devices(IgnoreInactive=True)[source]¶
RFOn all devices using CmdDevices Input: IgnoreInactive=True Return: return val of CmdDevices
- RFOff_Devices(IgnoreInactive=False)[source]¶
RFOff all devices using CmdDevices Input: IgnoreInactive=False Return: return val of CmdDevices
- Trigger_Devices(IgnoreInactive=True)[source]¶
Trigger all devices using CmdDevices Input: IgnoreInactive=True Return: return val of CmdDevices
- getBatteryLow_Devices(IgnoreInactive=True)[source]¶
Get a list of all devices in the graph with a low battery state Input: IgnoreInactive=True Return: list of nodes with low battery state
- GetAntennaEfficiency(node)[source]¶
Get the antenna efficiency of an antenna connected to node.
- Input:
node, the node to which the antenna is connected. Typically this is a ‘virtual’ node in the graph, e.g. ‘ant’ to which the real antennas are connected.
- Return:
antenna efficiency of the first active , real antenna connected to ‘node’ None is returned if no antenna is found
- AmplifierProtect(start, end, startlevel, sg_unit=<scuq.units.AlternateUnit object>, typ='save')[source]¶
Check amplifier safety margins along all active paths.
- conducted_emission_mpylab.ce.fstrcmp(a, possibilities, cutoff=0.0, ignorecase=True, use_rmcp=True)[source]¶
fstrcmp function.
- class conducted_emission_mpylab.ce.Quantity(unit, value)[source]¶
Bases:
objectBase class that provides an interface to model quantities. arithmetic.RationalNumber) are automatically transformed to an dimensionless quantity if the operations are performed on them. This also applies if a quantity is the right operand of the numeric types stated above.
- __init__(unit, value)[source]¶
Default constructor.
- Parameters:
unit – The corresponding unit.
value – The value assigned
instances of ucomponents.UncertainInput as values.
- reduce_to(unit)[source]¶
Return this quantity expressed in
unit.If the target unit has the same physical dimension as this quantity’s current unit, the numeric value is converted with the corresponding unit operator and a new
Quantityin the target unit is returned. If the target unit is dimensionally incompatible, this quantity is returned unchanged.This is an explicit unit conversion and is therefore performed consistently regardless of the global strict-mode setting. Strict mode only affects implicit compatibility checks, such as addition, subtraction, comparisons, and
get_value().
- get_value(unit)[source]¶
Get the absolute value of the quantity using the specified unit.
- Parameters:
unit – The unit in which the quantity should be expressed in.
- Returns:
The absolute value of the quantity. comparable.
- get_default_unit()[source]¶
Get the unit that is used commonly for this quantity.
- Returns:
The corresponding unit.
- is_dimensionless()[source]¶
Check if this quantity copatible to dimensionless.
- Returns:
True, if the unit assigned is comparable to units.ONE.
- is_dimensionless_strict()[source]¶
Check if this quantity is dimensionless (strict).
- Returns:
True, if the unit assigned IS units.ONE.
- static value_of(other)[source]¶
Factory for generating quantities.
- Parameters:
other – A quantity, or another value.
- Returns:
A Quantity. If the argument is a quantity this method returns it. If the argument is a numeric value, this method generates a dimensionless quantity having the argument as value. instances of ucomponents.UncertainInput as values.
- arccos()[source]¶
This method provides the broadcast interface for numpy.arccos.
- Returns:
The inverse Cosine of this quantity. If the unit assigned is not dimensionless.
- arccosh()[source]¶
This method provides the broadcast interface for numpy.arccosh.
- Returns:
The inverse hyperbolic Cosine of this quantity. If the unit assigned is not dimensionless.
- arcsin()[source]¶
This method provides the broadcast interface for numpy.arcsin.
- Returns:
The inverse Sine of this quantity. If the unit assigned is not dimensionless.
- arcsinh()[source]¶
This method provides the broadcast interface for numpy.arcsinh.
- Returns:
The inverse hyperbolic Sine of this quantity. If the unit assigned is not dimensionless.
- arctan()[source]¶
This method provides the broadcast interface for numpy.arctan.
- Returns:
The inverse Tangent of this quantity. If the unit assigned is not dimensionless.
- arctanh()[source]¶
This method provides the broadcast interface for numpy.arctanh.
- Returns:
The inverse hyperbolic Tangent of this quantity. If the unit assigned is not dimensionless.
- cos()[source]¶
This method provides the broadcast interface for numpy.cos.
- Returns:
The Cosine of this quantity. If the unit assigned is not dimensionless.
- cosh()[source]¶
This method provides the broadcast interface for numpy.cosh.
- Returns:
The hyperbolic Cosine of this quantity. If the unit assigned is not dimensionless.
- tan()[source]¶
This method provides the broadcast interface for numpy.tan.
- Returns:
The Tangent of this quantity. If the unit assigned is not dimensionless.
- tanh()[source]¶
This method provides the broadcast interface for numpy.tanh.
- Returns:
The hyperbolic Tangent of this quantity. If the unit assigned is not dimensionless.
- log10()[source]¶
This method provides the broadcast interface for numpy.log10.
- Returns:
The decadic Logarithm of this quantity. If the unit assigned is not dimensionless.
- log2()[source]¶
This method provides the broadcast interface for numpy.log2.
- Returns:
The binary logarithm of this quantity. If the unit assigned is not dimensionless.
- sin()[source]¶
This method provides the broadcast interface for numpy.sin.
- Returns:
The Sine of this quantity. If the unit assigned is not dimensionless.
- sinh()[source]¶
This method provides the broadcast interface for numpy.sinh.
- Returns:
The hyperbolic Sine of this quantity. If the unit assigned is not dimensionless.
- sqrt()[source]¶
This method provides the broadcast interface for numpy.sqrt.
- Returns:
The Square Root of this quantity.
- square()[source]¶
This method provides the broadcast interface for numpy.sqrt.
- Returns:
The Square Root of this quantity.
- fabs()[source]¶
This method provides the broadcast interface for numpy.fabs.
- Returns:
The absolute value of this quantity.
- absolute()[source]¶
This method provides the broadcast interface for numpy.absolute.
- Returns:
The absolute value of this quantity.
- exp()[source]¶
This method provides the broadcast interface for numpy.exp.
- Returns:
The Exponential of this quantity. If the unit assigned is not dimensionless.
- log()[source]¶
This method provides the broadcast interface for numpy.log.
- Returns:
The Natural Logarithm of this quantity. If the unit assigned is not dimensionless.
- arctan2(other)[source]¶
This method provides the broadcast interface for numpy.arctan2.
- Parameters:
other – Another instance of Quantity.
- Returns:
The inverse two-argument tangent of the arguments. If the unit assigned is not dimensionless.
- hypot(other)[source]¶
This method provides the broadcast interface for hypothenusis.
- Parameters:
other – Another instance of Quantity.
- Returns:
The hypothenusis of the arguments.
- conjugate()[source]¶
This method provides the broadcast interface for numpy.conjugate.
- Returns:
This quantity.
- static set_strict(bValue=True)[source]¶
Turn on/off the strict evaluation of quantities. This will affect any quantities calculation beyond this point.
- Parameters:
bValue – True or False
- 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 conducted emission measurement
- Parameters:
dot – filename, file-like object or data; the graph dot file
names – dict; maps internal used names ‘eut’, ‘lisn’, ‘rec’ to the names in dot file
searchpaths – list; search paths for ini-files and data-files
paths – list or tuple; the different measurent paths, e.g. “(‘L’, ‘N’)”, or “(‘L1’, ‘L2’, ‘L3’, ‘N’)”
freqs – list; the frequencies
limitline – callable or None; gives the actual limit at freq
dut_description – str; description of the device under test (DUT)
- Returns:
None
- 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]¶
Perform a pre scan (PEAK or AVERAGE-Detector) conducted emission measurement
- Parameters:
paths – list or tuple; e.g. “(‘L, ‘N’)”, or “(‘L1’, ‘L2’, ‘L3’, ‘N’)”
detector – str; either ‘PEAK’ or ‘AVERAGE’
- Returns:
None
- 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]¶
Perform pre scan for one frequency
- Parameters:
freq – float; the frequency
- Returns:
data; scuq object with pre scan data for this frequency
- 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]¶
Perform a final conducted emission measurement
QPEAK measurements are performed at frequencies and paths where prescan is larger that limit - margin (on dB scale) :param paths: list or tuple; e.g. [‘L’, ‘N’] :param margin: float; dB value below limit :return: None
- 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
- 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