#!/net/python/bin/python from Data1D import * from Function2D import * import numpy as num from AnalyticFit import AnalyticFit class Data2D: """ A class to hold a 2D set of data with error bars """ def __init__(self,data=[],x=[]): """ data is an array of Data1D objects, which will become the y,z,dz coordinates of the Data2D object. x gives the x coordinates of data """ assert len(data) == len(self) self.x = [] self.y = [] self.z = [] self.dz = [] for i in range(len(data)): self.x.append(x[i]) self.y.append( data[i].x.copy() ) self.z.append( data[i].y.copy() ) if len(data.dz) > 0: self.dz.append( data[i].dz.copy() ) self.x = num.array( self.x ) def has_dz(self): if len(self.dz) > 0 and len(self.dz[0]) > 0: return True else: return False def copy(self): selfcopy = self.__class__() selfcopy.x = self.x.copy() selfcopy.y = [yi.copy() for yi in self.y] selfcopy.z = [zi.copy() for zi in self.z] selfcopy.dz = [dzi.copy() for dzi in self.dz] return selfcopy