diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-03 09:59:41 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-03 09:59:41 -0500 |
commit | 65a220c30593c86cc2ea4291b794196146880e9d (patch) | |
tree | c4c9a76f5fe9e75ed8e9014e683dbb45abada473 | |
parent | e9a6a48fead03d3c59c44fa2295b2ffa82403593 (diff) | |
download | qolab-65a220c30593c86cc2ea4291b794196146880e9d.tar.gz qolab-65a220c30593c86cc2ea4291b794196146880e9d.zip |
added grabing and ploting all traces capabilities
-rw-r--r-- | qolab/data/trace.py | 45 | ||||
-rw-r--r-- | qolab/hardware/scope/__init__.py | 5 | ||||
-rw-r--r-- | qolab/hardware/scope/sds1104x.py | 1 |
3 files changed, 44 insertions, 7 deletions
diff --git a/qolab/data/trace.py b/qolab/data/trace.py index 9b14264..ef44041 100644 --- a/qolab/data/trace.py +++ b/qolab/data/trace.py @@ -1,16 +1,51 @@ - -class Trace: +class TraceYonly: def __init__(self, descrStr): self.descr = descrStr - self.x = None - self.xlabel = None - self.xunit = None self.y = None self.ylabel = None self.yunit = None def plot(self): import matplotlib.pyplot as plt + plt.plot(self.y, label=self.descr) + plt.legend() + + +class Trace(TraceYonly): + def __init__(self, descrStr): + super().__init__(descrStr) + self.x = None + self.xlabel = None + self.xunit = None + + def plot(self): + import matplotlib.pyplot as plt plt.plot(self.x, self.y, label=self.descr) plt.legend() +class TraceSetSameX: + def __init__(self, descrStr): + self.descr = descrStr + self.x = None + self.xlabel = None + self.xunit = None + self.traces={} + + def addTrace(self, tr): + if len(self.traces) == 0: + self.x = tr.x + self.xlabel = tr.xlabel + self.xunit = tr.xunit + trY = TraceYonly(tr.descr) + trY.y = tr.y + trY.ylabel = tr.ylabel + trY.yunit = tr.yunit + self.traces[trY.descr]=trY + + def plot(self): + import matplotlib.pyplot as plt + for k, v in self.traces.items(): + plt.plot(self.x, v.y, label=v.descr) + plt.legend() + + diff --git a/qolab/hardware/scope/__init__.py b/qolab/hardware/scope/__init__.py index e05645f..8face45 100644 --- a/qolab/hardware/scope/__init__.py +++ b/qolab/hardware/scope/__init__.py @@ -3,6 +3,7 @@ Provide basic class to operate scope Created by Eugeniy E. Mikhailov 2021/11/29 """ from qolab.hardware.scpi import SCPIinstr +from qolab.data.trace import TraceSetSameX class Scope: @@ -16,9 +17,9 @@ class Scope: warnings.warn( 'this function is not implemented' ) def getAllTraces(self, availableNpnts=None, maxRequiredPoints=None): - allTraces={} + allTraces=TraceSetSameX('scope traces') for chNum in range(1, self.numberOfChannels+1): - allTraces[chNum] = self.getTrace(chNum, availableNpnts, maxRequiredPoints) + allTraces.addTrace( self.getTrace(chNum, availableNpnts, maxRequiredPoints) ) return( allTraces ) diff --git a/qolab/hardware/scope/sds1104x.py b/qolab/hardware/scope/sds1104x.py index 2a78857..f77883d 100644 --- a/qolab/hardware/scope/sds1104x.py +++ b/qolab/hardware/scope/sds1104x.py @@ -165,6 +165,7 @@ if __name__ == '__main__': print(f'Ch1 Volts per Div: {scope.getChanVoltsPerDiv(1)}') print(f'Ch1 Voltage Offset: {scope.getChanOffset(1)}') ch1 = scope.getTrace(1) + traces = scope.getAllTraces() |