- Timestamp:
- Apr 11, 2008 2:53:40 PM (17 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 106ef4d
- Parents:
- 370e587
- Location:
- guitools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
guitools/PlotPanel.py
r7a03e65 r1fdb81d 623 623 self.graph.add(plottable) 624 624 self.graph.render(self) 625 625 626 self.subplot.figure.canvas.draw_idle() 626 627 self.graph.delete(plottable) 628 627 629 628 630 -
guitools/fitDialog.py
r7a03e65 r1fdb81d 89 89 from LineModel import LineModel 90 90 self.model = LineModel() 91 92 93 #Display the fittings values 94 self.default_A = self.model.getParam('A') 95 self.default_B = self.model.getParam('B') 96 self.cstA = fittings.Parameter(self.model, 'A', self.default_A) 97 self.cstB = fittings.Parameter(self.model, 'B', self.default_B) 98 99 # Set default value of parameter in fit dialog 100 self.tcA.SetLabel(str(self.default_A)) 101 self.tcB.SetLabel(str(self.default_B)) 102 self.tcErrA.SetLabel(str(0.0)) 103 self.tcErrB.SetLabel(str(0.0)) 104 self.tcChi.SetLabel(str(0.0)) 105 self.tcXmin.SetLabel(str(0.0)) 106 self.tcXmax.SetLabel(str(0.0)) 107 91 108 # new data for the fit 92 109 self.file_data1 = Theory1D(x=[], y=[], dy=None) … … 99 116 Push a plottable to 100 117 """ 101 temp=[]118 102 119 tempx=[] 103 120 tempy=[] … … 112 129 # Receive transformations of x and y 113 130 self.xtrans,self.ytrans= self.transform() 114 # The x array min and max 115 _min = min(x) 116 _max = max(x) 117 131 118 132 119 133 if (xmin ==None)and (xmax == None): … … 121 135 self.tcXmin.SetValue(str(min(x))) 122 136 self.tcXmax.SetValue(str(max(x))) 123 124 125 #Display the fittings values 126 default_A = self.model.getParam('A') 127 default_B = self.model.getParam('B') 128 cstA = fittings.Parameter(self.model, 'A', default_A) 129 cstB = fittings.Parameter(self.model, 'B', default_B) 130 137 138 139 # Store the transformed values of view x, y,dy in variables before the fit 131 140 if self.ytrans == "Log(y)": 132 141 for y_i in y: 133 temp.append(math.log(y_i)) 134 tempdy.append(1.0) 135 if (xmin !=None and xmin>= _min) and (xmax != None and xmax<= _max): 136 chisqr, out, cov = fittings.sansfit(self.model, 137 [cstA, cstB],x, temp,tempdy,xmin,xmax) 138 else: 139 chisqr, out, cov = fittings.sansfit(self.model, 140 [cstA, cstB],x, temp,tempdy,_min,_max) 141 else : 142 if (xmin !=None and xmin >= _min) and (xmax != None and xmax <= _max): 143 chisqr, out, cov = fittings.sansfit(self.model, 144 [cstA, cstB],x, y,dy,xmin,xmax) 145 else: 146 chisqr, out, cov = fittings.sansfit(self.model, 147 [cstA, cstB],x, y,dy,_min,_max) 142 tempy.append(math.log(y_i)) 143 dy = 1/y_i 144 if dy >= y_i: 145 dy = 0.9*y_i 146 tempdy.append(dy) 147 else: 148 tempy = y 149 if self.xtrans == "Log(x)": 150 for x_i in x: 151 tempx.append(math.log(x_i)) 152 else: 153 tempx = x 154 155 #Find the fitting parameters 156 if (xmin !=None and xmin >= min(tempx) ) and (xmax != None and xmax <= max(tempx)): 157 chisqr, out, cov = fittings.sansfit(self.model, 158 [self.cstA, self.cstB],tempx, tempy,tempdy,xmin,xmax) 159 else: 160 chisqr, out, cov = fittings.sansfit(self.model, 161 [self.cstA, self.cstB],tempx, tempy,tempdy,min(tempx),max(tempx)) 162 148 163 #Check that cov and out are iterable before displaying them 149 164 if cov ==None: … … 159 174 cstA=out[0] 160 175 cstB=out[1] 176 # Reset model with the right values of A and B 161 177 self.model.setParam('A', float(cstA)) 162 178 self.model.setParam('B', float(cstB)) 163 164 #Check if View contains a x array and makes transformation for y as a line to fit 179 tempy = [] 180 # Check if View contains a x array .we online fit when x exits 181 # makes transformation for y as a line to fit 165 182 if x != []: 166 183 for j in range(len(x)): … … 170 187 else: 171 188 # x has a default value in case the user doesn't load data 172 y_model = self.model.run(x[j]) 189 if self.xtrans == "Log(x)": 190 y_model = self.model.run(math.log(x[j])) 191 else: 192 y_model = self.model.run(x[j]) 193 173 194 if self.ytrans == "Log(y)": 174 195 tempy.append(math.exp(y_model)) 175 196 else: 176 197 tempy.append(y_model) 177 198 178 199 # Create new data plottable with result 179 self.file_data1. y =[]180 self.file_data1. x =x200 self.file_data1.x =x 201 self.file_data1.y =[] 181 202 self.file_data1.y =tempy 182 203 self.file_data1.dx=None 183 204 self.file_data1.dy=None 184 205 185 206 #Load the view with the new values 186 207 self.file_data1.reset_view()
Note: See TracChangeset
for help on using the changeset viewer.