diff options
Diffstat (limited to 'qolab')
-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'] = {} |