aboutsummaryrefslogtreecommitdiff
path: root/qolab/hardware/scope
diff options
context:
space:
mode:
Diffstat (limited to 'qolab/hardware/scope')
-rw-r--r--qolab/hardware/scope/rigolds1054z.py77
1 files changed, 11 insertions, 66 deletions
diff --git a/qolab/hardware/scope/rigolds1054z.py b/qolab/hardware/scope/rigolds1054z.py
index 674f4d0..177f72a 100644
--- a/qolab/hardware/scope/rigolds1054z.py
+++ b/qolab/hardware/scope/rigolds1054z.py
@@ -236,80 +236,25 @@ class RigolDS1054z(ScopeSCPI):
pass # we repeat this loop iteration again
logger.debug(f"final {chunk_size=}")
- if True:
- return wfRaw, errorFreeChunkSize, errorProneChunkSize
+ if maxRequiredPoints is None:
+ maxRequiredPoints = self.maxRequiredPoints
(
sparsing,
Npnts,
availableNpnts,
maxRequiredPoints,
- ) = self.calcSparsingAndNumPoints(availableNpnts, maxRequiredPoints)
- if decimate:
- Npnts = availableNpnts # get all of them and decimate later
- if (sparsing == 1 and Npnts == availableNpnts) or decimate:
- # We are getting all points of the trace
- # Apparently sparsing has no effect with this command
- # and effectively uses SP=1 for any sparsing
- # but I want to make sure and force it
- cstr = "WAVEFORM_SETUP NP,0,FP,0,SP,1"
- # technically when we know Npnts and sparsing
- # we can use command from the follow up 'else' clause
- else:
- # we just ask every point with 'sparsing' interval
- # fast to grab but we could do better with more advance decimate
- # method, which allow better precision for the price
- # of longer acquisition time
- cstr = f"WAVEFORM_SETUP SP,{sparsing},NP,{Npnts},FP,0"
- # Note: it is not enough to provide sparsing (SP),
- # number of points (NP) needed to be calculated properly too!
- # From the manual
- # WAVEFORM_SETUP SP,<sparsing>,NP,<number>,FP,<point>
- # SP Sparse point. It defines the interval between data points.
- # For example:
- # SP = 0 sends all data points.
- # SP = 1 sends all data points.
- # SP = 4 sends every 4th data point
- # NP — Number of points. It indicates how many points should be transmitted.
- # For example:
- # NP = 0 sends all data points.
- # NP = 50 sends a maximum of 50 data points.
- # FP — First point. It specifies the address of the first data point
- # to be sent.
- # For example:
- # FP = 0 corresponds to the first data point.
- # FP = 1 corresponds to the second data point
- self.write(cstr)
+ ) = calcSparsingAndNumPoints(availableNpnts=availableNpnts, maxRequiredPoints=maxRequiredPoints)
+ if not decimate and sparsing > 1:
+ wfRaw = wfRaw[::sparsing]
trRaw = Trace(f"Ch{chNum}")
-
- qstr = f"C{chNum}:WAVEFORM? DAT2"
- # expected full reply: 'C1:WF DAT2,#9000000140.........'
- try:
- wfRaw = self.query_binary_values(
- qstr,
- datatype="b",
- header_fmt="ieee",
- container=np.array,
- chunk_size=(Npnts + 100),
+ trRaw.values = wfRaw.reshape(wfRaw.size, 1)
+ if decimate and sparsing != 1:
+ numtaps = 3
+ # not sure it is the best case
+ trRaw.values = scipy.signal.decimate(
+ trRaw.values, sparsing, numtaps, axis=0
)
- if self.resource.interface_type == InterfaceType.usb:
- # Somehow on windows (at least with USB interface)
- # there is a lingering empty string which we need to flush out
- r = self.read()
- if r != "":
- print(f"WARNING: We expected an empty string but got {r=}")
- trRaw.values = wfRaw.reshape(wfRaw.size, 1)
- if decimate and sparsing != 1:
- numtaps = 3
- # not sure it is the best case
- trRaw.values = scipy.signal.decimate(
- trRaw.values, sparsing, numtaps, axis=0
- )
- except ValueError as err:
- # most likely we get crazy number of points
- # self.read() # flushing the bogus output of previous command
- print(f"Error {err=}: getting waveform failed for {qstr=}")
- wfRaw = np.array([])
trRaw.config["unit"] = "Count"
trRaw.config["tags"]["Decimate"] = decimate
return (trRaw, availableNpnts, Npnts)