1 | |
---|
2 | class FitProblem: |
---|
3 | """ |
---|
4 | FitProblem class allows to link a model with the new name created in _on_model, |
---|
5 | a name theory created with that model and the data fitted with the model. |
---|
6 | FitProblem is mostly used as value of the dictionary by fitting module. |
---|
7 | """ |
---|
8 | |
---|
9 | def __init__(self): |
---|
10 | |
---|
11 | """ |
---|
12 | contains information about data and model to fit |
---|
13 | """ |
---|
14 | ## data used for fitting |
---|
15 | self.fit_data=None |
---|
16 | ## the current model |
---|
17 | self.model = None |
---|
18 | ## if 1 this fit problem will be selected to fit , if 0 |
---|
19 | ## it will not be selected for fit |
---|
20 | self.schedule=0 |
---|
21 | ##list containing parameter name and value |
---|
22 | self.list_param=[] |
---|
23 | ## smear object to smear or not data1D |
---|
24 | self.smearer= None |
---|
25 | ## same as fit_data but with more info for plotting |
---|
26 | ## axis unit info and so on see plottables definition |
---|
27 | self.plotted_data=None |
---|
28 | ## fitting range |
---|
29 | self.qmin = None |
---|
30 | self.qmax = None |
---|
31 | |
---|
32 | def clone(self): |
---|
33 | """ |
---|
34 | copy fitproblem |
---|
35 | """ |
---|
36 | import copy |
---|
37 | obj = FitProblem() |
---|
38 | model= None |
---|
39 | if self.model!=None: |
---|
40 | model = self.model.clone() |
---|
41 | obj.model = model |
---|
42 | obj.fit_data = copy.deepcopy(self.fit_data) |
---|
43 | obj.model = copy.deepcopy(self.model) |
---|
44 | obj.schedule = copy.deepcopy(self.schedule) |
---|
45 | obj.list_param = copy.deepcopy(self.list_param) |
---|
46 | obj.smearer = copy.deepcopy(self.smearer) |
---|
47 | obj.plotted_data = copy.deepcopy(self.plotted_data) |
---|
48 | obj.qmin = copy.deepcopy(self.qmin) |
---|
49 | obj.qmax = copy.deepcopy(self.qmax) |
---|
50 | |
---|
51 | return obj |
---|
52 | |
---|
53 | |
---|
54 | def set_smearer(self, smearer): |
---|
55 | """ |
---|
56 | save reference of smear object on fitdata |
---|
57 | @param smear : smear object from DataLoader |
---|
58 | """ |
---|
59 | self.smearer= smearer |
---|
60 | |
---|
61 | def get_smearer(self): |
---|
62 | """ |
---|
63 | return smear object |
---|
64 | """ |
---|
65 | return self.smearer |
---|
66 | |
---|
67 | def save_model_name(self, name): |
---|
68 | self.name_per_page= name |
---|
69 | |
---|
70 | |
---|
71 | def get_name(self): |
---|
72 | return self.name_per_page |
---|
73 | |
---|
74 | def set_model(self,model): |
---|
75 | """ |
---|
76 | associates each model with its new created name |
---|
77 | @param model: model selected |
---|
78 | @param name: name created for model |
---|
79 | """ |
---|
80 | self.model= model |
---|
81 | |
---|
82 | |
---|
83 | def get_model(self): |
---|
84 | """ @return: saved model """ |
---|
85 | return self.model |
---|
86 | |
---|
87 | |
---|
88 | def add_plotted_data(self,data): |
---|
89 | """ |
---|
90 | save a copy of the data select to fit |
---|
91 | @param data: data selected |
---|
92 | """ |
---|
93 | self.plotted_data = data |
---|
94 | |
---|
95 | |
---|
96 | def get_plotted_data(self): |
---|
97 | """ @return: list of data dList""" |
---|
98 | return self.plotted_data |
---|
99 | |
---|
100 | |
---|
101 | def add_fit_data(self,data): |
---|
102 | """ |
---|
103 | save a copy of the data select to fit |
---|
104 | @param data: data selected |
---|
105 | """ |
---|
106 | self.fit_data = data |
---|
107 | |
---|
108 | |
---|
109 | def get_fit_data(self): |
---|
110 | return self.fit_data |
---|
111 | |
---|
112 | |
---|
113 | def set_model_param(self,name,value=None): |
---|
114 | """ |
---|
115 | Store the name and value of a parameter of this fitproblem's model |
---|
116 | @param name: name of the given parameter |
---|
117 | @param value: value of that parameter |
---|
118 | """ |
---|
119 | self.list_param.append([name,value]) |
---|
120 | |
---|
121 | |
---|
122 | def get_model_param(self): |
---|
123 | """ |
---|
124 | @return list of couple of parameter name and value |
---|
125 | """ |
---|
126 | return self.list_param |
---|
127 | |
---|
128 | |
---|
129 | def schedule_tofit(self, schedule=0): |
---|
130 | """ |
---|
131 | set schedule to true to decide if this fit must be performed |
---|
132 | """ |
---|
133 | self.schedule=schedule |
---|
134 | |
---|
135 | |
---|
136 | def get_scheduled(self): |
---|
137 | """ return true or false if a problem as being schedule for fitting""" |
---|
138 | return self.schedule |
---|
139 | |
---|
140 | |
---|
141 | def set_range(self, qmin=None, qmax=None): |
---|
142 | """ |
---|
143 | set fitting range |
---|
144 | """ |
---|
145 | self.qmin = qmin |
---|
146 | self.qmax = qmax |
---|
147 | |
---|
148 | |
---|
149 | def get_range(self): |
---|
150 | """ |
---|
151 | @return fitting range: |
---|
152 | """ |
---|
153 | return self.qmin, self.qmax |
---|
154 | |
---|
155 | def clear_model_param(self): |
---|
156 | """ |
---|
157 | clear constraint info |
---|
158 | """ |
---|
159 | self.list_param=[] |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | |
---|