lockin module¶
Continuous-wave generation and measurement.
Detailed information is provided in the documentation for each class.
Use the hardware in continuous-wave mode. |
|
Special-purpose version of |
|
Settings of a lock-in input group. |
|
Settings of a lock-in output group. |
|
Settings of a symmetric lock-in group. |
|
A receiver of lockin data running in the background. |
Lockin class¶
- class presto.lockin.Lockin(*, ext_ref_clk=False, force_reload=False, dry_run=False, address=None, port=None, adc_mode=AdcMode.Direct, adc_fsample=None, dac_mode=DacMode.Direct, dac_fsample=None, force_config=False)¶
Use the hardware in continuous-wave mode.
Warning
Create only one instance at a time. This class is designed to be instantiated with Python’s with statement, see Examples section.
- Parameters:
ext_ref_clk (
Union[None,bool,int,float]) – ifNoneorFalseuse internal reference clock; ifTrueuse external reference clock (10 MHz); iffloatorintuse external reference clock atext_ref_clkHzforce_reload (
bool) – ifTruere-configure clock and reload firmware even if there’s no change from the previous settings.dry_run (
bool) – ifTruedon’t connect to hardware, for testing only.address (
Optional[str]) – IP address or hostname of the hardware. IfNone, use factory default"192.168.42.50".port (
Optional[int]) – port number of the server running on the hardware. IfNone, use factory default7878.adc_mode (AdcMode or list) – configure the inputs to sample in direct mode (default), or to use the digital mixers for downconversion. See Notes.
adc_fsample (AdcFSample or list) – configure the inputs sampling rate. If
None(default), choose optimal rate automatically. See Notes.dac_mode (DacMode or list) – configure the outputs to work in direct mode (default), or to use the digital mixers for upconversion. See Notes.
dac_fsample (DacFSample or list) – configure the outputs sampling rate. If
None(default), choose optimal rate automatically. See Notes.force_config (
bool) – ifTrueskip checks onDacModes not recommended for high DAC sampling rates.
- Raises:
ValueError – if
adc_modeordac_modeare not valid Converter modes; ifadc_fsampleordac_fsampleare not valid Converter rates.
Notes
In all the Examples, it is assumed that the imports
import numpy as npandfrom presto import lockinhave been performed, and that this class has been instantiated in the formlck = lockin.Lockin(), or, much much better, using thewith lockin.Lockin() as lckconstruct as below.For an introduction to
adc_modeanddac_mode, see Direct and Mixed mode. For valid values ofadc_modeanddac_mode, see Converter modes. For valid values ofadc_fsampleanddac_fsample, see Converter rates. For advanced configuration, e.g. different converter rates on different ports, see Advanced tile configuration.- add_input_group(port, nr_freq)¶
Create and return a new
input group- Parameters:
- Return type:
- add_output_group(ports, nr_freq)¶
Create and return a new
output group- Parameters:
- Return type:
- apply_required()¶
Check whether calling
apply_settings()is required to sync outstanding changes.- Return type:
- apply_settings(*, auto_sync=True, only_if=False)¶
Apply the settings to the hardware.
- Parameters:
auto_sync (
bool) – ifTrue(default), trigger signal generation internally. Set toFalseto synchronize to an external source, e.g. a Metronomo unit.
Note
Prior to a call to this function, any change of settings has no effect on the hardware.
- close()¶
Gracely disconnect from the hardware.
Call this method if the class was instantiated without a with statement. This method is called automatically when exiting a
withblock and before the object is destructed.
- get_Tm()¶
Get measurement time in seconds.
The inverse of the measurement bandwidth.
- Return type:
See also
- get_clk_T()¶
Period of the programmable-logic clock in seconds.
- Return type:
See also
- get_clk_f()¶
Frequency of the programmable-logic clock in Hz.
- Return type:
See also
- get_fs(which)¶
Get sampling frequency for
whichconverter in Hz.- Parameters:
which (
str) –"adc"for input and"dac"for output.- Raises:
ValueError – if
whichis unknown.- Return type:
- get_ns(which='adc')¶
Get number of samples per lock-in window.
The sampling rate divided by the measurement bandwidth.
- get_pixels(n, *, summed=False, fir_coeffs=None, nsum=250, quiet=False, auto_sync=True)¶
Get lock-in packets (pixels) from the hardware.
- Parameters:
n (
int) – the number of lock-in packets to measure.summed (
bool) – whenTrue, calculate on the hardware the mean and standard deviation of the acquired data in chunks ofnsumlock-in packets.fir_coeffs (array_like of float) – coefficients for FIR filter to be applied to measured data. 43 coefficients must be provided, or pass None (default) to disable the filter. Not available if
summed=False. See also Notes and Examples sections.nsum (
int) – Only active whensummed=True. How many lock-in packets (at rateget_df()) are included in a “chunk”. The resulting data rate isdf / nsum. Ignored ifsummed=False.quiet (
bool) – if True, don’t check for inputs out of rangeauto_sync (
bool) – ifTrue(default), trigger signal acquisition internally. Set toFalseto synchronize to an external source, e.g. a Metronomo unit.
- Return type:
- Returns:
A dictionary with key
portand value depending on the value ofsummed.The key is always:
port(int): input port measured
When
summed=False(default), the value is a tuple of:freqs(ndarray,dtype=np.float64): frequencies at which the lockin measurement was done.pixels(ndarray,dtype=np.complex64): measured lock-in data in ratio of full-scale input.shapeis(n, len(freqs)). When using digital downconversion (adc_modeisAdcMode.Mixed), these are the pixels of the I port of the digital mixer.pixels_q(ndarray,dtype=np.complex64): only present when using digital downconversion (adc_modeisAdcMode.Mixed), these are the pixels of the Q port of the digital mixer.
When
summed=True, the value is a tuple of:freqs(ndarray,dtype=np.float64): frequencies at which the lockin measurement was done.mean_I(ndarray,dtype=np.complex64): calculated mean ofnsumconsecutive lock-in packets from the I port of the digital downconversion.shapeis(n, len(freqs)).std_I(ndarray,dtype=np.complex64): calculated standard deviation ofnsumconsecutive lock-in packets from the I port of the digital downconversion.shapeis(n, len(freqs)). The standard deviation has a real and an imaginary part;abs(std)is the total standard deviation according to Complex random variable.mean_Q(ndarray,dtype=np.complex64): same asmean_I, but from the Q port.std_Q(ndarray,dtype=np.complex64): same asstd_I, but from the Q port.
- Raises:
RuntimeError – if
apply_settings()was not called after changing some setting
Notes
This method locks execution until at least
nmeasured packets are available.summed=Trueis only implemented when using digital downconversion (adc_modeisAdcMode.Mixed).Useful functions for computing the coefficients
fir_coeffsfor the FIR filter areremez()andfirwin()inscipy.signal.Examples
Measure 1k lock-in packets, and low-pass filter the measured data:
>>> from scipy.signal import firwin >>> coeffs = firwin(43, 80e3, fs=lck.get_df()) # low-pass filter with 80 kHz cutoff >>> data = lck.get_pixels(n=1000, fir_coeffs=coeffs) >>> freqs, (pixels_I, pixels_Q) = data[input_port] >>> freqs.shape (32,) >>> pixels_I.shape (1000, 32) >>> pixels_Q.shape (1000, 32)
Measure 100k lock-in packets, and compute mean and standard deviation in chunks of 100 packets:
>>> data = lck.get_pixels(n=1000, summed=True, nsum=100) >>> freqs, (mean_I, std_I, mean_Q, std_Q) = data[input_port] >>> freqs.shape (32,) >>> mean_I.shape (1000, 32) >>> std_Q.shape (1000, 32)
- set_df(df)¶
Set measurement bandwith.
The new setting is not applied until
apply_settings()is called!- Parameters:
df (
float) – Measurement bandwith in Hz.
Notes
Non-tuned measurement bandwidths can’t be set in hardware. When passing a non-tuned
df, the closest tuned value will be set in hardware. To avoid confusion, it is recommended to explicitly tunedfbefore calling this method.See also
- set_dither(state, output_ports)¶
Add pseudorandom noise to the generated output.
Can improve harmonic and intermodulation distortion when working with small output amplitudes.
The change is active immediately
- set_phase_reset(reset_phase)¶
Reset the phase of the reference signals at the end of every lock-in window.
The new setting is not applied until
apply_settings()is called!Notes
This setting is enabled by default. See Notes in
tune()for rationale.
- set_trigger_out(states, delay=0.0, width=1e-07)¶
Output a trigger on the digital output ports at the start of every demodulation or summing window.
Times will be rounded to closest integer multiple of
get_clk_T().- Parameters:
states (
Union[int,List[int]]) –enable/disable the trigger on each of the digital output ports. Valid values are:
0no trigger output1trigger for each new lock-in window2trigger for each new sum window (mean and std)
delay (
float) – delay trigger rising edge from start of lock-in window, in secondswidth (
float) – trigger-high duration, in seconds
- Raises:
ValueError – if
delayandwidthare negative, or too large- Return type:
Examples
Output a 100ns trigger on port 1 every summing window and on port 2 every demodulation window:
>>> lck.set_trigger_out([2, 1])
- stream_pixels(*, summed=False, fir_coeffs=None, nsum=250, quiet=False, auto_sync=True, rpu_params=None)¶
Receive lock-in packets (pixels) from the hardware in the background.
This method returns a
LockinReceiverobject that receives a stream of packets in a separate thread, without blocking the execution of the current thread.Warning
This method is experimental and the exposed API might change in future releases.
- Parameters:
summed (
bool) – whenTrue, calculate on the hardware the mean and standard deviation of the acquired data in chunks ofnsumlock-in packets.fir_coeffs (array_like of float) – coefficients for FIR filter to be applied to measured data. 43 coefficients must be provided, or pass None (default) to disable the filter. Not available if
summed=False. See also Notes and Examples sections.nsum (
int) – Only active whensummed=True. How many lock-in packets (at rateget_df()) are included in a “chunk”. The resulting data rate isdf / nsum. Ignored ifsummed=False.quiet (
bool) – if True, don’t check for inputs out of rangeauto_sync (
bool) – ifTrue(default), trigger signal acquisition internally. Set toFalseto synchronize to an external source, e.g. a Metronomo unit.rpu_params (
Optional[Tuple]) –set to
Noneto not start the RPU. Otherwise, set to atupleof:RPU firmware filename (str)
quadrature select (list of int): a list of indexes for which lockin quadratures the RPU firmware should have access to. E.g.
[0, 1]for I and Q quadratures of first frequency.length of sliding window (int): the number of lockin pixels in the sliding sum/average performed by the RPU
- Return type:
- Returns:
An instance of
LockinReceiver, to be used with Python’s with statement, see Examples section.- Raises:
RuntimeError – if
apply_settings()was not called after changing some setting
Notes
summed=Trueis only implemented when using digital downconversion (adc_modeisAdcMode.Mixed).Useful functions for computing the coefficients
fir_coeffsfor the FIR filter areremez()andfirwin()inscipy.signal.Examples
See
LockinReceiverfor examples.
- tune(f, df)¶
Perform standard level of tuning.
This provides frequencies closer to the requested ones, with a level of Fourier leakage that is adequate to most experiments. See Notes.
- Parameters:
- Return type:
- Returns:
a tuple of
(f_tuned, df_tuned)where
See also
tune_perfect(): perfect tuningset_phase_reset(): enable/disable phase reset every1/dfNotes
First, this level of tuning forces the measurement bandwith
dfto be a divisor of the sampling frequencyfs, i.e. there is an integer number of samplesns = fs/df_tunedin each lock-in measurement window. Second, the tuning forces each frequencyfto be integer multiple of the measurement bandwithdf_tuned, i.e. there is an integer numbern = f_tuned/df_tunedof oscillations within each measurement window.In theory, this level of tuning allows for measurement without Fourier leakage, or spectral leakage. In practice, however, not every value of
f_tunedcan be represented exactly in the hardware. With this level of tuning, the frequency that is actually set in hardwaref_setis slightly different from the tuned frequencyf_tuned. Therefore, the ratiof_set/df_tunedis not an integer, and some Fourier leakage occurs. To avoid long-term phase drift, the phase of the oscillation at frequencyf_setis reset at the end of each lock-in window (every1/df_tuned). Seeset_phase_reset()for a way to disable this behavior.Nonetheless, the difference between
f_setandf_tunedis actually really small: the worst-case error isget_fs("dac")/2/2**48, on the order of a single microhertz (1 μHz)! For most common applications, the resulting Fourier leakage and the phase-reset glitches are well below the noise level. If however, this is not acceptable, seetune_perfect().
- tune_perfect(f, df)¶
Perform perfect level of tuning.
This provides frequencies that might be further from the requested ones, but with zero Fourier leakage. See Notes.
- Parameters:
- Return type:
- Returns:
a tuple of
(f_tuned, df_tuned)where
See also
tune(): standard tuningNotes
First, this level of tuning forces the measurement bandwith
dfto divide the sampling frequencyfsby a power of 2, i.e. the number of samples in each lock-in measurement window is a power of 2:ns = fs/df_tuned = 2**m. Second, the tuning forces each frequencyfto be integer multiple of the measurement bandwithdf_tuned, i.e. there is an integer numbern = f_tuned/df_tunedof oscillations within each measurement window.This level of tuning always allows for measurement without Fourier leakage, or spectral leakage, and guarantees that
f_tunedcan be represented exactly in the hardware.
SymmetricLockin class¶
- class presto.lockin.SymmetricLockin(*, ext_ref_clk=False, force_reload=False, dry_run=False, address=None, port=None, adc_mode=AdcMode.Mixed, adc_fsample=None, dac_mode=DacMode.Mixed, dac_fsample=None, force_config=False)¶
Special-purpose version of
Lockinwith same frequencies on input and output ports (symmetric).The symmetric lock-in only supports Mixed mode. The digital mixers are configured for single-sideband upconversion and downconversion, using the upper sideband. The frequency of the output tones will therefore be the sum of the IF frequency set with
set_frequencies()and of the LO frequency set withhardware.configure_mixer.Warning
Create only one instance at a time. This class is designed to be instantiated with Python’s with statement, see Examples section.
- Parameters:
ext_ref_clk (
Union[None,bool,int,float]) – ifNoneorFalseuse internal reference clock; ifTrueuse external reference clock (10 MHz); iffloatorintuse external reference clock atext_ref_clkHzforce_reload (
bool) – ifTruere-configure clock and reload firmware even if there’s no change from the previous settings.dry_run (
bool) – ifTruedon’t connect to hardware, for testing only.address (
Optional[str]) – IP address or hostname of the hardware. IfNone, use factory default"192.168.42.50".port (
Optional[int]) – port number of the server running on the hardware. IfNone, use factory default7878.adc_mode (AdcMode or list) – configure the inputs to use the digital mixers for downconversion. Direct mode is not supported.
adc_fsample (AdcFSample or list) – configure the inputs sampling rate. If
None(default), choose optimal rate automatically. See Notes.dac_mode (DacMode or list) – configure the outputs to use the digital mixers for upconversion. Direct mode is not supported. See Notes.
dac_fsample (DacFSample or list) – configure the outputs sampling rate. If
None(default), choose optimal rate automatically. See Notes.force_config (
bool) – ifTrueskip checks onDacModes not recommended for high DAC sampling rates.
- Raises:
ValueError – if
adc_modeordac_modeare not valid Converter modes; ifadc_fsampleordac_fsampleare not valid Converter rates.
Notes
In all the Examples, it is assumed that the imports
import numpy as npandfrom presto import lockinhave been performed, and that this class has been instantiated in the formlck = lockin.SymmetricLockin(), or, much much better, using thewith lockin.SymmetricLockin() as lckconstruct as below.For an introduction to
adc_modeanddac_mode, see Direct and Mixed mode. For valid values ofadc_modeanddac_mode, see Converter modes. For valid values ofadc_fsampleanddac_fsample, see Converter rates. For advanced configuration, e.g. different converter rates on different ports, see Advanced tile configuration.- add_symmetric_group(input_port, output_ports, nr_freq)¶
Create and return a new
symmetric group.- Parameters:
- Return type:
- apply_required()¶
Check whether calling
apply_settings()is required to sync outstanding changes.- Return type:
- apply_settings(*, auto_sync=True, only_if=False)¶
Apply the settings to the hardware.
- Parameters:
auto_sync (
bool) – ifTrue(default), trigger signal generation internally. Set toFalseto synchronize to an external source, e.g. a Metronomo unit.
Note
Prior to a call to this function, any change of settings has no effect on the hardware.
- close()¶
Gracely disconnect from the hardware.
Call this method if the class was instantiated without a with statement. This method is called automatically when exiting a
withblock and before the object is destructed.
- get_Tm()¶
Get measurement time in seconds.
The inverse of the measurement bandwidth.
- Return type:
See also
- get_clk_T()¶
Period of the programmable-logic clock in seconds.
- Return type:
See also
- get_clk_f()¶
Frequency of the programmable-logic clock in Hz.
- Return type:
See also
- get_fs(which)¶
Get sampling frequency for
whichconverter in Hz.- Parameters:
which (
str) –"adc"for input and"dac"for output.- Raises:
ValueError – if
whichis unknown.- Return type:
- get_ns(which='adc')¶
Get number of samples per lock-in window.
The sampling rate divided by the measurement bandwidth.
- get_pixels(n, *, summed=False, fir_coeffs=None, nsum=250, quiet=False, auto_sync=True)¶
Get lock-in packets (pixels) from the hardware.
- Parameters:
n (
int) – the number of lock-in packets to measure. Whensummed=True,nis the number of means and standard deviation acquired: the number of lock-in packets measured will ben*nsum.summed (
bool) – whenTrue, calculate on the hardware the mean and standard deviation of the acquired data in chunks ofnsumlock-in packets.fir_coeffs (array_like of float) – coefficients for FIR filter to be applied to measured data. 43 coefficients must be provided, or pass None (default) to disable the filter. Not available if
summed=False. See also Notes and Examples sections.nsum (
int) – Ignored ifsummed=False. How many lock-in packets (at rateget_df()) The resulting data rate will bedf / nsum.quiet (
bool) – if True, don’t check for inputs out of rangeauto_sync (
bool) – ifTrue(default), trigger signal acquisition internally. Set toFalseto synchronize to an external source, e.g. a Metronomo unit.
- Return type:
- Returns:
a dictionary with key
port(int) and value depending on the argumentsummed.The key is always:
port(int): input port measured
When
summed=False(default), the value is a tuple of:When
summed=True, the value is a tuple of:freqs(ndarray,dtype=np.float64): frequencies at which the lockin measurement was done.mean(ndarray,dtype=np.complex64): calculated mean ofnsumconsecutive lock-in packets.shapeis(n, len(freqs)).std(ndarray,dtype=np.complex64): calculated standard deviation ofnsumconsecutive lock-in packets.shapeis(n, len(freqs)). The standard deviation has a real and an imaginary part;abs(std)is the total standard deviation according to Complex random variable.
- Raises:
RuntimeError – if
apply_settings()was not called after changing some setting
Notes
This method locks execution until at least
nmeasured packets are available.Useful functions for computing the coefficients
fir_coeffsfor the FIR filter areremez()andfirwin()in thescipy.signalmodule.Examples
Measure 1k lock-in packets, and low-pass filter the measured data:
>>> from scipy.signal import firwin >>> coeffs = firwin(43, 80e3, fs=lck.get_df()) # low-pass filter with 80 kHz cutoff >>> data = lck.get_pixels(n=1000, fir_coeffs=coeffs) >>> freqs, pixels = data[input_port] >>> freqs.shape (32,) >>> pixels.shape (1000, 32)
Measure 100k lock-in packets, and compute mean and standard deviation in chunks of 100 packets:
>>> data = lck.get_pixels(n=1000, summed=True, nsum=100) >>> freqs, mean, std = data[input_port] >>> freqs.shape (32,) >>> mean.shape (1000, 32) >>> std.shape (1000, 32)
- set_df(df)¶
Set measurement bandwith.
The new setting is not applied until
apply_settings()is called!- Parameters:
df (
float) – Measurement bandwith in Hz.
Notes
Non-tuned measurement bandwidths can’t be set in hardware. When passing a non-tuned
df, the closest tuned value will be set in hardware. To avoid confusion, it is recommended to explicitly tunedfbefore calling this method.See also
- set_dither(state, output_ports)¶
Add pseudorandom noise to the generated output.
Can improve harmonic and intermodulation distortion when working with small output amplitudes.
The change is active immediately
- set_phase_reset(reset_phase)¶
Reset the phase of the reference signals at the end of every lock-in window.
The new setting is not applied until
apply_settings()is called!Notes
This setting is enabled by default. See Notes in
tune()for rationale.
- set_trigger_out(states, delay=0.0, width=1e-07)¶
Output a trigger on the digital output ports at the start of every demodulation or summing window.
Times will be rounded to closest integer multiple of
get_clk_T().- Parameters:
states (
Union[int,List[int]]) –enable/disable the trigger on each of the digital output ports. Valid values are:
0no trigger output1trigger for each new lock-in window2trigger for each new sum window (mean and std)
delay (
float) – delay trigger rising edge from start of lock-in window, in secondswidth (
float) – trigger-high duration, in seconds
- Raises:
ValueError – if
delayandwidthare negative, or too large- Return type:
Examples
Output a 100ns trigger on port 1 every summing window and on port 2 every demodulation window:
>>> lck.set_trigger_out([2, 1])
- stream_pixels(*, summed=False, fir_coeffs=None, nsum=250, quiet=False, auto_sync=True, rpu_params=None)¶
Receive lock-in packets (pixels) from the hardware in the background.
This method returns a
LockinReceiverobject that receives a stream of packets in a separate thread, without blocking the execution of the current thread.Warning
This method is experimental and the exposed API might change in future releases.
- Parameters:
summed (
bool) – whenTrue, calculate on the hardware the mean and standard deviation of the acquired data in chunks ofnsumlock-in packets.fir_coeffs (array_like of float) – coefficients for FIR filter to be applied to measured data. 43 coefficients must be provided, or pass None (default) to disable the filter. Not available if
summed=False. See also Notes and Examples sections.nsum (
int) – Only active whensummed=True. How many lock-in packets (at rateget_df()) are included in a “chunk”. The resulting data rate isdf / nsum. Ignored ifsummed=False.quiet (
bool) – if True, don’t check for inputs out of rangeauto_sync (
bool) – ifTrue(default), trigger signal acquisition internally. Set toFalseto synchronize to an external source, e.g. a Metronomo unit.rpu_params (
Optional[Tuple]) –set to
Noneto not start the RPU. Otherwise, set to atupleof:RPU firmware filename (str)
quadrature select (list of int): a list of indexes for which lockin quadratures the RPU firmware should have access to. E.g.
[0, 1]for I and Q quadratures of first frequency.length of sliding window (int): the number of lockin pixels in the sliding sum/average performed by the RPU
- Return type:
- Returns:
An instance of
LockinReceiver, to be used with Python’s with statement, see Examples section.- Raises:
RuntimeError – if
apply_settings()was not called after changing some setting
Notes
summed=Trueis only implemented when using digital downconversion (adc_modeisAdcMode.Mixed).Useful functions for computing the coefficients
fir_coeffsfor the FIR filter areremez()andfirwin()inscipy.signal.Examples
See
LockinReceiverfor examples.
- tune(f, df)¶
Perform standard level of tuning.
This provides frequencies closer to the requested ones, with a level of Fourier leakage that is adequate to most experiments. See Notes.
- Parameters:
- Return type:
- Returns:
a tuple of
(f_tuned, df_tuned)where
See also
tune_perfect(): perfect tuningset_phase_reset(): enable/disable phase reset every1/dfNotes
First, this level of tuning forces the measurement bandwith
dfto be a divisor of the sampling frequencyfs, i.e. there is an integer number of samplesns = fs/df_tunedin each lock-in measurement window. Second, the tuning forces each frequencyfto be integer multiple of the measurement bandwithdf_tuned, i.e. there is an integer numbern = f_tuned/df_tunedof oscillations within each measurement window.In theory, this level of tuning allows for measurement without Fourier leakage, or spectral leakage. In practice, however, not every value of
f_tunedcan be represented exactly in the hardware. With this level of tuning, the frequency that is actually set in hardwaref_setis slightly different from the tuned frequencyf_tuned. Therefore, the ratiof_set/df_tunedis not an integer, and some Fourier leakage occurs. To avoid long-term phase drift, the phase of the oscillation at frequencyf_setis reset at the end of each lock-in window (every1/df_tuned). Seeset_phase_reset()for a way to disable this behavior.Nonetheless, the difference between
f_setandf_tunedis actually really small: the worst-case error isget_fs("dac")/2/2**48, on the order of a single microhertz (1 μHz)! For most common applications, the resulting Fourier leakage and the phase-reset glitches are well below the noise level. If however, this is not acceptable, seetune_perfect().
- tune_perfect(f, df)¶
Perform perfect level of tuning.
This provides frequencies that might be further from the requested ones, but with zero Fourier leakage. See Notes.
- Parameters:
- Return type:
- Returns:
a tuple of
(f_tuned, df_tuned)where
See also
tune(): standard tuningNotes
First, this level of tuning forces the measurement bandwith
dfto divide the sampling frequencyfsby a power of 2, i.e. the number of samples in each lock-in measurement window is a power of 2:ns = fs/df_tuned = 2**m. Second, the tuning forces each frequencyfto be integer multiple of the measurement bandwithdf_tuned, i.e. there is an integer numbern = f_tuned/df_tunedof oscillations within each measurement window.This level of tuning always allows for measurement without Fourier leakage, or spectral leakage, and guarantees that
f_tunedcan be represented exactly in the hardware.
Input and output groups¶
- class presto.lockin.InputGroup(port, nr_freq, lockin)¶
Settings of a lock-in input group.
Used as return type by
Lockin.add_input_group(). Contains access functions for changing the settings of this input group.The lock-in input is divided into 16 groups. Each group is capable of demodulating 12 different quadratures, for a total of 192 demodulations (96 I/Q pairs). Each demodulator has a configurable frequency and phase. Each group can acquire data from a single (configurable) input port.
Warning
Do not instantiate this class directly! Call
Lockin.add_input_group()to obtain a valid instance.- get_frequencies()¶
Get the lock-in input frequencies.
- get_phases(*, deg=False)¶
Get the lock-in input phases.
- set_frequencies(freqs)¶
Set the lock-in input frequencies.
The new setting is not applied until
Lockin.apply_settings()is called!- Parameters:
freqs (float or array_like) – frequency/ies in Hz. If less than available number of frequencies, the rest is set to zero.
- Return type:
Notes
This function performs no tuning, make sure
freqsaretunedto the user needs before calling this function.See also
- set_phases(phases, *, deg=False)¶
Set the lock-in input phases.
The new setting is not applied until
Lockin.apply_settings()is called!- Parameters:
phases (float or array_like) – phases in rad/deg. If less than available number of frequencies, set the rest to zero. When using the digital mixers (
adc_modeisAdcMode.Mixed), sets the phase of both the I and the Q port of the downconversion mixer.deg (
bool) – ifTrue, set the phases in degrees; ifFalse(default) radians.
- Return type:
- class presto.lockin.OutputGroup(ports, nr_freq, lockin)¶
Settings of a lock-in output group.
Used as return type by
Lockin.add_output_group(). Contains access functions for changing the settings of this output group.The lock-in output is divided into 16 groups. Each group is capable of driving tones at 12 different frequencies, for a total of 192 frequencies. Each tone has a configurable frequency, phase and amplitude. Each group can be output on one or more output ports.
Warning
Do not instantiate this class directly! Call
Lockin.add_output_group()to obtain a valid instance.- get_amplitudes()¶
Get the lock-in output amplitudes.
- get_frequencies()¶
Get the lock-in output frequencies.
- get_phases(*, deg=False)¶
Get the lock-in output phases.
- set_amplitudes(amps)¶
Set the lock-in output amplitudes.
The new setting is not applied until
Lockin.apply_settings()is called!- Parameters:
amps (float or array_like) – amplitudes with +/- 1.0 being full scale. If less than available number of frequencies, set the rest to zero.
- Return type:
- set_frequencies(freqs)¶
Set the lock-in output frequencies.
The new setting is not applied until
Lockin.apply_settings()is called!- Parameters:
freqs (float or array_like) – frequency/ies in Hz. If less than available number of frequencies, the rest is set to zero.
- Return type:
Notes
This function performs no tuning, make sure
freqsaretunedto the user needs before calling this function.See also
- set_phases(phases, phases_q=None, *, deg=False)¶
Set the lock-in output phases.
The new setting is not applied until
Lockin.apply_settings()is called!- Parameters:
phases (float or array_like) – phases in rad/deg. If less than available number of frequencies, set the rest to zero. When using the digital mixers (
dac_modeis one ofDacMode.Mixedxx), sets the phase of the I port of the upconversion mixer.phases_q (float or array_like, optional) – when using the digital mixers, sets the phase of the Q port of the upconversion mixer. In direct mode (
dac_modeisDacMode.Direct), settingphases_qthrows aValueErrorexception.deg (
bool) – ifTrue, set the phases in degrees; ifFalse(default) radians.
- Raises:
ValueError – if
phases_qis notNonein direct mode- Return type:
- class presto.lockin.SymmetricGroup(input_port, output_ports, nr_freq, lockin)¶
Settings of a symmetric lock-in group.
Used as return type by
SymmetricLockin.add_symmetric_group(). Contains access functions for changing the settings of this input-output group.The lock-in output is divided into 16 groups. Each group is capable of driving tones at 12 different frequencies, for a total of 192 frequencies. Each tone has a configurable frequency, phase and amplitude. Each group can be output on one or more output ports, and acquire data from a single (configurable) input port.
Warning
Do not instantiate this class directly! Call
SymmetricLockin.add_symmetric_group()to obtain a valid instance.- get_amplitudes()¶
Get the lock-in output amplitudes.
- get_frequencies()¶
Get the lock-in frequencies.
- get_phases(*, deg=False)¶
Get the lock-in output phases.
- set_amplitudes(amps)¶
Set the lock-in output amplitudes.
The new setting is not applied until
Lockin.apply_settings()is called!- Parameters:
amps (float or array_like) – amplitudes with +/- 1.0 being full scale. If less than available number of frequencies, set the rest to zero.
- Return type:
- set_frequencies(freqs)¶
Set the lock-in frequencies.
The new setting is not applied until
Lockin.apply_settings()is called!- Parameters:
freqs (float or array_like) – frequency/ies in Hz. If less than available number of frequencies, the rest is set to zero.
- Return type:
Notes
This function performs no tuning, make sure
freqsaretunedto the user needs before calling this function.
- set_phases(phases, *, deg=False)¶
Set the lock-in output phases.
The new setting is not applied until
Lockin.apply_settings()is called!- Parameters:
- Return type:
Other¶
- class presto.lockin.LockinReceiver(*, lck, sock, summed, bytes_per_meas, extra_bytes, buf_size=1073741824)¶
A receiver of lockin data running in the background.
Used as return type by
Lockin.stream_pixels().Warning
This class is experimental and the exposed API might change in future releases.
Warning
Do not instantiate this class directly! Call
Lockin.stream_pixels()to obtain a valid instance.Examples
>>> with lockin.Lockin( >>> address=PRESTOs_IP_ADDRESS, >>> ) as lck: >>> lck.set_df(1e3) >>> >>> og = lck.add_output_group(OUTPUT_PORT, 1) >>> og.set_frequencies(240e6).set_amplitudes(0.7).set_phases(0.0) >>> >>> ig = lck.add_input_group(INPUT_PORT, 1) >>> ig.set_frequencies(240e6) >>> >>> lck.apply_settings() >>> >>> # receive pixels with get_pixels >>> _, data0 = lck.get_pixels(1_000)[INPUT_PORT] >>> >>> # receive pixels with a LockinReceiver >>> with lck.stream_pixels() as recv: >>> _, data1 = recv.get_last(1_000)[INPUT_PORT]
- close()¶
Gracely terminate the stream receiver.
Call this method if the class was instantiated without a with statement. This method is called automatically when exiting a
withblock and before the object is destructed.
- get(n)¶
Return
nmeasurements received since the last call to this method.This method might block the current thread until
nnew measurements are available.- Return type:
TypeVar(SR_T)
Notes
This method keeps track of what measurements have already been returned, and always returns contiguous measurements (without gaps). If the requested measurements are available in the local buffer, they are returned immediately. Otherwise, the thread will block until all the requested measurements have been received.
That means that calling
get(n)twice results in the same data as callingget(2 * n)once. It also means that the data returned might have been already buffered locally and not be the latest received from the hardware.See See also section below for getter methods with different semantics.
See also
get_new(): always receive new data from the hardwareget_last(): return latest data from local buffer
- get_last(n)¶
Return the last
nmeasurements available in the local buffer.This method might block the current thread, if fewer than
nmeasurements are available in the local buffer.- Return type:
TypeVar(SR_T)
Notes
This method returns the most up-to-date data available in the local buffer, regardless of whether this data has already been returned to the user.
That means that calling
get_last(n)twice is not equivalent to callingget_last(2 * n)once: in the former case, the two data sets might overlap.See See also section below for getter methods with different semantics.
- get_new(n)¶
Receive
nnew measurements.This method blocks the current thread until
nnew measurements are received.- Return type:
TypeVar(SR_T)
Notes
This method always waits for
nnew measurements to be received from the hardware, without regard for what measurements have already been received in the background but not yet returned to the user.That means that calling
get_new(n)twice is not equivalent to callingget_new(2 * n)once: in the former case an arbitrary time gap might be present between the two data sets. Nevertheless, the two data sets will be distinct and non overlapping.See See also section below for getter methods with different semantics.
See also
get(): keep track of previously returned dataget_last(): return latest data from local buffer