API Modules¶
This page is generated from src/mpylab.
mpylab.device¶
mpylab.device.amp_ar_25s1g4¶
mpylab.device.amp_ar_25s1g4 module.
- class mpylab.device.amp_ar_25s1g4.AMPLIFIER(**kw)¶
AMPLIFIER class.
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None)¶
Init method.
- Operate()¶
Switch to mode ‘Operate’.
Calls SetState.
- POff()¶
Switch to mode ‘Power Off’.
Calls SetState.
- POn()¶
Switch to mode ‘Power On’.
Calls SetState.
- Quit()¶
Quit method.
- STATES = ('Operate', 'Standby', 'POn', 'POff')¶
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetState(state)¶
Switch the state of the amplifier (in remote operation).
state: string containig the state to switch to. The state is compared to the class variable STATES which is tuple of possible states. This comparison is made by meand of tools.Configuration.fstrcmp.
Returns 0 if succesfull or an error code < 0.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- Standby()¶
Switch to mode ‘Standby’.
Calls SetState.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.amp_ar_25s1g4.main()¶
main function.
mpylab.device.amp_blma_1018_100¶
mpylab.device.amp_blma_1018_100 module.
- class mpylab.device.amp_blma_1018_100.AMPLIFIER(**kw)¶
AMPLIFIER class.
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None)¶
Init method.
- Operate()¶
Switch to mode ‘Operate’.
Calls SetState.
- POff()¶
Switch to mode ‘Power Off’.
Calls SetState.
- POn()¶
Switch to mode ‘Power On’.
Calls SetState.
- Quit()¶
Quit method.
- STATES = ('Operate', 'Standby', 'POn', 'POff')¶
- SetFreq(freq)¶
SetFreq method.
- SetState(state)¶
Switch the state of the amplifier (in remote operation).
state: string containig the state to switch to. The state is compared to the class variable STATES which is tuple of possible states. This comparison is made by meand of tools.Configuration.fstrcmp.
Returns 0 if succesfull or an error code < 0.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- Standby()¶
Switch to mode ‘Standby’.
Calls SetState.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.amp_blma_1018_100.main()¶
main function.
mpylab.device.amp_blwa_0810_100¶
mpylab.device.amp_blwa_0810_100 module.
- class mpylab.device.amp_blwa_0810_100.AMPLIFIER(**kw)¶
AMPLIFIER class.
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None)¶
Init method.
- Operate()¶
Switch to mode ‘Operate’.
Calls SetState.
- POff()¶
Switch to mode ‘Power Off’.
Calls SetState.
- POn()¶
Switch to mode ‘Power On’.
Calls SetState.
- Quit()¶
Quit method.
- STATES = ('Operate', 'Standby', 'POn', 'POff')¶
- SetFreq(freq)¶
SetFreq method.
- SetState(state)¶
Switch the state of the amplifier (in remote operation).
state: string containig the state to switch to. The state is compared to the class variable STATES which is tuple of possible states. This comparison is made by meand of tools.Configuration.fstrcmp.
Returns 0 if succesfull or an error code < 0.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- Standby()¶
Switch to mode ‘Standby’.
Calls SetState.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.amp_blwa_0810_100.main()¶
main function.
mpylab.device.amp_cba_1g_030d¶
mpylab.device.amp_cba_1g_030d module.
- class mpylab.device.amp_cba_1g_030d.AMPLIFIER(**kw)¶
AMPLIFIER class.
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None)¶
Init method.
- Operate()¶
Switch to mode ‘Operate’.
Calls SetState.
- POff()¶
Switch to mode ‘Power Off’.
Calls SetState.
- POn()¶
Switch to mode ‘Power On’.
Calls SetState.
- Quit()¶
Quit method.
- STATES = ('Operate', 'Standby', 'POn', 'POff')¶
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetState(state)¶
Switch the state of the amplifier (in remote operation).
state: string containig the state to switch to. The state is compared to the class variable STATES which is tuple of possible states. This comparison is made by meand of tools.Configuration.fstrcmp.
Returns 0 if succesfull or an error code < 0.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- Standby()¶
Switch to mode ‘Standby’.
Calls SetState.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.amp_cba_1g_030d.main()¶
main function.
mpylab.device.amp_ifi_smx25¶
mpylab.device.amp_ifi_smx25 module.
- class mpylab.device.amp_ifi_smx25.AMPLIFIER(**kw)¶
AMPLIFIER class.
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None)¶
Init method.
- Operate()¶
Switch to mode ‘Operate’.
Calls SetState.
- POff()¶
Switch to mode ‘Power Off’.
Calls SetState.
- POn()¶
Switch to mode ‘Power On’.
Calls SetState.
- Quit()¶
Quit method.
- STATES = ('Operate', 'Standby', 'POn', 'POff')¶
- SetFreq(freq)¶
SetFreq method.
- SetState(state)¶
Switch the state of the amplifier (in remote operation).
state: string containig the state to switch to. The state is compared to the class variable STATES which is tuple of possible states. This comparison is made by meand of tools.Configuration.fstrcmp.
Returns 0 if succesfull or an error code < 0.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- Standby()¶
Switch to mode ‘Standby’.
Calls SetState.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.amp_ifi_smx25.main()¶
main function.
mpylab.device.amplifier¶
mpylab.device.amplifier module.
- class mpylab.device.amplifier.AMPLIFIER(SearchPaths=None)¶
Child class for all py-drivers for amplifiers The parent class is NPORT
This class is to be used for all passive amplifiers (no remote control). The class adds the methods ‘Operate’, ‘Standby’, ‘Pon’, ‘POff’ and ‘SetState’ to NPORT to complete the AMPLIFIER API.
The class is base class for all drivers of remote controlled amplifies.
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None, ignore_bus=False)¶
Init method.
- Operate()¶
Switch to mode ‘Operate’.
Calls SetState.
- POff()¶
Switch to mode ‘Power Off’.
Calls SetState.
- POn()¶
Switch to mode ‘Power On’.
Calls SetState.
- Quit()¶
Quit method.
- STATES = ('Operate', 'Standby', 'POn', 'POff')¶
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetState(state)¶
Switch the state of the amplifier (in remote operation).
state: string containig the state to switch to. The state is compared to the class variable STATES which is tuple of possible states. This comparison is made by meand of tools.Configuration.fstrcmp.
Returns 0 if succesfull or an error code < 0.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- Standby()¶
Switch to mode ‘Standby’.
Calls SetState.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.amplifier.main()¶
main function.
mpylab.device.amplifier_ui¶
Graphical test utility for amplifier drivers.
- class mpylab.device.amplifier_ui.AmplifierWidget(*args: Any, **kwargs: Any)¶
N-port style amplifier UI with guarded active-state controls.
- closeEvent(event)¶
- log_message(message)¶
Append one timestamped line to the log tab.
- on_export_csv_clicked()¶
Export the currently plotted rows to a CSV file.
- on_get_data_clicked()¶
Fetch one data point for the selected channel and frequency.
- on_init_clicked()¶
Select driver from INI, initialize it, and refresh UI state.
- on_load_ini_clicked()¶
Load INI text from a file into the editor.
- on_operate_clicked()¶
Ask for confirmation and run guarded Operate command.
- on_plot_clicked()¶
Acquire a sweep and plot values over the selected frequency range.
- on_save_ini_clicked()¶
Save current INI editor text to a file.
- on_set_freq_clicked(freq=None)¶
Set frequency from UI control or provided value.
- on_smoke_clicked()¶
Run a compact end-to-end smoke test and show textual output.
- refresh_status()¶
Query device status and update all status widgets.
- mpylab.device.amplifier_ui.UI¶
alias of
AmplifierWidget
- mpylab.device.amplifier_ui.main(argv=None)¶
Start the standalone amplifier UI test utility.
mpylab.device.amplifier_virtual¶
Virtual amplifier driver for UI and API tests.
- class mpylab.device.amplifier_virtual.AMPLIFIER(**kw)¶
Amplifier model with interpolated data and explicit state tracking.
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetState()¶
Return current virtual amplifier state.
- GetVirtual()¶
Return virtual-mode flag.
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize virtual amplifier state and force virtual mode on.
- Operate()¶
Switch amplifier to operate mode.
- POff()¶
Switch amplifier power off.
- POn()¶
Switch amplifier power on.
- Quit()¶
Put amplifier into standby and return status.
- STATES = ('Operate', 'Standby', 'POn', 'POff')¶
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetState(state)¶
Set amplifier state using normalized aliases for common commands.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- Standby()¶
Switch amplifier to standby mode.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
mpylab.device.communication_debug¶
This is the mpylab.device.communication_debug module.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.device.communication_debug.CommunicationDebug(idn, fout=None, fin=None)¶
CommunicationDebug class.
- query(cmd, tmpl=None, send_opc=False)¶
- Parameters:
cmd – str, command to send
tmpl – str, a re pattern for re.match or None
send_opc – bool, append
; *OPC?to a non-query command
- Returns:
str or dict or None: dict with the parsed result
See read function for more explanation regarding the re pattern
- read(tmpl=None)¶
- Parameters:
tmpl – str, a re pattern for re.match or None
- Returns:
str or dict or None: dict with the parsed result or raw result as str or None if no match
- write(cmd)¶
- Parameters:
cmd – str, command to send
- Returns:
int: status code; number of bytes sent or 0
mpylab.device.communication_generic¶
This is the mpylab.device.communication_generic module.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- mpylab.device.communication_generic.generic_query(query_fn, cmd, tmpl=None, send_opc=False)¶
- Parameters:
query_fn – device query function
cmd – str, command to send
tmpl – str, a re pattern for re.match or None
send_opc – bool, append
; *OPC?to a non-query command and return the resulting response (usually ‘1’)
- Returns:
str or dict or None: dict with the parsed result
Safety rule: send_opc=True is only allowed for commands that do not already contain a query marker ‘?’, because
<query>; *OPC?may create multiple responses and is transport- / instrument-dependent.
- mpylab.device.communication_generic.generic_read(read_fn, tmpl=None)¶
- Parameters:
read_fn – device read function
tmpl – str, a re pattern for re.match or None
- Returns:
str or dict or None: dict with the parsed result or raw result as str or None if no match
This is how the pattern works: tmpl = r’Test (?P<dbval>d+) dB’ # d+ matches decimals; here 3 and 0; this is stored with key dbval m = re.match(tmpl, ‘Test 30 dB’) m[‘dbval’] -> ‘30’ # access only one ‘named’ match m.groupdict() -> {‘dbval’: ‘30’} # access all ‘named’ matches
- mpylab.device.communication_generic.generic_write(write_fn, cmd)¶
- Parameters:
write_fn – function to write to the device
cmd – str, command to send
- Returns:
int: status code; number of bytes sent or 0
mpylab.device.communication_gpib¶
This is the mpylab.device.communication_gpib module.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.device.communication_gpib.CommunicationGpib(res_name, lock=None, timeout_s=3, chunk_size=20480, query_delay_s=0, send_end=True, read_term=None, write_term=None)¶
CommunicationGpib class.
- query(cmd, tmpl=None, send_opc=False)¶
- Parameters:
cmd – str, command to send
tmpl – str, a re pattern for re.match or None
send_opc – bool, append
; *OPC?to a non-query command
- Returns:
str or dict or None: dict with the parsed result
See read function for more explanation regarding the re pattern
- read(tmpl=None)¶
- Parameters:
tmpl – str, a re pattern for re.match or None
- Returns:
str or dict or None: dict with the parsed result or raw result as str or None if no match
This is how the pattern works: tmpl = r’Test (?P<dbval>d+) dB’ # d+ matches decimals; here 3 and 0; this is stored with key dbval m = re.match(tmpl, ‘Test 30 dB’) m[‘dbval’] -> ‘30’ # access only one ‘named’ match m.groupdict() -> {‘dbval’: ‘30’} # access all ‘named’ matches
- write(cmd)¶
- Parameters:
cmd – str, command to send
- Returns:
int: status code; number of bytes sent or 0
mpylab.device.communication_prologix¶
This is the mpylab.device.communication_prologix module.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.device.communication_prologix.CommunicationPrologix(ip, port, gpib, bufsize=4096, TXEOL=b'\n', timeout_s=3, send_clr=False, send_ifc=False, encoding='ascii')¶
CommunicationPrologix class.
- close()¶
close method.
- query(cmd, tmpl=None, send_opc=False)¶
- Parameters:
cmd – Command text sent to the instrument.
tmpl – Regex pattern for
generic_queryorNone.send_opc – Append
; *OPC?to non-query commands whenTrue.
- Returns:
Parsed response, raw response, or
None.
- read(tmpl=None)¶
- Parameters:
tmpl – Regex pattern for
generic_readorNone.- Returns:
Parsed response, raw response, or
None.
- write(cmd)¶
- Parameters:
cmd – Command text sent to the instrument.
- Returns:
Number of characters sent for the payload command.
mpylab.device.device¶
Legacy device wrapper and unit-conversion helpers.
- class mpylab.device.device.CONVERT¶
Current converter between compact display units and scuq units.
- c2c(fromunit, tounit, data)¶
Convert values from one unit string to another.
- c2scuq(cunit, data)¶
Convert native values into scuq values and return the scuq unit.
- scuq2c(sunit, cunit, data)¶
Convert scuq values back into the requested native unit.
- units_list = (('dimensionless', <scuq.units.ProductUnit object>, None, 1.0), ('dBm', <scuq.units.AlternateUnit object>, 10.0, 0.001), ('W', <scuq.units.AlternateUnit object>, None, 1.0), ('dBuV', <scuq.units.AlternateUnit object>, 20.0, 1e-06), ('V', <scuq.units.AlternateUnit object>, None, 1.0), ('dB', <scuq.units.AlternateUnit object>, 10.0, 1.0), ('Hz', <scuq.units.AlternateUnit object>, None, 1.0), ('kHz', <scuq.units.AlternateUnit object>, None, 1000.0), ('MHz', <scuq.units.AlternateUnit object>, None, 1000000.0), ('GHz', <scuq.units.AlternateUnit object>, None, 1000000000.0), ('V/m', <scuq.units.ProductUnit object>, None, 1.0), ('dBV/m', <scuq.units.ProductUnit object>, 20.0, 1.0), ('m', <scuq.units.BaseUnit object>, None, 1.0), ('cm', <scuq.units.BaseUnit object>, None, 0.01), ('mm', <scuq.units.BaseUnit object>, None, 0.001), ('deg', <scuq.units.AlternateUnit object>, None, 0.017453292519943295), ('rad', <scuq.units.AlternateUnit object>, None, 1.0), ('steps', <scuq.units.ProductUnit object>, None, 1.0), ('dB/m', <scuq.units.ProductUnit object>, 20.0, 1.0), ('dBi', <scuq.units.AlternateUnit object>, 10.0, 1.0), ('dBd', <scuq.units.AlternateUnit object>, 10.0, 1.64), ('1/m', <scuq.units.ProductUnit object>, None, 1.0), ('A/m', <scuq.units.ProductUnit object>, None, 1.0), ('dBA/m', <scuq.units.ProductUnit object>, 20.0, 1.0), ('W/m2', <scuq.units.ProductUnit object>, None, 1.0), ('dBW/m2', <scuq.units.ProductUnit object>, 10.0, 1.0), ('S/m', <scuq.units.ProductUnit object>, None, 1.0), ('dBS/m', <scuq.units.ProductUnit object>, 20.0, 1.0), ('amplituderatio', <scuq.units.AlternateUnit object>, None, 1.0), ('powerratio', <scuq.units.AlternateUnit object>, None, 1.0), ('sqrtW', <scuq.units.ProductUnit object>, None, 1.0), ('V/m/sqrtW', <scuq.units.ProductUnit object>, None, 1.0))¶
mpylab.device.driver¶
This is the mpylab.device.driver module.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.device.driver.DRIVER(SearchPaths=None)¶
Parent class for all py-drivers.
Beside the common API method for all drivers (see below) this class also implements the following low level methods:
- write(cmd)¶
Write a command to the instrument.
- Parameters:
cmd (string) – the command
- Return type:
status code of the native write operation
- read(tmpl)¶
Read an answer from the instrument instrument.
- Parameters:
tmpl (valid regular expression string) – a template string
- Return type:
the groupdict of the match
Example:
If a device (signal generator in this case) returns
:MODULATION:AM:INTERNAL 80 PCTto indicate a AM modulation depth of 80%, a template string of:MODULATION:AM:INTERNAL (?P<depth>\d+) PCTwill results in a return dict of{"depth": 80}.
- query(cmd, tmpl)¶
Write a command to the instrument and read the answer.
- Parameters:
cmd (string) – the command
tmpl (valid regular expression string) – a template string
- Return type:
the groupdict of the match
For other low level operation you may use the device stored in
self.devdirectly.- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=False)¶
Init the instrument.
Parameters:
ini: filename or file-like object with the initialization parameters for the device. This parameter is handled by
mpylab.tools.Configuration.Configuration()which takes also a configuration template stored inself.conftmpl.channel: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
Return: 0 if sucessful.
- Quit()¶
Quit the instrument.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- class mpylab.device.driver.MethodCall(name: str, args: tuple = (), kwargs: dict = <factory>)¶
Structured method-call action used in command/preset definitions.
- args: tuple = ()¶
- kwargs: dict¶
- name: str¶
- mpylab.device.driver.test_apply_presets_equivalence()¶
Check equivalence between legacy and normalized preset application paths.
- mpylab.device.driver.test_apply_presets_sequences_and_method_calls()¶
Verify sequence presets and string-method-call preset actions.
- mpylab.device.driver.test_do_cmds()¶
Run local integration checks for mixed legacy/new _do_cmds actions.
- mpylab.device.driver.test_dummy_driver()¶
Run a text-level smoke test for base DRIVER initialization flow.
- mpylab.device.driver.test_hybrid()¶
Verify _do_cmds behavior for hybrid template/callable command styles.
- mpylab.device.driver.test_presets_hybrid()¶
Verify legacy-style preset expansion and command rendering behavior.
mpylab.device.driver_base¶
Base abstractions for instrument sessions and TCP socket connections.
- class mpylab.device.driver_base.InstrumentSessionBase¶
Base class for Instrument sessions, to be inherited and specialized by VISAObject and PrologixGPIBObject
- abstractmethod LLO()¶
Issue local-lockout command.
- abstractmethod LOC()¶
Return instrument to local mode.
- abstractmethod clear()¶
Clear session or device buffers.
- abstractmethod close()¶
Close session connection.
- instrID()¶
Returns the *IDN? string
- abstractmethod open()¶
Open session connection.
- abstractmethod query()¶
Write query and return response.
- query_ascii_values(message, converter='f', separator=', ', container=<class 'list'>)¶
Taken from pvisa.
- abstractmethod query_raw_binary()¶
Query raw binary data from instrument.
- abstractmethod spoll()¶
Perform serial poll operation.
- abstract property timeout¶
Return session timeout in seconds.
- abstractmethod wait()¶
Wait for operation completion.
- abstractmethod write()¶
Write command to instrument.
- class mpylab.device.driver_base.TCPSocketConnection(ip_address, port, timeout=2, termination='\n')¶
Opens a TCP socket connection, much like netcat.
- Usage:
s = TCPSocketConnection(‘socket-server.school.edu’, 1111) s.connect() # connects to socket and leaves it open s.send(‘command’) # sends the command through the socket r = s.recv(1000) # receives a message of up to 1000 bytes s.disconnect() # shuts down connection
- connect()¶
Connects to the socket and leaves the connection open. If already connected, does nothing.
- Returns:
socket object.
- connected()¶
Context manager for ensuring that the socket is connected while sending and receiving commands to remote socket. This is safe to use everywhere, even if the socket is previously connected. It can also be nested. This is useful to bundle multiple commands that you desire to be executed together in a single socket connection, for example:
def query(self, query_msg, msg_length=2048): with self.connected(): self._send(self._socket, query_msg) recv = self._recv(self._socket, msg_length) return recv
- disconnect()¶
If connected, disconnects and kills the socket.
- port = None¶
socket server’s port number
- query(query_msg, msg_length=2048)¶
Send query and return received response string.
- recv(msg_length=2048)¶
Receives an ASCII string from the socket server. Auto-connects if necessary.
- Args:
msg_length (int): maximum message length.
- send(value)¶
Sends an ASCII string to the socket server. Auto-connects if necessary.
- Args:
value (str): value to be sent
- startup()¶
Perform protocol-specific startup sequence.
mpylab.device.fieldprobe¶
Base driver for field probe instruments.
- class mpylab.device.fieldprobe.FIELDPROBE(SearchPaths=None)¶
Parent class for all py-drivers for field probes.
The parent class is
mpylab.device.driver.DRIVER.- GetBatteryState()¶
Return reported battery state.
- GetData()¶
Return one measurement data record from the probe.
- GetDataNB(retrigger)¶
Return non-blocking measurement data with optional retrigger.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Query and return the current measurement frequency.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- GetWaveform()¶
Return unsupported marker for waveform acquisition.
- Init(ini=None, channel=None, ignore_bus=False)¶
Init the instrument.
Parameters:
ini: filename or file-like object with the initialization parameters for the device. This parameter is handled by
mpylab.tools.Configuration.Configuration()which takes also a configuration template stored inself.conftmpl.channel: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
Return: 0 if sucessful.
- Quit()¶
Quit the instrument.
- SetFreq(freq)¶
Set measurement frequency and return the confirmed value.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger one measurement cycle.
- Zero(state)¶
Enable or disable zeroing mode.
- conftmpl = {'channel_%d': {'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'nr_of_channels': <class 'int'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'com': <class 'int'>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
mpylab.device.fieldprobe_ui¶
Graphical test utility for field probe drivers.
- class mpylab.device.fieldprobe_ui.DriverTask(*args: Any, **kwargs: Any)¶
Execute one driver callable in a worker thread.
- completed¶
alias of
object
- run()¶
Execute the worker callable and emit completion signals.
- class mpylab.device.fieldprobe_ui.FieldProbeCanvas(*args: Any, **kwargs: Any)¶
Matplotlib canvas for field probe trend data.
- set_grid_enabled(enabled)¶
Enable or disable the trend grid.
- update_plot(history)¶
Redraw Ex/Ey/Ez and
|E|trend data.
- class mpylab.device.fieldprobe_ui.FieldProbeWidget(*args: Any, **kwargs: Any)¶
Thread-aware test UI for field-probe driver implementations.
- closeEvent(event)¶
- log_message(message)¶
Append a timestamped line to the log panel.
- on_channel_changed(channel)¶
Switch active channel to an already initialized channel driver.
- on_clear_trend_clicked()¶
Clear accumulated trend history and reset sample index.
- on_export_csv_clicked()¶
Export trend history to CSV.
- on_grid_toggled(checked)¶
Toggle trend plot grid visibility.
- on_init_clicked()¶
Initialize selected field-probe driver and active channel.
- on_load_ini_clicked()¶
Load INI content from disk into the editor.
- on_measure_clicked()¶
Acquire one blocking field vector measurement.
- on_measure_nb_clicked()¶
Acquire one non-blocking field vector measurement.
- on_poll_timeout()¶
Polling timer callback that requests non-blocking data.
- on_poll_toggled(checked)¶
Enable or disable periodic non-blocking polling.
- on_quit_clicked()¶
Call driver
Quitand reset runtime state.
- on_raw_query_clicked()¶
Execute a raw query command on the active driver.
- on_raw_write_clicked()¶
Execute a raw write command on the active driver.
- on_read_freq_clicked()¶
Read current measurement frequency from the driver.
- on_save_ini_clicked()¶
Save current INI editor content to disk.
- on_set_freq_clicked(freq=None)¶
Set measurement frequency on the active field-probe driver.
- on_smoke_clicked()¶
Run a basic field-probe smoke test and display result lines.
- on_trigger_clicked()¶
Trigger one measurement cycle.
- on_zero_clicked(state)¶
Enable or disable zeroing mode on the active probe.
- refresh_status()¶
Refresh status fields from device getters and cached state.
- mpylab.device.fieldprobe_ui.UI¶
alias of
FieldProbeWidget
- mpylab.device.fieldprobe_ui.main(argv=None)¶
Start the standalone field-probe test utility.
mpylab.device.mc_teseq_stirrer¶
TESEQ stirrer motor-controller driver and low-level serial helper.
- exception mpylab.device.mc_teseq_stirrer.AngleError(new_angle, current_angle, angle_error_threshold)¶
Raised when the stirrer cannot reach the requested target angle.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class mpylab.device.mc_teseq_stirrer.MOTORCONTROLLER¶
Class to control TESEQ stirrer.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetSpeed()¶
Return configured stirrer speed placeholder value.
- GetState()¶
Return error, current angle, and estimated motion direction.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Goto(pos)¶
Move stirrer to an absolute position in degrees.
- Init(ini=None, channel=None)¶
Initialize stirrer hardware and move to known idle state.
- Move(dir)¶
Start clockwise or counter-clockwise motion.
- Quit()¶
Stop the stirrer motor.
- SetSpeed(speed)¶
Set stirrer speed (currently not implemented).
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'gpib': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- class mpylab.device.mc_teseq_stirrer.Stirrer(port_parameters={}, status_retries=10, do_not_open=False)¶
Low-level serial controller for the TESEQ stirrer drive.
- close()¶
Close the serial port and mark drive as uninitialized.
- property current_angle¶
Return current stirrer angle in degrees.
- default_port_parameters = {'baudrate': 9600, 'bytesize': serial.EIGHTBITS, 'dsrdtr': False, 'exclusive': False, 'inter_byte_timeout': None, 'parity': serial.PARITY_NONE, 'port': '/dev/stirrer', 'rtscts': False, 'stopbits': serial.STOPBITS_ONE, 'xonxoff': True}¶
- degpersec = 36¶
- property drive_initialized¶
Return whether the drive is initialized and currently idle.
- property error¶
Return whether the controller reports an error.
- property error_message¶
Return current controller error message.
- goto_angle(angle, direction=1)¶
direction = 1 -> clockwise
- goto_next_angle()¶
Move to the previously stored target angle.
- initialize_drive()¶
Initialize the drive if required and return initialized state.
- lock_message = 'STIRRER Controller V1.50 is locked. Please check SYNC position and restart the controller!'¶
- property motor_running¶
Return whether the motor is currently moving.
- read_termination = ' \r'¶
- run_anti_clockwise()¶
Start continuous counter-clockwise rotation.
- run_clockwise()¶
Start continuous clockwise rotation.
- set_next_angle(angle)¶
Store the next absolute target angle on the controller.
- step_anti_clockwise_by(step)¶
Move counter-clockwise by a relative angle in degrees.
- step_clockwise_by(step)¶
Move clockwise by a relative angle in degrees.
- stirrer_parameters = {'acc': 65, 'maxspeed': 6, 'minspeed': 0.18}¶
- stop_motor()¶
Stop motor movement and return motor-running state.
- write_termination = '\r'¶
- exception mpylab.device.mc_teseq_stirrer.StirrerLockedError¶
Raised when the stirrer controller reports a locked state.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- mpylab.device.mc_teseq_stirrer.main()¶
Run a simple interactive CLI for the stirrer controller.
mpylab.device.mc_virtual¶
Virtual motor controller driver for tests without positioning hardware.
- class mpylab.device.mc_virtual.MOTORCONTROLLER(SearchPaths=None)¶
In-memory motor controller with deterministic angle and speed state.
- GetDescription()¶
Return a virtual identification string.
- GetSpeed()¶
Return virtual angular speed in degrees per second.
- GetState()¶
Return
(error, position_deg, direction).
- GetVirtual()¶
Return whether this driver is virtual.
- Goto(pos)¶
Start moving to an absolute angle in degrees using the configured speed.
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize the virtual motor controller without opening a bus.
- Move(direction)¶
Start continuous movement in direction -1, 0, or 1.
- Quit()¶
Stop virtual motion and quit.
- SetSpeed(speed)¶
Set and return virtual angular speed in degrees per second.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'gpib': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- query(cmd, tmpl=None)¶
Write a virtual command and return the raw or parsed response.
- read(tmpl=None)¶
Return or parse the last virtual command response.
- write(cmd)¶
Handle a small command subset for raw command tests.
- mpylab.device.mc_virtual.main()¶
Run a short virtual motor controller smoke test.
mpylab.device.motorcontroller¶
mpylab.device.motorcontroller module.
- class mpylab.device.motorcontroller.MOTORCONTROLLER(SearchPaths=None)¶
Parent class for all py-drivers for motor controllers.
The parent class is
mpylab.device.driver.DRIVER.- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=False)¶
Init the instrument.
Parameters:
ini: filename or file-like object with the initialization parameters for the device. This parameter is handled by
mpylab.tools.Configuration.Configuration()which takes also a configuration template stored inself.conftmpl.channel: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
Return: 0 if sucessful.
- Quit()¶
Quit the instrument.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'gpib': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
mpylab.device.motorcontroller_ui¶
Graphical test utility for motor controller drivers.
- class mpylab.device.motorcontroller_ui.DriverTask(*args: Any, **kwargs: Any)¶
Execute one driver callable in a worker thread.
- completed¶
alias of
object
- run()¶
Execute the worker callable and emit completion signals.
- class mpylab.device.motorcontroller_ui.MotorControllerWidget(*args: Any, **kwargs: Any)¶
Thread-aware test UI for motor controller drivers.
- closeEvent(event)¶
- log_message(message)¶
Append a timestamped message to the log view.
- on_goto_clicked()¶
Move controller to target absolute angle.
- on_init_clicked()¶
Initialize active motor-controller driver from INI text.
- on_load_ini_clicked()¶
Load INI content from file into the editor.
- on_move_clicked(direction)¶
Start continuous movement in given direction.
- on_poll_state()¶
Polling callback for fast motion-state refresh.
- on_poll_toggled(checked)¶
Enable or disable periodic state polling.
- on_quit_clicked()¶
Stop polling, request stop, and quit driver.
- on_raw_query_clicked()¶
Execute raw query command and append response.
- on_raw_write_clicked()¶
Execute raw write command and append response.
- on_save_ini_clicked()¶
Save current INI editor content to file.
- on_set_speed_clicked()¶
Set motion speed on controller.
- on_smoke_clicked()¶
Run conservative motor-controller smoke test.
- on_stop_clicked()¶
Issue emergency stop by requesting
Move(0).
- refresh_status()¶
Refresh status fields from supported driver getters.
- class mpylab.device.motorcontroller_ui.PositionDial(*args: Any, **kwargs: Any)¶
Simple visual angle and movement direction indicator.
- paintEvent(event)¶
Paint a compact compass-like motor position display.
- set_state(position, direction)¶
Update displayed angle and movement direction.
- mpylab.device.motorcontroller_ui.UI¶
alias of
MotorControllerWidget
- mpylab.device.motorcontroller_ui.main(argv=None)¶
Run the motor controller test UI.
mpylab.device.mpy_exceptions¶
This is mpylab.device.mpy_exceptions:
In diesem Modul werden verschiedene Exceptions definiert welche in dem myp.device Modul verwendet werden.
- exception mpylab.device.mpy_exceptions.DriverImplementedError(message='')¶
DriverImplementedError class.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception mpylab.device.mpy_exceptions.GeneralDriverError(message='')¶
GeneralDriverError class.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception mpylab.device.mpy_exceptions.InitError(message='Before Commands can be executed, the DRIVER.Init method must be called')¶
InitError class.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception mpylab.device.mpy_exceptions.Return_TypesError(message='')¶
Return_TypesError class.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception mpylab.device.mpy_exceptions.ValidateError(message='Validators Error', parameter=None, command=None)¶
ValidateError class.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
mpylab.device.networkanalyzer¶
This is mpylab.device.networkanalyzer
- author:
Christian Albrecht
- license:
GPL-3 or higher
- class mpylab.device.networkanalyzer.NETWORKANALYZER(SearchPaths=None)¶
Parent class of all py-drivers for networkanalyzer analyzers.
This Driver use the new dirver framework!
The parent class is
mpylab.device.driver.DRIVER.The configuration template for this device class is:
conftmpl={'description': {'description': str, 'type': str, 'vendor': str, 'serialnr': str, 'deviceid': str, 'driver': str}, 'init_value': {'fstart': float, 'fstop': float, 'fstep': float, 'gpib': int, 'visa': str, 'nr_of_channels': int, 'virtual': strbool}, 'channel_%d': {'unit': str, 'SetRefLevel': float, 'SetRBW': float, 'SetSpan': float, 'CreateWindow': str, 'CreateTrace': str, 'SetSweepCount': int, 'SetSweepPoints': int, 'SetSweepType': str }}
The meaning is:
- Section description
description: string describing the instrument
type: string with the instrument type (here: POWERMETER)
vendor: string ddescribing the vendor/manufactor
serialnr: string with a unique identification
deviceid: string with an internal id
driver: filename of the instrument driver (.py, .pyc, .pyd, .dll)
- Section init_value
fstart: lowest possible frequency in Hz of the device
fstop: highest possible frequency in Hz of the device
fstep: smallest frequency step in Hz of the device
gpib: GPIB address of the device
virtual: 0, false or 1, true. Virtual device are usefull for testing and debugging.
- Section channel_%d
unit:
SetRefLevel: Reference Level (for further information see function description)
SetRBW: Resolution Bandwidth (for further information see function description)
SetSpan: Span of Device (for further information see function description)
CreateWindow: Name of the first Window (for further information see function description)
CreateTrace: Name of the first Trace (for further information see function description)
SetSweepCount: Sets the number of sweeps to be measured in single sweep mode. (for further information see function description)
SetSweepPoints: Sweep Points (for further information see function description)
SetSweepType: Sweep Type (for further information see function description)
The
_commandsdictionary:_commandsdefines functions that should be available in concrete driver implementations derived from this class.Convention example:
_commands={"function_name": {'parameter': tuple_of_parameter_names_or_None, 'returntype': python_type_or_r_type}, ...}
Historical note:
r_typesandMeta_Driverare archived undermpylab.device.legacyand are not used by active drivers. See alsompylab.device.legacy.meta_driver.Meta_Driver.Possibility lists: Possibilities define valid values for specific parameters. For example,
sparamis restricted to values like('S11', 'S12', 'S21', 'S22'). A fuzzy string compare may map small typos to known valid entries.Possibility lists can be defined in a concrete driver class or in a base class. Defining them in shared base classes is recommended so valid values remain consistent across drivers.
Methods:
- SetCenterFreq(cfreq):
Set the CenterFreq of the Device.
- Parameters:
cfreq (float) – CenterFreq for the device
- Returns:
CenterFreq which is set on the Device after the set command
- Return type:
float
- GetCenterFreq():
- Get the CenterFreq of the Device
- Returns:
CenterFreq which is set on the Device
- Return type:
float
- SetSpan(span):
- Set the Span of the Device.
- Defines the width of the measurement and display range for a frequency sweep.
- Parameters:
span (float) – Span in Hz
- Returns:
Span which is set on the Device after the set command
- Return type:
float
- GetSpan():
- Get the Span of the Device
- Returns:
Span which is set on the Device
- Return type:
float
- SetStartFreq(stfreq):
- Set the Start Frequency of the Device
- Parameters:
stfreq (float) – Start Frequency of the Device
- Returns:
Start Frequency which is set on the Device after the set command
- Return type:
float
- GetStartFreq():
- Get the Start Frequency of the Device
- Returns:
Start Frequency which is set on the Device after the set command
- Return type:
float
- SetStopFreq(spfreq):
- Set the Stop Frequency of the Device
- Parameters:
spfreq (float) – Stop Frequency of the Device
- Returns:
Stop Frequency which is set on the Device after the set command
- Return type:
float
- GetStopFreq():
- Get the Stop Frequency of the Device
- Returns:
Stop Frequency which is set on the Device
- Return type:
float
- SetRBW(rbw):
- Set the Resolution Bandwidth of the Device
- Parameters:
rbw (float) – Resolution Bandwidth of the Device
- Returns:
Resolution Bandwidth which is set on the Device after the set command
- Return type:
float
- GetRBW():
- Get the Resolution Bandwidth of the Device
- Returns:
Resolution Bandwidth which is set on the Device
- Return type:
float
- SetRefLevel(reflevel):
- Set the Reference Level of the currently active Trace.
- Parameters:
reflevel (float) – Reference Level of the Device
- Returns:
Reference Level which is set on the Device after the set command
- Return type:
float
- GetRefLevel():
- Get the Reference Level of the currently active Trace.
- Returns:
Reference Level which is set on the Device
- Return type:
float
- SetDivisionValue(divivalue):
- Sets the value between two grid graticules (value per division) for the diagram area.
- Parameters:
divivalue (float) – Division Value of the Device
- Returns:
Division Value which is set on the Device after the set command
- Return type:
float
- GetDivisionValue():
- Gets the value between two grid graticules (value per division) for the diagram area.
- Returns:
Division Value which is set on the Device
- Return type:
float
- CreateTrace(tracename, sparam):
- Creates a Trace and assigns the given name to it.
- Parameters:
tracename (String) – Name of the new Trace
sparam (String) – S-parameter as String; (‘S11’, ‘S12’, ‘S21’, ‘S22’)
- Returns:
Name of the new Trace
- Return type:
String
- DelTrace(traceName):
- Deletes a trace with a specified trace name.
- Parameters:
traceName (String) – Name of the Trace which should deleted
- Return type:
None
- SetTrace(traceName):
- Selects an existing trace as the active trace.
- Parameters:
traceName (String) – Name of the trace which should be selected.
- Returns:
Name of the currently active Trace after the set command
- Return type:
String
- GetTrace():
- Gets the Name of the currently active Trace
- Returns:
Name of the currently active Trace
- Return type:
String
- SetSparameter(sparam):
- Assigns the s-parameter to the currently active Trace.
- See also SetTrace()
- Parameters:
sparam (String) – S-parameter as String; (‘S11’, ‘S12’, ‘S21’, ‘S22’)
- Returns:
S-parameter of the currently active Trace which is set on the Device after the set command
- Return type:
String
- GetTrace():
- Gets s-parameter of the currently active Trace.
- See also SetTrace()
- Returns:
S-parameter of the currently active Trace which is set on the Device
- Return type:
String
- SetChannel(chan):
- Sets the Channel Number of the Device
- Parameters:
chan (Integer) – Number of the Channel
- Returns:
Channel Number of the Device after the set command
- Return type:
Integer
- GetChannel():
- Gets the Channel Number of the Device
- Returns:
Channel Number of the Device
- Return type:
Integer
- SetSweepType(sweepType):
- Selects the sweep type and the position of the sweep points across the sweep range.
- Parameters:
sweepType (String) – sweep type as String (‘LINEAR’,’LOGARITHMIC’)
- Returns:
sweep type which is set on the device after the set command
- Return type:
String
- GetSweepType():
- Selects the sweep type and the position of the sweep points across the sweep range.
- Returns:
sweep type which is set on the Device
- Return type:
String
- SetSweepCount(sweepCount):
- Sets the number of sweeps to be measured in single sweep mode.
- Parameters:
sweepCount (Integer) – Reference Level of the Device
- Returns:
Sweep Count which is set on the Device after the set command
- Return type:
Integer
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=False)¶
Init the instrument.
Parameters:
ini: filename or file-like object with the initialization parameters for the device. This parameter is handled by
mpylab.tools.Configuration.Configuration()which takes also a configuration template stored inself.conftmpl.channel: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
Return: 0 if sucessful.
- Quit()¶
Quit the instrument.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'CreateTrace': <class 'str'>, 'CreateWindow': <class 'str'>, 'SetRBW': <class 'float'>, 'SetRefLevel': <class 'float'>, 'SetSpan': <class 'float'>, 'SetSweepCount': <class 'int'>, 'SetSweepPoints': <class 'int'>, 'SetSweepType': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- sparam_possib = ('S11', 'S12', 'S21', 'S22')¶
- sweepMode_possib = ('CONTINUOUS', 'SINGEL')¶
- sweepType_possib = ('LINEAR', 'LOGARITHMIC')¶
- triggerMode_possib = ('IMMEDIATE', 'EXTERNAL')¶
mpylab.device.networkanalyzer_ui¶
Qt-based interactive test utility for network analyzer drivers.
- class mpylab.device.networkanalyzer_ui.DriverTask(*args: Any, **kwargs: Any)¶
Execute one driver-related callable inside a dedicated Qt thread.
- completed¶
alias of
object
- run()¶
Execute the task function and emit
completed/finishedsignals.
- class mpylab.device.networkanalyzer_ui.MplCanvas(*args: Any, **kwargs: Any)¶
Matplotlib canvas used to display the currently acquired spectrum.
- clear_plot()¶
Clear the current plot contents.
- set_grid_enabled(enabled)¶
Enable or disable the plot grid.
- set_plot_title(title)¶
Update the plot title and redraw the canvas.
- set_y_label(label)¶
Update the Y-axis label and redraw the canvas.
- update_spectrum(x, y, logarithmic=False)¶
Redraw the spectrum plot with the provided x/y arrays.
- class mpylab.device.networkanalyzer_ui.NetworkAnalyzerWidget(*args: Any, **kwargs: Any)¶
Generic graphical test utility for network analyzer style drivers.
- after_refresh_all()¶
Refresh optional UI state that depends on the active driver.
- closeEvent(event)¶
- log_edit_clear()¶
Clear the log output widget.
- log_message(message)¶
Append a timestamped message to the log output widget.
- on_clear_plot_clicked()¶
Clear plotted spectrum data and related cached state.
- on_create_trace_clicked()¶
Create a new trace on the active driver window.
- on_create_window_clicked()¶
Create a new window on the active driver.
- on_delete_trace_clicked()¶
Delete the currently active trace on the driver.
- on_delete_window_clicked()¶
Delete the currently active window on the driver.
- on_export_csv_clicked()¶
Export the last acquired trace to a CSV file.
- on_get_spectrum_clicked()¶
Acquire one spectrum without forcing a sweep mode change.
- on_grid_toggled(checked)¶
Toggle grid visibility in the spectrum plot.
- on_init_clicked()¶
Initialize the active driver using the current INI editor content.
- on_load_ini_clicked()¶
Load INI text from a file into the editor.
- on_plot_title_changed()¶
Apply the current plot title from the title input field.
- on_run_smoke_test_clicked()¶
Run the smoke-test routine and log its results.
- on_save_ini_clicked()¶
Save the current INI editor content to a file.
- on_select_trace_clicked()¶
Select the target trace as active on the driver.
- on_select_window_clicked()¶
Select the target window as active on the driver.
- on_set_center_freq_clicked(value=None)¶
Write center frequency to the device.
- on_set_division_clicked()¶
Write division value to the device.
- on_set_rbw_clicked(value=None)¶
Write RBW to the device.
- on_set_ref_level_clicked()¶
Write reference level to the device.
- on_set_span_clicked(value=None)¶
Write span to the device.
- on_set_sparameter_clicked()¶
Set S-parameter for the active trace.
- on_set_sweep_count_clicked()¶
Write sweep count to the device.
- on_set_sweep_mode_clicked()¶
Write sweep mode to the device.
- on_set_sweep_points_clicked()¶
Write sweep points to the device.
- on_set_sweep_type_clicked()¶
Write sweep type to the device.
- on_set_trigger_delay_clicked()¶
Write trigger delay to the device.
- on_set_trigger_mode_clicked()¶
Write trigger mode to the device.
- on_single_sweep_and_get_spectrum_clicked()¶
Trigger a single sweep and acquire one spectrum.
- on_single_sweep_clicked()¶
Trigger one single sweep using the active driver.
- on_trace_selected_in_list()¶
Mirror selected trace list entry into the trace name field.
- on_window_selected_in_list()¶
Mirror selected window list entry into the window name field.
- populate_controls_from_status()¶
Copy latest status readback values into writable controls.
- refresh_all()¶
Refresh status, controls, and optional topology information.
- refresh_status(on_complete=None)¶
Read status values from the driver and update status fields.
- refresh_topology()¶
Refresh window/trace state if the active driver exposes it.
- mpylab.device.networkanalyzer_ui.UI¶
alias of
NetworkAnalyzerWidget
- mpylab.device.networkanalyzer_ui.main(argv=None)¶
Start the standalone network analyzer test UI.
mpylab.device.nport¶
Base driver for passive n-port style data models.
- class mpylab.device.nport.ANTENNA(SearchPaths=None)¶
Passive antenna model based on interpolated n-port data.
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize channel datasets and interpolation helpers from config.
- Quit()¶
Close driver state and return status.
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- class mpylab.device.nport.CABLE(SearchPaths=None)¶
Passive cable model based on interpolated n-port data.
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize channel datasets and interpolation helpers from config.
- Quit()¶
Close driver state and return status.
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- class mpylab.device.nport.NPORT(SearchPaths=None)¶
Child class for all py-drivers for n-ports (like antennas, cables, hybrids, …) The parent class is DRIVER
- GetChannels()¶
Return available channel names.
- GetData(what)¶
Return interpolated data for a requested channel name.
- GetDescription()¶
Return the configured description string.
- GetFreq()¶
Return current interpolation frequency in Hz.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize channel datasets and interpolation helpers from config.
- Quit()¶
Close driver state and return status.
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.nport.main()¶
Run a simple manual test for NPORT interpolation behavior.
mpylab.device.nport_ui¶
Graphical test utility for passive n-port, cable and antenna data drivers.
- class mpylab.device.nport_ui.DriverTask(*args: Any, **kwargs: Any)¶
Execute one callable in a worker thread.
- completed¶
alias of
object
- run()¶
Execute the wrapped task and emit result/error signals.
- class mpylab.device.nport_ui.MplCanvas(*args: Any, **kwargs: Any)¶
Matplotlib canvas for passive data plots.
- class mpylab.device.nport_ui.NPortWidget(*args: Any, **kwargs: Any)¶
Threaded test UI for NPORT/CABLE/ANTENNA passive data drivers.
- closeEvent(event)¶
- log_message(message)¶
Append one timestamped line to the log tab.
- on_export_csv_clicked()¶
Export the currently plotted rows to a CSV file.
- on_get_data_clicked()¶
Fetch one data point for the selected channel and frequency.
- on_init_clicked()¶
Initialize or reinitialize the driver with current INI settings.
- on_load_ini_clicked()¶
Load INI text from a file into the editor.
- on_plot_clicked()¶
Acquire a sweep and plot values over the selected frequency range.
- on_save_ini_clicked()¶
Save the current INI editor content to a file.
- on_set_freq_clicked(freq=None)¶
Set frequency from UI control or provided value.
- on_smoke_clicked()¶
Run a compact end-to-end smoke test and show textual results.
- refresh_status()¶
Query driver status and refresh the status and channel widgets.
- mpylab.device.nport_ui.UI¶
alias of
NPortWidget
- mpylab.device.nport_ui.demo_ini(kind='nport')¶
Return demo INI content for one passive device kind.
- mpylab.device.nport_ui.main(argv=None)¶
Start the standalone NPORT/CABLE/ANTENNA test utility.
- mpylab.device.nport_ui.make_instance(kind)¶
Create the passive driver instance for the requested kind.
mpylab.device.nw_rs_zvl¶
Driver for the Rohde & Schwarz ZVL network analyzer.
- class mpylab.device.nw_rs_zvl.NETWORKANALYZER(SearchPaths=None)¶
R&S ZVL network analyzer driver implemented on top of the DRIVER base class.
- CreateTrace(tracename, sparam)¶
Create a new trace, assign its measurement parameter and attach it to the active window.
- CreateWindow(windowName)¶
Create a logical window object and enable the corresponding analyzer display window.
- DelTrace()¶
Delete the currently active trace from the analyzer and from local bookkeeping.
- DelWindow()¶
Delete the currently active window and clear dependent active-trace state.
- GetChannel()¶
Return the analyzer channel number owned by this driver instance.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetSparameter()¶
Return the measurement parameter assigned to the active trace.
- GetSpectrum()¶
Return stimulus and formatted trace data for the active trace.
The method prefers
CALC:DATA:STIM?for the x-axis and validates that the formatted trace data returned byFDATcontains exactly one value per sweep point.
- GetSweepCount()¶
Return the configured number of sweeps for single-sweep operation.
- GetSweepMode_rmap = {'0': 'SINGLE', '1': 'CONTINUOUS', 'OFF': 'SINGLE', 'ON': 'CONTINUOUS'}¶
- GetSweepType_rmap = {'LIN': 'LINEAR', 'LOG': 'LOGARITHMIC', 'SEGM': 'SEGMENT'}¶
- GetTrace()¶
Return the active trace name together with its currently assigned measurement parameter.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- GetWindow()¶
Return the name of the currently active window.
- Init(ini=None, channel=None)¶
Initialize communication, create the channel/window/trace setup and apply INI settings.
- NETWORKANALYZERS = []¶
- NewSweepCount()¶
Start a new single-sweep measurement sequence.
- Quit()¶
Quit the instrument.
- SetChannel(chan)¶
Reject channel switching because each driver instance is permanently bound to one channel.
- SetSparameter(sparam)¶
Change the measurement parameter of the active trace.
- SetSweepCount(sweepCount)¶
Configure the sweep count and switch between single and continuous sweep mode as needed.
- SetTrace(traceName)¶
Select an existing trace as the active trace for trace-related commands.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- SetWindow(windowName)¶
Select an existing window as the active window for subsequent operations.
- close()¶
Best-effort cleanup of traces, windows and the channel owned by this instance.
- conftmpl = {'channel_%d': {'CreateTrace': <class 'str'>, 'CreateWindow': <class 'str'>, 'SetRBW': <class 'float'>, 'SetRefLevel': <class 'float'>, 'SetSpan': <class 'float'>, 'SetSweepCount': <class 'int'>, 'SetSweepPoints': <class 'int'>, 'SetSweepType': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- getChannelNumber()¶
Return the internal channel number used for global instance bookkeeping.
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- sparam_possib = ('S11', 'S12', 'S21', 'S22')¶
- sweepMode_possib = ('CONTINUOUS', 'SINGEL')¶
- sweepMode_possib_map = {'CONTINUOUS': 'ON', 'SINGLE': 'OFF'}¶
- sweepType_possib = ('LINEAR', 'LOGARITHMIC')¶
- triggerMode_possib = ('IMMEDIATE', 'EXTERNAL')¶
- class mpylab.device.nw_rs_zvl.TRACE(nw, name, win, sparam)¶
In-memory representation of one analyzer trace owned by a driver instance.
- TRACES = []¶
- getInternName()¶
Return the unique instrument-side trace name.
- getName()¶
Return the user-facing trace name.
- getTraceWindowNumber()¶
Return the display trace number associated with this trace.
- getWindow()¶
Return the window object this trace is attached to.
- getsparameter()¶
Return the measurement parameter assigned to this trace.
- class mpylab.device.nw_rs_zvl.WINDOW(name)¶
In-memory representation of one analyzer display window.
- WINDOWS = []¶
- getInternName()¶
Return the analyzer window identifier as a string.
- getInternNumber()¶
Return the numeric window identifier used by the analyzer.
- getName()¶
Return the user-facing window name.
mpylab.device.nw_rs_zvl_virtual¶
Virtual R&S ZVL driver used for UI and workflow testing without hardware.
- class mpylab.device.nw_rs_zvl_virtual.NETWORKANALYZER(SearchPaths=None)¶
In-memory simulation of the ZVL driver with synthetic trace generation.
- CreateTrace(tracename, sparam)¶
Create a new trace, assign its measurement parameter and attach it to the active window.
- CreateWindow(windowName)¶
Create a logical window object and enable the corresponding analyzer display window.
- DelTrace()¶
Delete the currently active trace from the analyzer and from local bookkeeping.
- DelWindow()¶
Delete the currently active window and clear dependent active-trace state.
- GetChannel()¶
Return the analyzer channel number owned by this driver instance.
- GetDescription()¶
Return the virtual instrument identification without bus access.
- GetSparameter()¶
Return the measurement parameter assigned to the active trace.
- GetSpectrum()¶
Return stimulus and formatted trace data for the active trace.
The method prefers
CALC:DATA:STIM?for the x-axis and validates that the formatted trace data returned byFDATcontains exactly one value per sweep point.
- GetSweepCount()¶
Return the configured number of sweeps for single-sweep operation.
- GetSweepMode_rmap = {'0': 'SINGLE', '1': 'CONTINUOUS', 'OFF': 'SINGLE', 'ON': 'CONTINUOUS'}¶
- GetSweepType_rmap = {'LIN': 'LINEAR', 'LOG': 'LOGARITHMIC', 'SEGM': 'SEGMENT'}¶
- GetTrace()¶
Return the active trace name together with its currently assigned measurement parameter.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- GetWindow()¶
Return the name of the currently active window.
- Init(ini=None, channel=None)¶
Initialize the virtual analyzer from the INI file without opening any bus.
- NETWORKANALYZERS = []¶
- NewSweepCount()¶
Start a new single-sweep measurement sequence.
- Quit()¶
Quit the instrument.
- SetChannel(chan)¶
Reject channel switching because each driver instance is permanently bound to one channel.
- SetSparameter(sparam)¶
Change the measurement parameter of the active trace.
- SetSweepCount(sweepCount)¶
Configure the sweep count and switch between single and continuous sweep mode as needed.
- SetTrace(traceName)¶
Select an existing trace as the active trace for trace-related commands.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- SetWindow(windowName)¶
Select an existing window as the active window for subsequent operations.
- close()¶
Best-effort cleanup of traces, windows and the channel owned by this instance.
- conftmpl = {'channel_%d': {'CreateTrace': <class 'str'>, 'CreateWindow': <class 'str'>, 'SetRBW': <class 'float'>, 'SetRefLevel': <class 'float'>, 'SetSpan': <class 'float'>, 'SetSweepCount': <class 'int'>, 'SetSweepPoints': <class 'int'>, 'SetSweepType': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- getChannelNumber()¶
Return the internal channel number used for global instance bookkeeping.
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- query(cmd, tmpl=None)¶
Write a virtual SCPI query and return the raw or parsed response.
- read(tmpl=None)¶
Return or parse the last virtual SCPI response.
- sparam_possib = ('S11', 'S12', 'S21', 'S22')¶
- sweepMode_possib = ('CONTINUOUS', 'SINGEL')¶
- sweepMode_possib_map = {'CONTINUOUS': 'ON', 'SINGLE': 'OFF'}¶
- sweepType_possib = ('LINEAR', 'LOGARITHMIC')¶
- triggerMode_possib = ('IMMEDIATE', 'EXTERNAL')¶
- write(cmd)¶
Handle a small SCPI-like command subset without a hardware bus.
- mpylab.device.nw_rs_zvl_virtual.main()¶
Run a small local smoke test against the virtual ZVL driver.
mpylab.device.pm_gt_8540c¶
Driver for the Gigatronics 8540C power meter family.
- class mpylab.device.pm_gt_8540c.POWERMETER(**kw)¶
Driver for the Gigatronics 854X powermeter
- GetData()¶
Read one power sample and return it as quantity with mismatch uncertainty.
- GetDataNB(retrigger)¶
Return data and optionally retrigger for the next read.
- GetDescription()¶
Return instrument identification string.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Initialize the selected meter channel and apply presets.
- Quit()¶
Close the driver and return status.
- RANGE = ('MANUAL', 'AUTO', 'AUTOONCE')¶
- SetFreq(freq)¶
Set measurement frequency in Hz.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger measurement acquisition (no-op for this backend).
- Zero(state='on')¶
Run zeroing sequence and return status.
- ZeroCorrection = ('OFF', 'ON')¶
- conftmpl = {'channel_%d': {'filter': <class 'int'>, 'manrange': <class 'float'>, 'name': <class 'str'>, 'rangemode': <class 'str'>, 'resolution': <class 'int'>, 'sensor': <class 'str'>, 'swr1': <class 'float'>, 'swr2': <class 'float'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- get_standard_mismatch_uncertainty()¶
Returns the standard uncertainty (relative error) due to the mismatch between generator and load.
vswr1 and vswr2 are the voltage standing wave ratio of generator and load.
The uncertainty is returned on a linear scale (dB = 10 * log10 (1+a)).
The expanded uncertainty is obtained by multiplying with the correct coverage factor. Here, this is 0.997*sqrt(2) approx 1.4 (U-shaped distribution) for 95% coverage.
- update_internal_unit()¶
Read meter output mode and update internal unit/averaging behavior.
Input: sequence of dB-scaled values Output: dB-scaled lin-average of the input sequence
Example: linav_dB([0,-10]) -> -0.301
Input: sequence of lin-scaled values Output: lin-scaled lin-average of the input sequence
Example: linav_lin([0,-10]) -> -5
- mpylab.device.pm_gt_8540c.main()¶
Start the standalone Qt test UI for this power meter driver.
- mpylab.device.pm_gt_8540c.test_init(cha)¶
Create and initialize a test instance for one channel.
mpylab.device.pm_lumiloop_lspm¶
Driver for the Lumiloop multi-channel LSPM power meter.
- class mpylab.device.pm_lumiloop_lspm.POWERMETER(**kw)¶
Power meter driver with synchronized trigger/waveform acquisition.
- GetData()¶
Acquire one synchronized power sample set and return channel data.
- GetDataNB(retrigger=False)¶
Return data via the blocking acquisition implementation.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Return the currently configured frequency in Hz.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Initialize one logical channel and shared LSPM controller state.
- Quit()¶
Close the driver and return status.
- RANGE = ('MANUAL', 'AUTO', 'AUTOONCE')¶
- SetFreq(freq)¶
Set frequency and switch between configured low/high modes.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger a single measurement.
self.erroris returned.
- Zero(state='on')¶
If state is ‘on’, zero correction is tuned on.
(self.error, 0) is returned.
- ZeroCorrection = ('OFF', 'ON')¶
- conftmpl = {'channel_%d': {'filter': <class 'int'>, 'manrange': <class 'float'>, 'name': <class 'str'>, 'rangemode': <class 'str'>, 'resolution': <class 'int'>, 'sensor': <class 'str'>, 'swr1': <class 'float'>, 'swr2': <class 'float'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'channels': <class 'int'>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'mfreq': <class 'float'>, 'mode': <class 'str'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- data = []¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- get_standard_mismatch_uncertainty()¶
Returns the standard uncertainty (relative error) due to the mismatch between generator and load.
vswr1 and vswr2 are the voltage standing wave ratio of generator and load.
The uncertainty is returned on a linear scale (dB = 10 * log10 (1+a)).
The expanded uncertainty is obtained by multiplying with the correct coverage factor. Here, this is 0.997*sqrt(2) approx 1.4 (U-shaped distribution) for 95% coverage.
- instances = {}¶
- main_instance = None¶
- npm = 1¶
- setMode(mode)¶
Set low/high measurement mode across all attached meters.
- update_internal_unit(ch=None, unit='DBM')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- wait_for_laser_ready()¶
Wait until measurement readiness is reported for all probes.
- mpylab.device.pm_lumiloop_lspm.dBm2W(vals)¶
Convert dBm values to watts.
- mpylab.device.pm_lumiloop_lspm.main2()¶
Run an interactive manual test loop for the LSPM driver.
mpylab.device.pm_rs_nrp¶
mpylab.device.pm_rs_nrp module.
- class mpylab.device.pm_rs_nrp.POWERMETER(**kw)¶
Driver for the R&S NRP
- GetData()¶
Read a power measurement from the instrument.
(self.error, obj)is returned whereobjis a instance ofscuq.quantities.Quantity.
- GetDataNB(retrigger=None)¶
Non-blocking version of
GetData().This function returns
(-1, None)until the answer from the device is available. Then``self.error, obj)``.If retrigger is
Trueor'on', the device is triggered for a new measurment after the measurement has been red.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Init method.
- InitSen(channel=None)¶
InitSen method.
- MEAS()¶
it makes only a one measuring
- Quit()¶
Quit the instrument.
- RANGE = ('MANUAL', 'AUTO', 'AUTOONCE')¶
- Reset()¶
Reset of device. Sets the device to the defined default state
- SelfTestQuery()¶
It makes a selftest.
- Return: self.error = 0 no error found
self.error = 1 an error has occurred
- SetFreq(freq)¶
Set the frequency to freq (in Hz). This is importend to use the correct correction from the sensor EEPROM.
After setting, the freq is read back from the device.
(self.error, self.freq)is returned.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger a single measurement.
self.erroris returned.
- Unit(ch, unit)¶
Unit method.
- Zero(state='on')¶
If state is ‘on’, zero correction is tuned on.
(self.error, 0) is returned.
- ZeroCorrection = ('OFF', 'ON')¶
- conftmpl = {'channel_%d': {'filter': <class 'int'>, 'manrange': <class 'float'>, 'name': <class 'str'>, 'rangemode': <class 'str'>, 'resolution': <class 'int'>, 'sensor': <class 'str'>, 'swr1': <class 'float'>, 'swr2': <class 'float'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- get_standard_mismatch_uncertainty()¶
Returns the standard uncertainty (relative error) due to the mismatch between generator and load.
vswr1 and vswr2 are the voltage standing wave ratio of generator and load.
The uncertainty is returned on a linear scale (dB = 10 * log10 (1+a)).
The expanded uncertainty is obtained by multiplying with the correct coverage factor. Here, this is 0.997*sqrt(2) approx 1.4 (U-shaped distribution) for 95% coverage.
- update_internal_unit(ch=None, unit='DBM')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- mpylab.device.pm_rs_nrp.main()¶
main function.
- mpylab.device.pm_rs_nrp.test_init(ch)¶
test_init function.
mpylab.device.pm_rs_zlv_6¶
Power-meter adapter using marker readout on Rohde & Schwarz ZVL-6.
- class mpylab.device.pm_rs_zlv_6.POWERMETER(**kw)¶
ZVL-6-based power meter implementation.
- GetData()¶
Acquire peak marker power and return it as watt quantity.
- GetDataNB()¶
Return non-blocking measurement data (same as blocking path).
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Initialize the selected channel and unit configuration.
- Quit()¶
Quit the instrument.
- RANGE = ('MANUAL', 'AUTO', 'AUTOONCE')¶
- SetFreq(freq)¶
Set internal target frequency in Hz.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger a single measurement.
self.erroris returned.
- Zero(state='on')¶
If state is ‘on’, zero correction is tuned on.
(self.error, 0) is returned.
- ZeroCorrection = ('OFF', 'ON')¶
- conftmpl = {'channel_%d': {'filter': <class 'int'>, 'manrange': <class 'float'>, 'name': <class 'str'>, 'rangemode': <class 'str'>, 'resolution': <class 'int'>, 'sensor': <class 'str'>, 'swr1': <class 'float'>, 'swr2': <class 'float'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- get_standard_mismatch_uncertainty()¶
Returns the standard uncertainty (relative error) due to the mismatch between generator and load.
vswr1 and vswr2 are the voltage standing wave ratio of generator and load.
The uncertainty is returned on a linear scale (dB = 10 * log10 (1+a)).
The expanded uncertainty is obtained by multiplying with the correct coverage factor. Here, this is 0.997*sqrt(2) approx 1.4 (U-shaped distribution) for 95% coverage.
- update_internal_unit(ch=None, unit='DBM')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- mpylab.device.pm_rs_zlv_6.main()¶
Run a simple standalone smoke test for the ZVL-6 adapter.
mpylab.device.pm_rxatt¶
Composite power meter driver with automatic RX attenuation switching.
- class mpylab.device.pm_rxatt.POWERMETER(**kw)¶
Power meter wrapper that compensates fixed-path attenuator networks.
- GetData()¶
Acquire one measurement and compensate attenuation path settings.
- GetDataNB(retrigger)¶
Return non-blocking data and apply attenuation compensation when available.
- GetDescription()¶
Return combined wrapper and underlying meter description.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini, channel=1)¶
Initialize underlying power meter and RF switch controller.
- Quit()¶
Shut down all delegated devices and return success.
- RANGE = ('MANUAL', 'AUTO', 'AUTOONCE')¶
- SetFreq(freq)¶
Set frequency for meter/switch and update path correction factors.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger a single measurement.
self.erroris returned.
- Zero(state='on')¶
If state is ‘on’, zero correction is tuned on.
(self.error, 0) is returned.
- ZeroCorrection = ('OFF', 'ON')¶
- conftmpl = {'channel_%d': {'filter': <class 'int'>, 'manrange': <class 'float'>, 'name': <class 'str'>, 'rangemode': <class 'str'>, 'resolution': <class 'int'>, 'sensor': <class 'str'>, 'swr1': <class 'float'>, 'swr2': <class 'float'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'pmini': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- get_standard_mismatch_uncertainty()¶
Returns the standard uncertainty (relative error) due to the mismatch between generator and load.
vswr1 and vswr2 are the voltage standing wave ratio of generator and load.
The uncertainty is returned on a linear scale (dB = 10 * log10 (1+a)).
The expanded uncertainty is obtained by multiplying with the correct coverage factor. Here, this is 0.997*sqrt(2) approx 1.4 (U-shaped distribution) for 95% coverage.
- update_internal_unit(ch=None, unit='DBM')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- mpylab.device.pm_rxatt.main()¶
Run the standalone UI test harness for this wrapper driver.
- mpylab.device.pm_rxatt.test_init(ch)¶
Create and initialize a test instance for one channel.
mpylab.device.pm_virtual¶
Virtual power meter driver for deterministic test scenarios.
- class mpylab.device.pm_virtual.POWERMETER(**kw)¶
Power meter simulation with expression-based value generation.
- GetData()¶
Return virtual power as quantity in watt with uncertainty.
- GetDataNB()¶
Return non-blocking measurement data (same as blocking path).
- GetDescription()¶
Return virtual instrument identification.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Initialize virtual channel settings from configuration.
- Quit()¶
Quit the instrument.
- RANGE = ('MANUAL', 'AUTO', 'AUTOONCE')¶
- SetFreq(freq)¶
Set virtual measurement frequency in Hz.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger a single measurement.
self.erroris returned.
- Zero(state='on')¶
If state is ‘on’, zero correction is tuned on.
(self.error, 0) is returned.
- ZeroCorrection = ('OFF', 'ON')¶
- conftmpl = {'channel_%d': {'filter': <class 'int'>, 'manrange': <class 'float'>, 'name': <class 'str'>, 'rangemode': <class 'str'>, 'resolution': <class 'int'>, 'sensor': <class 'str'>, 'swr1': <class 'float'>, 'swr2': <class 'float'>, 'uncertainty': <class 'str'>, 'unit': <class 'str'>, 'value': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- get_standard_mismatch_uncertainty()¶
Returns the standard uncertainty (relative error) due to the mismatch between generator and load.
vswr1 and vswr2 are the voltage standing wave ratio of generator and load.
The uncertainty is returned on a linear scale (dB = 10 * log10 (1+a)).
The expanded uncertainty is obtained by multiplying with the correct coverage factor. Here, this is 0.997*sqrt(2) approx 1.4 (U-shaped distribution) for 95% coverage.
- query(cmd, tmpl=None)¶
Write a virtual SCPI query and return the raw or parsed response.
- read(tmpl=None)¶
Return or parse the last virtual SCPI response.
- update_internal_unit(ch=None, unit='DBM')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- write(cmd)¶
Handle a small SCPI-like command subset without a hardware bus.
- mpylab.device.pm_virtual.main()¶
Run a simple standalone smoke test for the virtual power meter.
mpylab.device.powermeter¶
mpylab.device.powermeter module.
- class mpylab.device.powermeter.POWERMETER(SearchPaths=None)¶
Child class for all py-drivers for power meters.
The parent class is
mpylab.device.driver.DRIVER.The configuration template for this device class is:
conftmpl={'description': {'description': str, 'type': str, 'vendor': str, 'serialnr': str, 'deviceid': str, 'driver': str}, 'init_value': {'fstart': float, 'fstop': float, 'fstep': float, 'gpib': int, 'virtual': strbool, 'nr_of_channels': int}, 'channel_%d': {'name': str, 'filter': int, 'unit': str, 'resolution': int, 'rangemode': str, 'manrange': float, 'swr1': float, 'swr2': float, 'sensor': str}}
The meaning is:
- Section description
description: string describing the instrument
type: string with the instrument type (here: POWERMETER)
vendor: string ddescribing the vendor/manufactor
serialnr: string with a unique identification
deviceid: string with an internal id
driver: filename of the instrument driver (.py, .pyc, .pyd, .dll)
- Section init_value
fstart: lowest possible frequency in Hz of the device
fstop: highest possible frequency in Hz of the device
fstep: smallest frequency step in Hz of the device
gpib: GPIB address of the device
virtual: 0, false or 1, true. Virtual device are usefull for testing and debugging.
nr_of_channels: indicates how many channel sections follow
- Section channel_%d (%d may be 1, 2, …)
name: a string identifying the channel.
filter: device specific integer specifying the filter used
unit: a string containing the unit of the returned power readings. However,
scuqwill ignore dB-settings, and the returned power will contain the unit anyway.resolution: device specific integer giving the resolutuion of the returned power
rangemode: ‘auto’, ‘autoonce’, or ‘manual’
manrange: fload specifiing the range in manual range mode
swr: VSWR of the measured two port. May be used in uncertainty calculations
sensor: string specifying the used power sensor. May be used in uncertainty calculations.
- GetData()¶
Read a power measurement from the instrument.
(self.error, obj)is returned whereobjis a instance ofscuq.quantities.Quantity.
- GetDataNB(retrigger)¶
Non-blocking version of
GetData().If implemented, this function will return
(-1, None)until the answer from the device is available. Then, it will returnself.error, obj).If retrigger is
Trueor'on', the device will be triggered for a new measurment after the measurement has been red.If not implemented, the method will return
GetData().
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=False)¶
Init the instrument.
Parameters:
ini: filename or file-like object with the initialization parameters for the device. This parameter is handled by
mpylab.tools.Configuration.Configuration()which takes also a configuration template stored inself.conftmpl.channel: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
Return: 0 if sucessful.
- Quit()¶
Quit the instrument.
- RANGE = ('MANUAL', 'AUTO', 'AUTOONCE')¶
- SetFreq(freq)¶
Set the frequency to freq (in Hz). This is importend to use the correct correction from the sensor EEPROM.
After setting, the freq is read back from the device.
(self.error, self.freq)is returned.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger a single measurement.
self.erroris returned.
- Zero(state='on')¶
If state is ‘on’, zero correction is tuned on.
(self.error, 0) is returned.
- ZeroCorrection = ('OFF', 'ON')¶
- conftmpl = {'channel_%d': {'filter': <class 'int'>, 'manrange': <class 'float'>, 'name': <class 'str'>, 'rangemode': <class 'str'>, 'resolution': <class 'int'>, 'sensor': <class 'str'>, 'swr1': <class 'float'>, 'swr2': <class 'float'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- get_standard_mismatch_uncertainty()¶
Returns the standard uncertainty (relative error) due to the mismatch between generator and load.
vswr1 and vswr2 are the voltage standing wave ratio of generator and load.
The uncertainty is returned on a linear scale (dB = 10 * log10 (1+a)).
The expanded uncertainty is obtained by multiplying with the correct coverage factor. Here, this is 0.997*sqrt(2) approx 1.4 (U-shaped distribution) for 95% coverage.
- update_internal_unit(ch=None, unit='DBM')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
mpylab.device.powermeter2c¶
mpylab.device.powermeter2c module.
- class mpylab.device.powermeter2c.POWERMETER(SearchPaths=None)¶
POWERMETER class.
- GetData()¶
GetData method.
- GetDataNB(retrigger)¶
GetDataNB method.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=False)¶
Init method.
- Quit()¶
Quit method.
- RANGE = ('MANUAL', 'AUTO', 'AUTOONCE')¶
- SetFreq(freq)¶
Set the frequency to freq (in Hz). This is importend to use the correct correction from the sensor EEPROM.
After setting, the freq is read back from the device.
(self.error, self.freq)is returned.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger the instrument. The Trigger is send only if no trigger was send from an othe instance ‘inst’ of the same instrument within (now-self.trg_threshold) and now.
- Zero(state='on')¶
If state is ‘on’, zero correction is tuned on.
(self.error, 0) is returned.
- ZeroCorrection = ('OFF', 'ON')¶
- conftmpl = {'channel_%d': {'filter': <class 'int'>, 'manrange': <class 'float'>, 'name': <class 'str'>, 'rangemode': <class 'str'>, 'resolution': <class 'int'>, 'sensor': <class 'str'>, 'swr1': <class 'float'>, 'swr2': <class 'float'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- get_standard_mismatch_uncertainty()¶
Returns the standard uncertainty (relative error) due to the mismatch between generator and load.
vswr1 and vswr2 are the voltage standing wave ratio of generator and load.
The uncertainty is returned on a linear scale (dB = 10 * log10 (1+a)).
The expanded uncertainty is obtained by multiplying with the correct coverage factor. Here, this is 0.997*sqrt(2) approx 1.4 (U-shaped distribution) for 95% coverage.
- instances = {}¶
- update_internal_unit(ch=None, unit='DBM')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
mpylab.device.powermeter_ui¶
Graphical test utility for powermeter drivers.
- class mpylab.device.powermeter_ui.DriverTask(*args: Any, **kwargs: Any)¶
Execute one driver callable in a worker thread.
- completed¶
alias of
object
- run()¶
Execute the worker callable and emit completion signals.
- class mpylab.device.powermeter_ui.PowerMeterWidget(*args: Any, **kwargs: Any)¶
Threaded test UI for the common powermeter driver API.
- closeEvent(event)¶
- log_edit_clear()¶
Clear the log output widget.
- log_message(message)¶
Append a timestamped line to the log output widget.
- on_apply_freq_clicked(freq=None)¶
Set powermeter frequency and validate readback.
- on_channel_changed(channel)¶
Switch active driver instance to selected initialized channel.
- on_init_clicked()¶
Initialize active powermeter driver from current INI text.
- on_load_ini_clicked()¶
Load INI content from file into the editor.
- on_measure_clicked()¶
Acquire one blocking power reading.
- on_measure_nb_clicked()¶
Acquire one non-blocking power reading.
- on_quit_clicked()¶
Call driver
Quitand reset channel/runtime state.
- on_raw_query_clicked()¶
Execute raw query command and display response.
- on_raw_write_clicked()¶
Execute raw write command and display response.
- on_read_freq_clicked()¶
Read current powermeter frequency.
- on_run_smoke_test_clicked()¶
Run conservative powermeter smoke test.
- on_save_ini_clicked()¶
Save current INI editor content to file.
- on_trigger_clicked()¶
Trigger one powermeter measurement cycle.
- on_zero_clicked(state)¶
Enable or disable sensor zeroing mode.
- refresh_all()¶
Refresh all status fields.
- refresh_status(on_complete=None)¶
Refresh status fields from device getters and cached state.
- mpylab.device.powermeter_ui.UI¶
alias of
PowerMeterWidget
- mpylab.device.powermeter_ui.main(argv=None)¶
Start standalone powermeter test utility.
mpylab.device.prb_ar_fm7004¶
Driver for the Amplifier Research FM7004/FL7018 field probe setup.
- class mpylab.device.prb_ar_fm7004.FIELDPROBE(**kw)¶
Concrete field probe driver for the AR FM7004 controller.
- GetBatteryState()¶
Return a fixed battery-state placeholder.
- GetData()¶
Return one three-axis field vector with fixed relative uncertainty.
- GetDataNB(retrigger)¶
Return data via the blocking acquisition path.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Query and return the current measurement frequency.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- GetWaveform()¶
Return unsupported marker for waveform acquisition.
- Init(ini=None, channel=None)¶
Initialize probe communication and enable correction mode.
- Quit()¶
Quit the instrument.
- SetFreq(freq)¶
Set probe frequency and return the confirmed frequency in Hz.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger one measurement cycle.
- Zero(state)¶
Enable or disable zeroing mode.
- conftmpl = {'channel_%d': {'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'nr_of_channels': <class 'int'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'com': <class 'int'>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.prb_ar_fm7004.main()¶
Start the legacy UI test harness for this probe driver.
- mpylab.device.prb_ar_fm7004.test()¶
Create and initialize a test field probe instance.
mpylab.device.prb_lumiloop_lsprobe¶
Driver for the Lumiloop LSProbe multi-channel field probe.
- class mpylab.device.prb_lumiloop_lsprobe.FIELDPROBE(**kw)¶
Field probe driver with synchronized multi-probe trigger handling.
- GetBatteryState()¶
Return a fixed battery state placeholder value.
- GetData()¶
Acquire one synchronized three-axis field sample for the current channel.
- GetDataNB(retrigger=False)¶
Return data using the same implementation as the blocking path.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Return the currently configured measurement frequency.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- GetWaveform(forceTRIG_CL=True)¶
Acquire one raw waveform frame and return time plus Ex/Ey/Ez traces.
- Init(ini=None, channel=None)¶
Initialize one logical channel and shared probe controller state.
- Quit()¶
Reset shared instance state and disable laser on the main instance.
- SetFreq(freq)¶
Set frequency and switch low/high measurement mode as needed.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger one measurement cycle.
- Zero(state)¶
Enable or disable zeroing mode.
- conftmpl = {'channel_%d': {'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'nr_of_channels': <class 'int'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'channels': <class 'int'>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'mfreq': <class 'float'>, 'mode': <class 'str'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- data = []¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- instances = {}¶
- main_instance = None¶
- nprb = 1¶
- setMode(mode)¶
Set measurement mode on all probes and refresh effective sample rate.
- wait_for_laser_ready()¶
Block until the probe laser/calibration state is reported ready.
- mpylab.device.prb_lumiloop_lsprobe.main2()¶
Run a manual integration test for multiple LSProbe channels.
mpylab.device.prb_pmm_ep601¶
PMM EP601 field-probe driver implementation.
- class mpylab.device.prb_pmm_ep601.FIELDPROBE(**kw)¶
Concrete PMM EP601 field-probe driver.
- GetBatteryState()¶
Query and return battery state as relative value.
- GetData()¶
Acquire one electric-field vector sample.
- GetDataNB(retrigger)¶
Acquire one non-blocking field sample.
- GetDescription()¶
Query and return probe description string.
- GetFreq()¶
Query and return the current measurement frequency.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- GetWaveform()¶
Return unsupported marker for waveform acquisition.
- Init(ini=None, channel=None)¶
Initialize probe communication and channel settings.
- Quit()¶
Close serial connection and end session.
- SetFreq(freq)¶
Set probe frequency in Hz.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger one measurement cycle.
- Zero(state)¶
Set zeroing mode state.
- conftmpl = {'channel_%d': {'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'nr_of_channels': <class 'int'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'com': <class 'int'>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.prb_pmm_ep601.dprint(arg)¶
Print debug messages when global
debugis enabled.
- mpylab.device.prb_pmm_ep601.main()¶
Start legacy traits-based field-probe test UI.
- mpylab.device.prb_pmm_ep601.test()¶
Create and initialize test probe instance with inline INI.
mpylab.device.prb_virtual¶
Virtual field probe driver for UI and workflow tests.
- class mpylab.device.prb_virtual.FIELDPROBE(**kw)¶
Virtual field probe backend with expression-based component synthesis.
- GetBatteryState()¶
Return virtual battery state.
- GetData()¶
Return synthetic three-axis field data as quantities.
- GetDataNB(retrigger=False)¶
Return data and optionally emulate retrigger behavior.
- GetDescription()¶
Return virtual instrument identification.
- GetFreq()¶
Return virtual operating frequency in Hz.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- GetWaveform()¶
Return unsupported marker for waveform access.
- Init(ini=None, channel=None)¶
Initialize virtual channel expressions and enable virtual mode.
- Quit()¶
Close virtual driver and return success.
- SetFreq(freq)¶
Set virtual operating frequency in Hz.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger acquisition (no-op in virtual mode).
- Zero(state)¶
Set virtual zero state flag to
onoroff.
- conftmpl = {'channel_%d': {'name': <class 'str'>, 'uncertainty': <class 'str'>, 'unit': <class 'str'>, 'x': <class 'str'>, 'y': <class 'str'>, 'z': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'nr_of_channels': <class 'int'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'com': <class 'int'>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- query(cmd, tmpl=None)¶
Write a virtual SCPI query and return the raw or parsed response.
- read(tmpl=None)¶
Return or parse the last virtual SCPI response.
- write(cmd)¶
Handle a small SCPI-like command subset without a hardware bus.
mpylab.device.prologix_gpib¶
mpylab.device.prologix_gpib module.
- class mpylab.device.prologix_gpib.PrologixGPIBObject(address=None, tempSess=False)¶
PrologixGPIBObject class.
- LLO()¶
This command disables front panel operation of the currently addressed instrument.
- LOC()¶
This command enables front panel operation of the currently addressed instrument.
- clear()¶
This command sends the Selected Device Clear (SDC) message to the currently specified GPIB address.
- close()¶
Closes the connection with the instrument. Side effect: disconnects prologix socket controller
- instrID()¶
Returns the *IDN? string
- open()¶
Open connection with instrument. If
tempSessis set to False, please remember to close after use.
- query(queryStr, withTimeout=None)¶
Read the unmodified string sent from the instrument to the computer.
- query_ascii_values(message, converter='f', separator=', ', container=<class 'list'>)¶
Taken from pvisa.
- query_raw_binary(queryStr, withTimeout=None)¶
Read the unmodified string sent from the instrument to the computer. In contrast to query(), no termination characters are stripped. Also no decoding.
- spoll()¶
Return status byte of the instrument.
- property termination¶
Termination GPIB character. Valid options: ‘\r\n’, ‘\r’, ‘\n’, ‘’.
- property timeout¶
This timeout is between the user and the instrument. For example, if we did a sweep that should take ~10 seconds but ends up taking longer, you can set the timeout to 20 seconds.
- wait(bigMsTimeout=10000)¶
wait method.
- write(writeStr)¶
write method.
- class mpylab.device.prologix_gpib.PrologixResourceManager(ip_address, timeout=2)¶
Controls a Prologix GPIB-ETHERNET Controller v1.2 manual: http://prologix.biz/downloads/PrologixGpibEthernetManual.pdf
Basic usage:
p = PrologixResourceManager('prologix.school.edu') p.connect() # connects to socket and leaves it open p.startup() # configures prologix to communicate via gpib p.send('++addr 23') # talks to address 23 p.send('command value') # sends the command and does not expect to read anything p.query('command') # sends a command but reads stuff back, this might hang if buffer is empty p.disconnect()
The problem with the above is that if there is any error with startup, send or query, the disconnect method will not be called. So we coded a decorator called
connected, to be used as such:p = PrologixResourceManager('prologix.school.edu') with p.connected(): p.startup() p.send('++addr 23') # talks to address 23 p.send('command value') # sends the command and does not expect to read anything p.query('command') # sends a command but reads stuff back
If we try to send a message without the decorator, then we should connect and disconnect right before.
p = PrologixResourceManager('prologix.school.edu') p.send('++addr 23') # opens and close socket automatically
Warning
If a second socket is opened from the same computer while the first was online, the first socket will stop responding and Prologix will send data to the just-opened socket.
- connect()¶
Connects to the socket and leaves the connection open. If already connected, does nothing.
- Returns:
socket object.
- connected()¶
Context manager for ensuring that the socket is connected while sending and receiving commands to remote socket. This is safe to use everywhere, even if the socket is previously connected. It can also be nested. This is useful to bundle multiple commands that you desire to be executed together in a single socket connection, for example:
def query(self, query_msg, msg_length=2048): with self.connected(): self._send(self._socket, query_msg) recv = self._recv(self._socket, msg_length) return recv
- disconnect()¶
If connected, disconnects and kills the socket.
- port = 1234¶
port that the Prologix GPIB-Ethernet controller listens to.
- query(query_msg, msg_length=2048)¶
Send a query and receive text from the controller.
Parameters¶
- query_msg:
Query message to send.
- msg_length:
Maximum chunk length per socket read. The method keeps reading until the received text ends with a newline.
- recv(msg_length=2048)¶
Receives an ASCII string from the socket server. Auto-connects if necessary.
- Args:
msg_length (int): maximum message length.
- send(value)¶
Sends an ASCII string to the socket server. Auto-connects if necessary.
- Args:
value (str): value to be sent
- startup()¶
Sends the startup configuration to the controller. Just in case it was misconfigured.
mpylab.device.prologix_simulator¶
mpylab.device.prologix_simulator module.
- mpylab.device.prologix_simulator.start_prologix_simulator(host='127.0.0.1', port=1234)¶
start_prologix_simulator function.
mpylab.device.rec_pmm_9010¶
PMM 9010 receiver driver (chapter 14 remote protocol).
- class mpylab.device.rec_pmm_9010.RECEIVER(**kw)¶
Concrete PMM 9010 receiver driver.
- GetAttenuation()¶
Return current attenuation in dB.
- GetData()¶
Acquire one blocking level reading.
- GetDataNB(retrigger)¶
Acquire one non-blocking level reading.
- GetDescription()¶
Query and return receiver identification string.
- GetDetector()¶
Return detector mode.
- GetFreq()¶
Return current receiver frequency in Hz.
- GetMeasTime()¶
Return measurement time in seconds.
- GetMinAttenuation()¶
Return configured minimum attenuation in dB.
- GetPreamplifier()¶
Return preamplifier state.
- GetResolutionBandwidth()¶
Return current receiver RBW setting.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Initialize receiver settings from INI channel configuration.
- Quit()¶
Close receiver session.
- SetAttenuation(attenuation)¶
Set attenuation in dB or switch to automatic attenuation.
- SetDetector(detector)¶
Set detector mode.
- SetFreq(freq)¶
Set receiver frequency in Hz.
- SetMeasTime(meas_time)¶
Set measurement time in seconds or enable automatic timing.
- SetMinAttenuation(min_attenuation)¶
Set minimum attenuation floor in dB.
- SetPreamplifier(preamplifier)¶
Set preamplifier state.
- SetResolutionBandwidth(rbw)¶
Set receiver RBW in Hz or enable RBW auto mode.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger one measurement cycle.
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'detector': <class 'str'>, 'meas_time': <class 'str'>, 'min_attenuation': <class 'int'>, 'name': <class 'str'>, 'preamplifier': <class 'str'>, 'rbw': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- update_internal_unit(ch=None, unit='DBUV')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- mpylab.device.rec_pmm_9010.main()¶
Run a minimal command-line smoke test for the PMM receiver.
mpylab.device.rec_rs_eshs30¶
This is mpylab.device.rec_rs_ESHS30`.
Provides driver for Rec RS ESHS30. :author: Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- class mpylab.device.rec_rs_eshs30.RECEIVER(**kw)¶
Driver for the Rohde & Schwarz ESHS30 EMI receiver.
- GetAttenuation()¶
Get the attenuation in dB.
(self.error, self.attenuation)is returned.
- GetData()¶
Trigger a measurement and return the measured level as quantity.
- GetDataNB(retrigger)¶
Non-blocking version of
GetData().This function will return
(-1, None)until the answer from the device is available. Then, it will return(self.error, obj).If retrigger is
Trueor'on', the device will be triggered for a new measurment after the measurement has been red.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetDetector()¶
Return the current detector mode.
- GetFreq()¶
Get the frequency to freq (in Hz).
(self.error, self.freq)is returned.
- GetMeasTime()¶
Return the configured measurement time.
- GetMinAttenuation()¶
Return the configured minimum attenuation floor in dB.
- GetPreamplifier()¶
Return the current preamplifier state.
- GetResolutionBandwidth()¶
Get the resolution bandwidth to rbw (in Hz).
(self.error, self.rbw)is returned.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Initialize the receiver channel and apply startup configuration.
- Quit()¶
Quit the instrument.
- SetAttenuation(attenuation)¶
Set RF attenuation and return the effective instrument value.
- SetDetector(detector)¶
Set detector mode and return the normalized detector name.
- SetFreq(freq)¶
Set the frequency to freq (in Hz).
After setting, the freq is read back from the device.
(self.error, self.freq)is returned.
- SetMeasTime(meas_time)¶
Set measurement time or enable automatic timing.
- SetMinAttenuation(att)¶
Set the minimum allowed attenuation floor in dB.
- SetPreamplifier(preamplifier)¶
Set preamplifier state and return the applied value.
- SetResolutionBandwidth(rbw)¶
Set resolution bandwidth or enable automatic RBW.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger a single measurement.
self.erroris returned.
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'detector': <class 'str'>, 'meas_time': <class 'str'>, 'min_attenuation': <class 'int'>, 'name': <class 'str'>, 'preamplifier': <class 'str'>, 'rbw': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- update_internal_unit(ch=None, unit='DBUV')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- mpylab.device.rec_rs_eshs30.main()¶
Run a basic manual smoke test for the ESHS30 driver.
mpylab.device.rec_rs_eshs30_dummy¶
This is mpylab.device.rec_rs_eshs30_dummy``.
Provides dummy driver for Rec RS ESHS30. :author: Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- class mpylab.device.rec_rs_eshs30_dummy.RECEIVER(**kw)¶
Dummy receiver implementation compatible with the ESHS30 API.
- GetAttenuation()¶
Return attenuation value in dB.
- GetData()¶
Return one synthetic uncertain level reading.
- GetDataNB(retrigger)¶
Non-blocking version of
GetData().This function will return
(-1, None)until the answer from the device is available. Then, it will return(self.error, obj).If retrigger is
Trueor'on', the device will be triggered for a new measurment after the measurement has been red.
- GetDescription()¶
Return a static dummy receiver description.
- GetDetector()¶
Return detector mode.
- GetFreq()¶
Return current receiver frequency in Hz.
- GetMeasTime()¶
Return measurement time in seconds.
- GetMinAttenuation()¶
Return minimum attenuation floor in dB.
- GetPreamplifier()¶
Return preamplifier state.
- GetResolutionBandwidth()¶
Return IF resolution bandwidth in Hz.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize dummy receiver state from INI configuration.
- Quit()¶
Quit the instrument.
- SetAttenuation(attenuation)¶
Set attenuation value in dB.
- SetDetector(detector)¶
Set detector mode.
- SetFreq(freq)¶
Set receiver frequency in Hz.
- SetMeasTime(meas_time)¶
Set measurement time in seconds.
- SetMinAttenuation(att)¶
Set minimum attenuation floor in dB.
- SetPreamplifier(preamplifier)¶
Set preamplifier state.
- SetResolutionBandwidth(rbw)¶
Set IF resolution bandwidth in Hz.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger one measurement cycle.
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'detector': <class 'str'>, 'meas_time': <class 'str'>, 'min_attenuation': <class 'int'>, 'name': <class 'str'>, 'preamplifier': <class 'str'>, 'rbw': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- update_internal_unit(ch=None, unit='DBUV')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- write(cmd)¶
Accept a raw command and report the written byte count.
- mpylab.device.rec_rs_eshs30_dummy.main()¶
Run a minimal command-line smoke test for the dummy receiver.
mpylab.device.rec_rs_eshs30_gpib_ctypes¶
Legacy GPIB-based sweep helper for the R&S ESHS30 receiver.
This module intentionally keeps a minimal API for older measurement scripts. Hardware communication is performed only when functions are called directly, so importing the module remains safe during documentation builds.
- mpylab.device.rec_rs_eshs30_gpib_ctypes.get_level(interface, device)¶
Query one level value from the currently configured receiver frequency.
- mpylab.device.rec_rs_eshs30_gpib_ctypes.main()¶
Run a sweep and print all measured levels to stdout.
- mpylab.device.rec_rs_eshs30_gpib_ctypes.sweep_levels(interface=0, primary_address=17, fstart=150000.0, fstop=30000000.0, fstep=1000.0) Iterator[Tuple[float, float]]¶
Yield
(frequency_hz, level)pairs for a full receiver sweep.
mpylab.device.rec_rs_esu¶
This is mpylab.device.rec_rs_esu.
Provides driver for Rohde&Schwarz ESU EMI receiver family. :author: Hans Georg Krauthaeuser (main author)
- license:
GPL-3 or higher
- class mpylab.device.rec_rs_esu.RECEIVER(**kw)¶
Concrete R&S ESU receiver driver based on the generic RECEIVER API.
- GetAttenuation()¶
Get the attenuation in dB.
(self.error, self.attenuation)is returned.
- GetData()¶
Trigger one measurement and return it as a quantity object.
- GetDataNB(retrigger)¶
Return a non-blocking measurement and optionally retrigger.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetDetector()¶
Return the currently selected detector token.
- GetFreq()¶
Get the frequency to freq (in Hz).
(self.error, self.freq)is returned.
- GetMeasTime()¶
Return the configured sweep time.
- GetMinAttenuation()¶
Return the configured minimum attenuation floor in dB.
- GetPreamplifier()¶
Return the current preamplifier state.
- GetResolutionBandwidth()¶
Get the resolution bandwidth to rbw (in Hz).
(self.error, self.rbw)is returned.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Initialize receiver state and apply configuration for one channel.
- Quit()¶
Quit the instrument.
- SetAttenuation(attenuation)¶
Set input attenuation and return the effective value in dB.
- SetDetector(detector)¶
Set detector mode and return the resulting detector token.
- SetFreq(freq)¶
Set the frequency to freq (in Hz).
After setting, the freq is read back from the device.
(self.error, self.freq)is returned.
- SetMeasTime(meas_time)¶
Set sweep time or keep automatic timing when requested.
- SetMinAttenuation(att)¶
Set minimum attenuation floor and enforce it on current settings.
- SetPreamplifier(preamplifier)¶
Set preamplifier state and return the applied value.
- SetResolutionBandwidth(rbw)¶
Set resolution bandwidth or enable automatic bandwidth.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger a single measurement.
self.erroris returned.
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'detector': <class 'str'>, 'meas_time': <class 'str'>, 'min_attenuation': <class 'int'>, 'name': <class 'str'>, 'preamplifier': <class 'str'>, 'rbw': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- update_internal_unit(ch=None, unit='DBUV')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- mpylab.device.rec_rs_esu.main()¶
Run a simple manual smoke test for the ESU receiver driver.
mpylab.device.receiver¶
This is the mpylab.device.receiver module.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.device.receiver.RECEIVER(SearchPaths=None)¶
Child class for all py-drivers for EMC receivers.
The parent class is
mpylab.device.driver.DRIVER.The configuration template for this device class is:
conftmpl={'description': {'description': str, 'type': str, 'vendor': str, 'serialnr': str, 'deviceid': str, 'driver': str}, 'init_value': {'fstart': float, 'fstop': float, 'fstep': float, 'visa': str, 'virtual': strbool, 'nr_of_channels': int}, 'channel_%d': {'name': str, 'detector': str, 'attenuation': str, 'meas_time': str, 'min_attenuation': int, 'unit': str, 'preamplifier': str}}
The meaning is:
- Section description
description: string describing the instrument
type: string with the instrument type (here: POWERMETER)
vendor: string ddescribing the vendor/manufactor
serialnr: string with a unique identification
deviceid: string with an internal id
driver: filename of the instrument driver (.py, .pyc, .pyd, .dll)
- Section init_value
fstart: lowest possible frequency in Hz of the device
fstop: highest possible frequency in Hz of the device
fstep: smallest frequency step in Hz of the device
visa: VISA identifier
virtual: 0, false or 1, true. Virtual device are usefull for testing and debugging.
nr_of_channels: indicates how many channel sections follow
- Section channel_%d (%d may be 1, 2, …)
name: a string identifying the channel.
detector: detector used fpr this channel
unit: a string containing the unit of the returned power/voltage readings. However,
scuqwill ignore dB-settings, and the returned power/voltage will contain the unit anyway.meas_time: the measuring time for that channel, or auto
attenuation: value of the attenuation, may be auto
min_attenuation: value of the minimum attenuation
detector: ‘PEAK’, ‘AVERAGE’, ‘QPEAK’
preamplifier: ‘on’ or ‘off’
- GetAttenuation()¶
Get the attenuation in dB.
(self.error, self.attenuation)is returned.
- GetData()¶
Read a power measurement from the instrument.
(self.error, obj)is returned whereobjis a instance ofscuq.quantities.Quantity.
- GetDataNB(retrigger)¶
Non-blocking version of
GetData().If implemented, this function will return
(-1, None)until the answer from the device is available. Then, it will returnself.error, obj).If retrigger is
Trueor'on', the device will be triggered for a new measurment after the measurement has been red.If not implemented, the method will return
GetData().
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetDetector()¶
Get the detector.
Values are PEAK, QPEAK, AVERAGE
(self.error, self.detector)is returned.
- GetFreq()¶
Get the frequency to freq (in Hz).
(self.error, self.freq)is returned.
- GetMeasTime()¶
Get the measurement time in seconds.
(self.error, self.meas_time)is returned.
- GetMinAttenuation()¶
Get the minimum attenuation in dB.
(self.error, self.min_attenuation)is returned.
- GetPreamplifier()¶
Get the preamplifier status.
Values are ON or OFF
(self.error, self.preamplifier)is returned.
- GetResolutionBandwidth()¶
Get the resolution bandwidth to rbw (in Hz).
(self.error, self.rbw)is returned.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=False)¶
Init the instrument.
Parameters:
ini: filename or file-like object with the initialization parameters for the device. This parameter is handled by
mpylab.tools.Configuration.Configuration()which takes also a configuration template stored inself.conftmpl.channel: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
Return: 0 if sucessful.
- Quit()¶
Quit the instrument.
- SetAttenuation(attenuation)¶
Set the attenuation to attenuation (in dB).
After setting, the attenuation is read back from the device.
(self.error, self.attenuation)is returned.
- SetDetector(detector)¶
Set the measurement detector.
detector has to de PEAK, QPEAK or AVERAGE
After setting, the detector is read back from the device.
(self.error, self.detector)is returned.
- SetFreq(freq)¶
Set the frequency to freq (in Hz).
After setting, the freq is read back from the device.
(self.error, self.freq)is returned.
- SetMeasTime(meas_time)¶
Set the measurement time to meas_time (in s).
After setting, the measurement time is read back from the device.
(self.error, self.meas_time)is returned.
- SetMinAttenuation(min_attenuation)¶
Set the minimum attenuation to min_attenuation (in dB).
After setting, the min_attenuation is read back from the device.
(self.error, self.min_attenuation)is returned.
- SetPreamplifier(preamplifier)¶
Set the preamplifier.
Values are ON or OFF
After setting, the status is read back from the device.
(self.error, self.preamplifier)is returned.
- SetResolutionBandwidth(rbw)¶
Set the resolution bandwidth to rbw (in Hz).
After setting, the bandwidth is read back from the device.
(self.error, self.rbw)is returned.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger a single measurement.
self.erroris returned.
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'detector': <class 'str'>, 'meas_time': <class 'str'>, 'min_attenuation': <class 'int'>, 'name': <class 'str'>, 'preamplifier': <class 'str'>, 'rbw': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- update_internal_unit(ch=None, unit='DBUV')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
mpylab.device.receiver_ui¶
Graphical test utility for receiver drivers.
- class mpylab.device.receiver_ui.DriverTask(*args: Any, **kwargs: Any)¶
Execute one driver callable in a worker thread.
- completed¶
alias of
object
- run()¶
Execute the worker callable and emit completion signals.
- class mpylab.device.receiver_ui.ReceiverWidget(*args: Any, **kwargs: Any)¶
Thread-aware test UI for the common receiver driver API.
- closeEvent(event)¶
- log_message(message)¶
Append a timestamped log line to the UI log view.
- on_att_auto_toggled(checked)¶
Toggle automatic attenuation mode.
- on_detector_changed(detector)¶
Apply detector mode change when the receiver is initialized.
- on_init_clicked()¶
Initialize the selected receiver driver from current INI text.
- on_load_ini_clicked()¶
Load INI content from a file into the editor.
- on_measure_clicked()¶
Acquire one blocking receiver measurement.
- on_measure_nb_clicked()¶
Acquire one non-blocking receiver measurement.
- on_poll_timeout()¶
Poll timer callback that triggers non-blocking measurement.
- on_poll_toggled(checked)¶
Start or stop periodic non-blocking measurement polling.
- on_preamp_changed(state)¶
Apply preamplifier state change when initialized.
- on_quit_clicked()¶
Call driver
Quitand reset UI runtime state.
- on_raw_query_clicked()¶
Send a raw query command to the receiver and show response.
- on_raw_write_clicked()¶
Send a raw write command to the receiver and show response.
- on_rbw_auto_toggled(checked)¶
Toggle automatic RBW mode.
- on_read_freq_clicked()¶
Read frequency from receiver and update controls.
- on_save_ini_clicked()¶
Save current INI editor content to a file.
- on_set_attenuation_clicked()¶
Set attenuation value or request automatic attenuation.
- on_set_freq_clicked(freq=None)¶
Set receiver frequency and validate readback consistency.
- on_set_meas_time_clicked()¶
Set integration or measurement time on the receiver.
- on_set_min_attenuation_clicked()¶
Set minimum attenuation threshold.
- on_set_rbw_clicked(rbw=None)¶
Set receiver RBW to a numeric value.
- on_smoke_clicked()¶
Run receiver smoke test and print command results.
- on_trigger_clicked()¶
Trigger one receiver measurement cycle.
- refresh_all()¶
Refresh all status-dependent UI fields.
- refresh_status(on_complete=None)¶
Refresh status fields by querying supported receiver getters.
- mpylab.device.receiver_ui.UI¶
alias of
ReceiverWidget
- mpylab.device.receiver_ui.main(argv=None)¶
Start the standalone receiver test utility.
mpylab.device.receiver_virtual¶
Virtual EMC receiver driver for UI and workflow tests without hardware.
- class mpylab.device.receiver_virtual.RECEIVER(SearchPaths=None)¶
In-memory receiver implementation using the public receiver API.
- GetAttenuation()¶
Return simulated attenuation in dB.
- GetData()¶
Return one synthetic receiver reading.
- GetDataNB(retrigger=True)¶
Return the latest synthetic reading and optionally retrigger.
- GetDescription()¶
Return the virtual device identification.
- GetDetector()¶
Return simulated detector mode.
- GetFreq()¶
Return the simulated receiver frequency in Hz.
- GetMeasTime()¶
Return simulated measurement time in seconds.
- GetMinAttenuation()¶
Return simulated minimum attenuation in dB.
- GetPreamplifier()¶
Return simulated preamplifier state.
- GetResolutionBandwidth()¶
Return simulated resolution bandwidth in Hz.
- GetVirtual()¶
Return whether this driver is virtual.
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize the virtual receiver from INI without opening a bus.
- Quit()¶
Close the virtual receiver.
- SetAttenuation(attenuation)¶
Set fixed attenuation or accept automatic attenuation.
- SetDetector(detector)¶
Set and return simulated detector mode.
- SetFreq(freq)¶
Set and return the simulated receiver frequency in Hz.
- SetMeasTime(meas_time)¶
Set and return simulated measurement time in seconds.
- SetMinAttenuation(min_attenuation)¶
Set and return simulated minimum attenuation in dB.
- SetPreamplifier(preamplifier)¶
Set and return simulated preamplifier state.
- SetResolutionBandwidth(rbw)¶
Set fixed RBW or accept automatic RBW.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- Trigger()¶
Trigger one synthetic measurement update.
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'detector': <class 'str'>, 'meas_time': <class 'str'>, 'min_attenuation': <class 'int'>, 'name': <class 'str'>, 'preamplifier': <class 'str'>, 'rbw': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- query(cmd, tmpl=None)¶
Write a virtual SCPI query and return the raw or parsed response.
- read(tmpl=None)¶
Return or parse the last virtual SCPI response.
- update_internal_unit(ch=None, unit='DBUV')¶
Selects the output unit for the measured power values.
Parameters:
ch: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
unit: an string specifiing the unit for the measured data.
The table shows the posibilities:
Unit SCPI notation Watt W dB DB dBm DBM dBuV DBUV
- write(cmd)¶
Handle a small SCPI-like command subset without a hardware bus.
mpylab.device.sa_pmm_9010¶
PMM 9010 spectrum analyzer driver (chapter 14 remote protocol).
- class mpylab.device.sa_pmm_9010.SPECTRUMANALYZER(**kw)¶
Concrete PMM 9010 analyzer driver.
- ATTMODES = ('NORMAL', 'LOWNOISE', 'LOWDIST')¶
- DETECTORS = ('AUTOSELECT', 'AUTOPEAK', 'MAXPEAK', 'MINPEAK', 'SAMPLE', 'RMS', 'AVERAGE', 'DET_QPEAK')¶
- GetAtt()¶
Return input attenuation in dB.
- GetAttMode()¶
Return attenuation mode.
- GetCenterFreq()¶
Return center frequency in Hz.
- GetDescription()¶
Query and return the instrument identification string.
- GetDetector()¶
Return detector mode.
- GetPreAmp()¶
Return preamplifier setting in dB.
- GetRefLevel()¶
Return cached display reference level in dBm.
- GetSpan()¶
Return configured frequency span in Hz.
- GetSpectrum()¶
Acquire one binary spectrum trace from the analyzer.
- GetStartFreq()¶
Return start frequency in Hz.
- GetStopFreq()¶
Return stop frequency in Hz.
- GetSweepCount()¶
Return sweep count.
- GetSweepPoints()¶
Return number of sweep points.
- GetSweepTime()¶
Return sweep time in seconds.
- GetTrace()¶
Return active trace number.
- GetTraceMode()¶
Return trace mode.
- GetTriggerDelay()¶
Return trigger delay in seconds.
- GetTriggerMode()¶
Return trigger mode.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Initialize the analyzer from INI data and apply channel defaults.
- Quit()¶
Stop analyzer operation.
- SetAtt(something)¶
Set input attenuation in dB or enable automatic attenuation.
- SetAttMode(attmode)¶
Set attenuation mode.
- SetCenterFreq(something)¶
Set center frequency in Hz while keeping the current span.
- SetDetector(something)¶
Set detector mode.
- SetPreAmp(something)¶
Enable or disable the preamplifier.
- SetRefLevel(something)¶
Set display reference level in dBm.
- SetSpan(something)¶
Set frequency span in Hz around the current center.
- SetStartFreq(something)¶
Set start frequency in Hz.
- SetStopFreq(something)¶
Set stop frequency in Hz.
- SetSweepCount(scount)¶
Set sweep count.
- SetSweepPoints(points)¶
Set number of sweep points.
- SetSweepTime(something)¶
Set sweep time in seconds or use device auto mode.
- SetTrace(trace)¶
Set active trace number.
- SetTraceMode(tmode)¶
Set trace mode.
- SetTriggerDelay(delay)¶
Set trigger delay in seconds.
- SetTriggerMode(trgmode)¶
Set trigger mode.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- TRACEMODES = ('WRITE', 'VIEW', 'AVERAGE', 'BLANK', 'MAXHOLD', 'MINHOLD')¶
- TRIGGERMODES = ('FREE', 'VIDEO', 'EXTERNAL')¶
- conftmpl = {'channel_%d': {'attenuation': <function _number_or_auto>, 'attmode': <class 'str'>, 'detector': <class 'str'>, 'rbw': <function _number_or_auto>, 'reflevel': <class 'float'>, 'span': <class 'float'>, 'sweepcount': <class 'int'>, 'sweeppoints': <class 'int'>, 'sweeptime': <function _number_or_auto>, 'trace': <class 'int'>, 'tracemode': <class 'str'>, 'triggermode': <class 'str'>, 'unit': <class 'str'>, 'vbw': <function _number_or_auto>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.sa_pmm_9010.main()¶
Run a minimal command-line smoke test for the PMM driver.
mpylab.device.sa_rs_esu¶
R&S ESU spectrum analyzer driver.
- class mpylab.device.sa_rs_esu.SPECTRUMANALYZER(**kw)¶
Spectrum analyzer driver for R&S ESU in analyzer mode.
- ATTMODES = ('NORMAL', 'LOWNOISE', 'LOWDIST')¶
- DETECTORS = ('AUTOSELECT', 'AUTOPEAK', 'MAXPEAK', 'MINPEAK', 'SAMPLE', 'RMS', 'AVERAGE', 'DET_QPEAK')¶
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetSpectrum()¶
GetSpectrum method.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Init method.
- Quit()¶
Quit the instrument.
- SetSANMode()¶
SetSANMode method.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- TRACEMODES = ('WRITE', 'VIEW', 'AVERAGE', 'BLANK', 'MAXHOLD', 'MINHOLD')¶
- TRIGGERMODES = ('FREE', 'VIDEO', 'EXTERNAL')¶
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'attmode': <class 'str'>, 'detector': <class 'str'>, 'rbw': <class 'str'>, 'reflevel': <class 'float'>, 'span': <class 'float'>, 'sweepcount': <class 'int'>, 'sweeppoints': <class 'int'>, 'sweeptime': <function _number_or_auto>, 'trace': <class 'int'>, 'tracemode': <class 'str'>, 'triggermode': <class 'str'>, 'unit': <class 'str'>, 'vbw': <function _number_or_auto>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.sa_rs_esu.main()¶
main function.
mpylab.device.sa_rs_zvl¶
mpylab.device.sa_rs_zvl module.
- class mpylab.device.sa_rs_zvl.SPECTRUMANALYZER(**kw)¶
SPECTRUMANALYZER class.
- ATTMODES = ('NORMAL', 'LOWNOISE', 'LOWDIST')¶
- DETECTORS = ('AUTOSELECT', 'AUTOPEAK', 'MAXPEAK', 'MINPEAK', 'SAMPLE', 'RMS', 'AVERAGE', 'DET_QPEAK')¶
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetSpectrum()¶
GetSpectrum method.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Init method.
- Quit()¶
Quit the instrument.
- SetSANMode()¶
SetSANMode method.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- TRACEMODES = ('WRITE', 'VIEW', 'AVERAGE', 'BLANK', 'MAXHOLD', 'MINHOLD')¶
- TRIGGERMODES = ('FREE', 'VIDEO', 'EXTERNAL')¶
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'attmode': <class 'str'>, 'detector': <class 'str'>, 'rbw': <class 'str'>, 'reflevel': <class 'float'>, 'span': <class 'float'>, 'sweepcount': <class 'int'>, 'sweeppoints': <class 'int'>, 'sweeptime': <class 'float'>, 'trace': <class 'int'>, 'tracemode': <class 'str'>, 'triggermode': <class 'str'>, 'unit': <class 'str'>, 'vbw': <class 'float'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.sa_rs_zvl.main()¶
main function.
mpylab.device.sg_gt_12000a¶
mpylab.device.sg_gt_12000a module.
- class mpylab.device.sg_gt_12000a.SIGNALGENERATOR(**kw)¶
SIGNALGENERATOR class.
- AMOff()¶
Switch AM modulation off.
- AMOn()¶
Switch AM modulation on.
- AM_LFOut = ('OFF', 'ON')¶
- AM_sources = ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF')¶
- AM_waveforms = ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH')¶
- ATT_modes = ('AUTO', 'FIXED')¶
- ConfAM(source, freq, depth, waveform, LFOut)¶
Configure AM modulation parameters.
- ConfPM(source, freq, pol, width, delay)¶
Configure PM modulation parameters.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Read and return output frequency in Hz.
- GetLevel()¶
Read and return RF output level as scuq quantity.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Init method.
- PARAMETER_SETS = {'AM_LFOut': ('OFF', 'ON'), 'AM_sources': ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF'), 'AM_waveforms': ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH'), 'ATT_modes': ('AUTO', 'FIXED'), 'PM_pol': ('NORMAL', 'INVERTED'), 'PM_sources': ('INT', 'EXT1', 'EXT2', 'OFF')}¶
- PMOff()¶
Switch PM modulation off.
- PMOn()¶
Switch PM modulation on.
- PM_pol = ('NORMAL', 'INVERTED')¶
- PM_sources = ('INT', 'EXT1', 'EXT2', 'OFF')¶
- Quit()¶
Quit the instrument.
- RFOff()¶
Switch RF output off.
- RFOn()¶
Switch RF output on.
- SetAM(state)¶
Enable or disable AM modulation.
- SetFreq(freq)¶
Set output frequency in Hz and read back value.
- SetLevel(lv)¶
Set RF output level as scuq quantity and return readback quantity.
- SetPM(state)¶
Enable or disable PM modulation.
- SetState(state)¶
Set RF output state using
on/offsemantics.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'attenuation': <class 'float'>, 'attmode': <class 'str'>, 'level': <class 'float'>, 'levellimit': <class 'float'>, 'leveloffset': <class 'float'>, 'name': <class 'str'>, 'outputstate': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- map = {'AM_LFOut': bidict({'OFF': 'OFF', 'ON': 'ON'}), 'AM_sources': bidict({'INT1': 'INT1', 'INT2': 'INT2', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'EXT_AC': 'EXT_AC', 'EXT_DC': 'EXT_DC', 'TWOTONE_AC': 'TWOTONE_AC', 'TWOTONE_DC': 'TWOTONE_DC', 'OFF': 'OFF'}), 'AM_waveforms': bidict({'SINE': 'SINE', 'SQUARE': 'SQUARE', 'TRIANGLE': 'TRIANGLE', 'NOISE': 'NOISE', 'SAWTOOTH': 'SAWTOOTH'}), 'ATT_modes': bidict({'AUTO': 'AUTO', 'FIXED': 'FIXED'}), 'PM_pol': bidict({'NORMAL': 'NORMAL', 'INVERTED': 'INVERTED'}), 'PM_sources': bidict({'INT': 'INT', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'OFF': 'OFF'})}¶
- mpylab.device.sg_gt_12000a.main()¶
main function.
mpylab.device.sg_rs_smb100a¶
mpylab.device.sg_rs_smb100a module.
- class mpylab.device.sg_rs_smb100a.SIGNALGENERATOR(**kw)¶
SIGNALGENERATOR class.
- AMOff()¶
Switch AM modulation off.
- AMOn()¶
Switch AM modulation on.
- AM_LFOut = ('OFF', 'ON')¶
- AM_sources = ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF')¶
- AM_waveforms = ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH')¶
- ATT_modes = ('AUTO', 'FIXED')¶
- ConfAM(source, freq, depth, waveform, LFOut)¶
Configure AM modulation parameters.
- ConfPM(source, freq, pol, width, delay)¶
Configure PM modulation parameters.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Read and return output frequency in Hz.
- GetLevel()¶
Read and return RF output level as scuq quantity.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Init method.
- PARAMETER_SETS = {'AM_LFOut': ('OFF', 'ON'), 'AM_sources': ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF'), 'AM_waveforms': ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH'), 'ATT_modes': ('AUTO', 'FIXED'), 'PM_pol': ('NORMAL', 'INVERTED'), 'PM_sources': ('INT', 'EXT1', 'EXT2', 'OFF')}¶
- PMOff()¶
Switch PM modulation off.
- PMOn()¶
Switch PM modulation on.
- PM_pol = ('NORMAL', 'INVERTED')¶
- PM_sources = ('INT', 'EXT1', 'EXT2', 'OFF')¶
- Quit()¶
Quit the instrument.
- RFOff()¶
Switch RF output off.
- RFOn()¶
Switch RF output on.
- SetAM(state)¶
Enable or disable AM modulation.
- SetFreq(freq)¶
Set output frequency in Hz and read back value.
- SetLevel(lv)¶
Set RF output level as scuq quantity and return readback quantity.
- SetPM(state)¶
Enable or disable PM modulation.
- SetState(state)¶
Set RF output state using
on/offsemantics.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'attenuation': <class 'float'>, 'attmode': <class 'str'>, 'level': <class 'float'>, 'levellimit': <class 'float'>, 'leveloffset': <class 'float'>, 'name': <class 'str'>, 'outputstate': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- map = {'AM_LFOut': bidict({'OFF': 'OFF', 'ON': 'ON'}), 'AM_sources': bidict({'INT1': 'INT1', 'INT2': 'INT2', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'EXT_AC': 'EXT_AC', 'EXT_DC': 'EXT_DC', 'TWOTONE_AC': 'TWOTONE_AC', 'TWOTONE_DC': 'TWOTONE_DC', 'OFF': 'OFF'}), 'AM_waveforms': bidict({'SINE': 'SINE', 'SQUARE': 'SQUARE', 'TRIANGLE': 'TRIANGLE', 'NOISE': 'NOISE', 'SAWTOOTH': 'SAWTOOTH'}), 'ATT_modes': bidict({'AUTO': 'AUTO', 'FIXED': 'FIXED'}), 'PM_pol': bidict({'NORMAL': 'NORMAL', 'INVERTED': 'INVERTED'}), 'PM_sources': bidict({'INT': 'INT', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'OFF': 'OFF'})}¶
- mpylab.device.sg_rs_smb100a.main()¶
main function.
mpylab.device.sg_rs_smc100a¶
mpylab.device.sg_rs_smc100a module.
- class mpylab.device.sg_rs_smc100a.SIGNALGENERATOR(**kw)¶
SIGNALGENERATOR class.
- AMOff()¶
Switch AM modulation off.
- AMOn()¶
Switch AM modulation on.
- AM_LFOut = ('OFF', 'ON')¶
- AM_sources = ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF')¶
- AM_waveforms = ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH')¶
- ATT_modes = ('AUTO', 'FIXED')¶
- ConfAM(source, freq, depth, waveform, LFOut)¶
Configure AM modulation parameters.
- ConfPM(source, freq, pol, width, delay)¶
Configure PM modulation parameters.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Read and return output frequency in Hz.
- GetLevel()¶
Read and return RF output level as scuq quantity.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Init method.
- PARAMETER_SETS = {'AM_LFOut': ('OFF', 'ON'), 'AM_sources': ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF'), 'AM_waveforms': ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH'), 'ATT_modes': ('AUTO', 'FIXED'), 'PM_pol': ('NORMAL', 'INVERTED'), 'PM_sources': ('INT', 'EXT1', 'EXT2', 'OFF')}¶
- PMOff()¶
Switch PM modulation off.
- PMOn()¶
Switch PM modulation on.
- PM_pol = ('NORMAL', 'INVERTED')¶
- PM_sources = ('INT', 'EXT1', 'EXT2', 'OFF')¶
- Quit()¶
Quit the instrument.
- RFOff()¶
Switch RF output off.
- RFOn()¶
Switch RF output on.
- SetAM(state)¶
Enable or disable AM modulation.
- SetFreq(freq)¶
Set output frequency in Hz and read back value.
- SetLevel(lv)¶
Set RF output level as scuq quantity and return readback quantity.
- SetPM(state)¶
Enable or disable PM modulation.
- SetState(state)¶
Set RF output state using
on/offsemantics.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'attenuation': <class 'float'>, 'attmode': <class 'str'>, 'level': <class 'float'>, 'levellimit': <class 'float'>, 'leveloffset': <class 'float'>, 'name': <class 'str'>, 'outputstate': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- map = {'AM_LFOut': bidict({'OFF': 'OFF', 'ON': 'ON'}), 'AM_sources': bidict({'INT1': 'INT1', 'INT2': 'INT2', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'EXT_AC': 'EXT_AC', 'EXT_DC': 'EXT_DC', 'TWOTONE_AC': 'TWOTONE_AC', 'TWOTONE_DC': 'TWOTONE_DC', 'OFF': 'OFF'}), 'AM_waveforms': bidict({'SINE': 'SINE', 'SQUARE': 'SQUARE', 'TRIANGLE': 'TRIANGLE', 'NOISE': 'NOISE', 'SAWTOOTH': 'SAWTOOTH'}), 'ATT_modes': bidict({'AUTO': 'AUTO', 'FIXED': 'FIXED'}), 'PM_pol': bidict({'NORMAL': 'NORMAL', 'INVERTED': 'INVERTED'}), 'PM_sources': bidict({'INT': 'INT', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'OFF': 'OFF'})}¶
- mpylab.device.sg_rs_smc100a.main()¶
main function.
mpylab.device.sg_rs_smf100a¶
Driver for the Rohde & Schwarz SMF100A signal generator.
- class mpylab.device.sg_rs_smf100a.SIGNALGENERATOR(**kw)¶
SMF100A-specific signal generator implementation.
- AMOff()¶
Switch AM modulation off.
- AMOn()¶
Switch AM modulation on.
- AM_LFOut = ('OFF', 'ON')¶
- AM_sources = ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF')¶
- AM_waveforms = ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH')¶
- ATT_modes = ('AUTO', 'FIXED')¶
- ConfAM(source, freq, depth, waveform, LFOut)¶
Configure AM source, waveform, depth, frequency and LF output.
- ConfPM(source, freq, pol, width, delay)¶
Configure pulse modulation source, polarity, width and delay.
- GetAMState()¶
Query and return AM state as normalized text.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Read and return output frequency in Hz.
- GetLevel()¶
Read and return RF output level as scuq quantity.
- GetPMState()¶
Query and return pulse-modulation state as normalized text.
- GetRFState()¶
Query and return RF output state as normalized text.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Initialize SMF100A channel and apply configured presets.
- PARAMETER_SETS = {'AM_LFOut': ('OFF', 'ON'), 'AM_sources': ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF'), 'AM_waveforms': ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH'), 'ATT_modes': ('AUTO', 'FIXED'), 'PM_pol': ('NORMAL', 'INVERTED'), 'PM_sources': ('INT', 'EXT1', 'EXT2', 'OFF')}¶
- PMOff()¶
Switch PM modulation off.
- PMOn()¶
Switch PM modulation on.
- PM_pol = ('NORMAL', 'INVERTED')¶
- PM_sources = ('INT', 'EXT1', 'EXT2', 'OFF')¶
- Quit()¶
Quit the instrument.
- RFOff()¶
Switch RF output off.
- RFOn()¶
Switch RF output on.
- SetAM(state)¶
Enable or disable AM modulation.
- SetFreq(freq)¶
Set output frequency in Hz and read back value.
- SetLevel(lv)¶
Set RF output level as scuq quantity and return readback quantity.
- SetPM(state)¶
Enable or disable PM modulation.
- SetState(state)¶
Set RF output state using
on/offsemantics.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'attenuation': <class 'float'>, 'attmode': <class 'str'>, 'level': <class 'float'>, 'levellimit': <class 'float'>, 'leveloffset': <class 'float'>, 'name': <class 'str'>, 'outputstate': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- map = {'AM_LFOut': bidict({'OFF': 'OFF', 'ON': 'ON'}), 'AM_sources': bidict({'INT1': 'INT1', 'INT2': 'INT2', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'EXT_AC': 'EXT_AC', 'EXT_DC': 'EXT_DC', 'TWOTONE_AC': 'TWOTONE_AC', 'TWOTONE_DC': 'TWOTONE_DC', 'OFF': 'OFF'}), 'AM_waveforms': bidict({'SINE': 'SINE', 'SQUARE': 'SQUARE', 'TRIANGLE': 'TRIANGLE', 'NOISE': 'NOISE', 'SAWTOOTH': 'SAWTOOTH'}), 'ATT_modes': bidict({'AUTO': 'AUTO', 'FIXED': 'FIXED'}), 'PM_pol': bidict({'NORMAL': 'NORMAL', 'INVERTED': 'INVERTED'}), 'PM_sources': bidict({'INT': 'INT', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'OFF': 'OFF'})}¶
- mpylab.device.sg_rs_smf100a.main()¶
Start the standalone SMF100A UI (or virtual fallback).
- mpylab.device.sg_rs_smf100a.test()¶
Create and initialize a test SMF100A instance from default INI.
mpylab.device.sg_rs_smr¶
mpylab.device.sg_rs_smr module.
- class mpylab.device.sg_rs_smr.SIGNALGENERATOR(**kw)¶
SIGNALGENERATOR class.
- AMOff()¶
Switch AM modulation off.
- AMOn()¶
Switch AM modulation on.
- AM_LFOut = ('OFF', 'ON')¶
- AM_sources = ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF')¶
- AM_waveforms = ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH')¶
- ATT_modes = ('AUTO', 'FIXED')¶
- ConfAM(source, freq, depth, waveform, LFOut)¶
Configure AM modulation parameters.
- ConfPM(source, freq, pol, width, delay)¶
Configure PM modulation parameters.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Read and return output frequency in Hz.
- GetLevel()¶
Read and return RF output level as scuq quantity.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Init method.
- PARAMETER_SETS = {'AM_LFOut': ('OFF', 'ON'), 'AM_sources': ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF'), 'AM_waveforms': ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH'), 'ATT_modes': ('AUTO', 'FIXED'), 'PM_pol': ('NORMAL', 'INVERTED'), 'PM_sources': ('INT', 'EXT1', 'EXT2', 'OFF')}¶
- PMOff()¶
Switch PM modulation off.
- PMOn()¶
Switch PM modulation on.
- PM_pol = ('NORMAL', 'INVERTED')¶
- PM_sources = ('INT', 'EXT1', 'EXT2', 'OFF')¶
- Quit()¶
Quit the instrument.
- RFOff()¶
Switch RF output off.
- RFOn()¶
Switch RF output on.
- SetAM(state)¶
Enable or disable AM modulation.
- SetFreq(freq)¶
Set output frequency in Hz and read back value.
- SetLevel(lv)¶
Set RF output level as scuq quantity and return readback quantity.
- SetPM(state)¶
Enable or disable PM modulation.
- SetState(state)¶
Set RF output state using
on/offsemantics.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'attenuation': <class 'float'>, 'attmode': <class 'str'>, 'level': <class 'float'>, 'levellimit': <class 'float'>, 'leveloffset': <class 'float'>, 'name': <class 'str'>, 'outputstate': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- map = {'AM_LFOut': bidict({'OFF': 'OFF', 'ON': 'ON'}), 'AM_sources': bidict({'INT1': 'INT1', 'INT2': 'INT2', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'EXT_AC': 'EXT_AC', 'EXT_DC': 'EXT_DC', 'TWOTONE_AC': 'TWOTONE_AC', 'TWOTONE_DC': 'TWOTONE_DC', 'OFF': 'OFF'}), 'AM_waveforms': bidict({'SINE': 'SINE', 'SQUARE': 'SQUARE', 'TRIANGLE': 'TRIANGLE', 'NOISE': 'NOISE', 'SAWTOOTH': 'SAWTOOTH'}), 'ATT_modes': bidict({'AUTO': 'AUTO', 'FIXED': 'FIXED'}), 'PM_pol': bidict({'NORMAL': 'NORMAL', 'INVERTED': 'INVERTED'}), 'PM_sources': bidict({'INT': 'INT', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'OFF': 'OFF'})}¶
- mpylab.device.sg_rs_smr.main()¶
main function.
mpylab.device.sg_rs_swm¶
mpylab.device.sg_rs_swm module.
- class mpylab.device.sg_rs_swm.SIGNALGENERATOR(**kw)¶
SIGNALGENERATOR class.
- AMOff()¶
Switch AM modulation off.
- AMOn()¶
Switch AM modulation on.
- AM_LFOut = ('OFF', 'ON')¶
- AM_sources = ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF')¶
- AM_waveforms = ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH')¶
- ATT_modes = ('AUTO', 'FIXED')¶
- ConfAM(source, freq, depth, waveform, LFOut)¶
Configure AM modulation parameters.
- ConfPM(source, freq, pol, width, delay)¶
Configure PM modulation parameters.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Read and return output frequency in Hz.
- GetLevel()¶
Read and return RF output level as scuq quantity.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None)¶
Init method.
- PARAMETER_SETS = {'AM_LFOut': ('OFF', 'ON'), 'AM_sources': ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF'), 'AM_waveforms': ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH'), 'ATT_modes': ('AUTO', 'FIXED'), 'PM_pol': ('NORMAL', 'INVERTED'), 'PM_sources': ('INT', 'EXT1', 'EXT2', 'OFF')}¶
- PMOff()¶
Switch PM modulation off.
- PMOn()¶
Switch PM modulation on.
- PM_pol = ('NORMAL', 'INVERTED')¶
- PM_sources = ('INT', 'EXT1', 'EXT2', 'OFF')¶
- Quit()¶
Quit the instrument.
- RFOff()¶
Switch RF output off.
- RFOn()¶
Switch RF output on.
- SetAM(state)¶
Enable or disable AM modulation.
- SetFreq(freq)¶
Set output frequency in Hz and read back value.
- SetLevel(lv)¶
Set RF output level as scuq quantity and return readback quantity.
- SetPM(state)¶
Enable or disable PM modulation.
- SetState(state)¶
Set RF output state using
on/offsemantics.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'attenuation': <class 'float'>, 'attmode': <class 'str'>, 'level': <class 'float'>, 'levellimit': <class 'float'>, 'leveloffset': <class 'float'>, 'name': <class 'str'>, 'outputstate': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- map = {'AM_LFOut': bidict({'OFF': 'OFF', 'ON': 'ON'}), 'AM_sources': bidict({'INT1': 'INT1', 'INT2': 'INT2', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'EXT_AC': 'EXT_AC', 'EXT_DC': 'EXT_DC', 'TWOTONE_AC': 'TWOTONE_AC', 'TWOTONE_DC': 'TWOTONE_DC', 'OFF': 'OFF'}), 'AM_waveforms': bidict({'SINE': 'SINE', 'SQUARE': 'SQUARE', 'TRIANGLE': 'TRIANGLE', 'NOISE': 'NOISE', 'SAWTOOTH': 'SAWTOOTH'}), 'ATT_modes': bidict({'AUTO': 'AUTO', 'FIXED': 'FIXED'}), 'PM_pol': bidict({'NORMAL': 'NORMAL', 'INVERTED': 'INVERTED'}), 'PM_sources': bidict({'INT': 'INT', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'OFF': 'OFF'})}¶
- mpylab.device.sg_rs_swm.main()¶
main function.
mpylab.device.sg_virtual¶
Virtual signal generator driver for UI and workflow tests.
- class mpylab.device.sg_virtual.SIGNALGENERATOR(SearchPaths=None)¶
In-memory signal generator implementation without hardware access.
- AMOff()¶
Disable simulated AM.
- AMOn()¶
Enable simulated AM.
- AM_LFOut = ('OFF', 'ON')¶
- AM_sources = ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF')¶
- AM_waveforms = ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH')¶
- ATT_modes = ('AUTO', 'FIXED')¶
- ConfAM(source, freq, depth, waveform, LFOut)¶
Configure simulated amplitude modulation parameters.
- ConfPM(source, freq, pol, width, delay)¶
Configure simulated pulse modulation parameters.
- GetAMState()¶
Return the simulated AM output state.
- GetDescription()¶
Return the virtual device identification.
- GetFreq()¶
Return the simulated RF frequency.
- GetLevel()¶
Return the simulated RF level.
- GetPMState()¶
Return the simulated PM output state.
- GetRFState()¶
Return the simulated RF output state.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize the virtual generator from INI without opening a bus.
- PARAMETER_SETS = {'AM_LFOut': ('OFF', 'ON'), 'AM_sources': ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF'), 'AM_waveforms': ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH'), 'ATT_modes': ('AUTO', 'FIXED'), 'PM_pol': ('NORMAL', 'INVERTED'), 'PM_sources': ('INT', 'EXT1', 'EXT2', 'OFF')}¶
- PMOff()¶
Disable simulated PM.
- PMOn()¶
Enable simulated PM.
- PM_pol = ('NORMAL', 'INVERTED')¶
- PM_sources = ('INT', 'EXT1', 'EXT2', 'OFF')¶
- Quit()¶
Safely stop all simulated outputs.
- RFOff()¶
Disable simulated RF output.
- RFOn()¶
Enable simulated RF output.
- SetAM(state)¶
Set simulated AM output state.
- SetFreq(freq)¶
Set and return the simulated RF frequency.
- SetLevel(lv)¶
Set and return the simulated RF level.
- SetPM(state)¶
Set simulated PM output state.
- SetState(state)¶
Set RF output state using the public signal-generator API vocabulary.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'attenuation': <class 'float'>, 'attmode': <class 'str'>, 'level': <class 'float'>, 'levellimit': <class 'float'>, 'leveloffset': <class 'float'>, 'name': <class 'str'>, 'outputstate': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- map = {'AM_LFOut': bidict({'OFF': 'OFF', 'ON': 'ON'}), 'AM_sources': bidict({'INT1': 'INT1', 'INT2': 'INT2', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'EXT_AC': 'EXT_AC', 'EXT_DC': 'EXT_DC', 'TWOTONE_AC': 'TWOTONE_AC', 'TWOTONE_DC': 'TWOTONE_DC', 'OFF': 'OFF'}), 'AM_waveforms': bidict({'SINE': 'SINE', 'SQUARE': 'SQUARE', 'TRIANGLE': 'TRIANGLE', 'NOISE': 'NOISE', 'SAWTOOTH': 'SAWTOOTH'}), 'ATT_modes': bidict({'AUTO': 'AUTO', 'FIXED': 'FIXED'}), 'PM_pol': bidict({'NORMAL': 'NORMAL', 'INVERTED': 'INVERTED'}), 'PM_sources': bidict({'INT': 'INT', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'OFF': 'OFF'})}¶
- query(cmd, tmpl=None)¶
Write a virtual SCPI query and return the raw or parsed response.
- read(tmpl=None)¶
Return or parse the last virtual SCPI response.
- write(cmd)¶
Handle a small SCPI-like command subset without a hardware bus.
- mpylab.device.sg_virtual.main()¶
main function.
mpylab.device.signalgenerator¶
Base signal-generator driver with shared command helpers and tests.
- class mpylab.device.signalgenerator.SIGNALGENERATOR(SearchPaths=None)¶
Parent class for all py-drivers for signal generators.
The parent class is
mpylab.device.driver.DRIVER.- AMOff()¶
Switch AM modulation off.
- AMOn()¶
Switch AM modulation on.
- AM_LFOut = ('OFF', 'ON')¶
- AM_sources = ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF')¶
- AM_waveforms = ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH')¶
- ATT_modes = ('AUTO', 'FIXED')¶
- ConfAM(source, freq, depth, waveform, LFOut)¶
Configure AM modulation parameters.
- ConfPM(source, freq, pol, width, delay)¶
Configure PM modulation parameters.
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetFreq()¶
Read and return output frequency in Hz.
- GetLevel()¶
Read and return RF output level as scuq quantity.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=False)¶
Init the instrument.
Parameters:
ini: filename or file-like object with the initialization parameters for the device. This parameter is handled by
mpylab.tools.Configuration.Configuration()which takes also a configuration template stored inself.conftmpl.channel: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
Return: 0 if sucessful.
- PARAMETER_SETS = {'AM_LFOut': ('OFF', 'ON'), 'AM_sources': ('INT1', 'INT2', 'EXT1', 'EXT2', 'EXT_AC', 'EXT_DC', 'TWOTONE_AC', 'TWOTONE_DC', 'OFF'), 'AM_waveforms': ('SINE', 'SQUARE', 'TRIANGLE', 'NOISE', 'SAWTOOTH'), 'ATT_modes': ('AUTO', 'FIXED'), 'PM_pol': ('NORMAL', 'INVERTED'), 'PM_sources': ('INT', 'EXT1', 'EXT2', 'OFF')}¶
- PMOff()¶
Switch PM modulation off.
- PMOn()¶
Switch PM modulation on.
- PM_pol = ('NORMAL', 'INVERTED')¶
- PM_sources = ('INT', 'EXT1', 'EXT2', 'OFF')¶
- Quit()¶
Quit the instrument.
- RFOff()¶
Switch RF output off.
- RFOn()¶
Switch RF output on.
- SetAM(state)¶
Enable or disable AM modulation.
- SetFreq(freq)¶
Set output frequency in Hz and read back value.
- SetLevel(lv)¶
Set RF output level as scuq quantity and return readback quantity.
- SetPM(state)¶
Enable or disable PM modulation.
- SetState(state)¶
Set RF output state using
on/offsemantics.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'channel_%d': {'attenuation': <class 'float'>, 'attmode': <class 'str'>, 'level': <class 'float'>, 'levellimit': <class 'float'>, 'leveloffset': <class 'float'>, 'name': <class 'str'>, 'outputstate': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- map = {'AM_LFOut': bidict({'OFF': 'OFF', 'ON': 'ON'}), 'AM_sources': bidict({'INT1': 'INT1', 'INT2': 'INT2', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'EXT_AC': 'EXT_AC', 'EXT_DC': 'EXT_DC', 'TWOTONE_AC': 'TWOTONE_AC', 'TWOTONE_DC': 'TWOTONE_DC', 'OFF': 'OFF'}), 'AM_waveforms': bidict({'SINE': 'SINE', 'SQUARE': 'SQUARE', 'TRIANGLE': 'TRIANGLE', 'NOISE': 'NOISE', 'SAWTOOTH': 'SAWTOOTH'}), 'ATT_modes': bidict({'AUTO': 'AUTO', 'FIXED': 'FIXED'}), 'PM_pol': bidict({'NORMAL': 'NORMAL', 'INVERTED': 'INVERTED'}), 'PM_sources': bidict({'INT': 'INT', 'EXT1': 'EXT1', 'EXT2': 'EXT2', 'OFF': 'OFF'})}¶
- mpylab.device.signalgenerator.test_normal()¶
Run manual integration test against configured driver.
- mpylab.device.signalgenerator.test_signalgenerator_virtual()¶
Run internal virtual-driver smoke test.
mpylab.device.signalgenerator_ui¶
Graphical test utility for signal generator drivers.
- class mpylab.device.signalgenerator_ui.DriverTask(*args: Any, **kwargs: Any)¶
Execute a driver callable in a dedicated worker thread.
- completed¶
alias of
object
- run()¶
Execute the worker callable and emit completion signals.
- class mpylab.device.signalgenerator_ui.SignalGeneratorWidget(*args: Any, **kwargs: Any)¶
Threaded test UI for the common signal generator driver API.
- closeEvent(event)¶
- log_edit_clear()¶
Clear the UI log view.
- log_message(message)¶
Append a timestamped message to the log view.
- on_am_off_clicked()¶
Disable AM modulation.
- on_am_on_clicked()¶
Enable AM modulation.
- on_apply_freq_clicked(value=None)¶
Apply frequency setpoint to the signal generator.
- on_apply_level_clicked()¶
Apply output level setpoint to the signal generator.
- on_conf_am_clicked()¶
Apply AM modulation configuration.
- on_conf_pm_clicked()¶
Apply PM modulation configuration.
- on_init_clicked()¶
Initialize selected signal-generator driver from INI text.
- on_load_ini_clicked()¶
Load INI content from a file into the editor.
- on_pm_off_clicked()¶
Disable PM modulation.
- on_pm_on_clicked()¶
Enable PM modulation.
- on_read_freq_clicked()¶
Request a frequency readback refresh.
- on_read_level_clicked()¶
Request a level readback refresh.
- on_rf_off_clicked()¶
Switch RF output off.
- on_rf_on_clicked()¶
Switch RF output on.
- on_run_smoke_test_clicked()¶
Run conservative smoke test and display collected results.
- on_save_ini_clicked()¶
Save current INI content to a file.
- populate_controls_from_status()¶
Populate writable controls from latest driver status snapshot.
- refresh_all()¶
Refresh all status-dependent UI fields.
- refresh_status(on_complete=None)¶
Refresh status fields from driver readback values.
- mpylab.device.signalgenerator_ui.UI¶
alias of
SignalGeneratorWidget
mpylab.device.spectrumanalyzer¶
mpylab.device.spectrumanalyzer module.
- class mpylab.device.spectrumanalyzer.SPECTRUMANALYZER(SearchPaths=None)¶
Parent class of all py-drivers for spectrum analyzers.
The parent class is
mpylab.device.driver.DRIVER.- ATTMODES = ('NORMAL', 'LOWNOISE', 'LOWDIST')¶
- DETECTORS = ('AUTOSELECT', 'AUTOPEAK', 'MAXPEAK', 'MINPEAK', 'SAMPLE', 'RMS', 'AVERAGE', 'DET_QPEAK')¶
- GetDescription()¶
Returns
(0, desc)withdescis the concatenation ofself.conf['description']andself.IDN. The former comes from the ini file, the latter may be set by the driver during initialization.
- GetVirtual()¶
Returns
(0, self.conf['init_value']['virtual'])
- Init(ini=None, channel=None, ignore_bus=False)¶
Init the instrument.
Parameters:
ini: filename or file-like object with the initialization parameters for the device. This parameter is handled by
mpylab.tools.Configuration.Configuration()which takes also a configuration template stored inself.conftmpl.channel: an integer specifiing the channel number of multi channel devices. Numbering is starting with 1.
Return: 0 if sucessful.
- Quit()¶
Quit the instrument.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- TRACEMODES = ('WRITE', 'VIEW', 'AVERAGE', 'BLANK', 'MAXHOLD', 'MINHOLD')¶
- TRIGGERMODES = ('FREE', 'VIDEO', 'EXTERNAL')¶
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'attmode': <class 'str'>, 'detector': <class 'str'>, 'rbw': <class 'str'>, 'reflevel': <class 'float'>, 'span': <class 'float'>, 'sweepcount': <class 'int'>, 'sweeppoints': <class 'int'>, 'sweeptime': <class 'float'>, 'trace': <class 'int'>, 'tracemode': <class 'str'>, 'triggermode': <class 'str'>, 'unit': <class 'str'>, 'vbw': <class 'float'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
mpylab.device.spectrumanalyzer_ui¶
Graphical test utility for spectrum analyzer drivers.
- class mpylab.device.spectrumanalyzer_ui.DriverTask(*args: Any, **kwargs: Any)¶
Execute one driver callable in a worker thread.
- completed¶
alias of
object
- run()¶
Execute the worker callable and emit completion signals.
- class mpylab.device.spectrumanalyzer_ui.MplCanvas(*args: Any, **kwargs: Any)¶
Matplotlib canvas for spectrum data.
- set_grid_enabled(enabled)¶
Enable or disable plot grid.
- set_title_text(title)¶
Update plot title.
- update_plot(x, y)¶
Redraw spectrum data.
- class mpylab.device.spectrumanalyzer_ui.SpectrumAnalyzerWidget(*args: Any, **kwargs: Any)¶
Thread-aware test UI for the common spectrum analyzer driver API.
- choice_fields = {'Att': ('auto',), 'AttMode': ('NORMAL', 'LOWNOISE', 'LOWDIST'), 'Detector': ('AUTOSELECT', 'AUTOPEAK', 'MAXPEAK', 'MINPEAK', 'SAMPLE', 'RMS', 'AVERAGE', 'DET_QPEAK'), 'RBW': ('auto',), 'TraceMode': ('WRITE', 'VIEW', 'AVERAGE', 'BLANK', 'MAXHOLD', 'MINHOLD'), 'TriggerMode': ('FREE', 'VIDEO', 'EXTERNAL')}¶
- closeEvent(event)¶
- controls = ('CenterFreq', 'Span', 'StartFreq', 'StopFreq', 'RBW', 'VBW', 'RefLevel', 'Att', 'AttMode', 'PreAmp', 'Detector', 'TraceMode', 'Trace', 'SweepCount', 'SweepTime', 'TriggerMode', 'TriggerDelay', 'SweepPoints')¶
- field_types = {'Att': <class 'str'>, 'AttMode': <class 'str'>, 'CenterFreq': <class 'float'>, 'Detector': <class 'str'>, 'PreAmp': <class 'float'>, 'RBW': <class 'str'>, 'RefLevel': <class 'float'>, 'Span': <class 'float'>, 'StartFreq': <class 'float'>, 'StopFreq': <class 'float'>, 'SweepCount': <class 'int'>, 'SweepPoints': <class 'int'>, 'SweepTime': <class 'float'>, 'Trace': <class 'int'>, 'TraceMode': <class 'str'>, 'TriggerDelay': <class 'float'>, 'TriggerMode': <class 'str'>, 'VBW': <class 'float'>}¶
- frequency_fields = {'CenterFreq', 'RBW', 'Span', 'StartFreq', 'StopFreq', 'VBW'}¶
- log_message(message)¶
Append a timestamped message to the log view.
- on_export_csv_clicked()¶
Export last acquired spectrum to CSV.
- on_get_spectrum_clicked()¶
Acquire one blocking spectrum trace.
- on_get_spectrum_nb_clicked()¶
Acquire one non-blocking spectrum trace.
- on_grid_toggled(checked)¶
Toggle spectrum plot grid visibility.
- on_init_clicked()¶
Initialize active spectrum-analyzer driver from INI text.
- on_load_ini_clicked()¶
Load INI content from file into the editor.
- on_quit_clicked()¶
Call driver
Quitand reset initialized state.
- on_raw_query_clicked()¶
Execute raw query command and append response.
- on_raw_write_clicked()¶
Execute raw write command and append response.
- on_save_ini_clicked()¶
Save current INI editor content to file.
- on_smoke_clicked()¶
Run conservative spectrum-analyzer smoke test.
- refresh_all()¶
Refresh status and detailed control readbacks.
- refresh_controls()¶
Refresh control rows not covered by compact status view.
- refresh_status(on_complete=None)¶
Refresh high-level status fields from driver getters.
- mpylab.device.spectrumanalyzer_ui.UI¶
alias of
SpectrumAnalyzerWidget
- mpylab.device.spectrumanalyzer_ui.main(argv=None)¶
Start standalone spectrum-analyzer test utility.
mpylab.device.spectrumanalyzer_virtual¶
Virtual spectrum analyzer driver for UI and API tests.
- class mpylab.device.spectrumanalyzer_virtual.SPECTRUMANALYZER(SearchPaths=None)¶
Deterministic spectrum analyzer model with the standard driver API.
- ATTMODES = ('NORMAL', 'LOWNOISE', 'LOWDIST')¶
- DETECTORS = ('AUTOSELECT', 'AUTOPEAK', 'MAXPEAK', 'MINPEAK', 'SAMPLE', 'RMS', 'AVERAGE', 'DET_QPEAK')¶
- GetAtt()¶
Return current input attenuation setting.
- GetAttMode()¶
Return current attenuation mode.
- GetCenterFreq()¶
Return current center frequency in Hz.
- GetDescription()¶
Return the configured instrument description string.
- GetDetector()¶
Return current detector mode.
- GetPreAmp()¶
Return current preamplifier gain setting.
- GetRBW()¶
Return current resolution bandwidth setting.
- GetRefLevel()¶
Return current display reference level.
- GetSpan()¶
Return current frequency span in Hz.
- GetSpectrum()¶
Generate a deterministic synthetic spectrum trace.
- GetSpectrumNB()¶
Return the same synthetic spectrum as the blocking API.
- GetStartFreq()¶
Return current start frequency in Hz.
- GetStopFreq()¶
Return current stop frequency in Hz.
- GetSweepCount()¶
Return configured sweep count.
- GetSweepPoints()¶
Return configured number of sweep points.
- GetSweepTime()¶
Return sweep time in seconds.
- GetTrace()¶
Return active trace index.
- GetTraceMode()¶
Return current trace mode.
- GetTriggerDelay()¶
Return trigger delay in seconds.
- GetTriggerMode()¶
Return current trigger mode.
- GetVBW()¶
Return current video bandwidth in Hz.
- GetVirtual()¶
Report that this driver instance is virtual.
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize the virtual analyzer from optional INI content.
- Quit()¶
Close the virtual driver session.
- SetAtt(value)¶
Set input attenuation setting.
- SetAttAuto()¶
Enable automatic attenuation mode.
- SetAttMode(value)¶
Set attenuation mode string.
- SetCenterFreq(value)¶
Set center frequency in Hz and update start/stop frequencies.
- SetDetector(value)¶
Set detector mode.
- SetPreAmp(value)¶
Set preamplifier gain setting.
- SetRBW(value)¶
Set resolution bandwidth setting.
- SetRefLevel(value)¶
Set display reference level.
- SetSpan(value)¶
Set frequency span in Hz and update start/stop frequencies.
- SetStartFreq(value)¶
Set start frequency in Hz and update center/span values.
- SetStopFreq(value)¶
Set stop frequency in Hz and update center/span values.
- SetSweepCount(value)¶
Set configured sweep count.
- SetSweepPoints(value)¶
Set number of sweep points (minimum 2).
- SetSweepTime(value)¶
Set sweep time in seconds.
- SetTrace(value)¶
Set active trace index.
- SetTraceMode(value)¶
Set trace mode.
- SetTriggerDelay(value)¶
Set trigger delay in seconds.
- SetTriggerMode(value)¶
Set trigger mode.
- SetVBW(value)¶
Set video bandwidth in Hz.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- TRACEMODES = ('WRITE', 'VIEW', 'AVERAGE', 'BLANK', 'MAXHOLD', 'MINHOLD')¶
- TRIGGERMODES = ('FREE', 'VIDEO', 'EXTERNAL')¶
- conftmpl = {'channel_%d': {'attenuation': <class 'str'>, 'attmode': <class 'str'>, 'detector': <class 'str'>, 'rbw': <class 'str'>, 'reflevel': <class 'float'>, 'span': <class 'float'>, 'sweepcount': <class 'int'>, 'sweeppoints': <class 'int'>, 'sweeptime': <class 'float'>, 'trace': <class 'int'>, 'tracemode': <class 'str'>, 'triggermode': <class 'str'>, 'unit': <class 'str'>, 'vbw': <class 'float'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'gpib': <class 'int'>, 'nr_of_channels': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- query(cmd, tmpl=None)¶
Write a virtual SCPI query and return the raw or parsed response.
- read(tmpl=None)¶
Return or parse the last virtual SCPI response.
- write(cmd)¶
Handle a small SCPI-like command subset without a hardware bus.
mpylab.device.switch¶
mpylab.device.switch module.
- mpylab.device.switch.switch(swstr=None, fstr=None, fs=None)¶
Switch the relais. swstr: a string refering to the instance of the switch device, e.g. ‘self.sw’ fstr: a string with the name of the variable to look for (frequency), e.g. ‘f’ fs: upper limit for switch states, e.g. fs=1e9 -> f=900MHz->state=0; f=1.1e9->state=1
mpylab.device.switch_virtual¶
Virtual switch driver for tests without switching hardware.
- class mpylab.device.switch_virtual.SWITCH(SearchPaths=None)¶
In-memory switch implementation exposing the expected
switch_toAPI.- GetDescription()¶
Return a virtual identification string.
- GetState()¶
Return the active switch state.
- GetStates()¶
Return the number of available virtual switch states.
- GetVirtual()¶
Return whether this driver is virtual.
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize the virtual switch without opening a hardware bus.
- Quit()¶
Quit the virtual switch.
- SetState(state)¶
Set and return the active switch state.
- SetVirtual(virtual)¶
Sets
self.conf['init_value']['virtual']tovirtual.
- conftmpl = {'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'initial_state': <class 'int'>, 'states': <class 'int'>, 'virtual': <function strbool>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- query(cmd, tmpl=None)¶
Write a virtual command and return the raw or parsed response.
- read(tmpl=None)¶
Return or parse the last virtual command response.
- switch_to(state)¶
Switch to a zero-based state index and return an error code.
- write(cmd)¶
Handle a small command subset for raw command tests.
- mpylab.device.switch_virtual.main()¶
Run a short virtual switch smoke test.
mpylab.device.ui_frequency¶
Reusable frequency input widget with direct unit apply buttons.
- class mpylab.device.ui_frequency.FrequencyControl(*args: Any, **kwargs: Any)¶
Input a frequency-like value using a normalized value field and unit buttons.
- UNITS = (('Hz', 1.0), ('kHz', 1000.0), ('MHz', 1000000.0), ('GHz', 1000000000.0))¶
- apply_unit(unit)¶
Select a unit and emit the resulting value in Hz.
- set_enabled(enabled)¶
Enable or disable the input and unit buttons.
- set_value_hz(value_hz)¶
Display a Hz value using the largest unit that keeps the value <= 1000.
- valueApplied¶
alias of
float
- value_hz()¶
Return the currently displayed value converted to Hz.
mpylab.device.ui_ini_draft¶
Shared autosave support for editable INI tabs in device UIs.
- class mpylab.device.ui_ini_draft.IniPlainTextEdit(*args: Any, **kwargs: Any)¶
Plain-text INI editor that normalizes pasted indented blocks.
- insertFromMimeData(source)¶
insertFromMimeData method.
- keyPressEvent(event)¶
- paste()¶
paste method.
- mpylab.device.ui_ini_draft.clear_ini_draft(owner)¶
Drop the autosaved draft after an explicit successful file save.
- mpylab.device.ui_ini_draft.load_ini_with_draft(owner, editor, ini_source, default_text, settings_app, use_draft=True)¶
Load INI text, preferring an unsaved draft stored in QSettings.
mpylab.device.ui_quantity_display¶
Shared display conversion for quantities loaded from INI data files.
- mpylab.device.ui_quantity_display.data_file_unit(device, what)¶
Return the unit declared in the parsed file block for a data channel.
- mpylab.device.ui_quantity_display.quantity_display_values(quantity, *, device=None, what=None, mode='INI/file unit', context=None)¶
Return
(value, uncertainty, unit)for UI display.The default mode converts logarithmic INI/file units back to their original notation, while
SCUQ_UNIT_MODEexposes the raw scuq representation.
mpylab.device.validators¶
This is mpylab.device.validators:
This module provides validator helpers used by parameter handling code. A validator checks whether a value satisfies a given rule.
- author:
Christian Albrecht
- license:
GPL-3 or higher
- class mpylab.device.validators.IN_RANGE(mini, maxi, message='')¶
Validate that a numeric value is inside a closed interval.
- class mpylab.device.validators.IS_GREATER_EQUAL_THAN(mini, message='')¶
Validate that a numeric value is greater than or equal to a limit.
- class mpylab.device.validators.IS_GREATER_THAN(mini, message='')¶
Validate that a numeric value is strictly greater than a limit.
- class mpylab.device.validators.IS_IN_SET(seti, message='')¶
Validate that a value is contained in an allowed set.
- class mpylab.device.validators.IS_LOWER_EQUAL_THAN(maxi, message='')¶
Validate that a numeric value is less than or equal to a limit.
- class mpylab.device.validators.IS_LOWER_THAN(maxi, message='')¶
Validate that a numeric value is strictly smaller than a limit.
mpylab.device.vlisn¶
Base driver for V-type LISN data sources.
- class mpylab.device.vlisn.VLISN(SearchPaths=None)¶
Child class for all py-drivers for V-Type LISN The parent class is DRIVER
- GetData(what)¶
Return interpolated LISN data for the selected channel name.
- GetDescription()¶
Return the device description from configuration.
- GetFilter()¶
Return the current filter state flag.
- GetPath()¶
Return the currently selected LISN path.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None, ignore_bus=False)¶
Initialize LISN channels and load interpolation data from files.
- Quit()¶
Close the driver and return the status code.
- SetFilter(state)¶
Set internal filter state flag.
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetPath(path)¶
Set LISN path token and request manual switch confirmation.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'filter': <function strbool>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'ip': <class 'str'>, 'nr_of_channels': <class 'int'>, 'path': <class 'str'>, 'unit': <class 'str'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.vlisn.main()¶
Run a simple manual smoke test for the VLISN driver.
mpylab.device.vlisn_heinen_nnb4_32¶
mpylab.device.vlisn_heinen_nnb4_32 module.
- class mpylab.device.vlisn_heinen_nnb4_32.VLISN(**kw)¶
V-Type LISN device R&S ENV216
- GetData(what)¶
Return interpolated LISN data for the selected channel name.
- GetDescription()¶
Return the device description from configuration.
- GetFilter()¶
Return the current filter state flag.
- GetPath()¶
Return the currently selected LISN path.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None, ignore_bus=True)¶
Init method.
- Quit()¶
Close the driver and return the status code.
- SetFilter(state)¶
SetFilter method.
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetPath(path)¶
SetPath method.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'filter': <function strbool>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'ip': <class 'str'>, 'nr_of_channels': <class 'int'>, 'path': <class 'str'>, 'unit': <class 'str'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- ip = '192.168.88.6'¶
- mpylab.device.vlisn_heinen_nnb4_32.main()¶
main function.
mpylab.device.vlisn_rs_env216¶
mpylab.device.vlisn_rs_env216 module.
- class mpylab.device.vlisn_rs_env216.VLISN(**kw)¶
V-Type LISN device R&S ENV216
- GetData(what)¶
Return interpolated LISN data for the selected channel name.
- GetDescription()¶
Return the device description from configuration.
- GetFilter()¶
Return the current filter state flag.
- GetPath()¶
Return the currently selected LISN path.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None, ignore_bus=True)¶
Init method.
- Quit()¶
Close the driver and return the status code.
- SetFilter(state)¶
SetFilter method.
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetPath(path)¶
SetPath method.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'filter': <function strbool>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'ip': <class 'str'>, 'nr_of_channels': <class 'int'>, 'path': <class 'str'>, 'unit': <class 'str'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- ip = '192.168.88.6'¶
- mpylab.device.vlisn_rs_env216.main()¶
main function.
mpylab.device.vlisn_rs_env216_dummy¶
mpylab.device.vlisn_rs_env216_dummy module.
- class mpylab.device.vlisn_rs_env216_dummy.VLISN(**kw)¶
V-Type LISN device R&S ENV216 dummy driver
- GetData(what)¶
Return interpolated LISN data for the selected channel name.
- GetDescription()¶
Return the device description from configuration.
- GetFilter()¶
Return the current filter state flag.
- GetPath()¶
Return the currently selected LISN path.
- GetVirtual()¶
Return whether virtual mode is enabled.
- Init(ini=None, channel=None, ignore_bus=True)¶
Init method.
- Quit()¶
Close the driver and return the status code.
- SetFilter(state)¶
Set internal filter state flag.
- SetFreq(freq)¶
Set current interpolation frequency in Hz.
- SetPath(path)¶
SetPath method.
- SetVirtual(virtual)¶
Enable or disable virtual mode in runtime configuration.
- conftmpl = {'channel_%d': {'file': <function _file_source>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'filter': <function strbool>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'ip': <class 'str'>, 'nr_of_channels': <class 'int'>, 'path': <class 'str'>, 'unit': <class 'str'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- mpylab.device.vlisn_rs_env216_dummy.main()¶
main function.
mpylab.device.vlisn_ui¶
Graphical test utility for V-LISN drivers.
- class mpylab.device.vlisn_ui.DriverTask(*args: Any, **kwargs: Any)¶
Execute one driver callable in a worker thread.
- completed¶
alias of
object
- run()¶
Execute the worker callable and emit completion signals.
- mpylab.device.vlisn_ui.UI¶
alias of
VlisnWidget
- class mpylab.device.vlisn_ui.VlisnCanvas(*args: Any, **kwargs: Any)¶
Matplotlib canvas for V-LISN correction data.
- set_grid_enabled(enabled)¶
Enable or disable plot grid.
- update_plot(rows, what='')¶
Redraw correction values over frequency.
- class mpylab.device.vlisn_ui.VlisnWidget(*args: Any, **kwargs: Any)¶
Thread-aware test UI for the common V-LISN driver API.
- closeEvent(event)¶
- log_message(message)¶
Append a timestamped message to the log view.
- on_clear_plot_clicked()¶
Clear current plot data.
- on_export_csv_clicked()¶
Export last acquired plot rows to CSV.
- on_get_data_clicked()¶
Acquire one correction value for selected data name.
- on_grid_toggled(checked)¶
Toggle plot grid visibility.
- on_init_clicked()¶
Initialize active V-LISN driver from current INI text.
- on_load_ini_clicked()¶
Load INI content from file into the editor.
- on_plot_clicked()¶
Acquire a sweep over frequency range and plot values.
- on_quit_clicked()¶
Call driver
Quitand reset initialized state.
- on_raw_query_clicked()¶
Execute raw query command and append response.
- on_raw_write_clicked()¶
Execute raw write command and append response.
- on_read_freq_clicked()¶
Read current V-LISN frequency.
- on_save_ini_clicked()¶
Save current INI editor content to file.
- on_set_filter_toggled(checked)¶
Enable or disable LISN filter state.
- on_set_freq_clicked(freq=None)¶
Set V-LISN frequency in Hz.
- on_set_path_clicked()¶
Set active LISN path.
- on_smoke_clicked()¶
Run conservative V-LISN smoke test sequence.
- refresh_status()¶
Refresh status fields from supported driver getters.
- mpylab.device.vlisn_ui.main(argv=None)¶
Start standalone V-LISN test utility.
mpylab.device.vlisn_virtual¶
Virtual V-LISN driver for UI and workflow tests without hardware.
- class mpylab.device.vlisn_virtual.VLISN(SearchPaths=None)¶
Synthetic V-LISN implementation using the public VLISN API.
- GetChannels()¶
Return available correction data names.
- GetData(what)¶
Return a synthetic correction value for the selected data channel.
- GetDescription()¶
Return the virtual device identification.
- GetFilter()¶
Return the simulated filter state.
- GetFreq()¶
Return the active interpolation frequency in Hz.
- GetPath()¶
Return the selected LISN path.
- GetVirtual()¶
Return whether this driver is virtual.
- Init(ini=None, channel=None, ignore_bus=True)¶
Initialize the virtual V-LISN from INI without opening a bus.
- Quit()¶
Close the virtual V-LISN.
- SetFilter(state)¶
Set and return the simulated filter state.
- SetFreq(freq)¶
Set and return the active interpolation frequency in Hz.
- SetPath(path)¶
Set and return the selected LISN path.
- SetVirtual(virtual)¶
Set virtual flag for API compatibility.
- conftmpl = {'channel_%d': {'file': <function VLISN.<lambda>>, 'interpolation': <class 'str'>, 'name': <class 'str'>, 'unit': <class 'str'>}, 'description': {'description': <class 'str'>, 'deviceid': <class 'str'>, 'driver': <class 'str'>, 'serialnr': <class 'str'>, 'type': <class 'str'>, 'vendor': <class 'str'>}, 'init_value': {'filter': <function strbool>, 'fstart': <class 'float'>, 'fstep': <class 'float'>, 'fstop': <class 'float'>, 'ip': <class 'str'>, 'nr_of_channels': <class 'int'>, 'path': <class 'str'>, 'unit': <class 'str'>, 'virtual': <function strbool>, 'visa': <class 'str'>}}¶
- get_config(ini, channel)¶
Load configuration for a channel from ini source into
self.conf.
- query(cmd, tmpl=None)¶
Write a virtual SCPI query and return the raw or parsed response.
- read(tmpl=None)¶
Return or parse the last virtual SCPI response.
- write(cmd)¶
Handle a small SCPI-like command subset without a hardware bus.
mpylab.env¶
mpylab.env.Measure¶
This is mpylab.env.Measure with mpylab.env.Measure.Measure being the base class for e.g. mpylab.env.msc.MSC.MSC
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- exception mpylab.env.Measure.AmplifierProtectionError(message)¶
AmplifierProtectionError class.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception mpylab.env.Measure.Error¶
Base class for all exceptions of this module
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class mpylab.env.Measure.Measure(SearchPaths=None)¶
Base class for measurements.
- MakeDeslist(thedata, description)¶
Backward-compatible wrapper around
make_deslist().
- MakeWhatlist(thedata, what)¶
Backward-compatible wrapper around
make_whatlist().
- doLeveling(leveling, mg, names, dct)¶
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 returningNone.
- do_autosave(name_or_obj=None, depth=None, prefixes=None)¶
Serialize self using
pickle.Assuming a calling sequence like so:
script -> method of measurement class -> do_autosave
depth = 1 (default) will set self.ascmd to the command issued in the script.
If depth is too large, the outermost command is used.
Thus, the issued command in script is extracted and saved in self.ascmd. This can be used to redo the command after a crash.
Return: None
- make_deslist(thedata, description)¶
make_deslist method.
- make_whatlist(thedata, what)¶
make_whatlist method.
- out(item)¶
Helper function for all output functions.
Prints item recursively all in one line.
The parameter item can be:
a
dictof items (hasattr(item, ‘keys’)==True)a
listof items (hasattr(item, ‘index’)==True)a sequence of items (using
mpylab.tools.util.issequence())or anything else (will be printed via print item,)
The return value is None.
- setLevel(mg, level_or_names, level_or_leveler=None)¶
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)
- set_autosave(name)¶
Setter for the class attribute asname (name of the auto save file).
Parameter name: file name oif the auto save file
Return: None
- set_autosave_interval(interval)¶
Set the intervall between auto save.
intervall: seconds between auto save
This method returns None.
- set_interactive_runner(runner)¶
Set function used for interactive user sessions.
- set_level(mg, l, leveler=None)¶
- set_logfile(name)¶
Tries to open a file with the given name with mode ‘a+’. If this fails, nothing will happen, else
stdloogger()will log to this file.Parameter name: full qualified name of the file to be used as logfile
Return: None
- set_logger(logger=None)¶
Set up the list of logger fuctions (self.logger).
If logger is None,
stdlogger()is used.Parameter logger: list of functions called to log events
Return: None
- set_messenger(messenger)¶
Set function to present messages.
Parameter messenger: the messenger (see
stdUserMessenger())Return: None
- set_post_user_event(event_cb)¶
Set function called after user-facing UI interactions.
- set_pre_user_event(event_cb)¶
Set function called before user-facing UI interactions.
- set_user_interrupt_Tester(tester)¶
Backward-compatible alias for
set_user_interrupt_tester().
- set_user_interrupt_tester(tester)¶
Set function to test for user interrupt.
Parameter tester: callable (see
stdUserInterruptTester()).Return: None
- static stdEutStatusChecker(status)¶
stdEutStatusChecker method.
- static stdInteractiveSession(obj, banner)¶
Default interactive session hook for terminal usage.
- static stdPostUserEvent()¶
stdPostUserEvent method.
- static stdPreUserEvent()¶
stdPreUserEvent method.
- static stdUserInterruptTester() int | None¶
The standard (default) user interrupt tester.
Returns return value of
mpylab.util.anykeyevent()
- stdUserMessenger(msg: str = 'Are you ready?', but: list[str] | None = None, level: str = '', dct: dict[Any, Any] | None = None) int¶
The standard (default) method to present messages to the user.
The behaviour depends on the value of the parameter but. If len(but) (buttons are given) the funttions waits for a user answer. Else, the msg is presented only.
The function also calls all additional logger functions given in self.logger with the same arguments.
Parameters:
msg: message to display
but: sequence with the text strings of the buttons
level: to indicate something (not used in the standard logger)
dct: a
dictwith further parameters (not used in the standard logger)
Return value: the index of the selected button (starting from 0), or -1 if len(but) is False.
- static std_eut_status_checker(status)¶
Backward-compatible alias for
stdEutStatusChecker().
- stdlogger(block, *args)¶
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 functionout_block(). Else, the block is printed directly.Parameter block: object to log
Return value: None
- wait(delay, dct, uitester, intervall=0.1)¶
A wait function that can be interrupted.
delay: seconds to wait
dct: namespace passed to legacy handler style
uitester: interrupt callback; supports
fn(dct)andfn()intervall: seconds to sleep between callback calls
Return: None
mpylab.env.custom¶
mpylab.env.custom module.
- mpylab.env.custom.my_switch(swstr, fstr, fs=1000000000.0)¶
Function to switch a switch swstr depending from the value of the variable fstr with respect to fs.
mpylab.env.msc.ImmunityThreshold¶
This is mpylab.env.msc.ImmunityThreshold.
Provides mpylab.env.msc.ImmunityThreshold for EMC measurements in MSC were the threshold is searched
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.env.msc.ImmunityThreshold.FieldLst(lst: Iterable[float])¶
A callable list of field strength values
- next_freq(max_last: int = -5) float | None¶
Indicate switch to next frequency and return field strength value or None if list is exhausted.
Parameter: max_last: maximum number of field strength values to test for this frequency (default: 5)
- class mpylab.env.msc.ImmunityThreshold.ImmunityKernel_Thres(messenger: Callable[[str, Iterable[str] | None, str, dict[Any, Any] | None], int], UIHandler: Callable[[], int | None], locals: dict[str, Any], dwell: float, keylist: str = 'sS', tp: dict[float, list[Any]] | None = None, field: list[float] | None = None, testfreqs: list[float] | None = None)¶
Class for EMC radiated immunity testing. Aims to find the susceptibility threshold by increasing the field strength
- test(stat: str)¶
Perform the test according to test plan.
- Parameter:
stat: string, at the moment, only ‘AmplifierProtectionError’ is used. If called with this status -> go to next frequency.
mpylab.env.msc.MSC¶
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¶
A class for Mode Stirred Chamber measurements
The following main functions are defined: Measure_MainCal -> Performs a msc main calibration according to IEC 61000-4-21 Measure_Autocorrelation -> Performs a msc autocorrelation measurement Measure_EUTCal -> Performs a msc EUT calibration according to IEC 61000-4-21 Measure_Immunity -> Performs a msc immunity measurement according to IEC 61000-4-21 getMaxE -> Determine maximum E-field strength Measure_Emission -> Performs a msc emission measurement according to IEC 61000-4-21
- CalculateLoading_EUTCal(empty_cal='empty', eut_cal='EUT', freqs=None, interpolation='linxliny')¶
Calculate the chamber loading from processed data (MainCal) If freqs is None, freqs are taken fron first ACF and second ACF is interpolated Else both are interpolated
- CalculateLoading_MainCal(empty_cal='empty', loaded_cal='loaded', freqs=None, interpolation='linxliny')¶
Calculate the chamber loading from processed data (MainCal) If freqs is None, freqs are taken fron first ACF and second ACF is interpolated Else both are interpolated
- Evaluate_AutoCorr(description='empty', lag=None, alpha=0.05, rho=0.44, rho0=None, skip=None, every=1, offset=0)¶
Evaluate autocorrelation, independence, and distribution metrics.
- Evaluate_EUTCal(description='EUT', calibration='empty')¶
Evaluate EUT calibration measurements against chamber calibration.
- 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 raw data using chamber calibration data.
- Evaluate_Immunity(description='EUT', empty_cal='empty', loaded_cal='loaded', EUT_cal='EUT', EUT_OK=None, interpolation='linxliny')¶
Evaluate immunity measurements and derive threshold statistics.
- Evaluate_MainCal(description='empty', standard=None, freqs=None)¶
Evaluate main calibration raw data into processed metrics.
- GetAllTPos(description)¶
Return all tuner-position combinations found in main-cal raw data.
- GetFreqs_MainCal(description)¶
Return sorted frequencies for one raw main-calibration description.
- GetKeys_MainCal()¶
Return available processed main-calibration description keys.
- MakeDeslist(thedata, description)¶
Backward-compatible wrapper around
make_deslist().
- MakeWhatlist(thedata, what)¶
Backward-compatible wrapper around
make_whatlist().
- MaxtoAvET2()¶
Return interpolation from max to average E^2 conversion factors.
- Measure_Autocorrelation(description='empty', dotfile='testgr.dot', delay=1.0, SGLevel=-20, leveling=None, freqs=None, toffsets=None, ntunerpos=None, SearchPaths=None, names=None)¶
Performs a msc autocorrelation measurement
- Measure_EUTCal(description='EUT', dotfile='msc-calibration.dot', delay=1.0, freqs=None, SGLevel=-20, leveling=None, calibration='empty', SearchPaths=None, names=None)¶
Performs a msc EUT calibration according to IEC 61000-4-21
- Measure_Emission(description='EUT', dotfile='msc-emission.dot', calibration='empty', delay=1.0, freqs=None, receiverconf=None, SearchPaths=None, names=None)¶
Performs a msc emission measurement according to IEC 61000-4-21
- Measure_Immunity(description='EUT', dotfile='msc-immunity.dot', calibration='empty', kernel=(None, None), leveling=None, freqs=None, SearchPaths=None, names=None)¶
Performs a msc immunity measurement according to IEC 61000-4-21
- 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)¶
Performs a msc main calibration according to IEC 61000-4-21
- OutputProcessedData_AutoCorr(description=None, what=None, fname=None)¶
Print or write processed autocorrelation data.
- OutputProcessedData_EUTCal(description=None, what=None, fname=None)¶
Print or write processed EUT-calibration data.
- OutputProcessedData_Emission(description=None, what=None, fname=None)¶
Print or write processed emission data.
- OutputProcessedData_Immunity(description=None, what=None, fname=None)¶
Print or write processed immunity data.
- OutputProcessedData_MainCal(description=None, what=None, fname=None)¶
Print or write processed main-calibration data.
- OutputRawData_AutoCorr(description=None, what=None, fname=None)¶
Print or write raw autocorrelation data.
- OutputRawData_EUTCal(description=None, what=None, fname=None)¶
Print or write raw EUT-calibration data.
- OutputRawData_Emission(description=None, what=None, fname=None)¶
Print or write raw emission data.
- OutputRawData_Immunity(description=None, what=None, fname=None)¶
Print or write raw immunity data.
- OutputRawData_MainCal(description=None, what=None, fname=None)¶
Print or write raw main-calibration data.
- UseTunerPos(description, f, t)¶
Return whether tuner position
texists for frequencyf.
- doLeveling(leveling, mg, names, dct)¶
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 returningNone.
- do_autosave(name_or_obj=None, depth=None, prefixes=None)¶
Serialize self using
pickle.Assuming a calling sequence like so:
script -> method of measurement class -> do_autosave
depth = 1 (default) will set self.ascmd to the command issued in the script.
If depth is too large, the outermost command is used.
Thus, the issued command in script is extracted and saved in self.ascmd. This can be used to redo the command after a crash.
Return: None
- getMaxE(mg, names, f, etest, rfac=None)¶
Compute the required source level to reach a target test field.
- getStandard(s=None)¶
Normalize standard aliases to canonical standard names.
- make_deslist(thedata, description)¶
make_deslist method.
- make_whatlist(thedata, what)¶
make_whatlist method.
- out(item)¶
Helper function for all output functions.
Prints item recursively all in one line.
The parameter item can be:
a
dictof items (hasattr(item, ‘keys’)==True)a
listof items (hasattr(item, ‘index’)==True)a sequence of items (using
mpylab.tools.util.issequence())or anything else (will be printed via print item,)
The return value is None.
- setLevel(mg, level_or_names, level_or_leveler=None)¶
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)
- set_autosave(name)¶
Setter for the class attribute asname (name of the auto save file).
Parameter name: file name oif the auto save file
Return: None
- set_autosave_interval(interval)¶
Set the intervall between auto save.
intervall: seconds between auto save
This method returns None.
- set_interactive_runner(runner)¶
Set function used for interactive user sessions.
- set_level(mg, l, leveler=None)¶
- set_logfile(name)¶
Tries to open a file with the given name with mode ‘a+’. If this fails, nothing will happen, else
stdloogger()will log to this file.Parameter name: full qualified name of the file to be used as logfile
Return: None
- set_logger(logger=None)¶
Set up the list of logger fuctions (self.logger).
If logger is None,
stdlogger()is used.Parameter logger: list of functions called to log events
Return: None
- set_messenger(messenger)¶
Set function to present messages.
Parameter messenger: the messenger (see
stdUserMessenger())Return: None
- set_post_user_event(event_cb)¶
Set function called after user-facing UI interactions.
- set_pre_user_event(event_cb)¶
Set function called before user-facing UI interactions.
- set_user_interrupt_Tester(tester)¶
Backward-compatible alias for
set_user_interrupt_tester().
- set_user_interrupt_tester(tester)¶
Set function to test for user interrupt.
Parameter tester: callable (see
stdUserInterruptTester()).Return: None
- static stdEutStatusChecker(status)¶
stdEutStatusChecker method.
- static stdInteractiveSession(obj, banner)¶
Default interactive session hook for terminal usage.
- static stdPostUserEvent()¶
stdPostUserEvent method.
- static stdPreUserEvent()¶
stdPreUserEvent method.
- static stdTPosCmp(t1, t2)¶
Compare tuner positions by sum of coordinates.
Accepts: - sequence objects - strings like “[0, 5, 10]” or “(1,2)”
- stdUserInterruptHandler(dct, ignorelist='')¶
Default interrupt handler used by measurement loops.
- static stdUserInterruptTester() int | None¶
The standard (default) user interrupt tester.
Returns return value of
mpylab.util.anykeyevent()
- stdUserMessenger(msg: str = 'Are you ready?', but: list[str] | None = None, level: str = '', dct: dict[Any, Any] | None = None) int¶
The standard (default) method to present messages to the user.
The behaviour depends on the value of the parameter but. If len(but) (buttons are given) the funttions waits for a user answer. Else, the msg is presented only.
The function also calls all additional logger functions given in self.logger with the same arguments.
Parameters:
msg: message to display
but: sequence with the text strings of the buttons
level: to indicate something (not used in the standard logger)
dct: a
dictwith further parameters (not used in the standard logger)
Return value: the index of the selected button (starting from 0), or -1 if len(but) is False.
- static std_eut_status_checker(status)¶
Backward-compatible alias for
stdEutStatusChecker().
- stdlogger(block, *args)¶
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 functionout_block(). Else, the block is printed directly.Parameter block: object to log
Return value: None
- wait(delay, dct, uitester, intervall=0.1)¶
A wait function that can be interrupted.
delay: seconds to wait
dct: namespace passed to legacy handler style
uitester: interrupt callback; supports
fn(dct)andfn()intervall: seconds to sleep between callback calls
Return: None
- class mpylab.env.msc.MSC.TestField(instance, maincal='empty', eutcal=None)¶
Callable converter from forward power to expected electric field.
- class mpylab.env.msc.MSC.TestPower(instance, maincal='empty', eutcal=None)¶
Callable converter from target field strength to required power.
mpylab.env.msc.name_maps¶
Typed name-map contracts and coercion helpers for MSC measurements.
- class mpylab.env.msc.name_maps.MSCAutoCorrNames¶
Typed device-name mapping for MSC auto-correlation workflow.
- a1: str¶
- a2: str¶
- ant: str¶
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- fp: list[str]¶
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pmbwd: str¶
- pmfwd: str¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- sg: str¶
- tuner: list[str]¶
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- class mpylab.env.msc.name_maps.MSCEUTCalNames¶
Typed device-name mapping for MSC EUT calibration workflow.
- a1: str¶
- a2: str¶
- ant: str¶
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- fp: list[str]¶
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pmbwd: str¶
- pmfwd: str¶
- pmref: list[str]¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- refant: list[str]¶
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- sg: str¶
- tuner: list[str]¶
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- class mpylab.env.msc.name_maps.MSCEmissionNames¶
Typed device-name mapping for MSC emission measurement workflow.
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- receiver: list[str]¶
- refant: list[str]¶
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- tuner: list[str]¶
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- class mpylab.env.msc.name_maps.MSCImmunityNames¶
Typed device-name mapping for MSC immunity measurement workflow.
- a1: str¶
- a2: str¶
- ant: str¶
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- fp: list[str]¶
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pmbwd: str¶
- pmfwd: str¶
- pmref: list[str]¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- refant: list[str]¶
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- sg: str¶
- tuner: list[str]¶
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- class mpylab.env.msc.name_maps.MSCMainCalNames¶
Typed device-name mapping for MSC main calibration workflow.
- a1: str¶
- a2: str¶
- ant: str¶
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- fp: list[str]¶
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pmbwd: str¶
- pmfwd: str¶
- pmref: list[str]¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- refant: list[str]¶
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- sg: str¶
- tuner: list[str]¶
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- mpylab.env.msc.name_maps.coerce_msc_autocorr_names(names: Mapping[str, object] | None) MSCAutoCorrNames¶
Validate and complete an auto-correlation MSC name map.
- mpylab.env.msc.name_maps.coerce_msc_emission_names(names: Mapping[str, object] | None) MSCEmissionNames¶
Validate and complete an MSC emission name map.
- mpylab.env.msc.name_maps.coerce_msc_eutcal_names(names: Mapping[str, object] | None) MSCEUTCalNames¶
Validate and complete an EUT-calibration MSC name map.
- mpylab.env.msc.name_maps.coerce_msc_immunity_names(names: Mapping[str, object] | None) MSCImmunityNames¶
Validate and complete an MSC immunity name map.
- mpylab.env.msc.name_maps.coerce_msc_maincal_names(names: Mapping[str, object] | None) MSCMainCalNames¶
Validate and complete a main-calibration MSC name map.
mpylab.env.tem.TEMCell¶
This is mpylab.env.tem.TEMCell.
Provides mpylab.env.tem.TEMCell for EMC measurements in TEM cells
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- class mpylab.env.tem.TEMCell.TEMCell¶
A class for TEM-cell measurements according to IEC 61000-4-20
- Calculate_Emax(description='EUT', Dmax=3.0, s=10, hg=0.8, RH=(1, 4), rstep=None, Zc=50, is_oats=True)¶
This function estimates the maximum E field strength, as it would be expected from a OATS/FAR measurement, from the total radiated power determined by
Calculate_Prad().Parameters:
description: String to identify the emission measurement.
Dmax: the maximum of the direktivity of the EUT.
s: Distance from the EUT in meters
hg: height over ground plane in meters
RH: range of the hight scan in meters
rstep: the step width of the hight scan used to calculate the max. Used in
mpylab.tools.util.gmax_oats()Zc: characteristic impedance of the TEM cell in Ohms (forwarded to
Calculate_Prad())is_oats: if True, a ground plane is assumed, else free space
- Calculate_Prad(description='EUT', e0y_description='Main EUT Pos', use_e0y_GTEManalytical=None, EUTpos=None, Zc=50, component='y', evaluate3pos=None)¶
Calculate the total radiated power from a TEM-cell emission measurement.
Parameters:
description: String to identify the emission measurement.
e0y_description: Strind to identify the data for e0y factor.
use_e0y_GTEManalytical: if True, use the analytical formula, see
e0y_GTEM_analytical()EUTPos: Dictionary with keys
‘cell_width’
‘sep_height’
‘gap’
‘ypos’
‘xpos’
that are passed to
e0y_GTEM_analytical()Zc: characteristic impedance
component: the field component that represents the y direction (probe orientation could have been diffeent)
evaluate3pos: evaluate only with respect to the first 3 standard position even if more (12) are available
The reslults are appended to self.processedData_Emission[description][‘Prad’][f][port] (radiated power) and self.processedData_Emission[description][‘Prad_noise’][f][port] (radiated noise).
- Evaluate_Emission(description='EUT', e0y_description='Main EUT Pos', use_e0y_GTEManalytical=None, EUTpos=None, Zc=50, Dmax=3.0, s=10, hg=0.8, RH=(1, 4), is_oats=None, component='y', evaluate3pos=None)¶
Calculate the maximum radiated e field from a TEM-cell emission measurement.
Parameters:
description: String to identify the emission measurement.
e0y_description: Strind to identify the data for e0y factor.
use_e0y_GTEManalytical: if True, use the analytical formula, see
e0y_GTEM_analytical()EUTPos: Dictionary with keys
‘cell_width’
‘sep_height’
‘gap’
‘ypos’
‘xpos’
that are passed to
e0y_GTEM_analytical()Zc: characteristic impedance in Ohms
Dmax: the maximum of the direktivity of the EUT.
s: Distance from the EUT in meters
hg: height over ground plane in meters
RH: range of the hight scan in meters
is_oats: if True, a ground plane is assumed, else free space
component: the field component that represents the y direction (probe orientation could have been diffeent)
evaluate3pos: evaluate only with respect to the first 3 standard position even if more (12) are available
The function simply calls
Calculate_Prad()andCalculate_Emax()with the appropriate arguments.
- Evaluate_e0y(description=None)¶
- MakeDeslist(thedata, description)¶
Backward-compatible wrapper around
make_deslist().
- MakeWhatlist(thedata, what)¶
Backward-compatible wrapper around
make_whatlist().
- Measure_Emission(description='EUT', positions=None, dotfile='gtem-emission.dot', delay=0.0, freqs=None, receiverconf=None, names=None)¶
Performs a emission measurement according to IEC 61000-4-20.
Parameter:
description: key to identify the measurement in the result dictionary
positions: a sequence of EUT positions to be measured. Each position is a string characterizing the orientation of the cell coordinate system (without prime) relative to the EUT coordinate system. A standard choice is to align the z-axis in the direction of wave propagation, the y-axis parallel to the E-field (vertical) and the x-axis parallel to the H-field. The centre of the EUT is placed at (x = 0,y,z) with x = 0 in the middle of the septum. A local “primed” coordinate system (x’, y’, z’) is assigned to the EUT. Position xx’yy’zz’ aligns x’ with x, y’ with y, and z’ with z. Position xz’yx’zy’ is obtained by simply permuting the primed EUT axes: x’ to y, y’ to z, and z’ to x. This is equivalent to two 90° rotations of the EUT. Position xy’yz’zx’ is obtained by a further permutation: x’ to z, y’ to x, z’ to y. IEC 61000-4-21 defines two standard setups: with the 3 positions (“xx’yy’zz’”, “xz’yx’zy’”, “xy’yz’zx’”), or with 12 positions (see below).
3 standart positions (
std_3_positions):("xx'yy'zz'", "xz'yx'zy'", "xy'yz'zx'")
First three standard orientations.
12 standard positions (
std_12_positions):("xx'yy'zz'", "xz'yx'zy'", "xy'yz'zx'", "xz'yy'z(-x')", "x(-x')yz'zy'", "xy'y(-x')zz'", "x(-x')yy'z(-z')", "x(-z')y(-x')zy'", "xy'y(-z')z(-x')", "x(-z')yy'zx'", "xx'y(-z')zy'", "xy'yx'z(-z')")
12 standard orientations.
dotfile: forwarded to
mpylab.tools.mgraph.MGraphto create the mearsurment graph.delay: time in seconds to wait after setting the frequencie before pulling date from the instruments
freqs: sequence of frequencies in Hz to use for the measurements.
receiverconf: forwarded to
mpylab.tools.mgraph.MGraph.ConfReceivers()names: dict with the mapping from internal names to dot-file names.
The dict has to have keys ‘port’ and ‘receivers’. The corresponding values are sequences of equal length giving the names of the ports and of the receivers in the dot-file. For a GTEM the length of this lists is one. For a Crawford cell it would be two.
- Measure_Immunity(description='EUT', positions=None, dotfile='gtem-immunity.dot', delay=0.0, calibration='cal', kernel=(None, None), leveling=None, freqs=None, SearchPaths=None, names=None)¶
Performs an immunity measurement according to IEC 61000-4-20.
Parameter:
description: key to identify the measurement in the result dictionary
positions: a sequence of EUT positions to be measured. Each position is a string characterizing the orientation of the cell coordinate system (without prime) relative to the EUT coordinate system. A standard choice is to align the z-axis in the direction of wave propagation, the y-axis parallel to the E-field (vertical) and the x-axis parallel to the H-field. The centre of the EUT is placed at (x = 0,y,z) with x = 0 in the middle of the septum. A local “primed” coordinate system (x’, y’, z’) is assigned to the EUT. Position xx’yy’zz’ aligns x’ with x, y’ with y, and z’ with z. Position xz’yx’zy’ is obtained by simply permuting the primed EUT axes: x’ to y, y’ to z, and z’ to x. This is equivalent to two 90° rotations of the EUT. Position xy’yz’zx’ is obtained by a further permutation: x’ to z, y’ to x, z’ to y. IEC 61000-4-20 defines two standard setups: vertical and horizontal polarization (see below).
4 vertical positions (
std_vertical_positions):("xx'yy'zz'", "xz'yy'z(-x')", "x(-x')yy'z(-z')", "x(-z')yy'zx'")
Vertical standard orientations.
4 horizontal positions (
std_horizontal_positions):("xy'y(-x')zz'", "xy'y(-z')z(-x')", "xy'yx'z(-z')", "xy'yz'zx'")
Horizontal standard orientations.
dotfile: forwarded to
mpylab.tools.mgraph.MGraphto create the mearsurement graph.delay: time in seconds to wait after setting the frequency before pulling date from the instruments
freqs: sequence of frequencies in Hz to use for the measurements.
names: dict with the mapping from internal names to dot-file names.
- Measure_TEMMode_FieldUniformity_Validation_ConstPower(description='GTEM', distance=None, positions=None, dotfile='gtem-immunity.dot', delay=0.0, leveling=None, freqs=None, fwd_dbm=None, SearchPaths=None, names=None)¶
Performs an TEM Mode and Field Uniformity validation measurement according to IEC 61000-4-20. Here: Constant fwd Power method.
Parameter:
description: key to identify the measurement in the result dictionary
distance: position of the uniform area in mm. In GTEM: counted from feed point
positions: a sequence of probe positions to be measured. Each position is a (x,y)-pair of probe positions (in mm)
dotfile: forwarded to
mpylab.tools.mgraph.MGraphto create the mearsurement graph.delay: time in seconds to wait after setting the frequency before pulling date from the instruments
freqs: sequence of frequencies in Hz to use for the measurements.
fwd_dbm: forward power at feed point in dbm
names: dict with the mapping from internal names to dot-file names.
- Measure_Uniformity_TEMModeVerfication_constant_field(description=None, dotfile='gtem-uniformity.dot', delay=1.0, freqs=None, EFieldStrength=None, SGLevel=-20, leveling=None, names=None)¶
Performs uniformity and TEM verification according to IEC 61000-4-20. This routine uses the constant field method.
Parameters:
description: key to identify the measurement in the result dictionary
dotfile: forwarded to
mpylab.tools.mgraph.MGraphto create the mearsurement graph.delay: time in seconds to wait after setting the frequency before pulling date from the instruments
freqs: sequence of frequencies in Hz to use for the measurements.
EFieldStrength: iterable of desired field strength values. If None it is seit to [1]
SGLevel: initial signal generator level
leveling: If leveling is None it is initialized with:
leveling = [{'condition': 'False', 'actor': None, 'actor_min': None, 'actor_max': None, 'watch': None, 'nominal': None, 'reader': None, 'path': None}]
names: dict with the mapping from internal names to dot-file names.
The dict has to have keys
‘sg’: signalgenerator
‘a1’: amplifier input port
‘a2’: amplifier output port
‘port’: TEM cell feeding
‘pmfwd’: forward power meter
‘pmbwd’: backward power meter
‘fp’: list of field probes
The corresponding values give the names in the dot-file.
- Measure_e0y(description=None, dotfile='gtem-e0y.dot', delay=1.0, freqs=None, SGLevel=-20, leveling=None, names=None)¶
Performs determination of e0y according to IEC 61000-4-20.
Parameters:
description: key to identify the measurement in the result dictionary
dotfile: forwarded to
mpylab.tools.mgraph.MGraphto create the mearsurment graph.delay: time in seconds to wait after setting the frequency before pulling date from the instruments
freqs: sequence of frequencies in Hz to use for the measurements.
SGLevel: signal generator power level in dBm.
leveling: If leveling is None it is initialized with:
leveling = [{'condition': 'False', 'actor': None, 'actor_min': None, 'actor_max': None, 'watch': None, 'nominal': None, 'reader': None, 'path': None}]
names: dict with the mapping from internal names to dot-file names.
The dict has to have keys
‘sg’: signalgenerator
‘a1’: amplifier input port
‘a2’: amplifier output port
‘port’: TEM cell feeding
‘pmfwd’: forward power meter
‘pmbwd’: backward power meter
‘fp’: list of field probes
The corresponding values give the names in the dot-file.
- OutputProcessedData_Emission(description=None, what=None, fname=None)¶
Write processed emission results to stdout or a target file.
- OutputProcessedData_e0y(description=None, what=None, fname=None)¶
Write processed e0y results to stdout or a target file.
- OutputRawData_Emission(description=None, what=None, fname=None)¶
Write raw emission measurement data to stdout or a target file.
- OutputRawData_e0y(description=None, what=None, fname=None)¶
Write raw e0y calibration data to stdout or a target file.
- c0 = Quantity(m*s^(-1), 299792458.0)¶
- doLeveling(leveling, mg, names, dct)¶
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 returningNone.
- do_autosave(name_or_obj=None, depth=None, prefixes=None)¶
Serialize self using
pickle.Assuming a calling sequence like so:
script -> method of measurement class -> do_autosave
depth = 1 (default) will set self.ascmd to the command issued in the script.
If depth is too large, the outermost command is used.
Thus, the issued command in script is extracted and saved in self.ascmd. This can be used to redo the command after a crash.
Return: None
- e0y_GTEM_analytical(a, h, g, y, x=0, Zc=50, max_m=10)¶
Calculate the factor $e_{0y}$ from the analytical formula given in IEC 61000-4-20 (actually, it is from the PhD thesis of Michael Koch).
Parameters:
a: cell width in meter
h: septum height in meter
g: gap width in meter
y: position of the EUT center from the floor in meter
x: position of the EUT center from the middle in meter
Zc: characteristic impedance of the waveguide in ohms
max_m: upper index of the series expansion
Cross section of a GTEM-cell.
- eta0 = Quantity(u"Ω", 376.99111843077515)¶
- eut_positions_emission = (("xx'yy'zz'", "xz'yx'zy'", "xy'yz'zx'"), ("xz'yy'z(-x')", "x(-x')yz'zy'", "xy'y(-x')zz'"), ("x(-x')yy'z(-z')", "x(-z')y(-x')zy'", "xy'y(-z')z(-x')"), ("x(-z')yy'zx'", "xx'y(-z')zy'", "xy'yx'z(-z')"))¶
- eut_positions_immunity = {'h': ("xy'y(-x')zz'", "xy'y(-z')z(-x')", "xy'yx'z(-z')", "xy'yz'zx'"), 'v': ("xx'yy'zz'", "xz'yy'z(-x')", "x(-x')yy'z(-z')", "x(-z')yy'zx'")}¶
- k_factor = 0.125¶
- make_deslist(thedata, description)¶
make_deslist method.
- make_whatlist(thedata, what)¶
make_whatlist method.
- out(item)¶
Helper function for all output functions.
Prints item recursively all in one line.
The parameter item can be:
a
dictof items (hasattr(item, ‘keys’)==True)a
listof items (hasattr(item, ‘index’)==True)a sequence of items (using
mpylab.tools.util.issequence())or anything else (will be printed via print item,)
The return value is None.
- setLevel(mg, level_or_names, level_or_leveler=None)¶
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)
- set_autosave(name)¶
Setter for the class attribute asname (name of the auto save file).
Parameter name: file name oif the auto save file
Return: None
- set_autosave_interval(interval)¶
Set the intervall between auto save.
intervall: seconds between auto save
This method returns None.
- set_interactive_runner(runner)¶
Set function used for interactive user sessions.
- set_level(mg, l, leveler=None)¶
- set_logfile(name)¶
Tries to open a file with the given name with mode ‘a+’. If this fails, nothing will happen, else
stdloogger()will log to this file.Parameter name: full qualified name of the file to be used as logfile
Return: None
- set_logger(logger=None)¶
Set up the list of logger fuctions (self.logger).
If logger is None,
stdlogger()is used.Parameter logger: list of functions called to log events
Return: None
- set_messenger(messenger)¶
Set function to present messages.
Parameter messenger: the messenger (see
stdUserMessenger())Return: None
- set_post_user_event(event_cb)¶
Set function called after user-facing UI interactions.
- set_pre_user_event(event_cb)¶
Set function called before user-facing UI interactions.
- set_user_interrupt_Tester(tester)¶
Backward-compatible alias for
set_user_interrupt_tester().
- set_user_interrupt_tester(tester)¶
Set function to test for user interrupt.
Parameter tester: callable (see
stdUserInterruptTester()).Return: None
- static stdEutStatusChecker(status)¶
stdEutStatusChecker method.
- static stdInteractiveSession(obj, banner)¶
Default interactive session hook for terminal usage.
- static stdPostUserEvent()¶
stdPostUserEvent method.
- static stdPreUserEvent()¶
stdPreUserEvent method.
- static stdUserInterruptTester() int | None¶
The standard (default) user interrupt tester.
Returns return value of
mpylab.util.anykeyevent()
- stdUserMessenger(msg: str = 'Are you ready?', but: list[str] | None = None, level: str = '', dct: dict[Any, Any] | None = None) int¶
The standard (default) method to present messages to the user.
The behaviour depends on the value of the parameter but. If len(but) (buttons are given) the funttions waits for a user answer. Else, the msg is presented only.
The function also calls all additional logger functions given in self.logger with the same arguments.
Parameters:
msg: message to display
but: sequence with the text strings of the buttons
level: to indicate something (not used in the standard logger)
dct: a
dictwith further parameters (not used in the standard logger)
Return value: the index of the selected button (starting from 0), or -1 if len(but) is False.
- static std_eut_status_checker(status)¶
Backward-compatible alias for
stdEutStatusChecker().
- stdlogger(block, *args)¶
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 functionout_block(). Else, the block is printed directly.Parameter block: object to log
Return value: None
- wait(delay, dct, uitester, intervall=0.1)¶
A wait function that can be interrupted.
delay: seconds to wait
dct: namespace passed to legacy handler style
uitester: interrupt callback; supports
fn(dct)andfn()intervall: seconds to sleep between callback calls
Return: None
- class mpylab.env.tem.TEMCell.TestField(instance, cal='cal')¶
Callable converter from forward power to expected field strength.
- class mpylab.env.tem.TEMCell.TestPower(instance, cal='cal')¶
Callable converter from target field strength to required forward power.
mpylab.env.tem.name_maps¶
Typed name-map contracts and coercion helpers for TEM measurements.
- class mpylab.env.tem.name_maps.TEME0YNames¶
TEME0YNames class.
- a1: str¶
- a2: str¶
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- fp: list[str]¶
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pmbwd: str¶
- pmfwd: str¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- port: str¶
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- sg: str¶
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- class mpylab.env.tem.name_maps.TEMEmissionNames¶
TEMEmissionNames class.
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- port: list[str]¶
- receiver: list[str]¶
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- class mpylab.env.tem.name_maps.TEMImmunityNames¶
TEMImmunityNames class.
- a1: str¶
- a2: str¶
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pmbwd: str¶
- pmfwd: str¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- sg: str¶
- tem: str¶
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- mpylab.env.tem.name_maps.coerce_tem_e0y_names(names: Mapping[str, object] | None) TEME0YNames¶
coerce_tem_e0y_names function.
- mpylab.env.tem.name_maps.coerce_tem_emission_names(names: Mapping[str, object] | None) TEMEmissionNames¶
coerce_tem_emission_names function.
- mpylab.env.tem.name_maps.coerce_tem_immunity_names(names: Mapping[str, object] | None) TEMImmunityNames¶
coerce_tem_immunity_names function.
mpylab.env.ui.ui_adapter¶
UI adapter abstractions for measurement environments.
The adapter keeps UI interaction points (ask/log/interrupt/pre/post events) behind a small interface so that TUI and future GUI integrations can share the same measurement logic.
- class mpylab.env.ui.ui_adapter.MeasurementUIAdapter¶
Abstract UI adapter contract for measurement flows.
- ask(msg: str = 'Are you ready?', buttons: list[str] | None = None, level: str = '', data: dict[Any, Any] | None = None) int¶
Display question and return selected button index.
- check_interrupt() int | None¶
Check for interrupt request using key polling.
- emit_log(block, *args) None¶
Emit one structured log block.
- poll_key() int | None¶
Poll one pending key event, if any.
- post_user_event() None¶
Run hook after user-facing event.
- pre_user_event() None¶
Run hook before user-facing event.
- run_interactive(obj: Any, banner: str) None¶
Start interactive shell for an object.
- class mpylab.env.ui.ui_adapter.TUIAdapter(messenger: Callable[[str, list[str] | None, str, dict[Any, Any] | None], int], logger: list[Callable[[...], Any]] | None, interrupt_tester: Callable[[], int | None], pre_user_event: Callable[[], None], post_user_event: Callable[[], None], interactive_runner: Callable[[Any, str], None])¶
Default terminal-oriented adapter using callables from Measure.
- ask(msg: str = 'Are you ready?', buttons: list[str] | None = None, level: str = '', data: dict[Any, Any] | None = None) int¶
Forward user prompt request to configured messenger.
- check_interrupt() int | None¶
Check for interrupt request using key polling.
- emit_log(block, *args) None¶
Forward one log block to all configured loggers.
- poll_key() int | None¶
Poll and return key code from interrupt tester.
- post_user_event() None¶
Call post-user-event hook.
- pre_user_event() None¶
Call pre-user-event hook.
- run_interactive(obj: Any, banner: str) None¶
Call interactive runner with object and banner.
- set_interactive_runner(runner: Callable[[Any, str], None]) None¶
Replace interactive-runner callback.
- set_interrupt_tester(tester: Callable[[], int | None]) None¶
Replace interrupt polling callback.
- set_logger(logger: list[Callable[[...], Any]] | None) None¶
Replace logger callback list.
- set_messenger(messenger: Callable[[str, list[str] | None, str, dict[Any, Any] | None], int]) None¶
Replace messenger callback.
- set_post_user_event(cb: Callable[[], None]) None¶
Replace post-user-event callback.
- set_pre_user_event(cb: Callable[[], None]) None¶
Replace pre-user-event callback.
- mpylab.env.ui.ui_adapter.resolve_poll_key(handler: Any, caller_locals: dict[str, Any] | None = None) Callable[[], int | None] | None¶
Resolve a poll-key callable from explicit handler or caller context.
mpylab.env.univers.AmplifierTest¶
mpylab.env.univers.AmplifierTest module.
- class mpylab.env.univers.AmplifierTest.AmplifierTest(SearchPaths=None)¶
AmplifierTest class.
- GetGainAndCompression(description=None, small_signal_factor=10)¶
GetGainAndCompression method.
- MakeDeslist(thedata, description)¶
Backward-compatible wrapper around
make_deslist().
- MakeWhatlist(thedata, what)¶
Backward-compatible wrapper around
make_whatlist().
- Measure(description='AmplifierTest', dotfile='amplifier.dot', delay=0.2, freqs=None, levels=None, names=None, virtual=False)¶
Performs an amplifier test measurement.
Parameter:
description: key to identify the measurement in the result dictionary
dotfile: forwarded to
mpylab.tools.mgraph.MGraphto create the mearsurment graph.delay: time in seconds to wait after setting the frequencie before pulling date from the instruments
freqs: sequence of frequencies in Hz to use for the measurements.
names: dict with the mapping from internal names to dot-file names.
The dict has to have keys ‘sg’, ‘amp_in’, ‘amp_out’, ‘pm_fwd’, ‘pm_bwd’ and ‘output’.
- OutputIniFile(description=None, fname=None, driver='amplifier.py', gpib=1)¶
OutputIniFile method.
- doLeveling(leveling, mg, names, dct)¶
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 returningNone.
- do_autosave(name_or_obj=None, depth=None, prefixes=None)¶
Serialize self using
pickle.Assuming a calling sequence like so:
script -> method of measurement class -> do_autosave
depth = 1 (default) will set self.ascmd to the command issued in the script.
If depth is too large, the outermost command is used.
Thus, the issued command in script is extracted and saved in self.ascmd. This can be used to redo the command after a crash.
Return: None
- make_deslist(thedata, description)¶
make_deslist method.
- make_whatlist(thedata, what)¶
make_whatlist method.
- out(item)¶
Helper function for all output functions.
Prints item recursively all in one line.
The parameter item can be:
a
dictof items (hasattr(item, ‘keys’)==True)a
listof items (hasattr(item, ‘index’)==True)a sequence of items (using
mpylab.tools.util.issequence())or anything else (will be printed via print item,)
The return value is None.
- setLevel(mg, level_or_names, level_or_leveler=None)¶
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)
- set_autosave(name)¶
Setter for the class attribute asname (name of the auto save file).
Parameter name: file name oif the auto save file
Return: None
- set_autosave_interval(interval)¶
Set the intervall between auto save.
intervall: seconds between auto save
This method returns None.
- set_interactive_runner(runner)¶
Set function used for interactive user sessions.
- set_level(mg, l, leveler=None)¶
- set_logfile(name)¶
Tries to open a file with the given name with mode ‘a+’. If this fails, nothing will happen, else
stdloogger()will log to this file.Parameter name: full qualified name of the file to be used as logfile
Return: None
- set_logger(logger=None)¶
Set up the list of logger fuctions (self.logger).
If logger is None,
stdlogger()is used.Parameter logger: list of functions called to log events
Return: None
- set_messenger(messenger)¶
Set function to present messages.
Parameter messenger: the messenger (see
stdUserMessenger())Return: None
- set_post_user_event(event_cb)¶
Set function called after user-facing UI interactions.
- set_pre_user_event(event_cb)¶
Set function called before user-facing UI interactions.
- set_user_interrupt_Tester(tester)¶
Backward-compatible alias for
set_user_interrupt_tester().
- set_user_interrupt_tester(tester)¶
Set function to test for user interrupt.
Parameter tester: callable (see
stdUserInterruptTester()).Return: None
- static stdEutStatusChecker(status)¶
stdEutStatusChecker method.
- static stdInteractiveSession(obj, banner)¶
Default interactive session hook for terminal usage.
- static stdPostUserEvent()¶
stdPostUserEvent method.
- static stdPreUserEvent()¶
stdPreUserEvent method.
- static stdUserInterruptTester() int | None¶
The standard (default) user interrupt tester.
Returns return value of
mpylab.util.anykeyevent()
- stdUserMessenger(msg: str = 'Are you ready?', but: list[str] | None = None, level: str = '', dct: dict[Any, Any] | None = None) int¶
The standard (default) method to present messages to the user.
The behaviour depends on the value of the parameter but. If len(but) (buttons are given) the funttions waits for a user answer. Else, the msg is presented only.
The function also calls all additional logger functions given in self.logger with the same arguments.
Parameters:
msg: message to display
but: sequence with the text strings of the buttons
level: to indicate something (not used in the standard logger)
dct: a
dictwith further parameters (not used in the standard logger)
Return value: the index of the selected button (starting from 0), or -1 if len(but) is False.
- static std_eut_status_checker(status)¶
Backward-compatible alias for
stdEutStatusChecker().
- stdlogger(block, *args)¶
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 functionout_block(). Else, the block is printed directly.Parameter block: object to log
Return value: None
- wait(delay, dct, uitester, intervall=0.1)¶
A wait function that can be interrupted.
delay: seconds to wait
dct: namespace passed to legacy handler style
uitester: interrupt callback; supports
fn(dct)andfn()intervall: seconds to sleep between callback calls
Return: None
- mpylab.env.univers.AmplifierTest.W2dBm(v)¶
Convert a Watt input to dBm
- Parameters:
v (float or array-like) – input value(s) in Watt
- Returns:
input value(s) converted to dBm
- Return type:
float or array-like (same as input)
- mpylab.env.univers.AmplifierTest.dBm2W(v)¶
Convert a dBm input to Watt
- Parameters:
v (float or array-like) – input value(s) in dBm
- Returns:
input value(s) converted to Watt
- Return type:
float or array-like (same as input)
mpylab.env.univers.name_maps¶
Typed name-map contracts and coercion helpers for univers measurements.
- class mpylab.env.univers.name_maps.AmplifierNames¶
AmplifierNames class.
- amp_in: str¶
- amp_out: str¶
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- output: str¶
- pm_bwd: str¶
- pm_fwd: str¶
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- sg: str¶
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- mpylab.env.univers.name_maps.coerce_amplifier_names(names: Mapping[str, object] | None) AmplifierNames¶
coerce_amplifier_names function.
mpylab.limits¶
mpylab.limits.conducted_emission.en_55011¶
Conducted emission limit lines according to DIN EN 55011:2022-05.
- class mpylab.limits.conducted_emission.en_55011.LIMIT(group=None, classification=None, detector=None, port=None)¶
EN 55011 conducted-emission limit model with selectable variants.
- description_Classification = {'A': '\n ## Class A (higher emission limits, industrial) \n \n **Class A** devices are devices that are suitable for use in all areas other than \n residential and such areas, and they are connected to the public mains.\n \n Devices must have emissions which are below the limits of Class A, \n but the emissions may exceed the limits of Class B.\n \n For Class A equipment, the instructions for use accompanying the product shall \n contain the following text: \n \n *Caution: This equipment is not intended for use in residential environments \n and may not provide adequate protection to radio reception in such environments.*', 'B': '\n ## Class B (lower emission limits, residential): \n \n **Class B** devices are devices that are suitable for use in residential areas \n and such areas, and they are connected to the public mains.'}¶
- description_Group = {'1': '\n ## Group 1: (general purpose applications)\n \n All equipment in the scope of EN 55011 (CISPR 11) which is not classified as Group 2 equipment. \n \n Examples of **Group 1** equipment:\n \n - Laboratory equipment\n - Medical electrical equipment\n - Scientific equipment\n - Semiconductor-converters\n - Industrial electric heating equipment with operating frequencies less than or equal to 9 kHz\n - Machine tools\n - Industrial process measurement and control equipment\n - Semiconductor manufacturing equipment\n - Switch mode power supplies', '2': '\n ## Group 2 (ISM RF applications): \n \n All ISM RF equipment in which radio-frequency energy in the frequency \n range 9kHz to 400GHz is intentionally generated and used or only used locally, in the form \n of electromagnetic radiation, inductive and/or capacitive coupling, for the treatment \n of material, for inspection/analysis purposes, or for transfer of electromagnetic energy. \n \n Examples of **Group 2** equipment:\n \n - Microwave-powered UV irradiating apparatus\n - Microwave lighting apparatus\n - Industrial induction heating equipment operating at frequencies above 9 kHz\n - Dielectric heating equipment Industrial microwave heating equipment\n - Arc Welding equipment\n - Microwave ovens\n - Medical electrical equipment\n - Electric welding equipment\n - Electro-discharge machining (EDM) equipment\n - Demonstration models for education and training\n - Battery chargers and power supplies – wireless power transfer (WPT) mode'}¶
- description_TestSetup = {'A': '\n ## Test Setup:\n \n **Class A** equipment may be measured either on a test site or in situ \n (at installation site) as preferred by the manufacturer. Due to size, complexity or \n operating conditions some equipment may have to be measured in situ in order to \n show compliance with disturbance limits.\n ', 'B': '\n ## Test Setup: \n \n **Class B** equipment shall be measured on a test site.'}¶
- description_title = 'DIN EN 55011:2022-05 (CISPR-11), conducted'¶
- fmax = 30000000.0¶
- fmin = 150000.0¶
- limit_G1_CA_AC_less_20_kVA_AV(f)¶
Return Group 1/Class A AC <=20 kVA average limit values.
- limit_G1_CA_AC_less_20_kVA_QP(f)¶
Return Group 1/Class A AC <=20 kVA quasi-peak limit values.
- limit_G1_CA_AC_less_75_kVA_AV(f)¶
Return Group 1/Class A AC <=75 kVA average limit values.
- limit_G1_CA_AC_less_75_kVA_QP(f)¶
Return Group 1/Class A AC <=75 kVA quasi-peak limit values.
- limit_G1_CA_AC_over_75_kVA_AV(f)¶
Return Group 1/Class A AC >75 kVA average limit values.
- limit_G1_CA_AC_over_75_kVA_QP(f)¶
Return Group 1/Class A AC >75 kVA quasi-peak limit values.
- limit_G1_CA_DC_less_20_kVA_AV(f)¶
Return Group 1/Class A DC <=20 kVA average limit values.
- limit_G1_CA_DC_less_20_kVA_QP(f)¶
Return Group 1/Class A DC <=20 kVA quasi-peak limit values.
- limit_G1_CA_DC_less_75_kVA_AV(f)¶
Return Group 1/Class A DC <=75 kVA average limit values.
- limit_G1_CA_DC_less_75_kVA_QP(f)¶
Return Group 1/Class A DC <=75 kVA quasi-peak limit values.
- limit_G1_CA_DC_over_75_kVA_AV(f)¶
Return Group 1/Class A DC >75 kVA average limit values.
- limit_G1_CA_DC_over_75_kVA_QP(f)¶
Return Group 1/Class A DC >75 kVA quasi-peak limit values.
- limit_G1_CB_AC_less_20_kVA_AV(f)¶
Return Group 1/Class B AC <=20 kVA average limit values.
- limit_G1_CB_AC_less_20_kVA_QP(f)¶
Return Group 1/Class B AC <=20 kVA quasi-peak limit values.
- limit_G1_CB_AC_less_75_kVA_AV(f)¶
Return Group 1/Class B AC <=75 kVA average limit values.
- limit_G1_CB_AC_less_75_kVA_QP(f)¶
Return Group 1/Class B AC <=75 kVA quasi-peak limit values.
- limit_G1_CB_AC_over_75_kVA_AV(f)¶
Return Group 1/Class B AC >75 kVA average limit values.
- limit_G1_CB_AC_over_75_kVA_QP(f)¶
Return Group 1/Class B AC >75 kVA quasi-peak limit values.
- limit_G1_CB_DC_less_20_kVA_AV(f)¶
Return Group 1/Class B DC <=20 kVA average limit values.
- limit_G1_CB_DC_less_20_kVA_QP(f)¶
Return Group 1/Class B DC <=20 kVA quasi-peak limit values.
- limit_G1_CB_DC_less_75_kVA_AV(f)¶
Return Group 1/Class B DC <=75 kVA average limit values.
- limit_G1_CB_DC_less_75_kVA_QP(f)¶
Return Group 1/Class B DC <=75 kVA quasi-peak limit values.
- limit_G1_CB_DC_over_75_kVA_AV(f)¶
Return Group 1/Class B DC >75 kVA average limit values.
- limit_G1_CB_DC_over_75_kVA_QP(f)¶
Return Group 1/Class B DC >75 kVA quasi-peak limit values.
- limit_G2_CA_AC_less_20_kVA_AV(f)¶
Return Group 2/Class A AC <=20 kVA average limit values.
- limit_G2_CA_AC_less_20_kVA_QP(f)¶
Return Group 2/Class A AC <=20 kVA quasi-peak limit values.
- limit_G2_CA_AC_less_75_kVA_AV(f)¶
Return Group 2/Class A AC <=75 kVA average limit values.
- limit_G2_CA_AC_less_75_kVA_QP(f)¶
Return Group 2/Class A AC <=75 kVA quasi-peak limit values.
- limit_G2_CA_AC_over_75_kVA_AV(f)¶
Return Group 2/Class A AC >75 kVA average limit values.
- limit_G2_CA_AC_over_75_kVA_QP(f)¶
Return Group 2/Class A AC >75 kVA quasi-peak limit values.
- limit_G2_CA_DC_less_20_kVA_AV(f)¶
Return Group 2/Class A DC <=20 kVA average limit values.
- limit_G2_CA_DC_less_20_kVA_QP(f)¶
Return Group 2/Class A DC <=20 kVA quasi-peak limit values.
- limit_G2_CA_DC_less_75_kVA_AV(f)¶
Return Group 2/Class A DC <=75 kVA average limit values.
- limit_G2_CA_DC_less_75_kVA_QP(f)¶
Return Group 2/Class A DC <=75 kVA quasi-peak limit values.
- limit_G2_CA_DC_over_75_kVA_AV(f)¶
Return Group 2/Class A DC >75 kVA average limit values.
- limit_G2_CA_DC_over_75_kVA_QP(f)¶
Return Group 2/Class A DC >75 kVA quasi-peak limit values.
- limit_G2_CB_AC_less_20_kVA_AV(f)¶
Return Group 2/Class B AC <=20 kVA average limit values.
- limit_G2_CB_AC_less_20_kVA_QP(f)¶
Return Group 2/Class B AC <=20 kVA quasi-peak limit values.
- limit_G2_CB_AC_less_75_kVA_AV(f)¶
Return Group 2/Class B AC <=75 kVA average limit values.
- limit_G2_CB_AC_less_75_kVA_QP(f)¶
Return Group 2/Class B AC <=75 kVA quasi-peak limit values.
- limit_G2_CB_AC_over_75_kVA_AV(f)¶
Return Group 2/Class B AC >75 kVA average limit values.
- limit_G2_CB_AC_over_75_kVA_QP(f)¶
Return Group 2/Class B AC >75 kVA quasi-peak limit values.
- limit_G2_CB_DC_less_20_kVA_AV(f)¶
Return Group 2/Class B DC <=20 kVA average limit values.
- limit_G2_CB_DC_less_20_kVA_QP(f)¶
Return Group 2/Class B DC <=20 kVA quasi-peak limit values.
- limit_G2_CB_DC_less_75_kVA_AV(f)¶
Return Group 2/Class B DC <=75 kVA average limit values.
- limit_G2_CB_DC_less_75_kVA_QP(f)¶
Return Group 2/Class B DC <=75 kVA quasi-peak limit values.
- limit_G2_CB_DC_over_75_kVA_AV(f)¶
Return Group 2/Class B DC >75 kVA average limit values.
- limit_G2_CB_DC_over_75_kVA_QP(f)¶
Return Group 2/Class B DC >75 kVA quasi-peak limit values.
- no_limit(f)¶
no_limit method.
- unit = 'dBµV'¶
- variations = {'Classification': ('A', 'B'), 'Detector': ('QP', 'AV'), 'Group': ('1', '2'), 'Port': ('AC (≤ 20 kVA)', 'AC (≤ 75 kVA)', 'AC (> 75 kVA)', 'DC (≤ 20 kVA)', 'DC (≤ 75 kVA)', 'DC (> 75 kVA)')}¶
mpylab.limits.conducted_emission.en_55032¶
Conducted-emission limits according to EN 55032 (CISPR 32).
- class mpylab.limits.conducted_emission.en_55032.LIMIT(classification=None, detector=None, port=None)¶
Configurable EN 55032 conducted-emission limit model.
- description_Classification = {'A': '\n ## Class A (higher emission limits, industrial) \n \n **Class A** devices must have emissions which are below the limits of Class A, \n but the emissions exceed the limits of Class B.\n Class A devices shall have a warning notice in their manual (e.g. \n *"Warning! This is a Class A device. This device may cause radio \n interference in residential areas; in this case, the operator may be \n required to take appropriate measures"*.).', 'B': '\n ## Class B (lower emission limits, residential): \n \n **Class B** devices must have emissions which are below the limits of \n Class B. This is applicable for devices which are used in a residual and \n domestic environment. In other words: commercial devices. E.g.:\n \n - No permanent location (e.g. battery powered devices)\n - Telecommunication terminal equipment\n - Personal computers'}¶
- description_Group = '\n EN 55032 applies to multimedia equipment (MME) and having a rated RMS AC or DC \n supply voltage not exceeding 600 V. \n Equipment within the scope of CISPR 13 or CISPR 22 is within the scope of EN 55032. \n MME intended primarily for professional use is within the scope of EN 55032. \n The radiated emission requirements in EN 55032 are not intended to be applicable \n to the intentional transmissions from a radio transmitter as defined by the ITU, \n nor to any spurious emissions related to these intentional transmissions. \n Equipment, for which emission requirements in the frequency range covered by EN 55032\n are explicitly formulated in other CISPR publications (except CISPR 13 and CISPR 22), \n are excluded from the scope of this publication. EN 55032 does not contain \n requirements for in-situ assessment (in other words: the tests have to be done in \n an EMC test laboratory). \n The objectives of EN 55032 publication are:\n \n - To establish requirements which provide an adequate level of \n protection of the radio spectrum, allowing radio services to operate as \n intended in the frequency range 9 kHz to 400 GHz.\n - To specify procedures to ensure the reproducibility of measurement and the \n repeatability of results.\n \n The EN 55032 is often referenced by other product and product family standards, \n outside of the scope defined above.'¶
- description_title = 'DIN EN 55032:2022-08 (CISPR-32), conducted'¶
- fmax = 30000000.0¶
- fmin = 150000.0¶
- limit_CA_Mains_AV(f)¶
Return Class A mains-port AV limits.
- limit_CA_Mains_QP(f)¶
Return Class A mains-port QP limits.
- limit_CA_Telecom_LAN_AV(f)¶
Return Class B telecom/LAN-port QP limits.
- limit_CA_Telecom_LAN_QP(f)¶
Return Class A telecom/LAN-port QP limits.
- limit_CB_Mains_AV(f)¶
Return Class B mains-port AV limits.
- limit_CB_Mains_QP(f)¶
Return Class B mains-port QP limits.
- limit_CB_Telecom_LAN_AV(f)¶
Return Class B telecom/LAN-port AV limits.
- limit_CB_Telecom_LAN_QP(f)¶
Return Class B telecom/LAN-port QP limits.
- no_limit(f)¶
no_limit method.
- unit = 'dBµV'¶
- variations = {'Classification': ('A', 'B'), 'Detector': ('QP', 'AV'), 'Port': ('Mains', 'Telecom/LAN')}¶
mpylab.limits.conducted_emission.fcc_part15_subpartb¶
mpylab.limits.conducted_emission.fcc_part15_subpartb module.
- class mpylab.limits.conducted_emission.fcc_part15_subpartb.LIMIT(classification=None, detector=None, port=None)¶
LIMIT class.
- description_Classification = {'A': '\n ## Class A digital device\n\n Class A limits for equipment connected to public utility (AC) power lines.\n ', 'B': '\n ## Class B digital device\n\n Class B limits for equipment connected to public utility (AC) power lines.\n '}¶
- description_Detector = {'AV': '\n ## Average detector\n ', 'QP': '\n ## Quasi-peak detector\n '}¶
- description_title = 'FCC 47 CFR Part 15.107 (Subpart B), conducted'¶
- fmax = 30000000.0¶
- fmin = 150000.0¶
- limit_CA_AC_AV(f)¶
limit_CA_AC_AV method.
- limit_CA_AC_QP(f)¶
limit_CA_AC_QP method.
- limit_CB_AC_AV(f)¶
limit_CB_AC_AV method.
- limit_CB_AC_QP(f)¶
limit_CB_AC_QP method.
- no_limit(f)¶
no_limit method.
- source = '47 CFR 15.107 (eCFR / Cornell LII mirror)'¶
- unit = 'dBµV'¶
- variations = {'Classification': ('A', 'B'), 'Detector': ('QP', 'AV'), 'Port': ('AC',)}¶
mpylab.limits.conducted_emission.fcc_part18_subpartc¶
Conducted-emission limits according to FCC Part 18.307 (Subpart C).
- class mpylab.limits.conducted_emission.fcc_part18_subpartc.LIMIT(case=None, detector=None, port=None)¶
Configurable FCC Part 18.307 conducted-emission limit model.
- description_case = {'Induction/Ultrasonic': '\n ## Induction cooking ranges and ultrasonic equipment\n\n Conducted limits according to 47 CFR 18.307(a).\n ', 'Other consumer device': '\n ## All other Part 18 consumer devices\n\n Conducted limits according to 47 CFR 18.307(b).\n ', 'RF lighting (consumer)': '\n ## RF lighting devices (consumer)\n\n Maximum RF line voltage according to 47 CFR 18.307(c).\n ', 'RF lighting (non-consumer)': '\n ## RF lighting devices (non-consumer)\n\n Maximum RF line voltage according to 47 CFR 18.307(c).\n '}¶
- description_detector = {'AV': '## Average detector / maximum line voltage representation', 'QP': '## Quasi-peak detector / maximum line voltage representation'}¶
- description_title = 'FCC 47 CFR Part 18.307 (Subpart C), conducted'¶
- fmax = 30000000.0¶
- fmin = 9000.0¶
- limit_Induction_Ultrasonic_AV(f)¶
Return AV limits for induction cooking/ultrasonic equipment.
- limit_Induction_Ultrasonic_QP(f)¶
Return QP limits for induction cooking/ultrasonic equipment.
- limit_Other_consumer_device_AV(f)¶
Return AV limits for generic consumer Part 18 devices.
- limit_Other_consumer_device_QP(f)¶
Return QP limits for generic consumer Part 18 devices.
- limit_RF_lighting_consumer_AV(f)¶
Return AV limits for consumer RF lighting equipment.
- limit_RF_lighting_consumer_QP(f)¶
Return QP limits for consumer RF lighting equipment.
- limit_RF_lighting_non_consumer_AV(f)¶
Return AV limits for non-consumer RF lighting equipment.
- limit_RF_lighting_non_consumer_QP(f)¶
Return QP limits for non-consumer RF lighting equipment.
- no_limit(f)¶
no_limit method.
- source = '47 CFR 18.307 (eCFR / Cornell LII mirror)'¶
- unit = 'dBµV'¶
- variations = {'Case': ('Other consumer device', 'Induction/Ultrasonic', 'RF lighting (consumer)', 'RF lighting (non-consumer)'), 'Detector': ('QP', 'AV'), 'Port': ('AC',)}¶
- mpylab.limits.conducted_emission.fcc_part18_subpartc.uv_to_dbuv(uv)¶
Convert microvolt values to dBµV.
mpylab.limits.conducted_emission.iec_61000_6_3¶
mpylab.limits.conducted_emission.iec_61000_6_3 module.
- class mpylab.limits.conducted_emission.iec_61000_6_3.LIMIT(detector=None, port=None)¶
LIMIT class.
- description_mapping = '\n This module follows the Academy EMC mapping for generic residential emission and\n uses CISPR 32 Class B conducted limits as practical profile values.\n '¶
- description_title = 'IEC 61000-6-3 (generic residential/commercial), conducted'¶
- fmax = 30000000.0¶
- fmin = 150000.0¶
- no_limit(f)¶
no_limit method.
- source = 'Academy of EMC standards overview + CISPR 32 profile mapping'¶
- unit = 'dBµV'¶
- variations = {'Detector': ('QP', 'AV'), 'Port': ('Mains', 'Telecom/LAN')}¶
mpylab.limits.conducted_emission.iec_61000_6_4¶
mpylab.limits.conducted_emission.iec_61000_6_4 module.
- class mpylab.limits.conducted_emission.iec_61000_6_4.LIMIT(detector=None, port=None)¶
LIMIT class.
- description_mapping = '\n This module follows the Academy EMC mapping for generic industrial emission and\n uses CISPR 11 Group 1 Class A conducted limits as practical profile values.\n '¶
- description_title = 'IEC 61000-6-4 (generic industrial), conducted'¶
- fmax = 30000000.0¶
- fmin = 150000.0¶
- no_limit(f)¶
no_limit method.
- source = 'Academy of EMC standards overview + CISPR 11 profile mapping'¶
- unit = 'dBµV'¶
- variations = {'Detector': ('QP', 'AV'), 'Port': ('AC (≤ 20 kVA)', 'AC (≤ 75 kVA)', 'AC (> 75 kVA)', 'DC (≤ 20 kVA)', 'DC (≤ 75 kVA)', 'DC (> 75 kVA)')}¶
mpylab.limits.limit¶
mpylab.limits.limit module.
- mpylab.limits.limit.log_linear(f1, v1, f2, v2)¶
log_linear function.
mpylab.limits.limits_ui¶
mpylab.limits.limits_ui module.
mpylab.limits.limits_ui_main¶
Qt UI entrypoint for browsing and plotting limit definitions.
- class mpylab.limits.limits_ui_main.MainWindow(*args: Any, **kwargs: Any)¶
Main limits browser window with variation controls and plot area.
- clearLayout(layout)¶
Recursively remove all widgets/items from a Qt layout.
- populate_tree(root_path='.')¶
Populate the file tree with available Python limit modules.
- retranslateUi(MainWindow)¶
retranslateUi method.
- setupUi(MainWindow)¶
setupUi method.
- tree_view_clicked()¶
Load selected limit module and rebuild variation controls.
- update_description()¶
Recreate selected limit instance and refresh markdown description.
- update_plot()¶
Plot the currently selected limit curve on a logarithmic axis.
- class mpylab.limits.limits_ui_main.MplCanvas(*args: Any, **kwargs: Any)¶
Matplotlib canvas wrapper used by the limits UI.
mpylab.limits.qtlimit_proxy¶
mpylab.limits.qtlimit_proxy module.
- class mpylab.limits.qtlimit_proxy.HideFileTypesProxy(*args: Any, **kwargs: Any)¶
A proxy model that excludes files from the view that end with the given extension
- filterAcceptsRow(srcRow, srcParent)¶
filterAcceptsRow method.
- class mpylab.limits.qtlimit_proxy.Tree(*args: Any, **kwargs: Any)¶
Tree class.
mpylab.limits.radiated_emission.en_55011¶
Radiated-emission limits according to EN 55011 (CISPR 11).
- class mpylab.limits.radiated_emission.en_55011.LIMIT(group=None, classification=None, detector=None, port=None, distance=None)¶
Configurable EN 55011 radiated-emission limit model.
- description_Classification = {'A': '\n ## Class A (higher emission limits, industrial) \n \n **Class A** devices are devices that are suitable for use in all areas other than \n residential and such areas, and they are connected to the public mains.\n \n Devices must have emissions which are below the limits of Class A, \n but the emissions may exceed the limits of Class B.\n \n For Class A equipment, the instructions for use accompanying the product shall \n contain the following text: \n \n *Caution: This equipment is not intended for use in residential environments \n and may not provide adequate protection to radio reception in such environments.*', 'B': '\n ## Class B (lower emission limits, residential): \n \n **Class B** devices are devices that are suitable for use in residential areas \n and such areas, and they are connected to the public mains.'}¶
- description_Group = {'1': '\n ## Group 1: (general purpose applications)\n \n All equipment in the scope of EN 55011 (CISPR 11) which is not classified as Group 2 equipment. \n \n Examples of **Group 1** equipment:\n \n - Laboratory equipment\n - Medical electrical equipment\n - Scientific equipment\n - Semiconductor-converters\n - Industrial electric heating equipment with operating frequencies less than or equal to 9 kHz\n - Machine tools\n - Industrial process measurement and control equipment\n - Semiconductor manufacturing equipment\n - Switch mode power supplies', '2': '\n ## Group 2 (ISM RF applications): \n \n All ISM RF equipment in which radio-frequency energy in the frequency \n range 9kHz to 400GHz is intentionally generated and used or only used locally, in the form \n of electromagnetic radiation, inductive and/or capacitive coupling, for the treatment \n of material, for inspection/analysis purposes, or for transfer of electromagnetic energy. \n \n Examples of **Group 2** equipment:\n \n - Microwave-powered UV irradiating apparatus\n - Microwave lighting apparatus\n - Industrial induction heating equipment operating at frequencies above 9 kHz\n - Dielectric heating equipment Industrial microwave heating equipment\n - Arc Welding equipment\n - Microwave ovens\n - Medical electrical equipment\n - Electric welding equipment\n - Electro-discharge machining (EDM) equipment\n - Demonstration models for education and training\n - Battery chargers and power supplies – wireless power transfer (WPT) mode'}¶
- description_TestSetup = {'A': '\n ## Test Setup:\n \n On a test site, **Class A** equipment can be measured at a nominal distance d \n of 3m, 10m or 30m.\n \n **Class A** ***Group 1** equipment can be measured in situ, where the \n measurement takes place at a distance of 30m from the outer face of the exterior \n wall of the building in which the equipment is situated.\n \n **Class A** **Group 2** equipment can be measured in situ, where the measurement \n distance d from the exterior wall of the building in which the equipment is situated \n equals (30+x/a)m or 100m whichever is smaller, provided that the measuring \n distance d is within the boundary of the premises. In the case where the calculated \n distance d is beyond the boundary of the premises, the measuring distance \n d equals x or 30m, whichever is longer. For the calculation of the above values:\n\n - x is the nearest distance between the exterior wall of the building in which \n the equipment is situated and the boundary of the user’s premises in each \n measuring direction.\n - a = 2.5 for frequencies lower than 1 MHz.\n - a = 4.5 for frequencies equal to or higher than 1 MHz.', 'B': '\n ## Test Setup: \n \n On a test site, Class B equipment can be measured at a nominal distance d of 3m or 10m.\n \n - d < 10m. In the frequency range 30MHz to 1000MHz, a distance less than \n 10m is allowed only for equipment which complies with the definition \n for small size equipment. Small size equipment is either positioned on a \n table top or standing on the floor which, including its cables fits in an \n imaginary cylindrical test volume of 1.2m in diameter and 1.5m height \n (to ground plane).'}¶
- description_title = 'DIN EN 55011:2022-05 (CISPR-11), radiated'¶
- fmax = 6000000000.0¶
- fmin = 30000000.0¶
- limit_G1_CA_AC_less_20_kVA_AV_3_m(f)¶
Return Group 1 Class A AV limits for AC <= 20 kVA at 3 m.
- limit_G1_CA_AC_less_20_kVA_PK_3_m(f)¶
Return Group 1 Class A PK limits for AC <= 20 kVA at 3 m.
- limit_G1_CA_AC_less_20_kVA_QP_10_m(f)¶
Return Group 1 Class A QP limits for AC <= 20 kVA at 10 m.
- limit_G1_CA_AC_less_20_kVA_QP_3_m(f)¶
Return Group 1 Class A QP limits for AC <= 20 kVA at 3 m.
- limit_G1_CA_AC_over_20_kVA_QP_10_m(f)¶
Return Group 1 Class A QP limits for AC > 20 kVA at 10 m.
- limit_G1_CA_AC_over_20_kVA_QP_3_m(f)¶
Return Group 1 Class A QP limits for AC > 20 kVA at 3 m.
- limit_G1_CB_AC_less_20_kVA_AV_3_m(f)¶
Return Group 1 Class B AV limits for AC <= 20 kVA at 3 m.
- limit_G1_CB_AC_less_20_kVA_PK_3_m(f)¶
Return Group 1 Class B PK limits for AC <= 20 kVA at 3 m.
- limit_G1_CB_AC_less_20_kVA_QP_10_m(f)¶
Return Group 1 Class B QP limits for AC <= 20 kVA at 10 m.
- limit_G1_CB_AC_less_20_kVA_QP_3_m(f)¶
Return Group 1 Class B QP limits for AC <= 20 kVA at 3 m.
- no_limit(f)¶
no_limit method.
- unit = 'dBµV/m'¶
- variations = {'Classification': ('A', 'B'), 'Detector': ('QP', 'AV', 'PK'), 'Distance': ('3 m', '10 m', '30 m'), 'Group': ('1', '2'), 'Port': ('AC (≤ 20 kVA)', 'AC (> 20 kVA)')}¶
mpylab.limits.radiated_emission.fcc_part15_subpartb¶
Radiated-emission limits according to FCC Part 15.109 (Subpart B).
- class mpylab.limits.radiated_emission.fcc_part15_subpartb.LIMIT(classification=None, detector=None, distance=None)¶
Configurable FCC Part 15.109 radiated-emission limit model.
- description_Classification = {'A': '\n ## Class A digital device\n\n Reference distance for the tabulated limits: 10 m.\n ', 'B': '\n ## Class B digital device\n\n Reference distance for the tabulated limits: 3 m.\n '}¶
- description_Detector = {'AV': '\n ## Average detector\n\n Implemented for frequencies above 960 MHz.\n ', 'PK': '\n ## Peak detector\n\n Implemented as average + 20 dB above 960 MHz (per 47 CFR 15.35 relationship).\n ', 'QP': '\n ## Quasi-peak detector\n\n Implemented for 30 MHz to 960 MHz.\n '}¶
- description_title = 'FCC 47 CFR Part 15.109 (Subpart B), radiated'¶
- fmax = 6000000000.0¶
- fmin = 30000000.0¶
- limit_CA_10_m_AV(f)¶
Return Class A average limits above 960 MHz at 10 m.
- limit_CA_10_m_PK(f)¶
Return Class A peak limits above 960 MHz at 10 m.
- limit_CA_10_m_QP(f)¶
Return Class A quasi-peak limits at 10 m.
- limit_CB_3_m_AV(f)¶
Return Class B average limits above 960 MHz at 3 m.
- limit_CB_3_m_PK(f)¶
Return Class B peak limits above 960 MHz at 3 m.
- limit_CB_3_m_QP(f)¶
Return Class B quasi-peak limits at 3 m.
- no_limit(f)¶
no_limit method.
- source = '47 CFR 15.109 and 15.35 (eCFR / Cornell LII mirror)'¶
- unit = 'dBµV/m'¶
- variations = {'Classification': ('A', 'B'), 'Detector': ('QP', 'AV', 'PK'), 'Distance': ('3 m', '10 m')}¶
- mpylab.limits.radiated_emission.fcc_part15_subpartb.uv_to_dbuv(uv_per_m)¶
Convert microvolt-per-meter values to dBµV/m.
mpylab.limits.radiated_emission.fcc_part18_subpartc¶
Radiated-emission limits according to FCC Part 18.305 (Subpart C).
- class mpylab.limits.radiated_emission.fcc_part18_subpartc.LIMIT(case=None, distance=None)¶
Configurable FCC Part 18.305 radiated-emission limit model.
- description_case = {'Induction cooking range': '\n ## Induction cooking ranges\n\n Field-strength limits according to 47 CFR 18.305(b), measurement distance 30 m.\n ', 'Misc ISM (<500 W)': '\n ## Miscellaneous ISM equipment in ISM bands\n\n Field-strength limits according to 47 CFR 18.305(a), measurement distance 300 m.\n ', 'Misc non-ISM (<500 W)': '\n ## Miscellaneous ISM equipment outside ISM bands\n\n Field-strength limits according to 47 CFR 18.305(a), measurement distance 300 m.\n ', 'RF lighting (consumer)': '\n ## RF lighting devices (consumer)\n\n Field-strength limits according to 47 CFR 18.305(c), measurement distance 30 m.\n ', 'RF lighting (non-consumer)': '\n ## RF lighting devices (non-consumer)\n\n Field-strength limits according to 47 CFR 18.305(c), measurement distance 30 m.\n '}¶
- description_title = 'FCC 47 CFR Part 18.305 (Subpart C), radiated'¶
- fmax = 1000000000.0¶
- fmin = 9000.0¶
- limit_Induction_cooking_range_30_m(f)¶
Return induction-cooking-range limits at 30 m.
- limit_Misc_ISM_less500_W_300_m(f)¶
Return limits for miscellaneous ISM equipment below 500 W at 300 m.
- limit_Misc_non_ISM_less500_W_300_m(f)¶
Return limits for miscellaneous non-ISM equipment below 500 W at 300 m.
- limit_RF_lighting_consumer_30_m(f)¶
Return consumer RF-lighting limits at 30 m.
- limit_RF_lighting_non_consumer_30_m(f)¶
Return non-consumer RF-lighting limits at 30 m.
- no_limit(f)¶
no_limit method.
- source = '47 CFR 18.305 (eCFR / Cornell LII mirror)'¶
- unit = 'dBµV/m'¶
- variations = {'Case': ('RF lighting (consumer)', 'RF lighting (non-consumer)', 'Induction cooking range', 'Misc non-ISM (<500 W)', 'Misc ISM (<500 W)'), 'Distance': ('30 m', '300 m')}¶
- mpylab.limits.radiated_emission.fcc_part18_subpartc.uvm_to_dbuvm(uvm)¶
Convert microvolt-per-meter values to dBµV/m.
mpylab.limits.radiated_emission.iec_61000_6_3¶
mpylab.limits.radiated_emission.iec_61000_6_3 module.
- class mpylab.limits.radiated_emission.iec_61000_6_3.LIMIT(detector=None, distance=None)¶
LIMIT class.
- description_mapping = '\n This module follows the Academy EMC mapping for generic residential emission and\n uses CISPR 11 Group 1 Class B radiated profile combinations where available.\n '¶
- description_title = 'IEC 61000-6-3 (generic residential/commercial), radiated'¶
- fmax = 6000000000.0¶
- fmin = 30000000.0¶
- no_limit(f)¶
no_limit method.
- source = 'Academy of EMC standards overview + CISPR 11 profile mapping'¶
- unit = 'dBµV/m'¶
- variations = {'Detector': ('QP', 'AV', 'PK'), 'Distance': ('3 m', '10 m')}¶
mpylab.limits.radiated_emission.iec_61000_6_4¶
mpylab.limits.radiated_emission.iec_61000_6_4 module.
- class mpylab.limits.radiated_emission.iec_61000_6_4.LIMIT(detector=None, distance=None)¶
LIMIT class.
- description_mapping = '\n This module follows the Academy EMC mapping for generic industrial emission and\n uses CISPR 11 Group 1 Class A radiated profile combinations where available.\n '¶
- description_title = 'IEC 61000-6-4 (generic industrial), radiated'¶
- fmax = 6000000000.0¶
- fmin = 30000000.0¶
- no_limit(f)¶
no_limit method.
- source = 'Academy of EMC standards overview + CISPR 11 profile mapping'¶
- unit = 'dBµV/m'¶
- variations = {'Detector': ('QP', 'AV', 'PK'), 'Distance': ('3 m', '10 m')}¶
mpylab.tools¶
mpylab.tools.PControler¶
This is mpylab.tools.PController.
Provides different class Leveler
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- class mpylab.tools.PControler.Leveler(sg, amp, pin=None)¶
Iterative level controller using sampled inverse interpolation.
- add_samples(pin)¶
Measure and store output samples for one or more input levels.
- adjust_level(soll, maxiter=10, relerr=0.01)¶
Iteratively adjust input level to reach target output level.
- update_interpol()¶
Rebuild forward and inverse interpolators from current samples.
- class mpylab.tools.PControler.Rapp(g, Ps, S, PinMax=0.001, noise_loc=1.0, noise_sc=0.5)¶
Simple Rapp-like amplifier model with additive random noise.
- Pout(Pin)¶
Return noisy output power for a given input power.
- class mpylab.tools.PControler.SG¶
Minimal signal-generator stub exposing a level setter.
- SetLevel(lv)¶
Set generator level (console stub implementation).
- mpylab.tools.PControler.extrap1d(interpolator)¶
Wrap a 1D interpolator with bounded linear extrapolation at both ends.
mpylab.tools.aunits¶
This is mpylab.tools.aunits.
Provides alternative units based on scuq.si units
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
mpylab.tools.calling¶
This is mpylab.tools.calling.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- mpylab.tools.calling.get_calling_sequence(prefixes: Iterable[str] | None = None) Iterable[str]¶
Get the sequence of calls to this function.
- Parameter:
prefixes (Iterable[str] | None): prefixes that are lstripted from possible cmds, None -> [‘return’]
mpylab.tools.compare¶
mpylab.tools.compare module.
- mpylab.tools.compare.cmp(a, b)¶
cmp function.
- mpylab.tools.compare.cplx_cmp(a, b)¶
cplx_cmp function.
- mpylab.tools.compare.cplx_key(a)¶
cplx_key function.
- mpylab.tools.compare.fstrcmp(a, possibilities, cutoff=0.0, ignorecase=True, use_rmcp=True)¶
fstrcmp function.
- mpylab.tools.compare.fstrcmp_scpi(a, possibilities, cutoff=0.0, ignorecase=True)¶
Token-based fuzzy matcher for SCPI commands.
The command is split at ‘:’ and each token is compared separately. Ranking prefers: 1. exact token matches 2. token prefix matches 3. token substring matches 4. best fuzzy token similarity
- Example:
fstrcmp_scpi(“BAND”, [“SENS:FREQ:START”, “SENS:BAND:RES”]) -> [“SENS:BAND:RES”, “SENS:FREQ:START”]
- mpylab.tools.compare.relative(a, b, first_must_match=True)¶
Computes a relative distance between two strings. It’s in the range (0-1] where 1 means total equality. @type a: string @param a: arg one @type b: string @param b: arg two @rtype: float @return: the distance
- mpylab.tools.compare.rmcp(seq, ignorecase=True)¶
remove common prefix from sequence elements
mpylab.tools.configuration¶
This is mpylab.tools.configuration.
Provides the Configuration class; used for ini files
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.tools.configuration.Configuration(ini: str | TextIO, cnftmpl: dict, casesensitive: bool = False)¶
Class for all configuration files.
- mpylab.tools.configuration.parse_ini_value(value, inline_files=None)¶
Parse a value from an ini file without using eval().
Supported: - plain strings - ints, floats, bools, None - tuples, lists, dicts via ast.literal_eval - embedded inline data files via placeholders
- mpylab.tools.configuration.preprocess_ini_text(text)¶
Replace embedded inline-file Python expressions with placeholders so that configparser can parse the ini text.
- Returns:
processed_text, inline_files
- mpylab.tools.configuration.strbool(s) bool¶
Returns True if int(s) is True or False otherwise. ‘0’ -> False; ‘1’ -> True
mpylab.tools.dataparser¶
This is mpylab.tools.dataparser.
Provides the class DataFile(Parser); used for dat files
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.tools.dataparser.DatFile(**kw)¶
DatFileis the parser for data files, e.g. with S-parameter values.A typical usage is like so:
import sys import io import scuq from mpylab.tools.util import format_block from mpylab.tools.dataparser import DatFile name=None if len(sys.argv)>1: name=sys.argv[1] else: name=io.StringIO(format_block(''' FUNIT: Hz UNIT: powerratio ABSERROR: [0.1, 1] 10 [1, 0] 11 1 20 [0.9, 40] 30 [0.8, 70] 40 [0.7, 120] 50 [0.6, 180] 60 [0.5, 260] 70 [0.4, 310] 80 [0.3, 10] 90 [0.2, 50] ''')) DF=DatFile(filename=name) result=DF.run() ctx=scuq.ucomponents.Context() for f in sorted(result): uq=result[f] val,err,unit=ctx.value_uncertainty_unit(uq) print f, uq, val, err, unit
- p_error(p)¶
p_error method.
- p_idanycase_id(p)¶
idanycase : ID
- p_line_abserr(p)¶
line : ABSERROR val NEWLINE
- p_line_data1(p)¶
line : FPNUMBER val val val NEWLINE
- p_line_data2(p)¶
line : FPNUMBER val NEWLINE
- p_line_empty(p)¶
line : NEWLINE
- p_line_funit(p)¶
line : FUNIT idanycase NEWLINE
- p_line_relerr(p)¶
line : RELERROR FPNUMBER NEWLINE
- p_line_unit(p)¶
line : UNIT idanycase NEWLINE | UNIT idanycase idanycase NEWLINE
- p_lines_line(p)¶
lines : line lines | line
- p_number_fpnumber(p)¶
number : FPNUMBER
- p_val_ma(p)¶
val : LSBRACE FPNUMBER COMMA FPNUMBER RSBRACE
- p_val_number(p)¶
val : number
- p_val_ri(p)¶
val : LBRACE FPNUMBER COMMA FPNUMBER RBRACE
- precedence = ()¶
- reserved = ('FUNIT', 'UNIT', 'RELERROR', 'ABSERROR')¶
- run()¶
run method.
- t_COMMA = ','¶
- t_FPNUMBER(t)¶
[+-]?[0-9]+(.[0-9]+)?([eE][+-]?[0-9]+)?
- t_FUNIT(t)¶
FUNIT:
- t_ID(t)¶
[a-zA-Z][a-zA-Z0-9/]*
- t_LBRACE = '\\('¶
- t_LSBRACE = '\\['¶
- t_NEWLINE(t)¶
[nr]
- t_RBRACE = '\\)'¶
- t_RSBRACE = '\\]'¶
- t_error(t)¶
t_error method.
- t_ignore = ' \t:'¶
- t_ignore_COMMENT = '\\#.*'¶
- tokens = ('FUNIT', 'UNIT', 'RELERROR', 'ABSERROR', 'FPNUMBER', 'LBRACE', 'RBRACE', 'LSBRACE', 'RSBRACE', 'ID', 'COMMA', 'NEWLINE')¶
mpylab.tools.directivity¶
This is mpylab.tools.directivity.
Provides the class UnintentionalRad and Dmax_uRad_OneCut see: https://ieeexplore.ieee.org/document/5715864
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- class mpylab.tools.directivity.Dmax_uRad_OneCut(min_radius)¶
Dmax_uRad_OneCut class.
- Dmax(f)¶
Dmax method.
- chisq2fac(n)¶
chisq2fac method.
- cvacuum = 299792458¶
- ka(f)¶
ka method.
- static n_ind(ka)¶
n_ind method.
- twopi = 6.283185307179586¶
- class mpylab.tools.directivity.UnintentionalRad(min_radius)¶
UnintentionalRad class.
- chisq2fac(n)¶
returns sum_{i=0}^n 1/i aprox 0.577 + ln(n) + 1/2n see: https://ieeexplore.ieee.org/document/5715864
- cvacuum = 299792458¶
- ka(f)¶
wavevector times physical size -> electrical size a freq f: ka = 2pi f/c a = omega/c a
- twopi = 6.283185307179586¶
mpylab.tools.distributions¶
This is mpylab.tools.distributions.
Provides
mpylab.tools.distributions.RayleighDistfor Rayleigh distributions.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- mpylab.tools.distributions.ECDF(seq: list[float]) object¶
Calculate the Empirical Cumulated Distribution Function (ecdf) from a sequence ‘seq’.
A scipy interpolation object is returned.
- class mpylab.tools.distributions.RayleighDist(loc: float = 0, scale: float = 1)¶
Rayleigh distribution
- cdf(x: ArrayLike) object¶
Rayleigh probability function (cdf); loc and scale are given with the constructor
- Parameter:
x: array-like, support
- Return:
cdf: a scipy.stats.rayleigh.cdf object
- pdf(x: ArrayLike) object¶
Rayleigh probability density function (pdf); loc and scale are given with the constructor
- Parameter:
x: array-like, support
- Return:
pdf: a scipy.stats.rayleigh.pdf object
- rvs(size: int = 1, random_state: int | None | object = None) ArrayLike¶
Draw samples from this distribution
- Parameters:
size: number of samples to draw, default 1
random_state: random state object, default None see https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.random_state.html#scipy.stats.rv_continuous.random_state
- mpylab.tools.distributions.chi2_test(data: ArrayLike | Callable[[float], float], cdf: Callable[[float], float]) float¶
Performs a Chisquare test for the expected counts for the reference distribution (cdf) and those from the observed distribution (data).
- Parameters:
data: array-like | callable, rv to test
cdf: array-like | callable, cdf to test against
H0 = There are no differences between the classes in observed and expected distribution
p-value is the probability of obtaining test results at least as extreme as the result actually observed, under the assumption that the null hypothesis is correct. A very small p-value means that such an extreme observed outcome would be very unlikely under the null hypothesis.
small p (p<0.05, p<0.01) -> data is not drawn from cdf
- Results:
p: p-value for the test (probability that the sample is drawn from the reference distribution)
- mpylab.tools.distributions.fit_rayleigh(data: ArrayLike) tuple[float, float]¶
Fit a rayleigh distribution to data
- Parameters:
data: array-like, data to fit, data are samples assumed to be rayleigh distributed
- Return:
loc, scale: tuple, location and scale parameters
- mpylab.tools.distributions.ks_test(data: ArrayLike | Callable[[float], float], cdf: ArrayLike | Callable[[float], float]) float¶
Performs the Kolmogorov-Smirnov test for goodness of fit.
- Parameters:
data: array-like | callable, rv to test
cdf: array-like | callable, cdf to test against
H0 = The sample is drawn from the reference distribution
p-value is the probability of obtaining test results at least as extreme as the result actually observed, under the assumption that the null hypothesis is correct. A very small p-value means that such an extreme observed outcome would be very unlikely under the null hypothesis.
small p (p<0.05, p<0.01) -> data is not drawn from cdf
- Results:
p: p-value for the test (probability that the sample is drawn from the reference distribution)
- mpylab.tools.distributions.test_for_rayleigh(ees: ArrayLike) tuple[ArrayLike, ArrayLike, object, object, float, float]¶
test_for_rayleigh function.
mpylab.tools.dotparser¶
Handwritten DOT parser as migration path away from generated dot.py.
The module is currently kept active as a started refactoring attempt and may be integrated more broadly in future.
- class mpylab.tools.dotparser.DotParser(text: str)¶
Recursive descent parser for the supported DOT subset.
Return value is
(nodes, graph)where:nodesmaps each node name to a dictionary of node attributes.graphmaps each left node to its right-side neighbors and edge attribute dictionaries.
- parse() tuple[dict, dict]¶
Parse DOT text and return
(nodes, graph)dictionaries.
- exception mpylab.tools.dotparser.DotSyntaxError(message: str, pos: int | None = None)¶
Syntax error raised for invalid DOT input.
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class mpylab.tools.dotparser.DotTokenizer(text: str)¶
Tokenizer for the supported DOT subset.
- peek_type() str¶
Return the type of the current token.
- class mpylab.tools.dotparser.Token(type: str, value: str, pos: int)¶
Token produced by the DOT tokenizer.
- pos: int¶
- type: str¶
- value: str¶
- mpylab.tools.dotparser.parse(rule: str, text: str)¶
Compatibility wrapper for old parse(rule, text) usage.
Currently only ‘graph’ is supported.
- mpylab.tools.dotparser.parse_dot(text: str) tuple[dict, dict]¶
Parse DOT text with the handwritten parser.
- mpylab.tools.dotparser.test_typical_graph()¶
Run a smoke test on a representative DOT graph definition.
mpylab.tools.gtem_e0y¶
mpylab.tools.gtem_e0y module.
- class mpylab.tools.gtem_e0y.GTEM(az: float, hz: float, gz: float, zz: float, Zc: float = 50)¶
GTEM class.
- a(z)¶
a method.
- e0y(x, y, z, max_m: int = 1000)¶
e0y method.
- evaluate_function_on_points(points, fnc, chunk_size: int = 20000, **kwargs)¶
Evaluate a field function on a
(N, 3)point cloud.- Parameters:
points – Input points shaped
(N, 3).fnc – Function compatible with
e0y(x, y, z, ...).chunk_size – Number of points processed per chunk.
kwargs – Additional keyword arguments forwarded to
fnc.
- g(z)¶
g method.
- generate_points(zmax, num_points_z, num_points_xy)¶
Generate a 3D array of points
(x, y, z)from chamber geometry.- Parameters:
zmax (float): Maximum z coordinate. num_points_z (int): Number of samples along the z axis. num_points_xy (int): Number of samples for x and y per z slice.
- Returns:
numpy.ndarray: Array containing points
(x, y, z).
- h(z)¶
h method.
mpylab.tools.interpol¶
This is mpylab.tools.interpol.
Provides interpolation routines
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- class mpylab.tools.interpol.UQ_interpol(dct, typ=None)¶
Interpolation routine for a dct with uncertain quantities as values. type is not yet used.
cplx_interpol()is used to interpolate complex values.Example:
from mpylab.tools.interpol import * import numpy import scuq freqs=[p*1e6 for p in range(16)] phis=[p*math.pi/16 for p in range(16)] vals=[complex(math.cos(p),math.sin(p)) for p in phis] dct=dict((v for v in zip(freqs,vals))) cinter=cplx_interpol(dct) print "Complex interpolation:" print cinter(5e5) print uqvals=[scuq.quantities.Quantity(scuq.si.VOLT,v) for v in vals] dct2=dict((v for v in zip(freqs,uqvals))) uqinter=UQ_interpol(dct2) print "SCUQ interpolation:" print uqinter(5e5)
- class mpylab.tools.interpol.cplx_interpol(dct, typ=None)¶
Interpolation routine for a dct with complex values. type is not yet used. Phase is unwrapped using
unwrap()Example:
In [1]: from interpol import * You should use UTF-8 instead of mac-roman as encoding, or the SI units won't display correctly In [2]: freqs=[p*1e6 for p in range(16)] In [3]: phis=[p*math.pi/16 for p in range(16)] In [4]: vals=[complex(math.cos(p),math.sin(p)) for p in phis] In [5]: dct=dict((v for v in zip(freqs,vals))) In [6]: cinter=cplx_interpol(dct) In [7]: abs(cinter(5e5)) Out[8]: 1.0 In [9]: math.atan2(cinter(5e5).imag, cinter(5e5).real) Out[9]: 0.098174770424681035
- mpylab.tools.interpol.unwrap(dct, arg=None)¶
Phase unwrapping of values in dictionary dct.
dct is a dict with keys that can be sorted (frequencies). The values are typically complex values representing e.g. S-parameters.
If arg is given, it is expected to be a callable with a signature like
math.atan2()that returns the argument (phase) of the objects in dct.The function returns a 3-tuple of lists with the sorted keys, the magnitude, and the phase of the values.
mpylab.tools.keyboard¶
This is mpylab.tools.keyboard.
Provides getch, kbhit and getwch for POSIX
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
mpylab.tools.level_control¶
This is mpylab.tools.level_control.
Provides different classes for level control
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- class mpylab.tools.level_control.ControlBase(actual_reader: Callable[[], float | int], setter: Callable[[float], object], initial: Sequence[float | int], abstol: float | int, max_iter: int = 20, min_cntrl: float | int | None = None, max_cntrl: float | int | None = None, stagnation_tol: float = 1e-12)¶
Base class for iterative inverse control/calibration procedures.
Principle: -
setter(cntrl)applies a control value -reader()reads the measured actual value - a new control value is estimated from measured(cntrl, actual)pairs- clamp_cntrl(cntrl: float | int) float¶
Clamp a control value to configured min/max bounds.
- do_cntrl(nominal: float | int, initial: Sequence[float | int] | None = None, return_result_object: bool = False) Tuple[float, float] | ControlResult¶
Iteratively drive actual value towards nominal within tolerance.
- guess(cntrl: Sequence[float], act: Sequence[float], nominal: float) float¶
Estimate next control value from control/actual history.
- set_cntrl_val(cntrl: float | int) float¶
Apply a control value via setter and return measured actual value.
- class mpylab.tools.level_control.ControlBracketInterpol(actual_reader, setter, initial, abstol, max_iter=20, min_cntrl=None, max_cntrl=None, stagnation_tol=1e-12, max_step_up=3.0, max_step_down=6.0, safety_margin=0.0, prefer_from_below=True)¶
Monotonic inverse control using bracketing and interpolation.
The controller first searches measured points that bracket the nominal value. If no bracket exists yet, it performs bounded extrapolation with limited step sizes. Once a bracket exists, it applies inverse linear interpolation inside that interval.
- clamp_cntrl(cntrl: float | int) float¶
Clamp a control value to configured min/max bounds.
- do_cntrl(nominal: float | int, initial: Sequence[float | int] | None = None, return_result_object: bool = False) Tuple[float, float] | ControlResult¶
Iteratively drive actual value towards nominal within tolerance.
- guess(cntrl, act, nominal)¶
Estimate next control step with bracketing and guarded extrapolation.
- set_cntrl_val(cntrl: float | int) float¶
Apply a control value via setter and return measured actual value.
- class mpylab.tools.level_control.ControlInterpol(actual_reader: Callable[[], float | int], setter: Callable[[float], object], initial: Sequence[float | int], abstol: float | int, max_iter: int = 20, min_cntrl: float | int | None = None, max_cntrl: float | int | None = None, stagnation_tol: float = 1e-12)¶
Inverse controller using monotonic interpolation/extrapolation.
- clamp_cntrl(cntrl: float | int) float¶
Clamp a control value to configured min/max bounds.
- do_cntrl(nominal: float | int, initial: Sequence[float | int] | None = None, return_result_object: bool = False) Tuple[float, float] | ControlResult¶
Iteratively drive actual value towards nominal within tolerance.
- guess(cntrl: Sequence[float], act: Sequence[float], nominal: float) float¶
Estimate control by inverse interpolation at nominal.
- set_cntrl_val(cntrl: float | int) float¶
Apply a control value via setter and return measured actual value.
- class mpylab.tools.level_control.ControlPolyfit(actual_reader: Callable[[], float | int], setter: Callable[[float], object], initial: Sequence[float | int], abstol: float | int, maxorder: int = 2, **kwargs)¶
Inverse controller using polynomial fit from actual to control.
- clamp_cntrl(cntrl: float | int) float¶
Clamp a control value to configured min/max bounds.
- do_cntrl(nominal: float | int, initial: Sequence[float | int] | None = None, return_result_object: bool = False) Tuple[float, float] | ControlResult¶
Iteratively drive actual value towards nominal within tolerance.
- guess(cntrl: Sequence[float], act: Sequence[float], nominal: float) float¶
Estimate control by inverse polynomial evaluation at nominal.
- set_cntrl_val(cntrl: float | int) float¶
Apply a control value via setter and return measured actual value.
- class mpylab.tools.level_control.ControlRapp(actual_reader: Callable[[], float | int], setter: Callable[[float], object], initial: Sequence[float | int], abstol: float | int, p: float = 1.0, g: float = 1.0, sat: float = 20.0, **kwargs)¶
Fit a saturating Rapp model:
y = g*x / (1 + (g*x/sat)^(2p))^(1/(2p))
- clamp_cntrl(cntrl: float | int) float¶
Clamp a control value to configured min/max bounds.
- do_cntrl(nominal: float | int, initial: Sequence[float | int] | None = None, return_result_object: bool = False) Tuple[float, float] | ControlResult¶
Iteratively drive actual value towards nominal within tolerance.
- guess(cntrl: Sequence[float], act: Sequence[float], nominal: float) float¶
Estimate control by fitting Rapp model and solving inverse output.
- set_cntrl_val(cntrl: float | int) float¶
Apply a control value via setter and return measured actual value.
- class mpylab.tools.level_control.ControlResult(guess: float, actual: float, iterations: int, evaluations: int)¶
Convergence result bundle for one control run.
- actual: float¶
- evaluations: int¶
- guess: float¶
- iterations: int¶
- mpylab.tools.level_control.control¶
alias of
ControlBracketInterpol
mpylab.tools.levenshtein¶
mpylab.tools.levenshtein module.
- mpylab.tools.levenshtein.fstrcmp(a, possibilities, cutoff=0.0, ignorecase=True, use_rmcp=True)¶
fstrcmp function.
- mpylab.tools.levenshtein.fstrcmp_scpi(a, possibilities, cutoff=0.0, ignorecase=True)¶
Token-based fuzzy matcher for SCPI commands.
The command is split at ‘:’ and each token is compared separately. Ranking prefers: 1. exact token matches 2. token prefix matches 3. token substring matches 4. best fuzzy token similarity
- Example:
fstrcmp_scpi(“BAND”, [“SENS:FREQ:START”, “SENS:BAND:RES”]) -> [“SENS:BAND:RES”, “SENS:FREQ:START”]
- mpylab.tools.levenshtein.relative(a, b, first_must_match=True)¶
Computes a relative distance between two strings. It’s in the range (0-1] where 1 means total equality. @type a: string @param a: arg one @type b: string @param b: arg two @rtype: float @return: the distance
- mpylab.tools.levenshtein.rmcp(seq, ignorecase=True)¶
remove common prefix from sequence elements
mpylab.tools.mgraph¶
This is mpylab.tools.mgraph.
Provides the MGraph class (mainly)
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- class mpylab.tools.mgraph.DictObj¶
A dict with object-like attributes.
Instead of dct[‘name’] you can do dct.name
- clear()¶
Remove all items from the dict.
- copy()¶
Return a shallow copy of the dict.
- classmethod fromkeys(iterable, value=None, /)¶
Create a new dictionary with keys from iterable and values set to value.
- get(key, default=None, /)¶
Return the value for key if key is in the dictionary, else default.
- items()¶
Return a set-like object providing a view on the dict’s items.
- keys()¶
Return a set-like object providing a view on the dict’s keys.
- pop(k[, d]) v, remove specified key and return the corresponding value.¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- popitem()¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- setdefault(key, default=None, /)¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
- update([E, ]**F) None. Update D from mapping/iterable E and F.¶
If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- values()¶
Return an object providing a view on the dict’s values.
- class mpylab.tools.mgraph.GName(mginst: MGraph)¶
Helper class for
MGraphif mg is instance of
MGraphyo can access the ‘physical’ instrument name (that in the dot-file) with the ‘logical’ device mame (that in your code) by mg.name.logical_name
- class mpylab.tools.mgraph.Graph(fname_or_data=None, SearchPaths=None)¶
Graph class based on
pydot.The graph is created using the methods (called in this order)
pydot.graph_from_dot_filepydot.graph_from_dot_datapydot.graph_from_edgespydot.graph_from_adjacency_matrixpydot.graph_from_incidence_matrix
with the argument of the
__init__method.- find_all_paths(start, end, path=None, edge=None)¶
Find all all_paths in graph from start to end (without circles). Ignores edges with attribute active==False. As user: allways call with path=None and edges=None; these are only used within recursion
- find_path(start, end, path=None)¶
Returns a path from start to end. Ignores edges with attribute active==False.
- find_shortest_path(start, end, path=None)¶
Returns the shortest (in terms number of elements in path) path from start to end. Ignores edges with attribute active==False. Returns shortest path from start to end or None if no path is found. As user: don’t use the path= argument; used in recursion only
- get_common_parent(n1, n2)¶
Tries to find a node that is parent of n1 and n2. Only active paths are valid. Returns that node or None.
- class mpylab.tools.mgraph.Leveler(mg, actor, output, lpoint, observer, pin=None, datafunc=None, min_actor=None)¶
Iterative level control helper based on measurement-graph corrections.
- add_samples(pin)¶
Add one or more actor-level samples and measured observation values.
- adjust_level(soll, maxiter=10, relerr=0.01)¶
Iteratively adjust actor level to reach requested target quantity.
- update_interpol()¶
Rebuild forward and inverse interpolators from current sample set.
- class mpylab.tools.mgraph.MGraph(fname_or_data=None, themap=None, SearchPaths=None)¶
Measurement graph class based of
Graph. See there for the argument of the__init__()method.- AmplifierProtect(start, end, startlevel, sg_unit=<scuq.units.AlternateUnit object>, typ='save')¶
Check amplifier safety margins along all active paths.
- CalcLevelFrom(sg, limiter, what)¶
Validate nodes/path for level calculation and return status placeholder.
- CmdDevices(IgnoreInactive, cmd, *args)¶
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’].
- ConfReceivers(conf, IgnoreInactive=True)¶
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
- CreateDevices()¶
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
- EvaluateConditions(doAction=True)¶
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’.
- GetAntennaEfficiency(node)¶
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
- Init_Devices(IgnoreInactive=False)¶
Initialize all device.
Raises
UserWarningif a device fails to initialize.If IgnoreInactive = False (default), all devices are initialized, else only active devices are initialized.
- MaxSafeLevel(start, end, typ='save')¶
Return the minimum safe start level across all active paths.
- NBRead(lst, result)¶
Non Blocking read. See
_Read().
- NBTrigger(lst)¶
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
- Quit_Devices(IgnoreInactive=False)¶
Quit all devices using
CmdDevices().Input: IgnoreInactive=False
Return: return val of
CmdDevices()
- RFOff_Devices(IgnoreInactive=False)¶
RFOff all devices using CmdDevices Input: IgnoreInactive=False Return: return val of CmdDevices
- RFOn_Devices(IgnoreInactive=True)¶
RFOn all devices using CmdDevices Input: IgnoreInactive=True Return: return val of CmdDevices
- Read(lst)¶
Blocking read. See
_Read().
- SetFreq_Devices(freq, IgnoreInactive=True)¶
Set frequency on all (optionally active) devices and return min/max.
- Trigger_Devices(IgnoreInactive=True)¶
Trigger all devices using CmdDevices Input: IgnoreInactive=True Return: return val of CmdDevices
- Zero_Devices(IgnoreInactive=True)¶
Zero all devices using CmdDevices Input: IgnoreInactive=True Return: return val of CmdDevices
- find_all_paths(start, end, path=None, edge=None)¶
Find all all_paths in graph from start to end (without circles). Ignores edges with attribute active==False. As user: allways call with path=None and edges=None; these are only used within recursion
- find_path(start, end, path=None)¶
Returns a path from start to end. Ignores edges with attribute active==False.
- find_shortest_path(start, end, path=None)¶
Returns the shortest (in terms number of elements in path) path from start to end. Ignores edges with attribute active==False. Returns shortest path from start to end or None if no path is found. As user: don’t use the path= argument; used in recursion only
- getBatteryLow_Devices(IgnoreInactive=True)¶
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
- get_common_parent(n1, n2)¶
Tries to find a node that is parent of n1 and n2. Only active paths are valid. Returns that node or None.
- get_gname(name: str) str | None¶
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)¶
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)¶
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.
- mpylab.tools.mgraph.safe_action_exec(expr, names)¶
Safely execute one method-call action expression with literal arguments.
- mpylab.tools.mgraph.safe_condition_eval(expr, names)¶
Safe evaluator for graph conditions.
Supported: - numeric constants, strings, booleans, None - names from names - arithmetic: + - * / // % ** - unary: + - not - comparisons: < <= > >= == != - chained comparisons: 10e3 < f <= 1e6 - boolean operators: and, or
mpylab.tools.numeric_eval¶
mpylab.tools.numeric_eval module.
- mpylab.tools.numeric_eval.safe_numeric_eval(expr: str) float¶
Safely evaluate simple numeric expressions with SI prefixes.
- Allowed:
1e9 1e9/4 10M 2.45G 100kHz 3.3V -20dBm (2.45G + 100M) / 2
- Not allowed:
abs(1) x + 1 __import__(‘os’).system(…) self.x
mpylab.tools.plyparser¶
mpylab.tools.plyparser module.
mpylab.tools.plyparser_DatFile_parsetab¶
mpylab.tools.regular_expressions¶
This is the mpylab.tools.regular_expressions module.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
mpylab.tools.sin_fit¶
This is mpylab.tools.sin_fit.
Provides a sinus fit function
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- mpylab.tools.sin_fit.fit_sin(tt, yy)¶
Fit sin to the input time sequence, and return fitting parameters amp, omega, phase, offset, freq, period and fitfunc
mpylab.tools.space_generators¶
This is mpylab.tools.space_generators.
Provides Generator Versions of logspace and linspace
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- class mpylab.tools.space_generators.LinSpace(start=80000000.0, stop=1000000000.0, step=1000000.0, endpoint=True)¶
LinSpace class.
- class mpylab.tools.space_generators.LogSpace(start=80000000.0, stop=1000000000.0, step=1.01, endpoint=True)¶
LogSpace class.
mpylab.tools.spacing¶
This is mpylab.tools.spacing: routines returning sequences aka range
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- mpylab.tools.spacing.frange(limit1, limit2=None, increment=1.0)¶
Range function that accepts floats (and integers).
Usage:
frange(-2, 2, 0.1) frange(10) frange(10, increment = 0.5)
The returned value is a generator. Use list(frange) for a list.
- mpylab.tools.spacing.idxset(n, m)¶
returns a list of length n with equidistant elem of range(m)
- mpylab.tools.spacing.linspace(start, stop, step, endpoint=0, precision=2)¶
Evenly spaced samples on a linear scale.
Return evenly spaced samples from start to stop. If endpoint=1 then last sample is stop and step is adjusted.
- mpylab.tools.spacing.linspaceN(start, stop, number, endpoint=0, precision=2)¶
Evenly spaced samples on a linear scale.
Return number evenly spaced samples from start to stop. If endpoint=1 then last sample is stop and number is adjusted.
- mpylab.tools.spacing.logspace(start, stop, factor=1.01, endpoint=0, precision=2)¶
Evenly spaced samples on a logarithmic scale.
Returns evenly spaced samples from start to stop. If endpoint=1 then last sample is stop and factor is adjusted.
- mpylab.tools.spacing.logspaceN(start, stop, number, endpoint=0, precision=2)¶
Evenly spaced samples on a logarithmic scale.
Return number evenly spaced samples from start to stop. If endpoint=1 then last sample is stop and factor is adjusted.
- mpylab.tools.spacing.logspaceTab(start, end, ftab=None, nftab=None, endpoint=True)¶
logspaceTab function.
mpylab.tools.statistic¶
This is mpylab.tools.statistic.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPLv3 or higher
- mpylab.tools.statistic.autocorrelation(x, maxlag=None, cyclic=True)¶
Compute the autocorrelation function of an iterable (scuq.Quantity aware).
- mpylab.tools.statistic.correlation(x, y)¶
Compute the correlation of two iterable (scuq.Quantity aware).
- mpylab.tools.statistic.covariance(x, y)¶
Compute the covariance of two iterable (scuq.Quantity aware).
- mpylab.tools.statistic.linstat_dB(dbvals, fac=10)¶
Input: dbvals sequence of dB-scaled values fac: float, defaults to 10; sometimes 20 may be used
Output: dB-scaled lin-average of the input sequence, upper_std, lower_std
Example: linav_dB([0,-10]) -> -2.5963, 3.339, 445.9, linav_dB([0,-10], fac=20) -> -3.633, 4.78, 11.52
- mpylab.tools.statistic.linstat_lin(linvals)¶
Input: sequence of lin-scaled values Output: lin-scaled lin-average and lin-standart deviation of the input sequence
Example: linstat_lin([0,-10]) -> -5, 7.07
- mpylab.tools.statistic.mean(x)¶
Compute the mean value of an iterable (scuq.Quantity aware).
- mpylab.tools.statistic.stddev(x)¶
Compute the standard deviation of an iterable (scuq.Quantity aware).
- mpylab.tools.statistic.summation(x)¶
A scuq.Quantity aware summation function.
- Parameter:
x: a sequence
- Returns:
The sum of elements in x
- mpylab.tools.statistic.variance(x)¶
Compute the variance of an iterable (scuq.Quantity aware).
mpylab.tools.uconv¶
Unit conversion helpers used by parser and devices.
This module is the canonical conversion backend in mpylab. The public API supports both directions:
unit/value -> Quantity (to_quantity)
Quantity -> target unit/value (from_quantity)
The mapping is case-insensitive for unit names.
- class mpylab.tools.uconv.UConv¶
Central registry for unit conversion methods.
uconv maps input unit strings to tuples (target_scuq_unit, converter). uconv_from_quantity maps scuq unit-string representation to outbound converters keyed by destination unit string.
- classmethod available_output_units(obj)¶
Return outbound unit strings available for a Quantity object.
- classmethod available_units()¶
Return all supported input units.
- classmethod convert(unit, value)¶
Convert a numeric value from unit to canonical scuq base.
- classmethod from_quantity(tounit, obj)¶
Convert a scuq Quantity to a float in destination unit tounit.
- classmethod get(unit)¶
Return (scuq_unit, converter) for input unit string.
- classmethod normalize_unit(unit)¶
Normalize a unit name to its dictionary key representation.
- classmethod to_quantity(fromunit, value)¶
Create a scuq Quantity from unit string and value.
- uconv = {'1': (<scuq.units.ProductUnit object>, <function _ident>), '1/m': (<scuq.units.ProductUnit object>, <function _ident>), 'a/m': (<scuq.units.ProductUnit object>, <function _ident>), 'amplituderatio': (<scuq.units.AlternateUnit object>, <function _ident>), 'cm': (<scuq.units.BaseUnit object>, <function _mulfac.<locals>.new_m>), 'db': (<scuq.units.AlternateUnit object>, <function _from_dBfac.<locals>.lin>), 'db1/m': (<scuq.units.ProductUnit object>, <function _from_dBfac.<locals>.lin>), 'dba/m': (<scuq.units.ProductUnit object>, <function _from_dBfac.<locals>.lin>), 'dbd': (<scuq.units.AlternateUnit object>, <function _mulfac.<locals>.new_m>), 'dbi': (<scuq.units.AlternateUnit object>, <function _from_dBfac.<locals>.lin>), 'dbm': (<scuq.units.AlternateUnit object>, <function _mulfac.<locals>.new_m>), 'dbs/m': (<scuq.units.ProductUnit object>, <function _from_dBfac.<locals>.lin>), 'dbuv': (<scuq.units.AlternateUnit object>, <function _mulfac.<locals>.new_m>), 'dbv/m': (<scuq.units.ProductUnit object>, <function _from_dBfac.<locals>.lin>), 'dbw/m2': (<scuq.units.ProductUnit object>, <function _from_dBfac.<locals>.lin>), 'deg': (<scuq.units.AlternateUnit object>, <function _mulfac.<locals>.new_m>), 'dimensionless': (<scuq.units.ProductUnit object>, <function _ident>), 'f': (<scuq.units.AlternateUnit object>, <function _ident>), 'ghz': (<scuq.units.AlternateUnit object>, <function _mulfac.<locals>.new_m>), 'h': (<scuq.units.AlternateUnit object>, <function _ident>), 'hz': (<scuq.units.AlternateUnit object>, <function _ident>), 'khz': (<scuq.units.AlternateUnit object>, <function _mulfac.<locals>.new_m>), 'm': (<scuq.units.BaseUnit object>, <function _ident>), 'mhz': (<scuq.units.AlternateUnit object>, <function _mulfac.<locals>.new_m>), 'mm': (<scuq.units.BaseUnit object>, <function _mulfac.<locals>.new_m>), 'powerratio': (<scuq.units.AlternateUnit object>, <function _ident>), 'rad': (<scuq.units.AlternateUnit object>, <function _ident>), 's/m': (<scuq.units.ProductUnit object>, <function _ident>), 'steps': (<scuq.units.ProductUnit object>, <function _ident>), 'v': (<scuq.units.AlternateUnit object>, <function _ident>), 'v/m': (<scuq.units.ProductUnit object>, <function _ident>), 'w': (<scuq.units.AlternateUnit object>, <function _ident>), 'w/m2': (<scuq.units.ProductUnit object>, <function _ident>)}¶
- uconv_from_quantity = {'(V/V)': {'amplituderatio': <function _ident>}, '(W/W)': {'db': <function _to_dBfac.<locals>.db>, 'dbd': <function _addsum.<locals>.new_m>, 'dbi': <function _to_dBfac.<locals>.db>, 'powerratio': <function _ident>, 'powerration': <function _ident>}, '1': {'1': <function _ident>, 'dimensionless': <function _ident>, 'steps': <function _ident>}, 'A*m^(-1)': {'a/m': <function _ident>, 'dba/m': <function _to_dBfac.<locals>.db>}, 'A*m^(-1)*V^(-1)': {'a/m': <function _ident>, 'dbs/m': <function _to_dBfac.<locals>.db>, 's/m': <function _ident>}, 'F': {'f': <function _ident>}, 'H': {'h': <function _ident>}, 'Hz': {'ghz': <function _mulfac.<locals>.new_m>, 'hz': <function _ident>, 'khz': <function _mulfac.<locals>.new_m>, 'mhz': <function _mulfac.<locals>.new_m>}, 'V': {'dbuv': <function _addsum.<locals>.new_m>, 'v': <function _ident>}, 'V/m': {'dbv/m': <function _to_dBfac.<locals>.db>, 'v/m': <function _ident>}, 'W': {'dbm': <function _addsum.<locals>.new_m>, 'w': <function _ident>}, 'W*m^(-2)': {'dbw/m2': <function _to_dBfac.<locals>.db>, 'w/m2': <function _ident>}, 'm': {'cm': <function _mulfac.<locals>.new_m>, 'm': <function _ident>, 'mm': <function _mulfac.<locals>.new_m>}, 'm^(-1)': {'1/m': <function _ident>, 'db1/m': <function _to_dBfac.<locals>.db>}, 'rad': {'deg': <function _mulfac.<locals>.new_m>, 'rad': <function _ident>}}¶
- classmethod unit_exists(unit)¶
Return True if the input unit is known.
- mpylab.tools.uconv.V2dBuV(inp)¶
- mpylab.tools.uconv.W2dBm(inp)¶
- mpylab.tools.uconv.dB2lin(dBfac=None, sifac=None)¶
Create a converter from dB input to linear output.
Example: dBm2W = dB2lin(10, 1e-3)
- mpylab.tools.uconv.dBm2W(inp)¶
- mpylab.tools.uconv.dBm2mW(inp)¶
- mpylab.tools.uconv.dBuV2V(inp)¶
- mpylab.tools.uconv.dBuV2uV(inp)¶
- mpylab.tools.uconv.from_quantity(tounit, obj)¶
Backward-compatible convenience wrapper around UConv.from_quantity.
- mpylab.tools.uconv.lin2dB(dBfac=None, sifac=None)¶
Create a converter from linear input to dB output.
Example: W2dBm = lin2dB(10, 1e3)
- mpylab.tools.uconv.mW2dBm(inp)¶
- mpylab.tools.uconv.to_quantity(fromunit, value)¶
Backward-compatible convenience wrapper around UConv.to_quantity.
- mpylab.tools.uconv.uV2dBuV(inp)¶
mpylab.tools.uncertain¶
This is mpylab.tools.uncertain:
provides k-factor for expanded uncertainty calculations
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- mpylab.tools.uncertain.get_dB_factors(dB, k, A=10)¶
Calculate a k-factor on the dB scale.
dB: standard uncertainty in dB (dB=A*log10((E+sigma)/sigma) k: linear k-factor A: transformation factor lin<->dB; 10->power, 20->voltage, field strength,…
A 2-tuple of k-factors on the dB scale is returned
- mpylab.tools.uncertain.get_k_factor(*args, coverage=0.95, both_tails=True, dist=None, **kwargs)¶
get_k_factor function.
- mpylab.tools.uncertain.get_k_factor_norm(coverage=0.95, both_tails=True)¶
Return the k factor for the normal distribution.
The k-factor is defined as follows: in the interval width 2*k*sigma falls coverage * 100 percent of the values. The k-factor is used to calculated extended uncertainties from standard deviations (uncertainties) or vice versa.
- mpylab.tools.uncertain.get_k_factor_rect(coverage=0.95, both_tails=True)¶
Return the k factor for the rectangular distribution.
The k-factor is defined as follows: in the interval width 2*k*sigma falls coverage * 100 percent of the values. The k-factor is used to calculated extended uncertainties from standard deviations (uncertainties) or vice versa.
- mpylab.tools.uncertain.get_k_factor_ushape(coverage=0.95, both_tails=True)¶
Return the k factor for the u-shaped distribution.
The k-factor is defined as follows: in the interval width 2*k*sigma falls coverage * 100 percent of the values. The k-factor is used to calculated extended uncertainties from standard deviations (uncertainties) or vice versa.
mpylab.tools.unit_conversion¶
Backward-compatible unit conversion facade.
Historically this module contained its own conversion logic. The canonical
implementation now lives in mpylab.tools.uconv. This module keeps the
legacy API and delegates all behavior to that single code base.
mpylab.tools.unixcrt¶
kbhit.py - kbhit functionality for Unix (with termios)
How to use this module:
unbuffer_stdin() Call unbuffer_stdin() before using any other functions.
kbhit() Once stdin is in unbuffered mode, you can call kbhit() to see if a key is ready on stdin. kbhit() will return immediately. Returns 1 if a key is ready, 0 otherwise.
getch() Calling getch() will return one keypress from stdin. If a key is not ready, then getchar() will block until the next keypress. Recommended usage is to call kbhit() until a key is ready, then getch() to get the keypress.
restore_stdin() When you are all done, call restore_stdin() to return stdin to its prior state.
This module was tested with Linux. This module is NOT thread-safe.
Author: Tim Bird, (termios handling from Andrew Kuchling)
- mpylab.tools.unixcrt.getch()¶
getch() - reads one key from stdin. Waits if there is not a key available.
- mpylab.tools.unixcrt.kbhit()¶
kbhit() - returns 1 if a key is ready, 0 othewise. kbhit always returns immediately.
- mpylab.tools.unixcrt.restore_stdin()¶
restore_stdin() - used to convert stdin to whatever mode it was in before calling unbuffer_stdin()
- mpylab.tools.unixcrt.test()¶
test function.
- mpylab.tools.unixcrt.unbuffer_stdin()¶
unbuffer_stdin() - used to convert stdin to unbuffered mode. That is, you can read a single character from stdin, without having to wait for a whole line of input
mpylab.tools.util¶
This is mpylab.tools.util: all sort of utilities.
- author:
Hans Georg Krauthäuser (main author)
- license:
GPL-3 or higher
- mpylab.tools.util.CalcPsi(n, rho, eps=0.01)¶
Compute PDF/CDF samples for correlation-coefficient distribution.
- mpylab.tools.util.CalcRho0(r, cpsi, alpha)¶
Return critical rho values for given cumulative probabilities.
- mpylab.tools.util.CalcSigma(lst, av=None)¶
Calculate sample standard deviation for numeric/quantity values.
- mpylab.tools.util.InterpolateMResults(y, x, interpolation=None)¶
Create interpolation function with optional log-axis transforms.
- mpylab.tools.util.LogError(Messenger)¶
Send current exception traceback through project messenger.
- mpylab.tools.util.LookForUserInterrupt()¶
Poll keyboard and return True when user requests abort.
- mpylab.tools.util.MResult_Interpol(dct, interpolation)¶
Create interpolation function from mapping of x->y values.
- class mpylab.tools.util.OutputError¶
Small file-like collector used for traceback output capture.
- clear()¶
Reset stored output and read cursor.
- readline()¶
Return next collected line and advance read cursor.
- readlines(lines=None)¶
Return up to
linescollected output items.
- seek(count=0)¶
Move read cursor to
count.
- write(obj)¶
Append one output item.
- mpylab.tools.util.anykeyevent() int | None¶
Detects a key or function key pressed and returns its ascii or scancode.
- mpylab.tools.util.case_insensitive_string_compare(s1: str, s2: str) bool¶
Compares case insensitive string s1 and s2.
Returns True or False.
If s1 or s2 are not instances of str, False is returned.
- mpylab.tools.util.cmp(a: Any, b: Any) int¶
cmp was deprecated with python 3.0.
We rebuild it here according to https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
Returns +1 is a>b, -1 is a<b, 0 if a=b
- mpylab.tools.util.combinations(L)¶
Return cartesian combinations for a nested list-of-lists input.
- mpylab.tools.util.extrap1d(interpolator)¶
Interpolation with linear exprapolation
- mpylab.tools.util.flatten(a)¶
Flatten nested sequences into one flat list.
- mpylab.tools.util.format_block(block, nlspaces=0)¶
Format the given block of text, trimming leading/trailing empty lines and any leading whitespace that is common to all lines. The purpose is to let us list a code block as a multiline, triple-quoted Python string, taking care of indentation concerns.
- mpylab.tools.util.funkeypress()¶
Waits for the user to press any key including function keys. Returns the ascii code for the key or the scancode for the function key.
- mpylab.tools.util.getIndex(val, tab)¶
returns the index so that val is between tab[index-1], tab[index]. tab is a sorted list
- mpylab.tools.util.get_var_from_nearest_outerframe(varstr)¶
Lookup variable by name in nearest outer stack frames.
- mpylab.tools.util.gmax_fs(f, rstep=None, s=10, hg=0.8, RH=(0.8, 0.8))¶
Compute the geometry factor g_max for horizontal and vertical polarization for a dipole in free space (FAR).
Parameters:
f: frequency in meters (not used in the function)
rstep: the step width of the hight scan used to calculate the max. (not used in the function)
s: Distance from the EUT in meters
hg: height over ground plane in meters
RH: range of the hight scan in meters. The source is assumed to be at the lower end of this range.
The function returns dictionary with keys ‘h’ and ‘v’ containing the g_max factors (as floats, unit is 1/m).
- mpylab.tools.util.gmax_oats(f, rstep=None, s=10, hg=0.8, RH=(1, 4))¶
Compute the geometry factor g_max for horizontal and vertical polarization for a dipole over a plane, perfectly conducting ground (OATS) according to equation A.7 of IEC 61000-4-20.
Parameters:
f: frequency in meters
rstep: the step width of the hight scan used to calculate the max. If rstep is None, a value of a tenth of the wavelength ist used.
s: Distance from the EUT in meters
hg: height over ground plane in meters
RH: range of the hight scan in meters
The function returns dictionary with keys ‘h’ and ‘v’ containing the g_max factors (as floats, unit is 1/m).
- mpylab.tools.util.interactive(obj=None, banner=None)¶
Start interactive Python shell with
objnamespace.
- mpylab.tools.util.isiterable(obj)¶
Return whether object supports iteration.
- mpylab.tools.util.issequence(a)¶
Return whether
ais iterable but not a string.
- mpylab.tools.util.keypress()¶
Waits for the user to press a key. Returns the ascii code for the key pressed or zero for a function key pressed.
- mpylab.tools.util.locate(pattern, paths=None)¶
Locate all files matching supplied filename pattern in and below supplied root directory.
- mpylab.tools.util.map2singlechar(i)¶
Map integer index to compact alphanumeric symbol.
- mpylab.tools.util.mean(x, zero=0.0)¶
Return arithmetic mean of iterable
x.
- mpylab.tools.util.normalize_string(text: str) str¶
Returns a normalized version (NFKD) of the input string text.
The normal form KD (NFKD) will apply the compatibility decomposition, that is, replace all compatibility characters with their equivalents.
- mpylab.tools.util.removefrom(obj, pat)¶
Recursively delete members whose type string matches regex
pat.
- mpylab.tools.util.secant_solve(f, x1, x2, ftol, xtol)¶
Find root of
fwith SciPy secant solver.
- mpylab.tools.util.send_email(to=None, fr=None, subj='a message from mpylab.util', msg='')¶
Send an e-mail via localhost SMTP; return True on success, else False.
- mpylab.tools.util.tstamp()¶
Return local timestamp string with timezone.
mpylab.tools.yappsrt¶
Run time libraries needed to run parsers generated by Yapps.
This module defines parse-time exception classes, a scanner class, a base class for parsers produced by Yapps, and a context class that keeps track of the parse stack.
- class mpylab.tools.yappsrt.Context(parent, scanner, tokenpos, rule, args=())¶
Class to represent the parser’s call stack.
Every rule creates a Context that links to its parent rule. The contexts can be used for debugging.
- exception mpylab.tools.yappsrt.NoMoreTokens¶
Another exception object, for when we run out of tokens
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class mpylab.tools.yappsrt.Parser(scanner)¶
Base class for Yapps-generated parsers.
- class mpylab.tools.yappsrt.Scanner(patterns, ignore, input)¶
Yapps scanner.
The Yapps scanner can work in context sensitive or context insensitive modes. The token(i) method is used to retrieve the i-th token. It takes a restrict set that limits the set of tokens it is allowed to return. In context sensitive mode, this restrict set guides the scanner. In context insensitive mode, there is no restriction (the set is always the full set of tokens).
- get_char_pos()¶
Get the current char position in the input text.
- get_column_number()¶
Get the column number of the current position in the input text.
- get_input_scanned()¶
Get the portion of the input that has been tokenized.
- get_input_unscanned()¶
Get the portion of the input that has not yet been tokenized.
- get_line_number()¶
Get the line number of the current position in the input text.
- get_prev_char_pos(i=None)¶
Get the previous position (one token back) in the input text.
- get_token_pos()¶
Get the current token position in the input text.
- scan(restrict)¶
Should scan another token and add it to the list, self.tokens, and add the restriction to self.restrictions
- token(i, restrict=None)¶
Get the i’th token in the input.
If i is one past the end, then scan for another token.
Args:
restrict : [token, …] or None; if restrict is None, then any token is allowed. You may call token(i) more than once. However, the restrict set may never be larger than what was passed in on the first call to token(i).
- exception mpylab.tools.yappsrt.SyntaxError(charpos=-1, msg='Bad Token', context=None)¶
When we run into an unexpected token, this is the exception to use
- add_note(object, /)¶
Exception.add_note(note) – add a note to the exception
- args¶
- with_traceback(object, /)¶
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- mpylab.tools.yappsrt.print_error(input, err, scanner)¶
Print error messages, the parser stack, and the input text – for human-readable error messages.
- mpylab.tools.yappsrt.print_line_with_pointer(text, p)¶
Print the line of ‘text’ that includes position ‘p’, along with a second line with a single caret (^) at position p
- mpylab.tools.yappsrt.wrap_error_reporter(parser, rule)¶
wrap_error_reporter function.