Changeset ba1f0b2 in sasview for sansview/perspectives/fitting
- Timestamp:
- Apr 18, 2011 8:22:51 AM (14 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:
- 1a74523
- Parents:
- 4bd492f
- Location:
- sansview/perspectives/fitting
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r69f9084 rba1f0b2 2503 2503 else: 2504 2504 name = self.model.__class__.__name__ 2505 print "name",name2506 2505 2507 2506 frame = HelpWindow(None, -1, pageToOpen=model_path) -
sansview/perspectives/fitting/fitpage.py
r06aa2eeb rba1f0b2 16 16 _BOX_WIDTH = 76 17 17 _DATA_BOX_WIDTH = 300 18 SMEAR_SIZE_L = 0.00 519 SMEAR_SIZE_H = 0.00 618 SMEAR_SIZE_L = 0.00 19 SMEAR_SIZE_H = 0.00 20 20 21 21 import basepage … … 72 72 73 73 """ 74 if self.data.__class__.__name__ =="Data2D": 74 if self.data.__class__.__name__ == "Data2D" or \ 75 self.enable2D: 75 76 return True 76 77 return False … … 100 101 101 102 # Check if data is 2D 102 if self.data.__class__.__name__ == 'Data2D': 103 if self.data.__class__.__name__ == "Data2D" or \ 104 self.enable2D: 103 105 is_2Ddata = True 104 106 … … 315 317 316 318 #check if it is 2D data 317 if self.data.__class__.__name__ == 'Data2D': 319 if self.data.__class__.__name__ == "Data2D" or \ 320 self.enable2D: 318 321 is_2Ddata = True 319 322 … … 758 761 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 759 762 5) 760 if self.data.__class__.__name__ =="Data2D": 763 if self.data.__class__.__name__ == "Data2D" or \ 764 self.enable2D: 761 765 cb.Show(True) 762 766 elif cb.IsShown(): … … 769 773 ctl1.SetToolTipString(poly_tip) 770 774 ctl1.SetValue(str (format_number(value, True))) 771 if self.data.__class__.__name__ =="Data2D": 775 if self.data.__class__.__name__ == "Data2D" or \ 776 self.enable2D: 772 777 if first_orient: 773 778 values.SetLabel('PD[ratio], Sig[deg]') … … 820 825 ctl4.Hide() 821 826 822 if self.data.__class__.__name__ =="Data2D": 827 if self.data.__class__.__name__ == "Data2D" or \ 828 self.enable2D: 823 829 ctl3.Show(True) 824 830 ctl4.Show(True) … … 832 838 833 839 Tctl.SetValue(str (format_number(value))) 834 if self.data.__class__.__name__ =="Data2D": 840 if self.data.__class__.__name__ == "Data2D" or \ 841 self.enable2D: 835 842 Tctl.Show(True) 836 843 else: … … 851 858 852 859 Tct2.SetValue(str (format_number(value))) 853 if self.data.__class__.__name__ =="Data2D": 860 if self.data.__class__.__name__ == "Data2D" or \ 861 self.enable2D: 854 862 Tct2.Show(True) 855 863 else: … … 880 888 text2, ctl2, ctl3, ctl4, disp_box]) 881 889 882 if self.data.__class__.__name__ =="Data2D": 890 if self.data.__class__.__name__ == "Data2D" or \ 891 self.enable2D: 883 892 disp_box.Show(True) 884 893 else: … … 1117 1126 flag1 = self.update_pinhole_smear() 1118 1127 flag = flag or flag1 1119 elif self.data.__class__.__name__ !="Data2D": 1128 elif self.data.__class__.__name__ != "Data2D" and \ 1129 not self.enable2D: 1120 1130 self._manager.set_smearer(smearer=temp_smearer, 1131 enable2D=self.enable2D, 1121 1132 uid=self.uid, 1122 1133 qmin= float(self.qmin_x), … … 1216 1227 # check for 2d 1217 1228 if self.data is not None: 1218 if self.data.__class__.__name__ =="Data2D": 1229 if self.data.__class__.__name__ == "Data2D" or \ 1230 self.enable2D: 1219 1231 # set mask 1220 1232 radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + … … 1268 1280 for item in self.parameters: 1269 1281 #Skip t ifhe angle parameters if 1D data 1270 if self.data.__class__.__name__ !="Data2D": 1282 if self.data.__class__.__name__ != "Data2D" and \ 1283 not self.enable2D: 1271 1284 if item in self.orientation_params: 1272 1285 continue … … 1283 1296 for item in self.fittable_param: 1284 1297 #Skip t ifhe angle parameters if 1D data 1285 if self.data.__class__.__name__ !="Data2D": 1298 if self.data.__class__.__name__ != "Data2D" and \ 1299 not self.enable2D: 1286 1300 if item in self.orientation_params: 1287 1301 continue … … 1324 1338 if self.data is None: 1325 1339 return 1326 elif self.data.__class__.__name__ == 'Data2D': 1340 elif self.data.__class__.__name__ == "Data2D" or \ 1341 self.enable2D: 1327 1342 if data.dqx_data == None or data.dqy_data ==None: 1328 1343 return … … 1537 1552 if data is None: 1538 1553 return 1539 self.smearer = smear_selection( self.data, self.model)1554 self.smearer = smear_selection(data, self.model) 1540 1555 self.disable_smearer.SetValue(True) 1541 1556 if self.smearer == None: … … 1571 1586 self._set_save_flag(True) 1572 1587 self._set_preview_flag(True) 1588 1573 1589 self._set_smear(data) 1574 1590 # more disables for 2D 1575 if self.data.__class__.__name__ =="Data2D": 1591 if self.data.__class__.__name__ == "Data2D" or \ 1592 self.enable2D: 1576 1593 self.slit_smearer.Disable() 1594 self.pinhole_smearer.Enable(True) 1577 1595 self.default_mask = copy.deepcopy(self.data.mask) 1578 1596 else: … … 1683 1701 npts2fit = 0 1684 1702 qmin,qmax = self.get_range() 1685 if self.data.__class__.__name__ =="Data2D": 1703 if self.data.__class__.__name__ == "Data2D" or \ 1704 self.enable2D: 1686 1705 radius= numpy.sqrt( self.data.qx_data*self.data.qx_data + 1687 1706 self.data.qy_data*self.data.qy_data ) … … 1719 1738 return self.param_toFit 1720 1739 else: 1721 raise ValueError,"missing parameter to fit" 1740 msg = "missing parameters to fit" 1741 wx.MessageBox(msg, 'warning') 1742 return False 1743 #raise ValueError,"missing parameters to fit" 1722 1744 1723 1745 def onsetValues(self, chisqr, p_name, out, cov): … … 2000 2022 ## set smearing value whether or not the data contain the smearing info 2001 2023 self._manager.set_smearer(smearer=self.current_smearer, 2024 enable2D=self.enable2D, 2002 2025 qmin=float(self.qmin_x), 2003 2026 qmax= float(self.qmax_x), … … 2134 2157 of the values entered for slit smear 2135 2158 """ 2136 if self.data.__class__.__name__ == "Data2D": 2159 if self.data.__class__.__name__ == "Data2D" or \ 2160 self.enable2D: 2137 2161 return 2138 2162 temp_smearer = None … … 2172 2196 ## set smearing value whether or not the data contain the smearing info 2173 2197 self._manager.set_smearer(smearer=self.current_smearer, 2198 enable2D=self.enable2D, 2174 2199 qmin=float(self.qmin_x), 2175 2200 qmax= float(self.qmax_x), … … 2259 2284 self.Layout() 2260 2285 ## set smearing value whether or not the data contain the smearing info 2261 self._manager.set_smearer(uid=self.uid, smearer=temp_smearer, qmin= float(self.qmin_x), 2286 self._manager.set_smearer(uid=self.uid, smearer=temp_smearer, 2287 enable2D=self.enable2D, 2288 qmin= float(self.qmin_x), 2262 2289 qmax= float(self.qmax_x), draw=True) 2263 2264 ##Calculate chi22265 #self.compute_chisqr(smearer= temp_smearer)2266 2290 2267 2291 self.state.enable_smearer= self.enable_smearer.GetValue() … … 2300 2324 for item in self.parameters: 2301 2325 ## for data2D select all to fit 2302 if self.data.__class__.__name__=="Data2D": 2326 if self.data.__class__.__name__== "Data2D" or \ 2327 self.enable2D: 2303 2328 item[0].SetValue(True) 2304 2329 self.param_toFit.append(item ) … … 2310 2335 #if len(self.fittable_param)>0: 2311 2336 for item in self.fittable_param: 2312 if self.data.__class__.__name__=="Data2D": 2337 if self.data.__class__.__name__== "Data2D" or \ 2338 self.enable2D: 2313 2339 item[0].SetValue(True) 2314 2340 self.param_toFit.append(item ) … … 2353 2379 for item in self.parameters: 2354 2380 #Skip t ifhe angle parameters if 1D data 2355 if self.data.__class__.__name__ !="Data2D": 2381 if self.data.__class__.__name__ != "Data2D" and\ 2382 not self.enable2D: 2356 2383 if item in self.orientation_params: 2357 2384 continue … … 2369 2396 for item in self.fittable_param: 2370 2397 #Skip t ifhe angle parameters if 1D data 2371 if self.data.__class__.__name__ !="Data2D": 2398 if self.data.__class__.__name__ != "Data2D" and\ 2399 not self.enable2D: 2372 2400 if item in self.orientation_params: 2373 2401 continue … … 2381 2409 2382 2410 #Calculate num. of angle parameters 2383 if self.data.__class__.__name__ =="Data2D": 2411 if self.data.__class__.__name__ == "Data2D" or \ 2412 self.enable2D: 2384 2413 len_orient_para = 0 2385 2414 else: … … 2634 2663 sizer.Add(orient_angle,(iy, ix),(1,1), 2635 2664 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 2636 if not self.data.__class__.__name__ =="Data2D": 2665 if not self.data.__class__.__name__ == "Data2D" and \ 2666 not self.enable2D: 2637 2667 orient_angle.Hide() 2638 2668 else: … … 2655 2685 cb.SetToolTipString("Check mark to fit") 2656 2686 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 2657 if self.data.__class__.__name__ =="Data2D": 2687 if self.data.__class__.__name__ == "Data2D" or \ 2688 self.enable2D: 2658 2689 cb.Show(True) 2659 2690 else: … … 2669 2700 ctl1.SetToolTipString("Hit 'Enter' after typing.") 2670 2701 ctl1.SetValue(format_number(value, True)) 2671 if self.data.__class__.__name__ =="Data2D": 2702 if self.data.__class__.__name__ == "Data2D" or \ 2703 self.enable2D: 2672 2704 ctl1.Show(True) 2673 2705 else: … … 2705 2737 ctl4.Hide() 2706 2738 2707 if self.data.__class__.__name__ =="Data2D": 2739 if self.data.__class__.__name__ == "Data2D" or \ 2740 self.enable2D: 2708 2741 ctl3.Show(True) 2709 2742 ctl4.Show(True) … … 2717 2750 else: 2718 2751 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 2719 if self.data.__class__.__name__ =="Data2D": 2752 if self.data.__class__.__name__ == "Data2D" or \ 2753 self.enable2D: 2720 2754 units.Show(True) 2721 2755 … … 2789 2823 self.model_view.SetLabel("Switch to 1D") 2790 2824 self.enable2D = True 2825 2791 2826 else: 2792 2827 self.model_view.SetLabel("Switch to 2D") 2793 2828 self.enable2D = False 2829 2830 self.set_model_param_sizer(self.model) 2831 self._set_sizer_dispersion() 2794 2832 self._draw_model() 2795 2833 2834 2835 self.state.enable2D = copy.deepcopy(self.enable2D) 2836 2796 2837 class BGTextCtrl(wx.TextCtrl): 2797 2838 """ -
sansview/perspectives/fitting/fitproblem.py
re88ebfd rba1f0b2 29 29 self.qmax = None 30 30 31 # 1D or 2D 32 self.enable2D = False 33 31 34 def clone(self): 32 35 """ … … 48 51 obj.qmin = copy.deepcopy(self.qmin) 49 52 obj.qmax = copy.deepcopy(self.qmax) 53 obj.enable2D = copy.deepcopy(self.enable2D) 50 54 return obj 51 55 … … 112 116 """ 113 117 self.theory_data = copy.deepcopy(data) 114 118 119 def set_enable2D(self, enable2D): 120 """ 121 """ 122 self.enable2D = enable2D 123 115 124 def get_theory_data(self): 116 125 """ … … 191 200 """ 192 201 return self.fit_tab_caption 202 203 def get_enable2D(self): 204 """ 205 """ 206 return self.enable2D 193 207 194 -
sansview/perspectives/fitting/fitting.py
rf932c02 rba1f0b2 486 486 panel. _on_fit_complete() 487 487 488 def set_smearer(self, uid, smearer, qmin=None, qmax=None, draw=True): 488 def set_smearer(self, uid, smearer, qmin=None, qmax=None, draw=True, 489 enable2D=False): 489 490 """ 490 491 Get a smear object and store it to a fit problem … … 497 498 raise ValueError, msg 498 499 self.page_finder[uid].set_smearer(smearer) 500 self.page_finder[uid].set_enable2D(enable2D) 499 501 if draw: 500 502 ## draw model 1D with smeared data … … 503 505 if model is None: 504 506 return 507 enable1D = True 508 enable2D = self.page_finder[uid].get_enable2D() 509 if enable2D: 510 enable1D = False 511 505 512 ## if user has already selected a model to plot 506 513 ## redraw the model with data smeared 507 514 smear = self.page_finder[uid].get_smearer() 508 515 self.draw_model(model=model, data=data, page_id=uid, smearer=smear, 516 enable1D=enable1D, enable2D=enable2D, 509 517 qmin=qmin, qmax=qmax) 510 518 … … 533 541 if data.__class__.__name__ == "Data1D" or not enable2D: 534 542 ## draw model 1D with no loaded data 535 536 543 self._draw_model1D(model=model, 537 544 data=data, … … 547 554 else: 548 555 ## draw model 2D with no initial data 549 556 self._draw_model2D(model=model, 550 557 page_id=page_id, 551 558 data=data, … … 595 602 page = self.fit_panel.get_page_by_id(page_id) 596 603 templist = page.get_param_list() 604 # missing fit parameters 605 #if not templist: 606 # return 607 # have the list 597 608 for element in templist: 598 609 name = str(element[1]) … … 607 618 current_page_id = page_id 608 619 except: 609 raise610 #msg= "%s error: %s" % (engineType, sys.exc_value)611 #wx.PostEvent(self.parent, StatusEvent(status=msg, info="error",612 #type="stop"))613 #return620 #raise 621 msg= "%s error: %s" % (engineType, sys.exc_value) 622 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error", 623 type="stop")) 624 return 614 625 ## If a thread is already started, stop it 615 626 #if self.calc_fit!= None and self.calc_fit.isrunning(): … … 1083 1094 if model == None: 1084 1095 return 1085 1096 1086 1097 if self.page_finder[uid].get_model() is None: 1087 1098 model.name = "M" + str(self.index_model) … … 1392 1403 if (self.calc_2D is not None) and self.calc_2D.isrunning(): 1393 1404 self.calc_2D.stop() 1394 1395 1405 self.calc_2D = Calc2D(x=x, 1396 1406 y=y,
Note: See TracChangeset
for help on using the changeset viewer.