spvctrl.measurement.settings.GageScopeAcquisitionSettings#
- class GageScopeAcquisitionSettings(mode: Literal['Single', 'Dual'] = 'Dual', sampling_rate_Hz: str | int = 'max', segment_size: int | None = None, spv_channel: int = 1, diode_channel: int = 2, spv_range_V: float = 1.0, diode_range_V: float = 1.0, trigger_level_V: float = 0.02, pre_trigger_percent: float | None = 5.0, pre_trigger_depth: int | None = None)[source]#
Bases:
SettingsClassAcquisition settings for the Gage CompuScope oscilloscope.
The trigger source influences how many samples are available: when the diode channel is the trigger source, the diode channel must be enabled (it is only recorded in dual mode). With ‘Laser’, the laser TTL on the TRIG input triggers instead.
The timebase (sampling rate, record length, segment size) is not applied by
apply(): it is resolved byTspvSettings.prepare()and applied by the measurement handler.Methods
Apply the channel and trigger settings to the oscilloscope.
Return all fields of the settings class as a dictionary.
Convenience method for copy.deepcopy(self)
Return a tuple describing the fields of this dataclass.
Recursively construct a
SettingsClassfrom a dictionary.Return the settings as a dictionary.
Whether the diode channel data is recorded (dual mode).
Attributes
- __annotations__ = {'diode_channel': <class 'int'>, 'diode_range_V': <class 'float'>, 'mode': typing.Literal['Single', 'Dual'], 'pre_trigger_depth': typing.Optional[int], 'pre_trigger_percent': typing.Optional[float], 'sampling_rate_Hz': typing.Union[str, int], 'segment_size': typing.Optional[int], 'spv_channel': <class 'int'>, 'spv_range_V': <class 'float'>, 'trigger_level_V': <class 'float'>}#
- __dataclass_fields__ = {'diode_channel': Field(name='diode_channel',type=<class 'int'>,default=2,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Channel recording the stray-light diode'}),kw_only=False,_field_type=_FIELD), 'diode_range_V': Field(name='diode_range_V',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Voltage range of the diode channel'}),kw_only=False,_field_type=_FIELD), 'mode': Field(name='mode',type=typing.Literal['Single', 'Dual'],default='Dual',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Acquisition mode: single or dual channel. In single mode, only the SPV channel is recorded (the diode channel is still enabled when it is the trigger source). Influences the maximum available acquisition length.'}),kw_only=False,_field_type=_FIELD), 'pre_trigger_depth': Field(name='pre_trigger_depth',type=typing.Optional[int],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of pre-trigger samples. Mutually exclusive with pre_trigger_percent.'}),kw_only=False,_field_type=_FIELD), 'pre_trigger_percent': Field(name='pre_trigger_percent',type=typing.Optional[float],default=5.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Percentage of the acquisition time recorded before the trigger. Mutually exclusive with pre_trigger_depth.'}),kw_only=False,_field_type=_FIELD), 'sampling_rate_Hz': Field(name='sampling_rate_Hz',type=typing.Union[str, int],default='max',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': "Sampling rate in Hz (an integer number of Hz), or 'max' for the highest supported sampling rate that yields the most samples for the requested acquisition time without exceeding the maximum record length. Must be set to a concrete rate (not 'max') if no acquisition time is given."}),kw_only=False,_field_type=_FIELD), 'segment_size': Field(name='segment_size',type=typing.Optional[int],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Segment size in samples (pre-trigger + post-trigger samples). If None, it is computed from the acquisition time, the sampling rate and the pre-trigger. Must be set explicitly if no acquisition time is given; setting it together with an acquisition time is an error.'}),kw_only=False,_field_type=_FIELD), 'spv_channel': Field(name='spv_channel',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Channel recording the SPV voltage'}),kw_only=False,_field_type=_FIELD), 'spv_range_V': Field(name='spv_range_V',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Voltage range of the SPV channel'}),kw_only=False,_field_type=_FIELD), 'trigger_level_V': Field(name='trigger_level_V',type=<class 'float'>,default=0.02,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Trigger level in V'}),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__': 179, '__annotations__': {'mode': typing.Literal['Single', 'Dual'], 'sampling_rate_Hz': typing.Union[str, int], 'segment_size': typing.Optional[int], 'spv_channel': <class 'int'>, 'diode_channel': <class 'int'>, 'spv_range_V': <class 'float'>, 'diode_range_V': <class 'float'>, 'trigger_level_V': <class 'float'>, 'pre_trigger_percent': typing.Optional[float], 'pre_trigger_depth': typing.Optional[int]}, '__doc__': "Acquisition settings for the Gage CompuScope oscilloscope.\n\nThe trigger source influences how many samples are available: when the diode channel is the\ntrigger source, the diode channel must be enabled (it is only recorded in dual mode). With\n'Laser', the laser TTL on the TRIG input triggers instead.\n\nThe timebase (sampling rate, record length, segment size) is not applied by :py:meth:`.apply`: it is\nresolved by :py:meth:`TspvSettings.prepare` and applied by the measurement handler.\n", 'mode': 'Dual', 'sampling_rate_Hz': 'max', 'segment_size': None, 'spv_channel': 1, 'diode_channel': 2, 'spv_range_V': 1.0, 'diode_range_V': 1.0, 'trigger_level_V': 0.02, 'pre_trigger_percent': 5.0, 'pre_trigger_depth': None, 'records_diode': <function GageScopeAcquisitionSettings.records_diode>, 'apply': <function GageScopeAcquisitionSettings.apply>, '__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__': {'mode': Field(name='mode',type=typing.Literal['Single', 'Dual'],default='Dual',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Acquisition mode: single or dual channel. In single mode, only the SPV channel is recorded (the diode channel is still enabled when it is the trigger source). Influences the maximum available acquisition length.'}),kw_only=False,_field_type=_FIELD), 'sampling_rate_Hz': Field(name='sampling_rate_Hz',type=typing.Union[str, int],default='max',default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': "Sampling rate in Hz (an integer number of Hz), or 'max' for the highest supported sampling rate that yields the most samples for the requested acquisition time without exceeding the maximum record length. Must be set to a concrete rate (not 'max') if no acquisition time is given."}),kw_only=False,_field_type=_FIELD), 'segment_size': Field(name='segment_size',type=typing.Optional[int],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Segment size in samples (pre-trigger + post-trigger samples). If None, it is computed from the acquisition time, the sampling rate and the pre-trigger. Must be set explicitly if no acquisition time is given; setting it together with an acquisition time is an error.'}),kw_only=False,_field_type=_FIELD), 'spv_channel': Field(name='spv_channel',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Channel recording the SPV voltage'}),kw_only=False,_field_type=_FIELD), 'diode_channel': Field(name='diode_channel',type=<class 'int'>,default=2,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Channel recording the stray-light diode'}),kw_only=False,_field_type=_FIELD), 'spv_range_V': Field(name='spv_range_V',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Voltage range of the SPV channel'}),kw_only=False,_field_type=_FIELD), 'diode_range_V': Field(name='diode_range_V',type=<class 'float'>,default=1.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Voltage range of the diode channel'}),kw_only=False,_field_type=_FIELD), 'trigger_level_V': Field(name='trigger_level_V',type=<class 'float'>,default=0.02,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Trigger level in V'}),kw_only=False,_field_type=_FIELD), 'pre_trigger_percent': Field(name='pre_trigger_percent',type=typing.Optional[float],default=5.0,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Percentage of the acquisition time recorded before the trigger. Mutually exclusive with pre_trigger_depth.'}),kw_only=False,_field_type=_FIELD), 'pre_trigger_depth': Field(name='pre_trigger_depth',type=typing.Optional[int],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({'doc': 'Number of pre-trigger samples. Mutually exclusive with pre_trigger_percent.'}),kw_only=False,_field_type=_FIELD)}, '__replace__': <function _replace>, '__hash__': None, '__init__': <function GageScopeAcquisitionSettings.__init__>, '__repr__': <function GageScopeAcquisitionSettings.__repr__>, '__eq__': <function GageScopeAcquisitionSettings.__eq__>, '__match_args__': ('mode', 'sampling_rate_Hz', 'segment_size', 'spv_channel', 'diode_channel', 'spv_range_V', 'diode_range_V', 'trigger_level_V', 'pre_trigger_percent', 'pre_trigger_depth')})#
- __eq__(other)#
Return self==value.
- __firstlineno__ = 179#
- __hash__ = None#
- __init__(mode: Literal['Single', 'Dual'] = 'Dual', sampling_rate_Hz: str | int = 'max', segment_size: int | None = None, spv_channel: int = 1, diode_channel: int = 2, spv_range_V: float = 1.0, diode_range_V: float = 1.0, trigger_level_V: float = 0.02, pre_trigger_percent: float | None = 5.0, pre_trigger_depth: int | None = None) None#
- __match_args__ = ('mode', 'sampling_rate_Hz', 'segment_size', 'spv_channel', 'diode_channel', 'spv_range_V', 'diode_range_V', 'trigger_level_V', 'pre_trigger_percent', 'pre_trigger_depth')#
- __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,tupleorsetvalues.remove_None – If True, remove all keys with a
Nonevalue.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 offields().Walks the fields of
selfin parallel todand recurses into nestedSettingsClassinstances. 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().
- apply(device: Oscilloscope, trigger: Literal['Diode', 'Laser'] = 'Diode')[source]#
Apply the channel and trigger settings to the oscilloscope.
The timebase (sampling rate, record length, segment size) is applied by the measurement handler, see
TspvSettings.prepare().- Parameters:
device – The oscilloscope device.
trigger – Trigger source, see
MeasurementParameters.trigger.
- as_dict() dict#
Return all fields of the settings class as a dictionary.
Like
dataclasses.asdict(), but the keys are ordered likefields(): also the keys of nested SettingsClass instances (as field values and inside lists, tuples and dicts) are ordered by their fields. This waysave_yaml()and other YAML exports write the fields in the same order as they are defined in the class (or reordered bymetadata["order"], like in the GUI).- Returns:
Instance converted to dictionary.
- copy() Self#
Convenience method for copy.deepcopy(self)
- diode_channel: int = 2#
- diode_range_V: float = 1.0#
- 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
SettingsClassfrom 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
datathat are not field names ofcls. Unknown keys are ignored otherwise.- Raises:
- get_dict() dict#
Return the settings as a dictionary.
as_dict()returns the settings class with all fields, whileget_dict()may be configured by subclasses to skip certain fields in the output. The default implementation returns all fields, likeas_dict(). :return: Instance converted to dictionary.
- classmethod load_yaml(yaml_path: str, loader=<class 'yaml.loader.Loader'>)#
- mode: Literal['Single', 'Dual'] = 'Dual'#
- pre_trigger_depth: int | None = None#
- pre_trigger_percent: float | None = 5.0#
- records_diode() bool[source]#
Whether the diode channel data is recorded (dual mode).
In single mode, the diode channel is still enabled on the oscilloscope when it is the trigger source, but its data is not recorded.
- sampling_rate_Hz: str | int = 'max'#
- save_yaml(yaml_path: str)#
- segment_size: int | None = None#
- spv_channel: int = 1#
- spv_range_V: float = 1.0#
- trigger_level_V: float = 0.02#