aboutsummaryrefslogtreecommitdiff
path: root/qolab/hardware/scope
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2024-07-21 00:35:44 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2024-07-21 00:35:44 -0400
commitb8911a3a85f1a24e5da804d9c9a5d35f10c3e175 (patch)
tree41328bd9ed56b1e58d739407aa328f2a8fedd1dc /qolab/hardware/scope
parent2aaab1316d176950df7b8679c6fc1ffa32fc9cf7 (diff)
downloadqolab-b8911a3a85f1a24e5da804d9c9a5d35f10c3e175.tar.gz
qolab-b8911a3a85f1a24e5da804d9c9a5d35f10c3e175.zip
black formatter
Diffstat (limited to 'qolab/hardware/scope')
-rw-r--r--qolab/hardware/scope/rigolds1054z.py51
1 files changed, 29 insertions, 22 deletions
diff --git a/qolab/hardware/scope/rigolds1054z.py b/qolab/hardware/scope/rigolds1054z.py
index 8706cf1..d3dbd3c 100644
--- a/qolab/hardware/scope/rigolds1054z.py
+++ b/qolab/hardware/scope/rigolds1054z.py
@@ -19,7 +19,6 @@ logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
-
class RigolDS1054z(ScopeSCPI):
"""Rigol 1054 scope"""
@@ -174,19 +173,19 @@ class RigolDS1054z(ScopeSCPI):
<yreference>: the vertical reference position in the Y direction.
"""
rawChanCfg = {
- 'format': int(preamble[0]),
- 'type': int(preamble[1]),
- 'availableNpnts': int(preamble[2]),
- 'Navrg': int(preamble[3]),
- 'xincrement': float(preamble[4]),
- 'xorigin': float(preamble[5]),
- 'xreference': int(preamble[6]),
- 'yincrement': float(preamble[7]),
- 'yorigin': int(preamble[8]),
- 'yreference': int(preamble[9]),
- }
+ "format": int(preamble[0]),
+ "type": int(preamble[1]),
+ "availableNpnts": int(preamble[2]),
+ "Navrg": int(preamble[3]),
+ "xincrement": float(preamble[4]),
+ "xorigin": float(preamble[5]),
+ "xreference": int(preamble[6]),
+ "yincrement": float(preamble[7]),
+ "yorigin": int(preamble[8]),
+ "yreference": int(preamble[9]),
+ }
logger.info(f"rawChanCfg: {rawChanCfg}")
- availableNpnts = rawChanCfg['availableNpnts']
+ availableNpnts = rawChanCfg["availableNpnts"]
wfRaw = np.zeros(availableNpnts, dtype=np.uint8)
maxreadable = 250_000 # the maximum number of bytes readable in one go
chunk_size = 70_000 # unfortunately large chunk size prone to read errors
@@ -198,7 +197,7 @@ class RigolDS1054z(ScopeSCPI):
while strt <= availableNpnts:
stp = strt - 1 + chunk_size
stp = min(stp, availableNpnts)
- chunk_size = stp-strt+1
+ chunk_size = stp - strt + 1
# reading requested number of points in chunks
self.write(f":WAVeform:STARt {strt}")
self.write(f":WAVeform:STOP {stp}")
@@ -215,9 +214,13 @@ class RigolDS1054z(ScopeSCPI):
logger.info("Got empty chunk. Redoing.")
continue # we need to repeat chunk read
if len(wfRawChunk) != chunk_size:
- logger.info("Expected chunk with length" +
- f" {chunk_size} but got {len(wfRawChunk)}")
- logger.info(f"Current pointers are {strt=} {stp=} with {chunk_size=}")
+ logger.info(
+ "Expected chunk with length"
+ + f" {chunk_size} but got {len(wfRawChunk)}"
+ )
+ logger.info(
+ f"Current pointers are {strt=} {stp=} with {chunk_size=}"
+ )
logger.info("Redoing, chunk reading.")
continue # we need to repeat chunk read
wfRaw[strt - 1 : stp] = wfRawChunk
@@ -238,7 +241,9 @@ class RigolDS1054z(ScopeSCPI):
logger.info(f"Detected recoverable {err}")
errCnt += 1
errorProneChunkSize.append(chunk_size)
- logger.debug(f"Visa error count is {errCnt} while reading raw chunk the scope")
+ logger.debug(
+ f"Visa error count is {errCnt} while reading raw chunk the scope"
+ )
logger.debug(f"Current pointers are {strt=} {stp=} with {chunk_size=}")
if len(errorFreeChunkSize) > 10:
chunk_size = int(np.mean(errorFreeChunkSize))
@@ -256,7 +261,11 @@ class RigolDS1054z(ScopeSCPI):
Npnts,
availableNpnts,
maxRequiredPoints,
- ) = calcSparsingAndNumPoints(availableNpnts=availableNpnts, maxRequiredPoints=maxRequiredPoints)
+ ) = calcSparsingAndNumPoints(
+ availableNpnts=availableNpnts, maxRequiredPoints=maxRequiredPoints
+ )
+ rawChanCfg["Npnts"] = Npnts
+ rawChanCfg["sparsing"] = sparsing
if not decimate and sparsing > 1:
wfRaw = wfRaw[::sparsing]
@@ -332,9 +341,7 @@ class RigolDS1054z(ScopeSCPI):
maxRequiredPoints=maxRequiredPoints,
decimate=decimate,
)
- t = self.getTimeTrace(
- rawChanCfg
- )
+ t = self.getTimeTrace(rawChanCfg)
tr = TraceXY(f"Ch{chNum}")
tr.x = t
tr.y = wfVoltage