diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-07-20 18:03:42 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-07-20 18:04:44 -0400 |
commit | 5521a2dd65d6101b3881907b359444834e3f8cba (patch) | |
tree | e78f47ad82f2f65265742e4b94aa42b651f2533c | |
parent | bd959db874b0441e95bf7838589f6424a3561a81 (diff) | |
download | qolab-5521a2dd65d6101b3881907b359444834e3f8cba.tar.gz qolab-5521a2dd65d6101b3881907b359444834e3f8cba.zip |
refactor calcSparsingAndNumPoints to avoid use of unset availableNpnts
-rw-r--r-- | qolab/hardware/scope/_basic.py | 19 | ||||
-rw-r--r-- | qolab/hardware/scope/sds1104x.py | 21 |
2 files changed, 23 insertions, 17 deletions
diff --git a/qolab/hardware/scope/_basic.py b/qolab/hardware/scope/_basic.py index c0a6f13..e67e6af 100644 --- a/qolab/hardware/scope/_basic.py +++ b/qolab/hardware/scope/_basic.py @@ -10,9 +10,24 @@ from qolab.data.trace import TraceSetSameX def calcSparsingAndNumPoints(self, availableNpnts=None, maxRequiredPoints=None): + """Calculate sparcing and number of sparced points. + + Parameters + ---------- + availableNpnts: int or None + Number of available points. If set to None exit with error + maxRequiredPoints: int or (None) + number of requested points after decimation. + If availableNpnts< maxRequiredPoints*2, + decimation is impossible and we will get up to factor of 2 more + than requested. + + Return + ------ + (sparsing, Npnts, availableNpnts, maxRequiredPoints) + """ if availableNpnts is None: - # using channel 1 to get availableNpnts - availableNpnts = self.getAvailableNumberOfPoints(1) + raise ValueError("Invalid availableNpnts value, must be int.") if maxRequiredPoints is None: maxRequiredPoints = self.maxRequiredPoints diff --git a/qolab/hardware/scope/sds1104x.py b/qolab/hardware/scope/sds1104x.py index 4ef4988..af63609 100644 --- a/qolab/hardware/scope/sds1104x.py +++ b/qolab/hardware/scope/sds1104x.py @@ -62,21 +62,6 @@ class SDS1104X(ScopeSCPI): # it is not possible to do with this model directly pass - 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) - def getRawWaveform( self, chNum, availableNpnts=None, maxRequiredPoints=None, decimate=True ): @@ -107,6 +92,9 @@ class SDS1104X(ScopeSCPI): to use ``decimate=True``. """ + if availableNpnts is None: + # using channel 1 to get availableNpnts + availableNpnts = self.getAvailableNumberOfPoints(1) ( sparsing, Npnts, @@ -291,6 +279,9 @@ class SDS1104X(ScopeSCPI): return (tr, availableNpnts) def getTimeTrace(self, availableNpnts=None, maxRequiredPoints=None): + if availableNpnts is None: + # using channel 1 to get availableNpnts + availableNpnts = self.getAvailableNumberOfPoints(1) ( sparsing, Npnts, |