From 283540c16b3f078640c8bf0ed3e1d98339c6aed6 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 28 Nov 2017 16:13:11 +0100 Subject: [PATCH 01/28] added try/finally for data aquisition --- .../instrument_drivers/rohde_schwarz/ZNB.py | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 0c280a852c0..41866e02f55 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -139,21 +139,23 @@ def get(self): instrument_parameter)) self._instrument.write('SENS{}:AVER:STAT ON'.format(self._channel)) self._instrument.write('SENS{}:AVER:CLE'.format(self._channel)) - self._instrument._parent.cont_meas_off() - # instrument averages over its last 'avg' number of sweeps - # need to ensure averaged result is returned - for avgcount in range(self._instrument.avg()): - self._instrument.write('INIT{}:IMM; *WAI'.format(self._channel)) - data_str = self._instrument.ask( - 'CALC{}:DATA? FDAT'.format(self._channel)) - data = np.array(data_str.rstrip().split(',')).astype('float64') - if self._instrument.format() in ['Polar', 'Complex', - 'Smith', 'Inverse Smith']: - log.warning("QCoDeS Dataset does not currently support Complex " - "values. Will discard the imaginary part.") - data = data[0::2] + 1j * data[1::2] - self._instrument._parent.cont_meas_on() + self._instrument._parent.cont_meas_off() + try: + # instrument averages over its last 'avg' number of sweeps + # need to ensure averaged result is returned + for avgcount in range(self._instrument.avg()): + self._instrument.write('INIT{}:IMM; *WAI'.format(self._channel)) + data_str = self._instrument.ask( + 'CALC{}:DATA? FDAT'.format(self._channel)) + data = np.array(data_str.rstrip().split(',')).astype('float64') + if self._instrument.format() in ['Polar', 'Complex', + 'Smith', 'Inverse Smith']: + log.warning("QCoDeS Dataset does not currently support Complex " + "values. Will discard the imaginary part.") + data = data[0::2] + 1j * data[1::2] + finally: + self._instrument._parent.cont_meas_on() return data From b956c1810f4a2a93bba87ea3fc5a3281b88dd005 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 28 Nov 2017 16:25:33 +0100 Subject: [PATCH 02/28] extracted into method of channel --- .../instrument_drivers/rohde_schwarz/ZNB.py | 63 ++++++++++--------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 41866e02f55..bca83579ad8 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -128,36 +128,8 @@ def set_sweep(self, start, stop, npts): self.shape = (npts,) def get(self): - if not self._instrument._parent.rf_power(): - log.warning("RF output is off when getting mag") - # it is possible that the instrument and qcodes disagree about - # which parameter is measured on this channel - instrument_parameter = self._instrument.vna_parameter() - if instrument_parameter != self._instrument._vna_parameter: - raise RuntimeError("Invalid parameter. Tried to measure " - "{} got {}".format(self._instrument._vna_parameter, - instrument_parameter)) - self._instrument.write('SENS{}:AVER:STAT ON'.format(self._channel)) - self._instrument.write('SENS{}:AVER:CLE'.format(self._channel)) - - self._instrument._parent.cont_meas_off() - try: - # instrument averages over its last 'avg' number of sweeps - # need to ensure averaged result is returned - for avgcount in range(self._instrument.avg()): - self._instrument.write('INIT{}:IMM; *WAI'.format(self._channel)) - data_str = self._instrument.ask( - 'CALC{}:DATA? FDAT'.format(self._channel)) - data = np.array(data_str.rstrip().split(',')).astype('float64') - if self._instrument.format() in ['Polar', 'Complex', - 'Smith', 'Inverse Smith']: - log.warning("QCoDeS Dataset does not currently support Complex " - "values. Will discard the imaginary part.") - data = data[0::2] + 1j * data[1::2] - finally: - self._instrument._parent.cont_meas_on() - return data - + data = self._intrument._get_sweep_data() + return data class ZNBChannel(InstrumentChannel): @@ -359,6 +331,36 @@ def _set_center(self, val): self.trace.set_sweep(start, stop, npts) self.trace_mag_phase.set_sweep(start, stop, npts) + def _get_sweep_data(self): + if not self._parent.rf_power(): + log.warning("RF output is off when getting sweep data") + # it is possible that the instrument and qcodes disagree about + # which parameter is measured on this channel + instrument_parameter = self.vna_parameter() + if instrument_parameter != self._vna_parameter: + raise RuntimeError("Invalid parameter. Tried to measure " + "{} got {}".format(self._vna_parameter, + instrument_parameter)) + self.write('SENS{}:AVER:STAT ON'.format(self._instrument_channel)) + self.write('SENS{}:AVER:CLE'.format(self._instrument_channel)) + + self._parent.cont_meas_off() + try: + # instrument averages over its last 'avg' number of sweeps + # need to ensure averaged result is returned + for avgcount in range(self.avg()): + self.write('INIT{}:IMM; *WAI'.format(self._instrument_channel)) + data_str = self.ask( + 'CALC{}:DATA? FDAT'.format(self._instrument_channel)) + data = np.array(data_str.rstrip().split(',')).astype('float64') + if self.format() in ['Polar', 'Complex', + 'Smith', 'Inverse Smith']: + log.warning("QCoDeS Dataset does not currently support Complex " + "values. Will discard the imaginary part.") + data = data[0::2] + 1j * data[1::2] + finally: + self._parent.cont_meas_on() + return data class ZNB(VisaInstrument): """ @@ -483,3 +485,4 @@ def clear_channels(self): submodule._channels = [] submodule._channel_mapping = {} submodule._locked = False + From 043ad25ab61065fa1f0efd7c16c236374265fc30 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 28 Nov 2017 16:40:14 +0100 Subject: [PATCH 03/28] implementing FrequencySweepMagPhase through refactored method in channel --- .../instrument_drivers/rohde_schwarz/ZNB.py | 74 +++++-------------- 1 file changed, 18 insertions(+), 56 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index bca83579ad8..738eb18d37f 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -12,27 +12,7 @@ class FrequencySweepMagPhase(MultiParameter): """ - Hardware controlled parameter class for Rohde Schwarz ZNB trace. - - Instrument returns an list of transmission data in the form of a list of - complex numbers taken from a frequency sweep. - - This is a multiparameter containing both amplitude and phase - - Args: - name: parameter name - instrument: instrument the parameter belongs to - start: starting frequency of sweep - stop: ending frequency of sweep - npts: number of points in frequency sweep - - Methods: - set_sweep(start, stop, npts): sets the shapes and - setpoint arrays of the parameter to correspond with the sweep - get(): executes a sweep and returns magnitude and phase arrays - - TODO: - - ability to choose for linear or db in magnitude return + Sweep that return magnitude and phase. """ def __init__(self, name, instrument, start, stop, npts, channel): @@ -56,37 +36,8 @@ def set_sweep(self, start, stop, npts): self.shapes = ((npts,), (npts,)) def get(self): - if not self._instrument._parent.rf_power(): - log.warning("RF output is off when getting mag phase") - # it is possible that the instrument and qcodes disagree about - # which parameter is measured on this channel - instrument_parameter = self._instrument.vna_parameter() - if instrument_parameter != self._instrument._vna_parameter: - raise RuntimeError("Invalid parameter. Tried to measure " - "{} got {}".format(self._instrument._vna_parameter, - instrument_parameter)) - self._instrument.write('SENS{}:AVER:STAT ON'.format(self._channel)) - self._instrument.write('SENS{}:AVER:CLE'.format(self._channel)) - self._instrument._parent.cont_meas_off() - - # instrument averages over its last 'avg' number of sweeps - # need to ensure averaged result is returned - for avgcount in range(self._instrument.avg()): - self._instrument.write('INIT{}:IMM; *WAI'.format(self._channel)) - data_str = self._instrument.ask( - 'CALC{}:DATA? SDAT'.format(self._channel)).split(',') - data_list = [float(v) for v in data_str] - - # data_list of complex numbers [re1,im1,re2,im2...] - data_arr = np.array(data_list).reshape(int(len(data_list) / 2), 2) - mag_array, phase_array = [], [] - for comp in data_arr: - complex_num = complex(comp[0], comp[1]) - mag_array.append(abs(complex_num)) - phase_array.append(phase(complex_num)) - self._instrument._parent.cont_meas_on() - return mag_array, phase_array - + data = self._intrument._get_sweep_data(force_polar = True) + return abs(data), phase(data) class FrequencySweep(ArrayParameter): """ @@ -129,6 +80,10 @@ def set_sweep(self, start, stop, npts): def get(self): data = self._intrument._get_sweep_data() + if self.format() in ['Polar', 'Complex', + 'Smith', 'Inverse Smith']: + log.warning("QCoDeS Dataset does not currently support Complex " + "values. Will discard the imaginary part.") return data class ZNBChannel(InstrumentChannel): @@ -331,7 +286,8 @@ def _set_center(self, val): self.trace.set_sweep(start, stop, npts) self.trace_mag_phase.set_sweep(start, stop, npts) - def _get_sweep_data(self): + def _get_sweep_data(self, force_polar = False): + if not self._parent.rf_power(): log.warning("RF output is off when getting sweep data") # it is possible that the instrument and qcodes disagree about @@ -346,17 +302,23 @@ def _get_sweep_data(self): self._parent.cont_meas_off() try: + # if force polar is set, the SDAT data format will be used. Here + # the data will be transfered as a complex number independet of + # the set format in the instrument. + if force_polar: + data_format_command = 'SDAT' + else: + data_format_command = 'FDAT' # instrument averages over its last 'avg' number of sweeps # need to ensure averaged result is returned for avgcount in range(self.avg()): self.write('INIT{}:IMM; *WAI'.format(self._instrument_channel)) data_str = self.ask( - 'CALC{}:DATA? FDAT'.format(self._instrument_channel)) + 'CALC{}:DATA? {}'.format(self._instrument_channel), + data_format_command) data = np.array(data_str.rstrip().split(',')).astype('float64') if self.format() in ['Polar', 'Complex', 'Smith', 'Inverse Smith']: - log.warning("QCoDeS Dataset does not currently support Complex " - "values. Will discard the imaginary part.") data = data[0::2] + 1j * data[1::2] finally: self._parent.cont_meas_on() From c499932a09c0c8f7a1b4df548a9b8ab13514cbb1 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 28 Nov 2017 17:34:15 +0100 Subject: [PATCH 04/28] fixed typo: argument list --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 738eb18d37f..a92dbe250dc 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -314,8 +314,8 @@ def _get_sweep_data(self, force_polar = False): for avgcount in range(self.avg()): self.write('INIT{}:IMM; *WAI'.format(self._instrument_channel)) data_str = self.ask( - 'CALC{}:DATA? {}'.format(self._instrument_channel), - data_format_command) + 'CALC{}:DATA? {}'.format(self._instrument_channel, + data_format_command)) data = np.array(data_str.rstrip().split(',')).astype('float64') if self.format() in ['Polar', 'Complex', 'Smith', 'Inverse Smith']: From 2fb0c969503acefaa46a433075500236ca061581 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Wed, 6 Dec 2017 15:09:50 +0100 Subject: [PATCH 05/28] added CHANNEL_CLASS class variable for inheritance --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index a92dbe250dc..47743190712 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -59,7 +59,6 @@ class FrequencySweep(ArrayParameter): get(): executes a sweep and returns magnitude and phase arrays """ - def __init__(self, name, instrument, start, stop, npts, channel): super().__init__(name, shape=(npts,), instrument=instrument, @@ -342,6 +341,8 @@ class ZNB(VisaInstrument): TODO: - check initialisation settings and test functions """ + CHANNEL_CLASS = ZNBChannel + def __init__(self, name: str, address: str, init_s_params: bool=True, **kwargs): @@ -387,7 +388,7 @@ def __init__(self, name: str, address: str, init_s_params: bool=True, **kwargs): self.add_function('rf_off', call_cmd='OUTP1 OFF') self.add_function('rf_on', call_cmd='OUTP1 ON') self.clear_channels() - channels = ChannelList(self, "VNAChannels", ZNBChannel, + channels = ChannelList(self, "VNAChannels", self.CHANNEL_CLASS, snapshotable=True) self.add_submodule("channels", channels) if init_s_params: @@ -414,7 +415,7 @@ def display_grid(self, rows: int, cols: int): def add_channel(self, vna_parameter: str): n_channels = len(self.channels) - channel = ZNBChannel(self, vna_parameter, n_channels + 1) + channel = self.CHANNEL_CLASS(self, vna_parameter, n_channels + 1) self.channels.append(channel) if n_channels == 0: self.display_single_window() From 92e0153407cfd98755610e939d52efc3929cd724 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Wed, 6 Dec 2017 15:31:24 +0100 Subject: [PATCH 06/28] activate the sweep for selected channel and restore previous state --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 47743190712..437eea1fec2 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -299,6 +299,9 @@ def _get_sweep_data(self, force_polar = False): self.write('SENS{}:AVER:STAT ON'.format(self._instrument_channel)) self.write('SENS{}:AVER:CLE'.format(self._instrument_channel)) + # preserve original state of the znb + initial_state = self.status() + self.status(1) self._parent.cont_meas_off() try: # if force polar is set, the SDAT data format will be used. Here @@ -321,6 +324,7 @@ def _get_sweep_data(self, force_polar = False): data = data[0::2] + 1j * data[1::2] finally: self._parent.cont_meas_on() + self.status(initial_state) return data class ZNB(VisaInstrument): From 2f8b998c8f77c1f3b9d0b41190e9c984d3f27f5c Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Wed, 6 Dec 2017 15:34:50 +0100 Subject: [PATCH 07/28] renamig get->get_raw --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 437eea1fec2..02980c993a2 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -35,7 +35,7 @@ def set_sweep(self, start, stop, npts): self.setpoints = ((f,), (f,)) self.shapes = ((npts,), (npts,)) - def get(self): + def get_raw(self): data = self._intrument._get_sweep_data(force_polar = True) return abs(data), phase(data) @@ -77,7 +77,7 @@ def set_sweep(self, start, stop, npts): self.setpoints = (f,) self.shape = (npts,) - def get(self): + def get_raw(self): data = self._intrument._get_sweep_data() if self.format() in ['Polar', 'Complex', 'Smith', 'Inverse Smith']: From 3dd4d226adf5109d4742a2ffba7920cf156f8aab Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Fri, 15 Dec 2017 11:05:00 +0100 Subject: [PATCH 08/28] refactored update of traces out --- .../instrument_drivers/rohde_schwarz/ZNB.py | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 02980c993a2..47d9f04957e 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -227,8 +227,6 @@ def _set_start(self, val): channel = self._instrument_channel self.write('SENS{}:FREQ:START {:.4f}'.format(channel, val)) stop = self.stop() - npts = self.npts() - if val >= stop: raise ValueError( "Stop frequency must be larger than start frequency.") @@ -237,14 +235,11 @@ def _set_start(self, val): if val != start: log.warning( "Could not set start to {} setting it to {}".format(val, start)) - # update setpoints for FrequencySweep param - self.trace.set_sweep(start, stop, npts) - self.trace_mag_phase.set_sweep(start, stop, npts) + self._update_traces() def _set_stop(self, val): channel = self._instrument_channel start = self.start() - npts = self.npts() if val <= start: raise ValueError( "Stop frequency must be larger than start frequency.") @@ -254,38 +249,36 @@ def _set_stop(self, val): if val != stop: log.warning( "Could not set stop to {} setting it to {}".format(val, stop)) - # update setpoints for FrequencySweep param - self.trace.set_sweep(start, stop, npts) - self.trace_mag_phase.set_sweep(start, stop, npts) + self._update_traces() def _set_npts(self, val): channel = self._instrument_channel self.write('SENS{}:SWE:POIN {:.4f}'.format(channel, val)) - start = self.start() - stop = self.stop() - # update setpoints for FrequencySweep param - self.trace.set_sweep(start, stop, val) - self.trace_mag_phase.set_sweep(start, stop, val) + self._update_traces() def _set_span(self, val): channel = self._instrument_channel self.write('SENS{}:FREQ:SPAN {:.4f}'.format(channel, val)) - start = self.start() - stop = self.stop() - npts = self.npts() - self.trace.set_sweep(start, stop, npts) - self.trace_mag_phase.set_sweep(start, stop, npts) + self._update_traces() def _set_center(self, val): channel = self._instrument_channel self.write('SENS{}:FREQ:CENT {:.4f}'.format(channel, val)) + self._update_traces() + + def _update_traces(self): + """ updates start, stop and npts of all trace parameters""" start = self.start() stop = self.stop() npts = self.npts() - self.trace.set_sweep(start, stop, npts) - self.trace_mag_phase.set_sweep(start, stop, npts) + for p in self.parameters: + if isinstance(p, ArrayParameter): + try: + p.set_sweep(start, stop, npts) + except AttributeError: + pass - def _get_sweep_data(self, force_polar = False): + def _get_sweep_data(self, force_polar=False): if not self._parent.rf_power(): log.warning("RF output is off when getting sweep data") @@ -452,4 +445,3 @@ def clear_channels(self): submodule._channels = [] submodule._channel_mapping = {} submodule._locked = False - From b940ae08459bc27899a110cbd3af7252af8bd86d Mon Sep 17 00:00:00 2001 From: nataliejpg Date: Fri, 15 Dec 2017 09:51:20 +0100 Subject: [PATCH 09/28] T2 vna fixes --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 47d9f04957e..bff80ffab71 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -3,7 +3,6 @@ from qcodes import VisaInstrument from qcodes import ChannelList, InstrumentChannel from qcodes.utils import validators as vals -from cmath import phase import numpy as np from qcodes import MultiParameter, ArrayParameter @@ -36,8 +35,11 @@ def set_sweep(self, start, stop, npts): self.shapes = ((npts,), (npts,)) def get_raw(self): - data = self._intrument._get_sweep_data(force_polar = True) - return abs(data), phase(data) + old_format = self._instrument.format() + self._instrument.format('Complex') + data = self._instrument._get_sweep_data(force_polar = True) + self._instrument.format(old_format) + return abs(data), np.angle(data) class FrequencySweep(ArrayParameter): """ @@ -78,8 +80,8 @@ def set_sweep(self, start, stop, npts): self.shape = (npts,) def get_raw(self): - data = self._intrument._get_sweep_data() - if self.format() in ['Polar', 'Complex', + data = self._instrument._get_sweep_data() + if self._instrument.format() in ['Polar', 'Complex', 'Smith', 'Inverse Smith']: log.warning("QCoDeS Dataset does not currently support Complex " "values. Will discard the imaginary part.") @@ -384,6 +386,7 @@ def __init__(self, name: str, address: str, init_s_params: bool=True, **kwargs): call_cmd='DISP:LAY GRID;:DISP:LAY:GRID 1,1') self.add_function('rf_off', call_cmd='OUTP1 OFF') self.add_function('rf_on', call_cmd='OUTP1 ON') + self.reset() self.clear_channels() channels = ChannelList(self, "VNAChannels", self.CHANNEL_CLASS, snapshotable=True) @@ -410,9 +413,9 @@ def display_grid(self, rows: int, cols: int): """ self.write('DISP:LAY GRID;:DISP:LAY:GRID {},{}'.format(rows, cols)) - def add_channel(self, vna_parameter: str): + def add_channel(self, vna_parameter: str, **kwargs): n_channels = len(self.channels) - channel = self.CHANNEL_CLASS(self, vna_parameter, n_channels + 1) + channel = self.CHANNEL_CLASS(self, vna_parameter, n_channels + 1, **kwargs) self.channels.append(channel) if n_channels == 0: self.display_single_window() From 254223c267d2e543a3b4a7f5d527c167a2fb789a Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Mon, 22 Jan 2018 16:18:49 +0100 Subject: [PATCH 10/28] fix of iteration over parameters --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index bff80ffab71..e55f625f2d8 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -273,10 +273,10 @@ def _update_traces(self): start = self.start() stop = self.stop() npts = self.npts() - for p in self.parameters: - if isinstance(p, ArrayParameter): + for _, parameter in self.parameters.items(): + if isinstance(parameter, (ArrayParameter, MultiParameter)): try: - p.set_sweep(start, stop, npts) + parameter.set_sweep(start, stop, npts) except AttributeError: pass From a874c046d8ebbd64b4b667ba161ef4d396705be3 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Mon, 22 Jan 2018 16:19:33 +0100 Subject: [PATCH 11/28] thorvalds fix for averaging data --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index e55f625f2d8..193c54f3393 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -310,13 +310,13 @@ def _get_sweep_data(self, force_polar=False): # need to ensure averaged result is returned for avgcount in range(self.avg()): self.write('INIT{}:IMM; *WAI'.format(self._instrument_channel)) - data_str = self.ask( - 'CALC{}:DATA? {}'.format(self._instrument_channel, - data_format_command)) - data = np.array(data_str.rstrip().split(',')).astype('float64') - if self.format() in ['Polar', 'Complex', - 'Smith', 'Inverse Smith']: - data = data[0::2] + 1j * data[1::2] + data_str = self.ask( + 'CALC{}:DATA? {}'.format(self._instrument_channel, + data_format_command)) + data = np.array(data_str.rstrip().split(',')).astype('float64') + if self.format() in ['Polar', 'Complex', + 'Smith', 'Inverse Smith']: + data = data[0::2] + 1j * data[1::2] finally: self._parent.cont_meas_on() self.status(initial_state) From ec820008ee50a6c923fbe77b60f77cfc96b6c279 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Mon, 22 Jan 2018 16:20:51 +0100 Subject: [PATCH 12/28] fix validator for minimum source power to -60dBm --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 193c54f3393..b060da41acf 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -114,7 +114,7 @@ def __init__(self, parent, name, channel): get_cmd='SOUR{}:POW?'.format(n), set_cmd='SOUR{}:POW {{:.4f}}'.format(n), get_parser=lambda x: int(round(float(x))), - vals=vals.Numbers(-150, 25)) + vals=vals.Numbers(-60, 25)) self.add_parameter(name='bandwidth', label='Bandwidth', unit='Hz', From 09bb2522d4a3473ed0c14c3b27777c8beb52a2f0 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Mon, 22 Jan 2018 16:21:44 +0100 Subject: [PATCH 13/28] default to 7 decimals --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index b060da41acf..650399344e2 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -227,7 +227,7 @@ def _strip(self, var): def _set_start(self, val): channel = self._instrument_channel - self.write('SENS{}:FREQ:START {:.4f}'.format(channel, val)) + self.write('SENS{}:FREQ:START {:.7f}'.format(channel, val)) stop = self.stop() if val >= stop: raise ValueError( @@ -245,7 +245,7 @@ def _set_stop(self, val): if val <= start: raise ValueError( "Stop frequency must be larger than start frequency.") - self.write('SENS{}:FREQ:STOP {:.4f}'.format(channel, val)) + self.write('SENS{}:FREQ:STOP {:.7f}'.format(channel, val)) # we get stop as the vna may not be able to set it to the exact value provided stop = self.stop() if val != stop: @@ -255,17 +255,17 @@ def _set_stop(self, val): def _set_npts(self, val): channel = self._instrument_channel - self.write('SENS{}:SWE:POIN {:.4f}'.format(channel, val)) + self.write('SENS{}:SWE:POIN {:.7f}'.format(channel, val)) self._update_traces() def _set_span(self, val): channel = self._instrument_channel - self.write('SENS{}:FREQ:SPAN {:.4f}'.format(channel, val)) + self.write('SENS{}:FREQ:SPAN {:.7f}'.format(channel, val)) self._update_traces() def _set_center(self, val): channel = self._instrument_channel - self.write('SENS{}:FREQ:CENT {:.4f}'.format(channel, val)) + self.write('SENS{}:FREQ:CENT {:.7f}'.format(channel, val)) self._update_traces() def _update_traces(self): From 3fc12c3713edd0630a7f923a553565d3c99b260c Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Mon, 22 Jan 2018 16:49:23 +0100 Subject: [PATCH 14/28] dual window mode --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 650399344e2..c423a5c7617 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -384,6 +384,8 @@ def __init__(self, name: str, address: str, init_s_params: bool=True, **kwargs): num_ports, num_ports)) self.add_function('display_single_window', call_cmd='DISP:LAY GRID;:DISP:LAY:GRID 1,1') + self.add_function('display_dual_window', + call_cmd='DISP:LAY GRID;:DISP:LAY:GRID 2,1') self.add_function('rf_off', call_cmd='OUTP1 OFF') self.add_function('rf_on', call_cmd='OUTP1 ON') self.reset() @@ -419,6 +421,8 @@ def add_channel(self, vna_parameter: str, **kwargs): self.channels.append(channel) if n_channels == 0: self.display_single_window() + if n_channels == 1: + self.display_dual_window() def _set_default_values(self): for channel in self.channels: From 3e26d60dde75c598bb4484a97634b761a711343e Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Mon, 22 Jan 2018 16:49:50 +0100 Subject: [PATCH 15/28] Thorvald: removed blank line from setpoints --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index c423a5c7617..d458d5cd1e6 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -68,7 +68,7 @@ def __init__(self, name, instrument, start, stop, npts, channel): label='{} magnitude'.format( instrument._vna_parameter), setpoint_units=('Hz',), - setpoint_names=('{}_frequency'.format(instrument._vna_parameter),)) + setpoint_names=('{} frequency'.format(instrument._vna_parameter),)) self.set_sweep(start, stop, npts) self._channel = channel From 11201e933c813a328a3a9847e7c7c939eed38c3b Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 23 Jan 2018 10:22:31 +0100 Subject: [PATCH 16/28] remove blank line from setpoint names --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index d458d5cd1e6..c423a5c7617 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -68,7 +68,7 @@ def __init__(self, name, instrument, start, stop, npts, channel): label='{} magnitude'.format( instrument._vna_parameter), setpoint_units=('Hz',), - setpoint_names=('{} frequency'.format(instrument._vna_parameter),)) + setpoint_names=('{}_frequency'.format(instrument._vna_parameter),)) self.set_sweep(start, stop, npts) self._channel = channel From 9e556f63cbb7fa77090f17e86e9ab63824aa27b1 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 23 Jan 2018 10:33:01 +0100 Subject: [PATCH 17/28] Thorvald: fixing the channel initialisation --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index c423a5c7617..25f968afc73 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -394,21 +394,16 @@ def __init__(self, name: str, address: str, init_s_params: bool=True, **kwargs): snapshotable=True) self.add_submodule("channels", channels) if init_s_params: - n = 1 for i in range(1, num_ports + 1): for j in range(1, num_ports + 1): ch_name = 'S' + str(i) + str(j) self.add_channel(ch_name) - n += 1 self.channels.lock() - - self.initialise() - self.connect_message() - - if init_s_params: self.display_sij_split() self.channels.autoscale() + self.initialise() + self.connect_message() def display_grid(self, rows: int, cols: int): """ Display a grid of channels rows by cols @@ -432,13 +427,12 @@ def _set_default_values(self): channel.power(-50) def initialise(self): - for n in range(1, len(self.channels)): + for n in range(1, len(self.channels)+1): self.write('SENS{}:SWE:TYPE LIN'.format(n)) self.write('SENS{}:SWE:TIME:AUTO ON'.format(n)) self.write('TRIG{}:SEQ:SOUR IMM'.format(n)) self.write('SENS{}:AVER:STAT ON'.format(n)) self.update_display_on() - self._set_default_values() self.rf_off() def clear_channels(self): From 9e4e38da8cec8184182bcb1226f3400ac5446505 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 23 Jan 2018 11:26:57 +0100 Subject: [PATCH 18/28] remove initialise and default values --- .../instrument_drivers/rohde_schwarz/ZNB.py | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 25f968afc73..47acbf994e1 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -401,9 +401,11 @@ def __init__(self, name: str, address: str, init_s_params: bool=True, **kwargs): self.channels.lock() self.display_sij_split() self.channels.autoscale() - self.initialise() + self.update_display_on() + self.rf_off() self.connect_message() + def display_grid(self, rows: int, cols: int): """ Display a grid of channels rows by cols @@ -411,29 +413,19 @@ def display_grid(self, rows: int, cols: int): self.write('DISP:LAY GRID;:DISP:LAY:GRID {},{}'.format(rows, cols)) def add_channel(self, vna_parameter: str, **kwargs): - n_channels = len(self.channels) - channel = self.CHANNEL_CLASS(self, vna_parameter, n_channels + 1, **kwargs) + i_channel = len(self.channels) + 1 + channel = self.CHANNEL_CLASS(self, vna_parameter, i_channel, **kwargs) self.channels.append(channel) - if n_channels == 0: + if i_channel == 1: self.display_single_window() - if n_channels == 1: + if i_channel == 2: self.display_dual_window() - def _set_default_values(self): - for channel in self.channels: - channel.start(1e6) - channel.stop(2e6) - channel.npts(10) - channel.power(-50) - - def initialise(self): - for n in range(1, len(self.channels)+1): - self.write('SENS{}:SWE:TYPE LIN'.format(n)) - self.write('SENS{}:SWE:TIME:AUTO ON'.format(n)) - self.write('TRIG{}:SEQ:SOUR IMM'.format(n)) - self.write('SENS{}:AVER:STAT ON'.format(n)) - self.update_display_on() - self.rf_off() + # initialising channel + self.write('SENS{}:SWE:TYPE LIN'.format(i_channel)) + self.write('SENS{}:SWE:TIME:AUTO ON'.format(i_channel)) + self.write('TRIG{}:SEQ:SOUR IMM'.format(i_channel)) + self.write('SENS{}:AVER:STAT ON'.format(i_channel)) def clear_channels(self): """ From eff2dd8fd077469f3c43bb84e9e69511de59efa6 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 23 Jan 2018 12:51:19 +0100 Subject: [PATCH 19/28] setting validator for minimum source power to model specific value --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 47acbf994e1..c4893fde239 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -103,6 +103,17 @@ def __init__(self, parent, name, channel): self._tracename, self._vna_parameter)) + # source power is dependent on model, but not well documented. + # here we assume -60 dBm for ZNB20, the others are set, + # due to lack of knowledge, to -80 dBm as of before the edit + model = self._instrument.get_idn()['model'].split('-')[0] + if model == 'ZNB4': + self._min_source_power = -80 + elif model == 'ZNB8': + self._min_source_power = -80 + elif model == 'ZNB20': + self._min_source_power = -60 + self.add_parameter(name='vna_parameter', label='VNA parameter', get_cmd="CALC{}:PAR:MEAS? '{}'".format(self._instrument_channel, @@ -114,7 +125,7 @@ def __init__(self, parent, name, channel): get_cmd='SOUR{}:POW?'.format(n), set_cmd='SOUR{}:POW {{:.4f}}'.format(n), get_parser=lambda x: int(round(float(x))), - vals=vals.Numbers(-60, 25)) + vals=vals.Numbers(self._min_source_power, 25)) self.add_parameter(name='bandwidth', label='Bandwidth', unit='Hz', From 7363f24343e9033411bc5aaf209e2ea64ed39547 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 23 Jan 2018 12:53:12 +0100 Subject: [PATCH 20/28] get parser for source power to float --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index c4893fde239..d336fb79217 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -124,7 +124,7 @@ def __init__(self, parent, name, channel): unit='dBm', get_cmd='SOUR{}:POW?'.format(n), set_cmd='SOUR{}:POW {{:.4f}}'.format(n), - get_parser=lambda x: int(round(float(x))), + get_parser=float, vals=vals.Numbers(self._min_source_power, 25)) self.add_parameter(name='bandwidth', label='Bandwidth', From 6aab33818ffff61b77d9f13036016377336761f2 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 23 Jan 2018 14:22:26 +0100 Subject: [PATCH 21/28] added channels as submodules --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index d336fb79217..6636f1a8d8b 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -114,7 +114,7 @@ def __init__(self, parent, name, channel): elif model == 'ZNB20': self._min_source_power = -60 - self.add_parameter(name='vna_parameter', + self.add_parameter(name='channel_name', label='VNA parameter', get_cmd="CALC{}:PAR:MEAS? '{}'".format(self._instrument_channel, self._tracename), @@ -230,7 +230,7 @@ def _set_format(self, val): self.write('CALC{}:FORM {}'.format(channel, val)) self.trace.unit = unit_mapping[val] self.trace.label = "{} {}".format( - self.vna_parameter(), label_mapping[val]) + self.channel_name(), label_mapping[val]) def _strip(self, var): "Strip newline and quotes from instrument reply" @@ -297,7 +297,7 @@ def _get_sweep_data(self, force_polar=False): log.warning("RF output is off when getting sweep data") # it is possible that the instrument and qcodes disagree about # which parameter is measured on this channel - instrument_parameter = self.vna_parameter() + instrument_parameter = self.channel_name() if instrument_parameter != self._vna_parameter: raise RuntimeError("Invalid parameter. Tried to measure " "{} got {}".format(self._vna_parameter, @@ -423,15 +423,15 @@ def display_grid(self, rows: int, cols: int): """ self.write('DISP:LAY GRID;:DISP:LAY:GRID {},{}'.format(rows, cols)) - def add_channel(self, vna_parameter: str, **kwargs): + def add_channel(self, channel_name: str, **kwargs): i_channel = len(self.channels) + 1 - channel = self.CHANNEL_CLASS(self, vna_parameter, i_channel, **kwargs) + channel = self.CHANNEL_CLASS(self, channel_name, i_channel, **kwargs) self.channels.append(channel) if i_channel == 1: self.display_single_window() if i_channel == 2: self.display_dual_window() - + self.add_submodule(channel_name, channel) # initialising channel self.write('SENS{}:SWE:TYPE LIN'.format(i_channel)) self.write('SENS{}:SWE:TIME:AUTO ON'.format(i_channel)) From d30802e0b22fdfccd7736aa9d430c2367750ac4f Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 23 Jan 2018 14:28:28 +0100 Subject: [PATCH 22/28] _instrument->_parent --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 6636f1a8d8b..287fab20fc6 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -106,7 +106,7 @@ def __init__(self, parent, name, channel): # source power is dependent on model, but not well documented. # here we assume -60 dBm for ZNB20, the others are set, # due to lack of knowledge, to -80 dBm as of before the edit - model = self._instrument.get_idn()['model'].split('-')[0] + model = self._parent.get_idn()['model'].split('-')[0] if model == 'ZNB4': self._min_source_power = -80 elif model == 'ZNB8': From fac84d0a524a3fb6437323d6180df4462656c30d Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 23 Jan 2018 15:03:00 +0100 Subject: [PATCH 23/28] using setattr for shortcut instead of add_submodule --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 287fab20fc6..1f0f85ccaf6 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -431,7 +431,8 @@ def add_channel(self, channel_name: str, **kwargs): self.display_single_window() if i_channel == 2: self.display_dual_window() - self.add_submodule(channel_name, channel) + # shortcut + setattr(self, channel_name, channel) # initialising channel self.write('SENS{}:SWE:TYPE LIN'.format(i_channel)) self.write('SENS{}:SWE:TIME:AUTO ON'.format(i_channel)) From 90effe54c083755e366b02f161feb0194325d610 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 30 Jan 2018 12:49:32 +0100 Subject: [PATCH 24/28] added validator for Bandwidth --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 1f0f85ccaf6..530a63d5399 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -126,13 +126,19 @@ def __init__(self, parent, name, channel): set_cmd='SOUR{}:POW {{:.4f}}'.format(n), get_parser=float, vals=vals.Numbers(self._min_source_power, 25)) + # there is an 'increased bandwidth option' (p. 4 of manual) that does + # not get taken into account here self.add_parameter(name='bandwidth', label='Bandwidth', unit='Hz', get_cmd='SENS{}:BAND?'.format(n), set_cmd='SENS{}:BAND {{:.4f}}'.format(n), get_parser=int, - vals=vals.Numbers(1, 1e6)) + vals=vals.Enum( + *np.append(10**6, + np.kron([1, 1.5, 2, 3, 5, 7], + 10**np.arange(6)))) + ) self.add_parameter(name='avg', label='Averages', unit='', From 2fce66dd02b9cca1a2299324e73e6b0da88c7306 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Mon, 5 Feb 2018 11:32:11 +0100 Subject: [PATCH 25/28] added optional van parameter --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 530a63d5399..82f7259e526 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -89,11 +89,17 @@ def get_raw(self): class ZNBChannel(InstrumentChannel): - def __init__(self, parent, name, channel): + def __init__(self, parent, name, channel, vna_parameter: str=None): + """ + Args: + vna_parameter: if left empty name is used + """ n = channel self._instrument_channel = channel self._tracename = "Trc{}".format(channel) - self._vna_parameter = name + if vna_parameter is None: + vna_parameter = name + self._vna_parameter = vna_parameter super().__init__(parent, name) # map hardware channel to measurement From 5c881c07f9a33e284f85129d982277d34e84fcad Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 6 Feb 2018 09:44:12 +0100 Subject: [PATCH 26/28] added short name to differentiate between vna_parameter and name of channel --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 82f7259e526..428c3982ff3 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -21,11 +21,12 @@ def __init__(self, name, instrument, start, stop, npts, channel): self._channel = channel self.names = ('magnitude', 'phase') - self.labels = ('{} magnitude'.format(instrument._vna_parameter), - '{} phase'.format(instrument._vna_parameter)) + self.labels = ('{} magnitude'.format(instrument.short_name), + '{} phase'.format(instrument.short_name)) self.units = ('', 'rad') self.setpoint_units = (('Hz',), ('Hz',)) - self.setpoint_names = (('frequency',), ('frequency',)) + self.setpoint_labels = (('{} frequency'.format(instrument.short_name),), ('{} frequency'.format(instrument.short_name),)) + self.setpoint_names = (('{}_frequency'.format(instrument.short_name),), ('{}_frequency'.format(instrument.short_name),)) def set_sweep(self, start, stop, npts): # needed to update config of the software parameter on sweep change @@ -66,9 +67,10 @@ def __init__(self, name, instrument, start, stop, npts, channel): instrument=instrument, unit='dB', label='{} magnitude'.format( - instrument._vna_parameter), + instrument.short_name), setpoint_units=('Hz',), - setpoint_names=('{}_frequency'.format(instrument._vna_parameter),)) + setpoint_labels=('{} frequency'.format(instrument.short_name),), + setpoint_names=('{}_frequency'.format(instrument.short_name),)) self.set_sweep(start, stop, npts) self._channel = channel @@ -120,7 +122,7 @@ def __init__(self, parent, name, channel, vna_parameter: str=None): elif model == 'ZNB20': self._min_source_power = -60 - self.add_parameter(name='channel_name', + self.add_parameter(name='vna_parameter', label='VNA parameter', get_cmd="CALC{}:PAR:MEAS? '{}'".format(self._instrument_channel, self._tracename), @@ -242,7 +244,7 @@ def _set_format(self, val): self.write('CALC{}:FORM {}'.format(channel, val)) self.trace.unit = unit_mapping[val] self.trace.label = "{} {}".format( - self.channel_name(), label_mapping[val]) + self.short_name, label_mapping[val]) def _strip(self, var): "Strip newline and quotes from instrument reply" @@ -309,7 +311,7 @@ def _get_sweep_data(self, force_polar=False): log.warning("RF output is off when getting sweep data") # it is possible that the instrument and qcodes disagree about # which parameter is measured on this channel - instrument_parameter = self.channel_name() + instrument_parameter = self.vna_parameter() if instrument_parameter != self._vna_parameter: raise RuntimeError("Invalid parameter. Tried to measure " "{} got {}".format(self._vna_parameter, From 5ed254a841851cbc5d424927ae32a1709cdb39e0 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Tue, 6 Feb 2018 15:01:51 +0100 Subject: [PATCH 27/28] updated warning --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 428c3982ff3..0b5f4790ed9 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -82,12 +82,15 @@ def set_sweep(self, start, stop, npts): self.shape = (npts,) def get_raw(self): - data = self._instrument._get_sweep_data() - if self._instrument.format() in ['Polar', 'Complex', - 'Smith', 'Inverse Smith']: - log.warning("QCoDeS Dataset does not currently support Complex " - "values. Will discard the imaginary part.") - return data + data = self._instrument._get_sweep_data() + if self._instrument.format() in ['Polar', 'Complex', + 'Smith', 'Inverse Smith']: + log.warning("QCoDeS Dataset does not currently support Complex " + "values. Will discard the imaginary part. In order to " + "acquire phase and amplitude use the " + "FrequencySweepMagPhase parameter.") + return data + class ZNBChannel(InstrumentChannel): From c98baca3710b76c698b890da6c169c19ae12c784 Mon Sep 17 00:00:00 2001 From: Dominik Vogel Date: Wed, 7 Feb 2018 09:33:03 +0100 Subject: [PATCH 28/28] updated comment for InstrumentChannel init --- qcodes/instrument_drivers/rohde_schwarz/ZNB.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 0b5f4790ed9..10929beb8e5 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -97,7 +97,11 @@ class ZNBChannel(InstrumentChannel): def __init__(self, parent, name, channel, vna_parameter: str=None): """ Args: - vna_parameter: if left empty name is used + parent: Instrument that this channel is bound to. + name: Name to use for this channel. + vna_parameter: Name of parameter on the vna that this should + measure such as S12. If left empty this will fall back to + `name`. """ n = channel self._instrument_channel = channel