aboutsummaryrefslogtreecommitdiff
path: root/qolab/hardware/scope/_basic.py
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2024-07-22 15:44:21 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2024-07-22 15:44:21 -0400
commite7fee12153059f003be4091ebe5200077d3f6a8c (patch)
treed984547ae7b8bfb1bce60d9cfc2811fff1daff81 /qolab/hardware/scope/_basic.py
parent820cd4f2ab7480cab0e88c8aa9f3fce02e1dc581 (diff)
downloadqolab-e7fee12153059f003be4091ebe5200077d3f6a8c.tar.gz
qolab-e7fee12153059f003be4091ebe5200077d3f6a8c.zip
improvement in chanAutoScale
Diffstat (limited to 'qolab/hardware/scope/_basic.py')
-rw-r--r--qolab/hardware/scope/_basic.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/qolab/hardware/scope/_basic.py b/qolab/hardware/scope/_basic.py
index 4e546ac..c39ef1f 100644
--- a/qolab/hardware/scope/_basic.py
+++ b/qolab/hardware/scope/_basic.py
@@ -170,9 +170,9 @@ class Scope(BasicInstrument):
"""
starttime = time.time()
- deadline = starttime+timeout
+ deadline = starttime + timeout
scaled_corectly = False
- while (not scaled_corectly) and (time.time()<deadline):
+ while (not scaled_corectly) and (time.time() < deadline):
tr = self.getTrace(chNum)
vPerDiv = self.getChanVoltsPerDiv(chNum)
offset = self.getChanVoltageOffset(chNum)
@@ -182,26 +182,26 @@ class Scope(BasicInstrument):
y = tr.y.values
tr_max = y.max()
tr_min = y.min()
- screen_portion = (y.max - y.min) / vPerDiv / self.vertDivOnScreen
top_margin = (v_max - tr_max) / v_range
bottom_margin = (tr_min - v_min) / v_range
is_top_margin_good = (top_margin > margin / 2) and (top_margin < margin)
- is_bottom_margin_good = (bottom_margin > margin / 2) and (bottom_margin < margin)
+ is_bottom_margin_good = (bottom_margin > margin / 2) and (
+ bottom_margin < margin
+ )
if (is_bottom_margin_good) and (is_top_margin_good):
scaled_corectly = True
break
- offset = (tr_max+tr_min)/2
- vPerDiv = (tr_max -tr_min)/(self.vertDivOnScreen*(1-margin*1.5))
+ offset = -(tr_max + tr_min) / 2
+ vPerDiv = (tr_max - tr_min) / (self.vertDivOnScreen * (1 - margin * 1.5))
self.setChanVoltageOffset(chNum, offset)
self.setChanVoltsPerDiv(chNum, vPerDiv)
scaled_corectly = False
- if (time.time()>deadline):
+ if time.time() > deadline:
logger.warning(
- f"Scope did not make proper channel {chNum} scaling within {timeout=} sec, try to increase it."
+ f"Scope did not make proper channel {chNum} scaling within {timeout=} sec."
)
-
def plot(self, **kwargs):
allTraces = self.getAllTraces(**kwargs)
allTraces.plot()