From 4a118b2a99c3731d9a4a39c400917b313dff044c Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Sat, 10 Sep 2022 11:49:56 +0200 Subject: [PATCH 1/4] remove private r&s drivers These are only used for drivers that are now in qcodes contrib drivers --- .../rohde_schwarz/private/HMC804x.py | 95 ------------------- .../rohde_schwarz/private/__init__.py | 0 .../drivers/test_rohdeschwarz_HMC804x.py | 51 ---------- 3 files changed, 146 deletions(-) delete mode 100644 qcodes/instrument_drivers/rohde_schwarz/private/HMC804x.py delete mode 100644 qcodes/instrument_drivers/rohde_schwarz/private/__init__.py delete mode 100644 qcodes/tests/drivers/test_rohdeschwarz_HMC804x.py diff --git a/qcodes/instrument_drivers/rohde_schwarz/private/HMC804x.py b/qcodes/instrument_drivers/rohde_schwarz/private/HMC804x.py deleted file mode 100644 index 2538865d0d7..00000000000 --- a/qcodes/instrument_drivers/rohde_schwarz/private/HMC804x.py +++ /dev/null @@ -1,95 +0,0 @@ -from typing import Any, Union - -from qcodes import validators as vals -from qcodes.instrument import ChannelList, Instrument, InstrumentChannel, VisaInstrument - - -class RohdeSchwarzHMC804xChannel(InstrumentChannel): - def __init__(self, parent: Instrument, name: str, - channel: Union[str, int]) -> None: - super().__init__(parent, name) - - select_cmd = f":INSTrument:NSELect {channel};" - voltage_amp = ":SOURce:VOLTage:LEVel:IMMediate:AMPLitude" - current_amp = ":SOURce:CURRent:LEVel:IMMediate:AMPLitude" - - self.add_parameter("set_voltage", - label='Target voltage output', - set_cmd=f"{select_cmd} {voltage_amp} {{}}", - get_cmd=f"{select_cmd} {voltage_amp}?", - get_parser=float, - unit='V', - vals=vals.Numbers(0, 32.050) - ) - self.add_parameter("set_current", - label='Target current output', - set_cmd=f"{select_cmd} {current_amp} {{}}", - get_cmd=f"{select_cmd} {current_amp}?", - get_parser=float, - unit='A', - vals=vals.Numbers(0.5e-3, self._parent.max_current) - ) - self.add_parameter('state', - label='Output enabled', - set_cmd=f'{select_cmd} :OUTPut:CHANnel:STATe {{}}', - get_cmd=f'{select_cmd} :OUTPut:CHANnel:STATe?', - val_mapping={'ON': 1, 'OFF': 0}, - vals=vals.Enum('ON', 'OFF') - ) - self.add_parameter("voltage", - label='Measured voltage', - get_cmd=f"{select_cmd} :MEASure:SCALar:VOLTage:DC?", - get_parser=float, - unit='V', - ) - self.add_parameter("current", - label='Measured current', - get_cmd=f"{select_cmd} :MEASure:SCALar:CURRent:DC?", - get_parser=float, - unit='A', - ) - self.add_parameter("power", - label='Measured power', - get_cmd=f"{select_cmd} :MEASure:SCALar:POWer?", - get_parser=float, - unit='W', - ) - - -class _RohdeSchwarzHMC804x(VisaInstrument): - """ - This is the general HMC804x Power Supply driver class that implements - shared parameters and functionality among all similar power supply - from Rohde & Schwarz. - - This driver was written to be inherited from by a specific driver - (e.g. HMC8043). - """ - - _max_currents = {3: 3.0, 2: 5.0, 1: 10.0} - - def __init__(self, name: str, address: str, - num_channels: int, **kwargs: Any) -> None: - super().__init__(name, address, **kwargs) - - self.max_current = _RohdeSchwarzHMC804x._max_currents[num_channels] - - self.add_parameter('state', - label='Output enabled', - set_cmd='OUTPut:MASTer:STATe {}', - get_cmd='OUTPut:MASTer:STATe?', - val_mapping={'ON': 1, 'OFF': 0}, - vals=vals.Enum('ON', 'OFF') - ) - - # channel-specific parameters - channels = ChannelList(self, "SupplyChannel", - RohdeSchwarzHMC804xChannel, snapshotable=False) - for ch_num in range(1, num_channels+1): - ch_name = f"ch{ch_num}" - channel = RohdeSchwarzHMC804xChannel(self, ch_name, ch_num) - channels.append(channel) - self.add_submodule(ch_name, channel) - self.add_submodule("channels", channels.to_channel_tuple()) - - self.connect_message() diff --git a/qcodes/instrument_drivers/rohde_schwarz/private/__init__.py b/qcodes/instrument_drivers/rohde_schwarz/private/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/qcodes/tests/drivers/test_rohdeschwarz_HMC804x.py b/qcodes/tests/drivers/test_rohdeschwarz_HMC804x.py deleted file mode 100644 index ea47428a976..00000000000 --- a/qcodes/tests/drivers/test_rohdeschwarz_HMC804x.py +++ /dev/null @@ -1,51 +0,0 @@ -import pytest - -import qcodes.instrument.sims as sims -from qcodes.instrument_drivers.rohde_schwarz.private.HMC804x import _RohdeSchwarzHMC804x - -visalib = sims.__file__.replace('__init__.py', 'RSHMC804x.yaml@sim') - - -@pytest.fixture(scope='module') -def HMC8041(): - hmc8041 = _RohdeSchwarzHMC804x('hmc8041', - address='GPIB::1::INSTR', - num_channels=1, - visalib=visalib, - terminator='\n') - yield hmc8041 - - hmc8041.close() - - -@pytest.fixture(scope='module') -def HMC8042(): - hmc8042 = _RohdeSchwarzHMC804x('hmc8042', - address='GPIB::1::INSTR', - num_channels=2, - visalib=visalib, - terminator='\n') - yield hmc8042 - - hmc8042.close() - - -@pytest.fixture(scope='module') -def HMC8043(): - hmc8043 = _RohdeSchwarzHMC804x('hmc8043', - address='GPIB::1::INSTR', - num_channels=3, - visalib=visalib, - terminator='\n') - yield hmc8043 - - hmc8043.close() - - -def test_init(HMC8041, HMC8042, HMC8043): - - for hmc in [HMC8041, HMC8042, HMC8043]: - - idn_dict = hmc.IDN() - - assert idn_dict['vendor'] == 'QCoDeS' From 07020eee90b9b00b06a5a02285e6318587e8ae22 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Sat, 10 Sep 2022 13:08:12 +0200 Subject: [PATCH 2/4] Add public drivers for R&S --- .../rohde_schwarz/RTO1000.py | 34 ++++++++++++++----- .../rohde_schwarz/Rohde_Schwarz_ZNB20.py | 10 ++++++ .../rohde_schwarz/Rohde_Schwarz_ZNB8.py | 12 +++++++ .../rohde_schwarz/SGS100A.py | 6 +++- .../instrument_drivers/rohde_schwarz/ZNB.py | 27 ++++++++------- .../instrument_drivers/rohde_schwarz/ZNB20.py | 4 ++- .../rohde_schwarz/__init__.py | 19 +++++++++++ 7 files changed, 89 insertions(+), 23 deletions(-) create mode 100644 qcodes/instrument_drivers/rohde_schwarz/Rohde_Schwarz_ZNB20.py create mode 100644 qcodes/instrument_drivers/rohde_schwarz/Rohde_Schwarz_ZNB8.py diff --git a/qcodes/instrument_drivers/rohde_schwarz/RTO1000.py b/qcodes/instrument_drivers/rohde_schwarz/RTO1000.py index f5edc889055..6a22ec4cebf 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/RTO1000.py +++ b/qcodes/instrument_drivers/rohde_schwarz/RTO1000.py @@ -137,7 +137,7 @@ def get_raw(self) -> np.ndarray: return output -class ScopeMeasurement(InstrumentChannel): +class RohdeSchwarzRTO1000ScopeMeasurement(InstrumentChannel): """ Class to hold a measurement of the scope. """ @@ -290,7 +290,10 @@ def __init__(self, parent: Instrument, name: str, meas_nr: int) -> None: ' results.') -class ScopeChannel(InstrumentChannel): +ScopeMeasurement = RohdeSchwarzRTO1000ScopeMeasurement + + +class RohdeSchwarzRTO1000ScopeChannel(InstrumentChannel): """ Class to hold an input channel of the scope. @@ -432,7 +435,10 @@ def _set_scale(self, value: float) -> None: self._parent.write(f'CHANnel{self.channum}:SCALe {value}') -class RTO1000(VisaInstrument): +ScopeChannel = RohdeSchwarzRTO1000ScopeChannel + + +class RohdeSchwarzRTO1000(VisaInstrument): """ QCoDeS Instrument driver for the Rohde-Schwarz RTO1000 series oscilloscopes. @@ -684,13 +690,15 @@ def __init__(self, name: str, address: str, get_parser=str) # Add the channels to the instrument - for ch in range(1, self.num_chans+1): - chan = ScopeChannel(self, f'channel{ch}', ch) - self.add_submodule(f'ch{ch}', chan) + for ch in range(1, self.num_chans + 1): + chan = RohdeSchwarzRTO1000ScopeChannel(self, f"channel{ch}", ch) + self.add_submodule(f"ch{ch}", chan) - for measId in range(1, self.num_meas+1): - measCh = ScopeMeasurement(self, f'measurement{measId}', measId) - self.add_submodule(f'meas{measId}', measCh) + for measId in range(1, self.num_meas + 1): + measCh = RohdeSchwarzRTO1000ScopeMeasurement( + self, f"measurement{measId}", measId + ) + self.add_submodule(f"meas{measId}", measCh) self.add_function('stop', call_cmd='STOP') self.add_function('reset', call_cmd='*RST') @@ -805,3 +813,11 @@ def _get_trigger_level(self) -> float: val = self.ask(f'TRIGger1:LEVel{source}?') return float(val.strip()) + + +class RTO1000(RohdeSchwarzRTO1000): + """ + Backwards compatibility alias for RohdeSchwarzRTO1000 + """ + + pass diff --git a/qcodes/instrument_drivers/rohde_schwarz/Rohde_Schwarz_ZNB20.py b/qcodes/instrument_drivers/rohde_schwarz/Rohde_Schwarz_ZNB20.py new file mode 100644 index 00000000000..5a4cd33de8f --- /dev/null +++ b/qcodes/instrument_drivers/rohde_schwarz/Rohde_Schwarz_ZNB20.py @@ -0,0 +1,10 @@ +from .ZNB import ZNB + + +class RohdeSchwarzZNB20(ZNB): + """ + QCoDeS driver for Rohde & Schwarz ZNB20 + + """ + + pass diff --git a/qcodes/instrument_drivers/rohde_schwarz/Rohde_Schwarz_ZNB8.py b/qcodes/instrument_drivers/rohde_schwarz/Rohde_Schwarz_ZNB8.py new file mode 100644 index 00000000000..e26189b0acc --- /dev/null +++ b/qcodes/instrument_drivers/rohde_schwarz/Rohde_Schwarz_ZNB8.py @@ -0,0 +1,12 @@ +# Ensuring backwards compatibility + +from .ZNB import ZNB + + +class RohdeSchwarzZNB8(ZNB): + """ + QCoDeS driver for Rohde & Schwarz ZNB8 + + """ + + pass diff --git a/qcodes/instrument_drivers/rohde_schwarz/SGS100A.py b/qcodes/instrument_drivers/rohde_schwarz/SGS100A.py index f10422d60a5..baebabc1a5a 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/SGS100A.py +++ b/qcodes/instrument_drivers/rohde_schwarz/SGS100A.py @@ -5,7 +5,7 @@ from qcodes.parameters import create_on_off_val_mapping -class RohdeSchwarz_SGS100A(VisaInstrument): +class RohdeSchwarzSGS100A(VisaInstrument): """ This is the QCoDeS driver for the Rohde & Schwarz SGS100A signal generator. @@ -150,3 +150,7 @@ def on(self) -> None: def off(self) -> None: self.status('off') + + +class RohdeSchwarz_SGS100A(RohdeSchwarzSGS100A): + pass diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py index 17c2b221a66..5313c2d9355 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB.py @@ -29,7 +29,7 @@ class FixedFrequencyTraceIQ(MultiParameter): """ def __init__( - self, name: str, instrument: "ZNBChannel", npts: int, bandwidth: int + self, name: str, instrument: "RohdeSchwarzZNBChannel", npts: int, bandwidth: int ) -> None: super().__init__( name, @@ -74,7 +74,7 @@ def get_raw(self) -> Tuple[np.ndarray, np.ndarray]: `cw_check_sweep_first` is set to `True` then at the cost of a few ms overhead checks if the vna is setup correctly. """ - assert isinstance(self.instrument, ZNBChannel) + assert isinstance(self.instrument, RohdeSchwarzZNBChannel) i, q = self.instrument._get_cw_data() return i, q @@ -95,7 +95,7 @@ class FixedFrequencyPointIQ(MultiParameter): instrument: instrument the parameter belongs to """ - def __init__(self, name: str, instrument: "ZNBChannel") -> None: + def __init__(self, name: str, instrument: "RohdeSchwarzZNBChannel") -> None: super().__init__( name, instrument=instrument, @@ -112,7 +112,7 @@ def get_raw(self) -> Tuple[float, float]: parameter `cw_check_sweep_first` is set to `True` then at the cost of a few ms overhead checks if the vna is setup correctly. """ - assert isinstance(self.instrument, ZNBChannel) + assert isinstance(self.instrument, RohdeSchwarzZNBChannel) i, q = self.instrument._get_cw_data() return float(np.mean(i)), float(np.mean(q)) @@ -131,7 +131,7 @@ class FixedFrequencyPointMagPhase(MultiParameter): instrument: instrument the parameter belongs to """ - def __init__(self, name: str, instrument: "ZNBChannel") -> None: + def __init__(self, name: str, instrument: "RohdeSchwarzZNBChannel") -> None: super().__init__( name, instrument=instrument, @@ -152,7 +152,7 @@ def get_raw(self) -> Tuple[float, ...]: `True` for the instrument then at the cost of a few ms overhead checks if the vna is setup correctly. """ - assert isinstance(self.instrument, ZNBChannel) + assert isinstance(self.instrument, RohdeSchwarzZNBChannel) i, q = self.instrument._get_cw_data() s = np.mean(i) + 1j * np.mean(q) return np.abs(s), np.angle(s) @@ -166,7 +166,7 @@ class FrequencySweepMagPhase(MultiParameter): def __init__( self, name: str, - instrument: "ZNBChannel", + instrument: "RohdeSchwarzZNBChannel", start: float, stop: float, npts: int, @@ -203,7 +203,7 @@ def set_sweep(self, start: float, stop: float, npts: int) -> None: self.shapes = ((npts,), (npts,)) def get_raw(self) -> Tuple[ParamRawDataType, ...]: - assert isinstance(self.instrument, ZNBChannel) + assert isinstance(self.instrument, RohdeSchwarzZNBChannel) with self.instrument.format.set_to("Complex"): data = self.instrument._get_sweep_data(force_polar=True) return abs(data), np.angle(data) @@ -218,7 +218,7 @@ class FrequencySweepDBPhase(MultiParameter): def __init__( self, name: str, - instrument: "ZNBChannel", + instrument: "RohdeSchwarzZNBChannel", start: float, stop: float, npts: int, @@ -255,7 +255,7 @@ def set_sweep(self, start: float, stop: float, npts: int) -> None: self.shapes = ((npts,), (npts,)) def get_raw(self) -> Tuple[ParamRawDataType, ...]: - assert isinstance(self.instrument, ZNBChannel) + assert isinstance(self.instrument, RohdeSchwarzZNBChannel) with self.instrument.format.set_to("Complex"): data = self.instrument._get_sweep_data(force_polar=True) return 20*np.log10(np.abs(data)), np.angle(data) @@ -320,11 +320,11 @@ def set_sweep(self, start: float, stop: float, npts: int) -> None: self.shape = (npts,) def get_raw(self) -> ParamRawDataType: - assert isinstance(self.instrument, ZNBChannel) + assert isinstance(self.instrument, RohdeSchwarzZNBChannel) return self.instrument._get_sweep_data() -class ZNBChannel(InstrumentChannel): +class RohdeSchwarzZNBChannel(InstrumentChannel): def __init__( self, parent: "ZNB", @@ -922,6 +922,9 @@ def _get_cw_data(self) -> Tuple[np.ndarray, np.ndarray]: return i, q +ZNBChannel = RohdeSchwarzZNBChannel + + class ZNB(VisaInstrument): """ QCoDeS driver for the Rohde & Schwarz ZNB8 and ZNB20 diff --git a/qcodes/instrument_drivers/rohde_schwarz/ZNB20.py b/qcodes/instrument_drivers/rohde_schwarz/ZNB20.py index d151cc78ffd..0dec0995016 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/ZNB20.py +++ b/qcodes/instrument_drivers/rohde_schwarz/ZNB20.py @@ -1,3 +1,5 @@ # Ensuring backwards compatibility -from .ZNB import ZNB as ZNB20 +from .ZNB import ZNB + +ZNB20 = ZNB diff --git a/qcodes/instrument_drivers/rohde_schwarz/__init__.py b/qcodes/instrument_drivers/rohde_schwarz/__init__.py index e69de29bb2d..03b38cf0e2c 100644 --- a/qcodes/instrument_drivers/rohde_schwarz/__init__.py +++ b/qcodes/instrument_drivers/rohde_schwarz/__init__.py @@ -0,0 +1,19 @@ +from .Rohde_Schwarz_ZNB8 import RohdeSchwarzZNB8 +from .Rohde_Schwarz_ZNB20 import RohdeSchwarzZNB20 +from .RTO1000 import ( + RohdeSchwarzRTO1000, + RohdeSchwarzRTO1000ScopeChannel, + RohdeSchwarzRTO1000ScopeMeasurement, +) +from .SGS100A import RohdeSchwarzSGS100A +from .ZNB import RohdeSchwarzZNBChannel + +__all__ = [ + "RohdeSchwarzRTO1000", + "RohdeSchwarzRTO1000ScopeChannel", + "RohdeSchwarzRTO1000ScopeMeasurement", + "RohdeSchwarzSGS100A", + "RohdeSchwarzZNB20", + "RohdeSchwarzZNB8", + "RohdeSchwarzZNBChannel", +] From b8f673754dfc2946d95d6625d3eae1b1deafeda1 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Sun, 11 Sep 2022 06:54:59 +0200 Subject: [PATCH 3/4] add rs to driver api --- docs/drivers_api/RohdeSchwarz.rst | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 docs/drivers_api/RohdeSchwarz.rst diff --git a/docs/drivers_api/RohdeSchwarz.rst b/docs/drivers_api/RohdeSchwarz.rst new file mode 100644 index 00000000000..9ff4f265235 --- /dev/null +++ b/docs/drivers_api/RohdeSchwarz.rst @@ -0,0 +1,7 @@ +.. _rohdeschwarz_api : + +Rohde & Schwarz Drivers +======================= + +.. automodule:: qcodes.instrument_drivers.rohde_schwarz + :autosummary: From 669bd6aabcdb91ab38c36b349ac753ff94a05506 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Sun, 11 Sep 2022 06:55:25 +0200 Subject: [PATCH 4/4] remove rs from old api --- docs/Makefile | 1 + docs/make.bat | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/Makefile b/docs/Makefile index 48bd5406419..418e071395e 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -39,6 +39,7 @@ genapi: ../qcodes/instrument_drivers/QDev/* \ ../qcodes/instrument_drivers/QuantumDesign/DynaCoolPPMS/private/* \ ../qcodes/instrument_drivers/rigol/* \ + ../qcodes/instrument_drivers/rohde_schwarz/* \ ../qcodes/instrument_drivers/stahl/*\ ../qcodes/instrument_drivers/stanford_research/* \ ../qcodes/instrument_drivers/signal_hound/* \ diff --git a/docs/make.bat b/docs/make.bat index 29d61823ae8..f2150727dbe 100644 --- a/docs/make.bat +++ b/docs/make.bat @@ -49,6 +49,7 @@ sphinx-apidoc -o _auto -d 10 ..\qcodes ^ ..\qcodes\instrument_drivers\QuantumDesign\DynaCoolPPMS\private\* ^ ..\qcodes\instrument_drivers\QDev\* ^ ..\qcodes\instrument_drivers\rigol\* ^ + ..\qcodes\instrument_drivers\rohde_schwarz\* ^ ..\qcodes\instrument_drivers\stahl\* ^ ..\qcodes\instrument_drivers\stanford_research\* ^ ..\qcodes\instrument_drivers\signal_hound\* ^