aboutsummaryrefslogtreecommitdiff
path: root/qolab/hardware
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2024-07-20 17:50:36 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2024-07-20 17:50:36 -0400
commitbd959db874b0441e95bf7838589f6424a3561a81 (patch)
treeefcc038b496819341743023f1abe30cd6de7cccb /qolab/hardware
parentec71f9b969d21c6f78e56eee960ee95de7422167 (diff)
downloadqolab-bd959db874b0441e95bf7838589f6424a3561a81.tar.gz
qolab-bd959db874b0441e95bf7838589f6424a3561a81.zip
move calcSparsingAndNumPoints to a separate function
Diffstat (limited to 'qolab/hardware')
-rw-r--r--qolab/hardware/scope/_basic.py16
-rw-r--r--qolab/hardware/scope/sds1104x.py6
2 files changed, 19 insertions, 3 deletions
diff --git a/qolab/hardware/scope/_basic.py b/qolab/hardware/scope/_basic.py
index 1ceecbc..c0a6f13 100644
--- a/qolab/hardware/scope/_basic.py
+++ b/qolab/hardware/scope/_basic.py
@@ -9,6 +9,22 @@ from qolab.hardware.basic import BasicInstrument
from qolab.data.trace import TraceSetSameX
+def calcSparsingAndNumPoints(self, availableNpnts=None, maxRequiredPoints=None):
+ if availableNpnts is None:
+ # using channel 1 to get availableNpnts
+ availableNpnts = self.getAvailableNumberOfPoints(1)
+ if maxRequiredPoints is None:
+ maxRequiredPoints = self.maxRequiredPoints
+
+ if availableNpnts <= maxRequiredPoints * 2:
+ Npnts = availableNpnts
+ sparsing = 1
+ else:
+ sparsing = int(np.floor(availableNpnts / maxRequiredPoints))
+ Npnts = int(np.floor(availableNpnts / sparsing))
+ return (sparsing, Npnts, availableNpnts, maxRequiredPoints)
+
+
class Scope(BasicInstrument):
"""Minimal class to implement a scope.
diff --git a/qolab/hardware/scope/sds1104x.py b/qolab/hardware/scope/sds1104x.py
index 12763ce..4ef4988 100644
--- a/qolab/hardware/scope/sds1104x.py
+++ b/qolab/hardware/scope/sds1104x.py
@@ -3,7 +3,7 @@ Created by Eugeniy E. Mikhailov 2021/11/29
"""
from qolab.hardware.basic import BasicInstrument
-from ._basic import ScopeSCPI
+from ._basic import ScopeSCPI, calcSparsingAndNumPoints
from qolab.hardware.scpi import response2numStr
from qolab.data.trace import Trace, TraceXY
import numpy as np
@@ -112,7 +112,7 @@ class SDS1104X(ScopeSCPI):
Npnts,
availableNpnts,
maxRequiredPoints,
- ) = self.calcSparsingAndNumPoints(availableNpnts, maxRequiredPoints)
+ ) = calcSparsingAndNumPoints(availableNpnts, maxRequiredPoints)
if decimate:
Npnts = availableNpnts # get all of them and decimate later
if (sparsing == 1 and Npnts == availableNpnts) or decimate:
@@ -296,7 +296,7 @@ class SDS1104X(ScopeSCPI):
Npnts,
availableNpnts,
maxRequiredPoints,
- ) = self.calcSparsingAndNumPoints(availableNpnts, maxRequiredPoints)
+ ) = calcSparsingAndNumPoints(availableNpnts, maxRequiredPoints)
sampleRate = self.getSampleRate()
timePerDiv = self.getTimePerDiv()
trigDelay = self.getTrigDelay()