From ce04bc5f0c31dff01ac3ed57f146a6bf8d3da98f Mon Sep 17 00:00:00 2001 From: sldesnoo-Delft <s.l.desnoo@tudelft.nl> Date: Thu, 19 Jan 2023 11:03:53 +0100 Subject: [PATCH] Added read_channels (Currently Qblox only). --- pulse_lib/scan/read_input.py | 49 ++++++++++++++++++++++++++++ pulse_lib/tests/acquire/test_read.py | 31 ++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 pulse_lib/scan/read_input.py create mode 100644 pulse_lib/tests/acquire/test_read.py diff --git a/pulse_lib/scan/read_input.py b/pulse_lib/scan/read_input.py new file mode 100644 index 00000000..adeea40f --- /dev/null +++ b/pulse_lib/scan/read_input.py @@ -0,0 +1,49 @@ + + +def read_channels(pulselib, t_measure, channels=None, sample_rate=None, iq_mode='Complex'): + ''' + Reads the input channels without pulsing the AWG channels. + + Args: + pulselib: pulselib object. + t_measure (float): measurement time [ns]. + channels (Optional[list[name]]): pulselib names of channels to read. + sample_rate (Optional[float]): sample rate for time trace [Hz] + iq_mode (str): + when channel contains IQ data, i.e. iq_input=True or frequency is not None, + then this parameter specifies how the complex I/Q value should be returned: + 'Complex': return IQ data as complex value. + 'I': return only I value. + 'Q': return only Q value. + 'amplitude': return amplitude. + 'phase:' return phase [radians], + 'I+Q', return I and Q using channel name postfixes '_I', '_Q'. + 'amplitude+phase'. return amplitude and phase using channel name postfixes '_amp', '_phase'. + + Note: + The frequency and phase for IQ modulation is configured on the pulselib digitizer channel. + ''' + # set sample rate for Keysight upload. + if t_measure > 200_000: + awg_sample_rate = 1e7 + elif t_measure > 20_000: + awg_sample_rate = 1e8 + else: + awg_sample_rate = 1e9 + + if channels is None: + channels = pulselib.digitizer_channels.keys() + + seg = pulselib.mk_segment(sample_rate=awg_sample_rate) + for ch in channels: + seg[ch].acquire(0, t_measure, wait=True) + + sequence = pulselib.mk_sequence([seg]) +# sequence.set_hw_schedule() @@@ configure single shot and video mode schedules at pulselib init!! + sequence.n_rep = None + if sample_rate is not None: + sequence.set_acquisition(sample_rate=sample_rate) + + param = sequence.get_measurement_param(upload='auto', iq_mode=iq_mode) + return param + diff --git a/pulse_lib/tests/acquire/test_read.py b/pulse_lib/tests/acquire/test_read.py new file mode 100644 index 00000000..0f7a3637 --- /dev/null +++ b/pulse_lib/tests/acquire/test_read.py @@ -0,0 +1,31 @@ + +from pulse_lib.tests.configurations.test_configuration import context +from pulse_lib.scan.read_input import read_channels + +#%% +def test1(): + pulse = context.init_pulselib(n_gates=0, n_sensors=2, rf_sources=False) + + dc_param = read_channels(pulse, 1000) + + return context.run('read', dc_param) + +def test2(): + pulse = context.init_pulselib(n_gates=0, n_sensors=2, rf_sources=False) + + dc_param = read_channels(pulse, 100000, sample_rate=500e3) + + return context.run('read', dc_param) + +def test3(iq_mode='I+Q'): + pulse = context.init_pulselib(n_gates=0, n_sensors=2, rf_sources=True) + + dc_param = read_channels(pulse, 10000, iq_mode=iq_mode) + + return context.run('read_iq_'+iq_mode, dc_param) + +#%% +if __name__ == '__main__': + ds1 = test1() + ds2 = test2() + ds3 = test3() -- GitLab