Skip to content

Commit

Permalink
Merge pull request #6163 from jenshnielsen/srs_refactor
Browse files Browse the repository at this point in the history
Complete instrument refactor (except  Tektronix)
  • Loading branch information
jenshnielsen authored Jun 7, 2024
2 parents e06393b + 3135daf commit 07351c1
Show file tree
Hide file tree
Showing 15 changed files with 1,138 additions and 740 deletions.
6 changes: 6 additions & 0 deletions docs/changes/newsfragments/6163.improved_driver
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The SignalHound, SRS, Stahl, Weinschel and Yokogawa drivers shipping with QCoDeS
have been updated to ensure all Parameters are set as static
attributes that are documented and can be type checked. The docs for the same drivers have been
updated to not document inherited members. This makes the documentation significantly more readable
as it focuses on specific members for a given instrument. The documentation now also links superclasses.
Please consult these for inherited members.
1 change: 1 addition & 0 deletions docs/drivers_api/SRS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Stanford Research Systems Drivers

.. automodule:: qcodes.instrument_drivers.stanford_research
:autosummary:
:no-inherited-members:
1 change: 1 addition & 0 deletions docs/drivers_api/SignalHound.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Signal Hound Drivers

.. automodule:: qcodes.instrument_drivers.signal_hound
:autosummary:
:no-inherited-members:
1 change: 1 addition & 0 deletions docs/drivers_api/Stahl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Stahl Drivers

.. automodule:: qcodes.instrument_drivers.stahl
:autosummary:
:no-inherited-members:
1 change: 1 addition & 0 deletions docs/drivers_api/Weinschel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Weinschel Drivers

.. automodule:: qcodes.instrument_drivers.weinschel
:autosummary:
:no-inherited-members:
1 change: 1 addition & 0 deletions docs/drivers_api/Yokogawa.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Yokogawa Drivers

.. automodule:: qcodes.instrument_drivers.yokogawa
:autosummary:
:no-inherited-members:
111 changes: 85 additions & 26 deletions src/qcodes/instrument_drivers/signal_hound/SignalHound_USB_SA124B.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,38 +211,48 @@ def __init__(
self._set_ctypes_argtypes()

self.hf = Constants
self.add_parameter(
self.frequency: SweepTraceParameter = self.add_parameter(
"frequency",
label="Frequency",
unit="Hz",
initial_value=5e9,
vals=vals.Numbers(),
parameter_class=SweepTraceParameter,
docstring="Center frequency for sweep."
docstring="Center frequency for sweep. "
"This is the set center, the actual "
"center may be subject to round off "
"compared to this value",
)
self.add_parameter(
"""
Center frequency for sweep.
This is the set center, the actual center may be subject to round off compared to this value
"""
self.span: SweepTraceParameter = self.add_parameter(
"span",
label="Span",
unit="Hz",
initial_value=0.25e6,
vals=vals.Numbers(),
parameter_class=SweepTraceParameter,
docstring="Width of frequency span"
docstring="Width of frequency span. "
"This is the set span, the actual "
"span may be subject to round off "
"compared to this value",
)
self.add_parameter(
"""Width of frequency span.
This is the set span, the actual span may be subject to round off compared to this value
"""
self.npts: Parameter = self.add_parameter(
"npts",
label="Number of Points",
get_cmd=self._get_npts,
set_cmd=False,
docstring="Number of points in frequency sweep.",
)
self.add_parameter(
"""Number of points in frequency sweep."""
self.avg: Parameter = self.add_parameter(
"avg",
label="Averages",
initial_value=1,
Expand All @@ -253,19 +263,27 @@ def __init__(
"Averages are performed in software by "
"acquiring multiple sweeps",
)
self.add_parameter(
"""Number of averages to perform.
Averages are performed in software by acquiring multiple sweeps"""
self.ref_lvl: TraceParameter = self.add_parameter(
"ref_lvl",
label="Reference power",
unit="dBm",
initial_value=0,
vals=vals.Numbers(max_value=20),
parameter_class=TraceParameter,
docstring="Setting reference level will "
"automatically select gain and attenuation"
"automatically select gain and attenuation "
"optimal for measuring at and below "
"this level",
)
self.add_parameter(
"""
Setting reference level will automatically select gain and attenuation
optimal for measuring at and below this level
"""
self.external_reference: ExternalRefParameter = self.add_parameter(
"external_reference",
initial_value=False,
vals=vals.Bool(),
Expand All @@ -275,37 +293,60 @@ def __init__(
"disabling external ref. To disable close "
"the connection and restart.",
)
self.add_parameter("device_type", set_cmd=False, get_cmd=self._get_device_type)
self.add_parameter(
"""
Use an external 10 MHz reference source.
Note that Signal Hound does not support disabling external ref.
To disable close the connection and restart.
"""
self.device_type: Parameter = self.add_parameter(
"device_type", set_cmd=False, get_cmd=self._get_device_type
)
"""Parameter device_type"""
self.device_mode: Parameter = self.add_parameter(
"device_mode",
get_cmd=lambda: "sweeping",
set_cmd=False,
docstring="The driver currently only "
"supports sweeping mode. "
"It is therefor not possible"
"It is therefor not possible "
"to set this parameter to anything else",
)
self.add_parameter(
"""
The driver currently only supports sweeping mode.
It is therefor not possible to set this parameter to anything else
"""
self.acquisition_mode: Parameter = self.add_parameter(
"acquisition_mode",
get_cmd=lambda: "average",
set_cmd=False,
docstring="The driver only supports averaging "
"mode it is therefor not possible to set"
"mode it is therefor not possible to set "
"this parameter to anything else",
)
self.add_parameter(
"""
The driver only supports averaging mode.
It is therefor not possible to set
this parameter to anything else
"""
self.rbw: TraceParameter = self.add_parameter(
"rbw",
label="Resolution Bandwidth",
unit="Hz",
initial_value=1e3,
vals=vals.Numbers(0.1, 250e3),
parameter_class=TraceParameter,
docstring="Resolution Bandwidth (RBW) is"
docstring="Resolution Bandwidth (RBW) is "
"the bandwidth of "
"spectral energy represented in each "
"frequency bin",
)
self.add_parameter(
"""Resolution Bandwidth (RBW)
is the bandwidth of spectral energy represented in each frequency bin
"""
self.vbw: TraceParameter = self.add_parameter(
"vbw",
label="Video Bandwidth",
unit="Hz",
Expand All @@ -321,8 +362,15 @@ def __init__(
"bin over several overlapping FFTs. "
"For best performance use RBW as the VBW.",
)
"""
The video bandwidth (VBW)
is applied after the signal has been converted to frequency domain as power,
voltage, or log units. It is implemented as a simple rectangular window,
averaging the amplitude readings for each frequency bin over several overlapping FFTs.
For best performance use RBW as the VBW.
"""

self.add_parameter(
self.reject_image: TraceParameter = self.add_parameter(
"reject_image",
label="Reject image",
unit="",
Expand All @@ -332,7 +380,8 @@ def __init__(
docstring="Apply software filter to remove undersampling mirroring",
vals=vals.Bool(),
)
self.add_parameter(
"""Apply software filter to remove undersampling mirroring"""
self.sleep_time: Parameter = self.add_parameter(
"sleep_time",
label="Sleep time",
unit="s",
Expand All @@ -343,41 +392,49 @@ def __init__(
"getting data from the instrument",
vals=vals.Numbers(0),
)
"""Time to sleep before and after getting data from the instrument"""
# We don't know the correct values of
# the sweep parameters yet so we supply
# some defaults. The correct will be set when we call configure below
self.add_parameter(
self.trace: FrequencySweep = self.add_parameter(
name="trace",
sweep_len=1,
start_freq=1,
stepsize=1,
parameter_class=FrequencySweep,
)
self.add_parameter(
"""Parameter trace"""
self.power: Parameter = self.add_parameter(
"power",
label="Power",
unit="dBm",
get_cmd=self._get_power_at_freq,
set_cmd=False,
docstring="The maximum power in a window of 250 kHz"
"around the specified frequency with "
docstring="The maximum power in a window of 250 kHz "
"around the specified frequency with "
"Resolution bandwidth set to 1 kHz."
"The integration window is specified by "
"the VideoBandWidth (set by vbw)",
)
"""
The maximum power in a window of 250 kHz around the specified frequency with Resolution bandwidth set to 1 kHz.
The integration window is specified by the VideoBandWidth (set by vbw)
"""
# scale is defined after the trace and power parameter so that
# it can change the units of those in it's set method when the
# scale changes
self.add_parameter(
self.scale: ScaleParameter = self.add_parameter(
"scale",
initial_value="log-scale",
vals=vals.Enum(
"log-scale", "lin-scale", "log-full-scale", "lin-full-scale"
),
parameter_class=ScaleParameter,
)
"""Parameter scale"""

self.add_parameter(
self.frequency_axis: Parameter = self.add_parameter(
"frequency_axis",
label="Frequency",
unit="Hz",
Expand All @@ -386,7 +443,8 @@ def __init__(
vals=vals.Arrays(shape=(self.npts,)),
snapshot_value=False,
)
self.add_parameter(
"""Parameter frequency_axis"""
self.freq_sweep: ParameterWithSetpoints = self.add_parameter(
"freq_sweep",
label="Power",
unit="depends on mode",
Expand All @@ -397,6 +455,7 @@ def __init__(
setpoints=(self.frequency_axis,),
snapshot_value=False,
)
"""Parameter freq_sweep"""

self.openDevice()
self.configure()
Expand Down
Loading

0 comments on commit 07351c1

Please sign in to comment.