diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-21 10:55:16 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-12-21 10:55:16 -0500 |
commit | 959bd73af06903625aca2490ccf82a94abca93c5 (patch) | |
tree | 29104c9c04037e264bfb955c689994c9016dac95 /qolab/data/trace.py | |
parent | 6188068541c86bd5606b23f4310ad05a70317528 (diff) | |
download | qolab-959bd73af06903625aca2490ccf82a94abca93c5.tar.gz qolab-959bd73af06903625aca2490ccf82a94abca93c5.zip |
TraceSetSameX can be loaded now
Diffstat (limited to 'qolab/data/trace.py')
-rw-r--r-- | qolab/data/trace.py | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/qolab/data/trace.py b/qolab/data/trace.py index 4a96691..6061ad0 100644 --- a/qolab/data/trace.py +++ b/qolab/data/trace.py @@ -66,7 +66,21 @@ def traceFromHeaderAndData(header, data=None): tr.x = tx tr.y = ty elif model == 'TraceSetSameX': + tx = traceFromHeaderAndData(header['TraceX']) + tx.values=data[:,0] tr = TraceSetSameX(label) + tr.addTraceX(tx) + ytrs_header = header['TraceY'] + cnt=0 + for l, h in ytrs_header.items(): + ty = traceFromHeaderAndData(h) + cnt += 1 + ty.values=data[:,cnt] + trxy = TraceXY(l) + trxy.x = tx + trxy.y = ty + tr.addTrace( trxy ) + else: print(f'Error: unknown trace model: {model}') return None @@ -205,12 +219,22 @@ class TraceSetSameX(Trace): for k, tr in self.traces.items(): tr.clear_data() + def addTraceX(self, tr): + self.x = tr def addTrace(self, tr): - if len(self.traces) == 0: - self.x = tr.x - trY = tr.y - self.traces[tr.config['label']]=trY + if tr.config['model'] == 'TraceXY': + if self.x == None: + self.x = tr.x + trY = tr.y + self.traces[tr.config['label']]=trY + elif tr.config['model'] == 'Trace': + if self.x == None: + self.x = tr + else: + print(tr.config) + self.traces[tr.config['label']]=tr + print(self.traces) def plot(self): import matplotlib.pyplot as plt @@ -245,7 +269,8 @@ class TraceSetSameX(Trace): return (tr) def getConfig(self): - config = self.config.copy() + config = {} + config['config'] = self.config.copy() config['TraceX'] = {} config['TraceX'] = self.x.getConfig() config['TraceY'] = {} |