1 | """ |
---|
2 | Adapters for fitting module |
---|
3 | """ |
---|
4 | import copy |
---|
5 | import numpy |
---|
6 | |
---|
7 | from danse.common.plottools.plottables import Data1D as PlotData1D |
---|
8 | from danse.common.plottools.plottables import Data2D as PlotData2D |
---|
9 | from danse.common.plottools.plottables import Theory1D as PlotTheory1D |
---|
10 | |
---|
11 | from DataLoader.data_info import Data1D as LoadData1D |
---|
12 | from DataLoader.data_info import Data2D as LoadData2D |
---|
13 | |
---|
14 | class Data1D(PlotData1D, LoadData1D): |
---|
15 | |
---|
16 | def __init__(self, x=[], y=[], dx=None, dy=None): |
---|
17 | PlotData1D.__init__(self, x, y, dx, dy) |
---|
18 | LoadData1D.__init__(self, x, y, dx, dy) |
---|
19 | self.id= None |
---|
20 | self.group_id =None |
---|
21 | self.is_data = True |
---|
22 | |
---|
23 | def copy_from_datainfo(self, data1d): |
---|
24 | """ |
---|
25 | copy values of Data1D of type DataLaoder.Data_info |
---|
26 | """ |
---|
27 | self.x = copy.deepcopy(data1d.x) |
---|
28 | self.y = copy.deepcopy(data1d.y) |
---|
29 | self.dy = copy.deepcopy(data1d.dy) |
---|
30 | |
---|
31 | if hasattr(data1d, "dx"): |
---|
32 | self.dx = copy.deepcopy(data1d.dx) |
---|
33 | if hasattr(data1d, "dxl"): |
---|
34 | self.dxl = copy.deepcopy(data1d.dxl) |
---|
35 | if hasattr(data1d, "dxw"): |
---|
36 | self.dxw = copy.deepcopy(data1d.dxw) |
---|
37 | |
---|
38 | self.xaxis(data1d._xaxis,data1d._xunit) |
---|
39 | self.yaxis(data1d._yaxis,data1d._yunit) |
---|
40 | |
---|
41 | def __str__(self): |
---|
42 | """ |
---|
43 | print data |
---|
44 | """ |
---|
45 | _str = "%s\n" % LoadData1D.__str__(self) |
---|
46 | |
---|
47 | return _str |
---|
48 | class Theory1D(PlotTheory1D,LoadData1D): |
---|
49 | |
---|
50 | def __init__(self,x=[],y=[],dy=None): |
---|
51 | PlotTheory1D.__init__(self, x, y, dy) |
---|
52 | LoadData1D.__init__(self, x, y, dy) |
---|
53 | self.id= None |
---|
54 | self.group_id = None |
---|
55 | self.is_data = True |
---|
56 | |
---|
57 | def copy_from_datainfo(self, data1d): |
---|
58 | """ |
---|
59 | copy values of Data1D of type DataLaoder.Data_info |
---|
60 | """ |
---|
61 | self.x = copy.deepcopy(data1d.x) |
---|
62 | self.y = copy.deepcopy(data1d.y) |
---|
63 | self.dy = copy.deepcopy(data1d.dy) |
---|
64 | if hasattr(data1d, "dx"): |
---|
65 | self.dx = copy.deepcopy(data1d.dx) |
---|
66 | if hasattr(data1d, "dxl"): |
---|
67 | self.dxl = copy.deepcopy(data1d.dxl) |
---|
68 | if hasattr(data1d, "dxw"): |
---|
69 | self.dxw = copy.deepcopy(data1d.dxw) |
---|
70 | self.xaxis(data1d._xaxis,data1d._xunit) |
---|
71 | self.yaxis(data1d._yaxis,data1d._yunit) |
---|
72 | |
---|
73 | def __str__(self): |
---|
74 | """ |
---|
75 | print data |
---|
76 | """ |
---|
77 | _str = "%s\n" % LoadData1D.__str__(self) |
---|
78 | |
---|
79 | return _str |
---|
80 | |
---|
81 | class Data2D(PlotData2D,LoadData2D): |
---|
82 | def __init__(self,image=None,err_image=None,xmin=None,xmax=None,ymin=None,ymax=None,zmin=None,zmax=None): |
---|
83 | |
---|
84 | PlotData2D.__init__(self, image=image, err_image=err_image,xmin=xmin, xmax=xmax, |
---|
85 | ymin=ymin, ymax=ymax) |
---|
86 | |
---|
87 | LoadData2D.__init__(self,data=image, err_data=err_image, qx_data=None,qy_data=None,q_data=None,mask=None) |
---|
88 | |
---|
89 | def copy_from_datainfo(self, data2d): |
---|
90 | """ |
---|
91 | copy value of Data2D of type DataLoader.data_info |
---|
92 | """ |
---|
93 | self.data = copy.deepcopy(data2d.data) |
---|
94 | self.qx_data = copy.deepcopy(data2d.qx_data) |
---|
95 | self.qy_data = copy.deepcopy(data2d.qy_data) |
---|
96 | self.q_data = copy.deepcopy(data2d.q_data) |
---|
97 | self.mask = copy.deepcopy(data2d.mask) |
---|
98 | self.err_data = copy.deepcopy(data2d.err_data) |
---|
99 | self.x_bins = copy.deepcopy(data2d.x_bins) |
---|
100 | self.y_bins = copy.deepcopy(data2d.y_bins) |
---|
101 | |
---|
102 | self.xmin = data2d.xmin |
---|
103 | self.xmax = data2d.xmax |
---|
104 | self.ymin = data2d.ymin |
---|
105 | self.ymax = data2d.ymax |
---|
106 | |
---|
107 | self.xaxis(data2d._xaxis,data2d._xunit) |
---|
108 | self.yaxis(data2d._yaxis,data2d._yunit) |
---|
109 | |
---|
110 | def __str__(self): |
---|
111 | """ |
---|
112 | print data |
---|
113 | """ |
---|
114 | _str = "%s\n" % LoadData2D.__str__(self) |
---|
115 | |
---|
116 | return _str |
---|
117 | |
---|