spvctrl.measurement.settings.MeasurementParameters#

class MeasurementParameters(n_pulses: int = 10, wait_n_pulses: int = 0, trigger_retries: int = 3, laser_settle_time_s: float = 10.0, laser_ramp_up_time_s: float = 15.0, pump_power_mJcm2: float | None = None, trigger: Literal['Diode', 'Laser'] = 'Diode', acquisition_time_s: float | None = None, pulse_interval_s: float | None = None, turn_off_laser_after_measurement: bool = True, pulse_storage: Literal['full', 'downsampled'] = 'full', store_individual_pulses: bool = True, n_log_downsampled: int = 8192)[source]#

Bases: SettingsClass

General measurement parameters.

Methods

as_dict

Return all fields of the settings class as a dictionary.

copy

Convenience method for copy.deepcopy(self)

fields

Return a tuple describing the fields of this dataclass.

from_dict

Recursively construct a SettingsClass from a dictionary.

get_dict

Return the settings as a dictionary.

load_yaml

save_yaml

Attributes

__annotations__ = {'acquisition_time_s': typing.Optional[float], 'laser_ramp_up_time_s': <class 'float'>, 'laser_settle_time_s': <class 'float'>, 'n_log_downsampled': <class 'int'>, 'n_pulses': <class 'int'>, 'pulse_interval_s': typing.Optional[float], 'pulse_storage': typing.Literal['full', 'downsampled'], 'pump_power_mJcm2': typing.Optional[float], 'store_individual_pulses': <class 'bool'>, 'trigger': typing.Literal['Diode', 'Laser'], 'trigger_retries': <class 'int'>, 'turn_off_laser_after_measurement': <class 'bool'>, 'wait_n_pulses': <class 'int'>}#
__dataclass_fields__ = {'acquisition_time_s': Field(name='acquisition_time_s',type=typing.Optional[float],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Desired acquisition time per pulse in s, i.e. the time span recorded after the trigger. The oscilloscope is configured with the closest possible acquisition time that is equal or larger, given the sampling rate and the maximum record length. If not given, the sampling rate and segment size must be set explicitly in the acquisition settings.'}),kw_only=False,_field_type=_FIELD), 'laser_ramp_up_time_s': Field(name='laser_ramp_up_time_s',type=<class 'float'>,default=15.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Time in seconds to wait for the laser to ramp up after it is turned on, before the acquisition starts.', 'valid': (0, 999999)}),kw_only=False,_field_type=_FIELD), 'laser_settle_time_s': Field(name='laser_settle_time_s',type=<class 'float'>,default=10.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Time in seconds to wait for the laser to settle after the wavelength was changed, before the acquisition starts.', 'valid': (0, 999999)}),kw_only=False,_field_type=_FIELD), 'n_log_downsampled': Field(name='n_log_downsampled',type=<class 'int'>,default=8192,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of log-downsampled values for every measurement-side downsampling: the log-downsampled pulse files, the averaged transient and the live view.', 'valid': (1, 999999)}),kw_only=False,_field_type=_FIELD), 'n_pulses': Field(name='n_pulses',type=<class 'int'>,default=10,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of pulses to acquire.', 'valid': (0, 999999)}),kw_only=False,_field_type=_FIELD), 'pulse_interval_s': Field(name='pulse_interval_s',type=typing.Optional[float],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Target pulse interval in s: the laser frequency divider is chosen so that the actual pulse interval is equal or larger.\nAlternative to setting laser.frequency_divider explicitly  Setting both is an error.'}),kw_only=False,_field_type=_FIELD), 'pulse_storage': Field(name='pulse_storage',type=typing.Literal['full', 'downsampled'],default='full',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Storage format of the individual pulse files (always written to the measurement cache directory) and of the individual pulse parts in the finalized .tspv file:\nfull: Store the full transient (int16 ADC counts with the conversion information, or float64 voltages if the oscilloscope does not support raw ADC access). May take a lot of disk space.\ndownsampled: Store the log-downsampled transient.'}),kw_only=False,_field_type=_FIELD), 'pump_power_mJcm2': Field(name='pump_power_mJcm2',type=typing.Optional[float],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Pulse power density in mJ/cm^2, stored as measurement parameter.'}),kw_only=False,_field_type=_FIELD), 'store_individual_pulses': Field(name='store_individual_pulses',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': "Whether to include the individual pulse transients in the finalized .tspv file as parts 'pulse0001', 'pulse0002', .... The averaged transient is always stored as the '+' part. The individual pulse files are always written to the measurement cache directory regardless of this setting."}),kw_only=False,_field_type=_FIELD), 'trigger': Field(name='trigger',type=typing.Literal['Diode', 'Laser'],default='Diode',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': "The trigger source:\n'Diode' uses a photodiode connected to the oscilloscope; the diode channel is enabled for triggering and its data is recorded in dual mode.\n'Laser' uses the laser sync TTL connected to the trigger input."}),kw_only=False,_field_type=_FIELD), 'trigger_retries': Field(name='trigger_retries',type=<class 'int'>,default=3,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of times to re-arm and retry the capture after a trigger timeout, before the measurement fails.', 'valid': (0, 999)}),kw_only=False,_field_type=_FIELD), 'turn_off_laser_after_measurement': Field(name='turn_off_laser_after_measurement',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Whether to turn the laser off after the measurement. Turning it on again takes a while, so only turn it off when no further measurements are planned.'}),kw_only=False,_field_type=_FIELD), 'wait_n_pulses': Field(name='wait_n_pulses',type=<class 'int'>,default=0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of pulses to wait before starting acquisition.', 'valid': (0, 999999)}),kw_only=False,_field_type=_FIELD)}#
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False)#
__dict__ = mappingproxy({'__module__': 'spvctrl.measurement.settings', '__firstlineno__': 39, '__annotations__': {'n_pulses': <class 'int'>, 'wait_n_pulses': <class 'int'>, 'trigger_retries': <class 'int'>, 'laser_settle_time_s': <class 'float'>, 'laser_ramp_up_time_s': <class 'float'>, 'pump_power_mJcm2': typing.Optional[float], 'trigger': typing.Literal['Diode', 'Laser'], 'acquisition_time_s': typing.Optional[float], 'pulse_interval_s': typing.Optional[float], 'turn_off_laser_after_measurement': <class 'bool'>, 'pulse_storage': typing.Literal['full', 'downsampled'], 'store_individual_pulses': <class 'bool'>, 'n_log_downsampled': <class 'int'>}, '__doc__': 'General measurement parameters.', 'n_pulses': 10, 'wait_n_pulses': 0, 'trigger_retries': 3, 'laser_settle_time_s': 10.0, 'laser_ramp_up_time_s': 15.0, 'pump_power_mJcm2': None, 'trigger': 'Diode', 'acquisition_time_s': None, 'pulse_interval_s': None, 'turn_off_laser_after_measurement': True, 'pulse_storage': 'full', 'store_individual_pulses': True, 'n_log_downsampled': 8192, '__static_attributes__': (), '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False,match_args=True,kw_only=False,slots=False,weakref_slot=False), '__dataclass_fields__': {'n_pulses': Field(name='n_pulses',type=<class 'int'>,default=10,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of pulses to acquire.', 'valid': (0, 999999)}),kw_only=False,_field_type=_FIELD), 'wait_n_pulses': Field(name='wait_n_pulses',type=<class 'int'>,default=0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of pulses to wait before starting acquisition.', 'valid': (0, 999999)}),kw_only=False,_field_type=_FIELD), 'trigger_retries': Field(name='trigger_retries',type=<class 'int'>,default=3,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of times to re-arm and retry the capture after a trigger timeout, before the measurement fails.', 'valid': (0, 999)}),kw_only=False,_field_type=_FIELD), 'laser_settle_time_s': Field(name='laser_settle_time_s',type=<class 'float'>,default=10.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Time in seconds to wait for the laser to settle after the wavelength was changed, before the acquisition starts.', 'valid': (0, 999999)}),kw_only=False,_field_type=_FIELD), 'laser_ramp_up_time_s': Field(name='laser_ramp_up_time_s',type=<class 'float'>,default=15.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Time in seconds to wait for the laser to ramp up after it is turned on, before the acquisition starts.', 'valid': (0, 999999)}),kw_only=False,_field_type=_FIELD), 'pump_power_mJcm2': Field(name='pump_power_mJcm2',type=typing.Optional[float],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Pulse power density in mJ/cm^2, stored as measurement parameter.'}),kw_only=False,_field_type=_FIELD), 'trigger': Field(name='trigger',type=typing.Literal['Diode', 'Laser'],default='Diode',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': "The trigger source:\n'Diode' uses a photodiode connected to the oscilloscope; the diode channel is enabled for triggering and its data is recorded in dual mode.\n'Laser' uses the laser sync TTL connected to the trigger input."}),kw_only=False,_field_type=_FIELD), 'acquisition_time_s': Field(name='acquisition_time_s',type=typing.Optional[float],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Desired acquisition time per pulse in s, i.e. the time span recorded after the trigger. The oscilloscope is configured with the closest possible acquisition time that is equal or larger, given the sampling rate and the maximum record length. If not given, the sampling rate and segment size must be set explicitly in the acquisition settings.'}),kw_only=False,_field_type=_FIELD), 'pulse_interval_s': Field(name='pulse_interval_s',type=typing.Optional[float],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Target pulse interval in s: the laser frequency divider is chosen so that the actual pulse interval is equal or larger.\nAlternative to setting laser.frequency_divider explicitly  Setting both is an error.'}),kw_only=False,_field_type=_FIELD), 'turn_off_laser_after_measurement': Field(name='turn_off_laser_after_measurement',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Whether to turn the laser off after the measurement. Turning it on again takes a while, so only turn it off when no further measurements are planned.'}),kw_only=False,_field_type=_FIELD), 'pulse_storage': Field(name='pulse_storage',type=typing.Literal['full', 'downsampled'],default='full',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Storage format of the individual pulse files (always written to the measurement cache directory) and of the individual pulse parts in the finalized .tspv file:\nfull: Store the full transient (int16 ADC counts with the conversion information, or float64 voltages if the oscilloscope does not support raw ADC access). May take a lot of disk space.\ndownsampled: Store the log-downsampled transient.'}),kw_only=False,_field_type=_FIELD), 'store_individual_pulses': Field(name='store_individual_pulses',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': "Whether to include the individual pulse transients in the finalized .tspv file as parts 'pulse0001', 'pulse0002', .... The averaged transient is always stored as the '+' part. The individual pulse files are always written to the measurement cache directory regardless of this setting."}),kw_only=False,_field_type=_FIELD), 'n_log_downsampled': Field(name='n_log_downsampled',type=<class 'int'>,default=8192,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of log-downsampled values for every measurement-side downsampling: the log-downsampled pulse files, the averaged transient and the live view.', 'valid': (1, 999999)}),kw_only=False,_field_type=_FIELD)}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function MeasurementParameters.__init__>, '__repr__': <function MeasurementParameters.__repr__>, '__eq__': <function MeasurementParameters.__eq__>, '__match_args__': ('n_pulses', 'wait_n_pulses', 'trigger_retries', 'laser_settle_time_s', 'laser_ramp_up_time_s', 'pump_power_mJcm2', 'trigger', 'acquisition_time_s', 'pulse_interval_s', 'turn_off_laser_after_measurement', 'pulse_storage', 'store_individual_pulses', 'n_log_downsampled')})#
__eq__(other)#

Return self==value.

__firstlineno__ = 39#
__hash__ = None#
__init__(n_pulses: int = 10, wait_n_pulses: int = 0, trigger_retries: int = 3, laser_settle_time_s: float = 10.0, laser_ramp_up_time_s: float = 15.0, pump_power_mJcm2: float | None = None, trigger: Literal['Diode', 'Laser'] = 'Diode', acquisition_time_s: float | None = None, pulse_interval_s: float | None = None, turn_off_laser_after_measurement: bool = True, pulse_storage: Literal['full', 'downsampled'] = 'full', store_individual_pulses: bool = True, n_log_downsampled: int = 8192) → None#
__match_args__ = ('n_pulses', 'wait_n_pulses', 'trigger_retries', 'laser_settle_time_s', 'laser_ramp_up_time_s', 'pump_power_mJcm2', 'trigger', 'acquisition_time_s', 'pulse_interval_s', 'turn_off_laser_after_measurement', 'pulse_storage', 'store_individual_pulses', 'n_log_downsampled')#
__module__ = 'spvctrl.measurement.settings'#
__or__(other)#

Merge with another settings class or a dictionary. Unknown keys in a dictionary are ignored.

__replace__(**changes)#
__repr__()#

Return repr(self).

__static_attributes__ = ()#
__weakref__#

list of weak references to the object

_get_dict(remove_empty_containers: bool = False, remove_None: bool = False, remove_if_None: list[str] | None = None) → dict#

Return the settings as a dictionary, optionally cleaning up the output.

Base implementation for get_dict(). Subclasses may call it with different arguments to configure the output.

Parameters:
  • remove_empty_containers – If True, remove empty dict, list, tuple or set values.

  • remove_None – If True, remove all keys with a None value.

  • remove_if_None – If given, remove these keys only if their value is None (absent keys are ignored).

Returns:

Instance converted to dictionary, see as_dict().

_reorder_dict(d: dict) → dict#

Reorder the keys of a dictionary created by dataclasses.asdict() to the order of fields().

Walks the fields of self in parallel to d and recurses into nested SettingsClass instances. All other values are kept as-is.

Parameters:

d – Dictionary as returned by dataclasses.asdict() for this instance.

Returns:

Dictionary with the same values, but keys ordered like fields().

acquisition_time_s: float | None = None#
as_dict() → dict#

Return all fields of the settings class as a dictionary.

Like dataclasses.asdict(), but the keys are ordered like fields(): also the keys of nested SettingsClass instances (as field values and inside lists, tuples and dicts) are ordered by their fields. This way save_yaml() and other YAML exports write the fields in the same order as they are defined in the class (or reordered by metadata["order"], like in the GUI).

Returns:

Instance converted to dictionary.

copy() → Self#

Convenience method for copy.deepcopy(self)

fields()#

Return a tuple describing the fields of this dataclass.

Adapted version of dataclass.fields that applies additional sorting of the fields according to the field’s metadata[“order”] parameter.

Accepts a dataclass or an instance of one. Tuple elements are of type Field.

classmethod from_dict(data: dict, strict: bool = False) → Self#

Recursively construct a SettingsClass from a dictionary.

If the value of a field is another SettingsClass, from_dict() will be called for that field as well. Handled are:

  • SettingsClass

  • list[SettingsClass]

  • dict[<any>, SettingsClass]

  • all of the above as Optional (Union with None)

  • a Union with any handled types

Parameters:

strict – If True, raise a KeyError on keys in data that are not field names of cls. Unknown keys are ignored otherwise.

Raises:
  • ValueError – If data contains a value that has the wrong type for the field of cls (ONLY if the type is a subclass of SettingsClass! Other types are not enforced)

  • KeyError – If strict is True and data contains a key that is not a field name of cls

get_dict() → dict#

Return the settings as a dictionary.

as_dict() returns the settings class with all fields, while get_dict() may be configured by subclasses to skip certain fields in the output. The default implementation returns all fields, like as_dict(). :return: Instance converted to dictionary.

laser_ramp_up_time_s: float = 15.0#
laser_settle_time_s: float = 10.0#
classmethod load_yaml(yaml_path: str, loader=<class 'yaml.loader.Loader'>)#
n_log_downsampled: int = 8192#
n_pulses: int = 10#
pulse_interval_s: float | None = None#
pulse_storage: Literal['full', 'downsampled'] = 'full'#
pump_power_mJcm2: float | None = None#
save_yaml(yaml_path: str)#
store_individual_pulses: bool = True#
trigger: Literal['Diode', 'Laser'] = 'Diode'#
trigger_retries: int = 3#
turn_off_laser_after_measurement: bool = True#
wait_n_pulses: int = 0#