[d89f09b] | 1 | from sans.fit.AbstractFitEngine import Model |
---|
| 2 | |
---|
| 3 | class FitProblem: |
---|
| 4 | """ |
---|
| 5 | FitProblem class allows to link a model with the new name created in _on_model, |
---|
| 6 | a name theory created with that model and the data fitted with the model. |
---|
| 7 | FitProblem is mostly used as value of the dictionary by fitting module. |
---|
| 8 | """ |
---|
| 9 | |
---|
| 10 | def __init__(self): |
---|
| 11 | |
---|
| 12 | """ |
---|
| 13 | @ self.data :is the data selected to perform the fit |
---|
| 14 | @ self.theory_name: the name of the theory created with self.model |
---|
| 15 | @ self.model_list: is a list containing a model as first element |
---|
| 16 | and its name assign example [lineModel, M0] |
---|
| 17 | """ |
---|
[2a8fac1] | 18 | self.fit_data=None |
---|
[d89f09b] | 19 | self.theory_name=None |
---|
| 20 | self.model_list=[] |
---|
[948add7] | 21 | self.schedule=0 |
---|
[8e81af0] | 22 | self.list_param=[] |
---|
[6bcdad1] | 23 | self.name_per_page=None |
---|
[08b9c6c8] | 24 | self.smearer= None |
---|
[2a8fac1] | 25 | self.plotted_data=None |
---|
[08b9c6c8] | 26 | |
---|
| 27 | def set_smearer(self, smearer): |
---|
| 28 | self.smearer= smearer |
---|
[888e62c] | 29 | #print "smeaerer in fitproblem",self.smearer |
---|
[08b9c6c8] | 30 | def get_smearer(self): |
---|
| 31 | return self.smearer |
---|
| 32 | |
---|
[6bcdad1] | 33 | def save_model_name(self, name): |
---|
| 34 | self.name_per_page= name |
---|
[08b9c6c8] | 35 | |
---|
| 36 | |
---|
[6bcdad1] | 37 | def get_name(self): |
---|
| 38 | return self.name_per_page |
---|
[08b9c6c8] | 39 | |
---|
[d89f09b] | 40 | def set_model(self,model,name): |
---|
| 41 | """ |
---|
| 42 | associates each model with its new created name |
---|
| 43 | @param model: model selected |
---|
| 44 | @param name: name created for model |
---|
| 45 | """ |
---|
| 46 | self.model_list=[model,name] |
---|
| 47 | |
---|
| 48 | |
---|
[2a8fac1] | 49 | def add_plotted_data(self,data): |
---|
[d89f09b] | 50 | """ |
---|
| 51 | save a copy of the data select to fit |
---|
| 52 | @param data: data selected |
---|
| 53 | """ |
---|
[2a8fac1] | 54 | self.plotted_data = data |
---|
| 55 | def add_fit_data(self,data): |
---|
| 56 | """ |
---|
| 57 | save a copy of the data select to fit |
---|
| 58 | @param data: data selected |
---|
| 59 | """ |
---|
| 60 | self.fit_data = data |
---|
[d89f09b] | 61 | |
---|
| 62 | def get_model(self): |
---|
| 63 | """ @return: saved model """ |
---|
[948add7] | 64 | #print "fitproblem",self.model_list |
---|
[d89f09b] | 65 | return self.model_list |
---|
| 66 | |
---|
[2a8fac1] | 67 | def get_plotted_data(self): |
---|
[d89f09b] | 68 | """ @return: list of data dList""" |
---|
[2a8fac1] | 69 | return self.plotted_data |
---|
| 70 | |
---|
| 71 | |
---|
| 72 | def get_fit_data(self): |
---|
| 73 | return self.fit_data |
---|
| 74 | |
---|
| 75 | |
---|
[d89f09b] | 76 | def get_theory(self): |
---|
| 77 | """ @return the name of theory for plotting purpose""" |
---|
| 78 | return self.theory_name |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | def set_theory(self,name): |
---|
| 82 | """ |
---|
| 83 | Set theory name |
---|
| 84 | @param name: name of the theory |
---|
| 85 | """ |
---|
| 86 | self.theory_name = name |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | def set_model_param(self,name,value): |
---|
| 90 | """ |
---|
| 91 | set the value of a given parameter of this model |
---|
| 92 | @param name: name of the given parameter |
---|
| 93 | @param value: value of that parameter |
---|
| 94 | """ |
---|
[948add7] | 95 | #print "fitproblem",name,value |
---|
[00561739] | 96 | #self.model_list[0].setParam(name,value) |
---|
[8e81af0] | 97 | self.list_param.append([name,value]) |
---|
[00561739] | 98 | def get_model_param(self): |
---|
| 99 | """ |
---|
| 100 | set the value of a given parameter of this model |
---|
| 101 | @param name: name of the given parameter |
---|
| 102 | @param value: value of that parameter |
---|
| 103 | """ |
---|
[948add7] | 104 | #print self.param_name, self.param_value |
---|
[00561739] | 105 | #self.model_list[0].setParam(name,value) |
---|
[8e81af0] | 106 | return self.list_param |
---|
[d89f09b] | 107 | |
---|
| 108 | def reset_model(self,model): |
---|
| 109 | """ |
---|
| 110 | reset a model when parameter has changed |
---|
| 111 | @param value: new model |
---|
| 112 | """ |
---|
[948add7] | 113 | #print "fitproblem : reset model" |
---|
[d89f09b] | 114 | self.model_list[0]=model |
---|
| 115 | |
---|
[948add7] | 116 | def schedule_tofit(self, schedule=0): |
---|
[3b19ac9] | 117 | """ |
---|
| 118 | set schedule to true to decide if this fit must be performed |
---|
| 119 | """ |
---|
| 120 | self.schedule=schedule |
---|
[6bcdad1] | 121 | |
---|
[3b19ac9] | 122 | def get_scheduled(self): |
---|
| 123 | """ return true or false if a problem as being schedule for fitting""" |
---|
| 124 | return self.schedule |
---|
[9e27de9] | 125 | def clear_model_param(self): |
---|
| 126 | """ |
---|
| 127 | clear constraint info |
---|
| 128 | """ |
---|
| 129 | self.list_param=[] |
---|