2013-02-10 19:10:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PlotData(object):
|
|
|
|
"""
|
|
|
|
Class used for managing plot data
|
|
|
|
- allows data sharing between multiple graphics items (curve, scatter, graph..)
|
|
|
|
- each item may define the columns it needs
|
|
|
|
- column groupings ('pos' or x, y, z)
|
|
|
|
- efficiently appendable
|
|
|
|
- log, fft transformations
|
|
|
|
- color mode conversion (float/byte/qcolor)
|
|
|
|
- pen/brush conversion
|
|
|
|
- per-field cached masking
|
|
|
|
- allows multiple masking fields (different graphics need to mask on different criteria)
|
|
|
|
- removal of nan/inf values
|
|
|
|
- option for single value shared by entire column
|
|
|
|
- cached downsampling
|
2013-09-06 19:36:36 +00:00
|
|
|
- cached min / max / hasnan / isuniform
|
2013-02-10 19:10:30 +00:00
|
|
|
"""
|
|
|
|
def __init__(self):
|
|
|
|
self.fields = {}
|
|
|
|
|
|
|
|
self.maxVals = {} ## cache for max/min
|
|
|
|
self.minVals = {}
|
|
|
|
|
2013-02-20 16:13:50 +00:00
|
|
|
def addFields(self, **fields):
|
2013-02-10 19:10:30 +00:00
|
|
|
for f in fields:
|
|
|
|
if f not in self.fields:
|
|
|
|
self.fields[f] = None
|
|
|
|
|
|
|
|
def hasField(self, f):
|
|
|
|
return f in self.fields
|
|
|
|
|
|
|
|
def __getitem__(self, field):
|
|
|
|
return self.fields[field]
|
|
|
|
|
|
|
|
def __setitem__(self, field, val):
|
|
|
|
self.fields[field] = val
|
|
|
|
|
|
|
|
def max(self, field):
|
|
|
|
mx = self.maxVals.get(field, None)
|
|
|
|
if mx is None:
|
|
|
|
mx = np.max(self[field])
|
|
|
|
self.maxVals[field] = mx
|
|
|
|
return mx
|
|
|
|
|
|
|
|
def min(self, field):
|
|
|
|
mn = self.minVals.get(field, None)
|
|
|
|
if mn is None:
|
|
|
|
mn = np.min(self[field])
|
|
|
|
self.minVals[field] = mn
|
|
|
|
return mn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|