Changeset a48842a2 in sasview for sansguiframe
- Timestamp:
- Jun 13, 2012 4:40:41 PM (12 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:
- 1a98ded
- Parents:
- 9a14138
- Location:
- sansguiframe/src/sans/guiframe
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/dataFitting.py
rb21d32b ra48842a2 69 69 dy, dy_other = self._validity_check(other) 70 70 result = Data1D(x=[], y=[], dx=None, dy=None) 71 result.clone_without_data( clone=self)71 result.clone_without_data(length=len(self.x), clone=self) 72 72 result.copy_from_datainfo(data1d=self) 73 if self.dxw == None: 74 result.dxw = None 75 else: 76 result.dxw = numpy.zeros(len(self.x)) 77 if self.dxl == None: 78 result.dxl = None 79 else: 80 result.dxl = numpy.zeros(len(self.x)) 81 73 82 for i in range(len(self.x)): 74 83 result.x[i] = self.x[i] 75 84 if self.dx is not None and len(self.x) == len(self.dx): 76 85 result.dx[i] = self.dx[i] 86 if self.dxw is not None and len(self.x) == len(self.dxw): 87 result.dxw[i] = self.dxw[i] 88 if self.dxl is not None and len(self.x) == len(self.dxl): 89 result.dxl[i] = self.dxl[i] 77 90 78 91 a = Uncertainty(self.y[i], dy[i]**2) 79 92 if isinstance(other, Data1D): 80 93 b = Uncertainty(other.y[i], dy_other[i]**2) 94 if other.dx is not None: 95 result.dx[i] *= self.dx[i] 96 result.dx[i] += (other.dx[i]**2) 97 result.dx[i] /= 2 98 result.dx[i] = math.sqrt(result.dx[i]) 99 if result.dxl is not None and other.dxl is not None: 100 result.dxl[i] *= self.dxl[i] 101 result.dxl[i] += (other.dxl[i]**2) 102 result.dxl[i] /= 2 103 result.dxl[i] = math.sqrt(result.dxl[i]) 81 104 else: 82 105 b = other … … 84 107 output = operation(a, b) 85 108 result.y[i] = output.x 86 if result.dy is None: result.dy = numpy.zeros(len(self.x))87 109 result.dy[i] = math.sqrt(math.fabs(output.variance)) 110 return result 111 112 def _perform_union(self, other): 113 """ 114 """ 115 # First, check the data compatibility 116 self._validity_check_union(other) 117 result = Data1D(x=[], y=[], dx=None, dy=None) 118 tot_length = len(self.x) + len(other.x) 119 result = self.clone_without_data(length=tot_length, clone=result) 120 if self.dy == None or other.dy is None: 121 result.dy = None 122 else: 123 result.dy = numpy.zeros(tot_length) 124 if self.dx == None or other.dx is None: 125 result.dx = None 126 else: 127 result.dx = numpy.zeros(tot_length) 128 if self.dxw == None or other.dxw is None: 129 result.dxw = None 130 else: 131 result.dxw = numpy.zeros(tot_length) 132 if self.dxl == None or other.dxl is None: 133 result.dxl = None 134 else: 135 result.dxl = numpy.zeros(tot_length) 136 137 result.x = numpy.append(self.x, other.x) 138 #argsorting 139 ind = numpy.argsort(result.x) 140 result.x = result.x[ind] 141 result.y = numpy.append(self.y, other.y) 142 result.y = result.y[ind] 143 if result.dy != None: 144 result.dy = numpy.append(self.dy, other.dy) 145 result.dy = result.dy[ind] 146 if result.dx is not None: 147 result.dx = numpy.append(self.dx, other.dx) 148 result.dx = result.dx[ind] 149 if result.dxw is not None: 150 result.dxw = numpy.append(self.dxw, other.dxw) 151 result.dxw = result.dxw[ind] 152 if result.dxl is not None: 153 result.dxl = numpy.append(self.dxl, other.dxl) 154 result.dxl = result.dxl[ind] 88 155 return result 89 156 … … 142 209 # First, check the data compatibility 143 210 dy, dy_other = self._validity_check(other) 144 result = Theory1D(x=[], y=[], dy=None) 145 result.clone_without_data(clone=self) 211 result = self.clone_without_data(len(self.x)) 146 212 result.copy_from_datainfo(data1d=self) 147 for i in range(len(self.x)): 213 if self.dxw == None: 214 result.dxw = None 215 else: 216 result.dxw = numpy.zeros(len(self.x)) 217 if self.dxl == None: 218 result.dxl = None 219 else: 220 result.dxl = numpy.zeros(len(self.x)) 221 222 for i in range(numpy.size(self.x)): 148 223 result.x[i] = self.x[i] 149 224 if self.dx is not None and len(self.x) == len(self.dx): 225 result.dx[i] = self.dx[i] 226 if self.dxw is not None and len(self.x) == len(self.dxw): 227 result.dxw[i] = self.dxw[i] 228 if self.dxl is not None and len(self.x) == len(self.dxl): 229 result.dxl[i] = self.dxl[i] 230 150 231 a = Uncertainty(self.y[i], dy[i]**2) 151 232 if isinstance(other, Data1D): 152 233 b = Uncertainty(other.y[i], dy_other[i]**2) 234 if other.dx is not None: 235 result.dx[i] *= self.dx[i] 236 result.dx[i] += (other.dx[i]**2) 237 result.dx[i] /= 2 238 result.dx[i] = math.sqrt(result.dx[i]) 239 if result.dxl is not None and other.dxl is not None: 240 result.dxl[i] *= self.dxl[i] 241 other.dxl[i] += (other.dxl[i]**2) 242 result.dxl[i] /= 2 243 result.dxl[i] = math.sqrt(result.dxl[i]) 244 if result.dxw is not None and self.dxw is not None: 245 result.dxw[i] *= self.dxw[i] 246 other.dxw[i] += (other.dxw[i]**2) 247 result.dxw[i] /= 2 248 result.dxw[i] = math.sqrt(result.dxw[i]) 153 249 else: 154 250 b = other 251 155 252 output = operation(a, b) 156 253 result.y[i] = output.x 157 if result.dy is None:158 result.dy = numpy.zeros(len(self.x))159 254 result.dy[i] = math.sqrt(math.fabs(output.variance)) 160 255 return result 161 256 257 def _perform_union(self, other): 258 """ 259 """ 260 # First, check the data compatibility 261 self._validity_check_union(other) 262 result = Data1D(x=[], y=[], dx=None, dy=None) 263 tot_length = len(self.x)+len(other.x) 264 result.clone_without_data(length=tot_length, clone=self) 265 if self.dy == None or other.dy is None: 266 result.dy = None 267 else: 268 result.dy = numpy.zeros(tot_length) 269 if self.dx == None or other.dx is None: 270 result.dx = None 271 else: 272 result.dx = numpy.zeros(tot_length) 273 if self.dxw == None or other.dxw is None: 274 result.dxw = None 275 else: 276 result.dxw = numpy.zeros(tot_length) 277 if self.dxl == None or other.dxl is None: 278 result.dxl = None 279 else: 280 result.dxl = numpy.zeros(tot_length) 281 result.x = numpy.append(self.x, other.x) 282 #argsorting 283 ind = numpy.argsort(result.x) 284 result.x = result.x[ind] 285 result.y = numpy.append(self.y, other.y) 286 result.y = result.y[ind] 287 if result.dy != None: 288 result.dy = numpy.append(self.dy, other.dy) 289 result.dy = result.dy[ind] 290 if result.dx is not None: 291 result.dx = numpy.append(self.dx, other.dx) 292 result.dx = result.dx[ind] 293 if result.dxw is not None: 294 result.dxw = numpy.append(self.dxw, other.dxw) 295 result.dxw = result.dxw[ind] 296 if result.dxl is not None: 297 result.dxl = numpy.append(self.dxl, other.dxl) 298 result.dxl = result.dxl[ind] 299 return result 300 162 301 163 302 class Data2D(PlotData2D, LoadData2D): … … 234 373 # First, check the data compatibility 235 374 dy, dy_other = self._validity_check(other) 236 237 375 result = Data2D(image=None, qx_data=None, qy_data=None, 238 err_image=None, xmin=None, xmax=None,376 q_data=None, err_image=None, xmin=None, xmax=None, 239 377 ymin=None, ymax=None, zmin=None, zmax=None) 240 241 result.clone_without_data(clone=self) 378 result.clone_without_data(len(self.data), self) 242 379 result.copy_from_datainfo(data2d=self) 243 244 for i in range(numpy.size(self.data, 0)): 245 for j in range(numpy.size(self.data, 1)): 246 result.data[i][j] = self.data[i][j] 247 if self.err_data is not None and \ 248 numpy.size(self.data) == numpy.size(self.err_data): 249 result.err_data[i][j] = self.err_data[i][j] 250 251 a = Uncertainty(self.data[i][j], dy[i][j]**2) 252 if isinstance(other, Data2D): 253 b = Uncertainty(other.data[i][j], dy_other[i][j]**2) 254 else: 255 b = other 256 output = operation(a, b) 257 result.data[i][j] = output.x 258 result.err_data[i][j] = math.sqrt(math.fabs(output.variance)) 380 result.xmin = self.xmin 381 result.xmax = self.xmax 382 result.ymin = self.ymin 383 result.ymax = self.ymax 384 if self.dqx_data == None or self.dqy_data == None: 385 result.dqx_data = None 386 result.dqy_data = None 387 else: 388 result.dqx_data = numpy.zeros(len(self.data)) 389 result.dqy_data = numpy.zeros(len(self.data)) 390 for i in range(numpy.size(self.data)): 391 result.data[i] = self.data[i] 392 if self.err_data is not None and \ 393 numpy.size(self.data) == numpy.size(self.err_data): 394 result.err_data[i] = self.err_data[i] 395 if self.dqx_data is not None: 396 result.dqx_data[i] = self.dqx_data[i] 397 if self.dqy_data is not None: 398 result.dqy_data[i] = self.dqy_data[i] 399 result.qx_data[i] = self.qx_data[i] 400 result.qy_data[i] = self.qy_data[i] 401 result.q_data[i] = self.q_data[i] 402 result.mask[i] = self.mask[i] 403 404 a = Uncertainty(self.data[i], dy[i]**2) 405 if isinstance(other, Data2D): 406 b = Uncertainty(other.data[i], dy_other[i]**2) 407 if other.dqx_data is not None and \ 408 result.dqx_data is not None: 409 result.dqx_data[i] *= self.dqx_data[i] 410 result.dqx_data[i] += (other.dqx_data[i]**2) 411 result.dqx_data[i] /= 2 412 result.dqx_data[i] = math.sqrt(result.dqx_data[i]) 413 if other.dqy_data is not None and \ 414 result.dqy_data is not None: 415 result.dqy_data[i] *= self.dqy_data[i] 416 result.dqy_data[i] += (other.dqy_data[i]**2) 417 result.dqy_data[i] /= 2 418 result.dqy_data[i] = math.sqrt(result.dqy_data[i]) 419 else: 420 b = other 421 422 output = operation(a, b) 423 result.data[i] = output.x 424 result.err_data[i] = math.sqrt(math.fabs(output.variance)) 425 return result 426 427 def _perform_union(self, other): 428 """ 429 Perform 2D operations between data sets 430 431 :param other: other data set 432 :param operation: function defining the operation 433 434 """ 435 # First, check the data compatibility 436 self._validity_check_union(other) 437 result = Data2D(image=None, qx_data=None, qy_data=None, 438 q_data=None, err_image=None, xmin=None, xmax=None, 439 ymin=None, ymax=None, zmin=None, zmax=None) 440 length = len(self.data) 441 tot_length = length + len(other.data) 442 result.clone_without_data(tot_length, self) 443 result.xmin = self.xmin 444 result.xmax = self.xmax 445 result.ymin = self.ymin 446 result.ymax = self.ymax 447 if self.dqx_data == None or self.dqy_data == None or \ 448 other.dqx_data == None or other.dqy_data == None : 449 result.dqx_data = None 450 result.dqy_data = None 451 else: 452 result.dqx_data = numpy.zeros(len(self.data) + \ 453 numpy.size(other.data)) 454 result.dqy_data = numpy.zeros(len(self.data) + \ 455 numpy.size(other.data)) 456 457 result.data = numpy.append(self.data, other.data) 458 result.qx_data = numpy.append(self.qx_data, other.qx_data) 459 result.qy_data = numpy.append(self.qy_data, other.qy_data) 460 result.q_data = numpy.append(self.q_data, other.q_data) 461 result.mask = numpy.append(self.mask, other.mask) 462 if result.err_data is not None: 463 result.err_data = numpy.append(self.err_data, other.err_data) 464 if self.dqx_data is not None: 465 result.dqx_data = numpy.append(self.dqx_data, other.dqx_data) 466 if self.dqy_data is not None: 467 result.dqy_data = numpy.append(self.dqy_data, other.dqy_data) 468 259 469 return result 260 470 -
sansguiframe/src/sans/guiframe/gui_manager.py
r9a14138 ra48842a2 194 194 IS_WIN = False 195 195 TIME_FACTOR = 2 196 if int( str(wx.__version__).split('.')[0]) == 2:197 if int( str(wx.__version__).split('.')[1]) < 9:196 if int(wx.__version__.split('.')[0]) == 2: 197 if int(wx.__version__.split('.')[1]) < 9: 198 198 CLOSE_SHOW = False 199 199 … … 831 831 continue 832 832 path = [os.path.abspath(dir)] 833 file = None833 file = '' 834 834 try: 835 835 if toks[1] == '': … … 1787 1787 if self._data_panel is not None and \ 1788 1788 ID in self.plot_panels.keys(): 1789 self._data_panel.cb_plotpanel.Append(str(caption), 1790 self.panels[ID]) 1789 self._data_panel.cb_plotpanel.Append(str(caption), p) 1791 1790 # Do not Hide default panel here... 1792 1791 #self._mgr.GetPane(self.panels["default"].window_name).Hide() … … 1854 1853 log_msg += "Try Data opening...." 1855 1854 logging.info(log_msg) 1856 print log_msg 1857 #self.load_complete(output=output, error_message=error_message, 1858 # message=log_msg, path=path) 1855 self.load_complete(output=output, error_message=error_message, 1856 message=log_msg, path=path) 1859 1857 return 1860 1858 … … 2618 2616 for i in range(len(data.x)): 2619 2617 if has_errors: 2620 if data.dx != [] and data.dx != None:2618 if data.dx != None and data.dx != []: 2621 2619 if data.dx[i] != None: 2622 2620 out.write("%g %g %g %g\n" % (data.x[i], … … 3210 3208 drag 3211 3209 """ 3212 #if self.cpanel_on_focus is not None:3213 #self._toolbar.enable_drag(self.panel_on_focus)3210 if self.cpanel_on_focus is not None: 3211 self._toolbar.enable_drag(self.panel_on_focus) 3214 3212 3215 3213 def enable_reset(self): … … 3419 3417 self.frame.Show() 3420 3418 3421 #if hasattr(self.frame, 'special'):3422 #self.frame.special.SetCurrent()3419 if hasattr(self.frame, 'special'): 3420 self.frame.special.SetCurrent() 3423 3421 self.SetTopWindow(self.frame) 3424 3422
Note: See TracChangeset
for help on using the changeset viewer.