prsctrl.measurement.measurement.MeasurementHandler#
- class MeasurementHandler(measurement_settings: MeasurementSettings, wavelengths: list[str | int | float], data_queue: Queue, command_queue: Queue, monochromators: Monochromator | list[Monochromator], shutter: Shutter, add_measurement_info_to_metadata: bool = True, compress_data: bool = True)[source]#
Bases:
objectClass that performs the actual measurement.
- Parameters:
monochromator
shutter
measurement_params
signal_to_noise_f – A function that takes the PrsData and the current wavelength and determines whether the signal to noise ratio is already satisfying. If the function returns True, the measurement is stopped early.
command_queue – A queue used to receive a “stop” or other signals. Useful when run() is run in another thread
data_queue – A queue where the data of a certain wavelength is put in after it has been measured. Useful for live monitoring when run() is run in another thread
add_measurement_info_to_metadata
compress_data – Whether to use gzip compression on full data file
Methods
Add a Lock-In that records data using the measurement.
Auto-determine the optimum gain value for each pre-amplifier.
Setup some settings, filling in defaults for missing parameters.
Run the measurement.
- add_measurement_mode(mode: str, lockin: LockInAmp, lockin_settings: LockInSettings, data: PrsData, pre_amp: Amplifier | None = None)[source]#
Add a Lock-In that records data using the measurement.
- Parameters:
mode – key of the measurement mode, eg ‘ref’ or ‘tra’
lockin
data – PrsData object with no data initialized (it may already contain metadata). Each mode needs its own PrsData object
aux_DC – The name of auxiliary input channel the DC signal is connected to on the lock-in
- auto_determine_gain(min_DC: float = 0.8, max_DC: float = 9.95, N_test: int = 6, wait_time_s: float = 0.2)[source]#
Auto-determine the optimum gain value for each pre-amplifier.
Sweeps a few points in the spectrum and adjust the gain so that the DC value does not exceed max_DC V, but if possible, stays above min_DC mV.
This function must be called after prepare, all relevant parameters (especially the monochromator bandwidth) must have been set on the devices already.
- Parameters:
min_DC – The minimum voltage for the DC signal.
max_DC – The maximum voltage for the DC signal. If any value crosses this threshold, the gain is reduced, even if this causes other wavelengths to o below min_DC.
wait_time_s – Time to wait after setting the wavelength. Small values should be enough since only the DC value is measured.
N_test – Target number of wavelengths for which to check the DC value
- Raises:
RuntimeError – If prepare() was not called first