Changeset 9237df4 in sasview for sansview/perspectives/fitting
- Timestamp:
- Jan 26, 2010 2:04:48 PM (15 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:
- 2377cd4
- Parents:
- 693500a
- Location:
- sansview/perspectives/fitting
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/basepage.py
r484faf7 r9237df4 1236 1236 qstep= float(self.num_points), 1237 1237 enable2D=self.enable2D) 1238 1238 print "_draw_model" 1239 for name in self.model.getParamList(): 1240 print name , self.model.getParam(name) 1239 1241 1240 1242 def _set_model_sizer(self,sizer, box_sizer, title="", object=None): -
sansview/perspectives/fitting/fitpage.py
r66c488b r9237df4 20 20 (FitStopEvent, EVT_FIT_STOP) = wx.lib.newevent.NewEvent() 21 21 _BOX_WIDTH = 76 22 22 _DATA_BOX_WIDTH = 300 23 23 import basepage 24 24 from basepage import BasicPage … … 197 197 fill sizer 0 with data info 198 198 """ 199 self.sizer0.Clear(True)200 199 ## no loaded data , don't fill the sizer 201 if self.data== None: 202 self.sizer0.Layout() 203 return 200 if self.data is None: 201 data_min = "" 202 data_max = "" 203 data_name = "" 204 else: 205 data_name = self.data.name 206 #set maximum range for x in linear scale 207 if not hasattr(self.data,"data"): #Display only for 1D data fit 208 # Minimum value of data 209 data_min = min(self.data.x) 210 # Maximum value of data 211 data_max = max(self.data.x) 212 else: 213 ## Minimum value of data 214 data_min = 0 215 x = max(math.fabs(self.data.xmin), math.fabs(self.data.xmax)) 216 y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) 217 ## Maximum value of data 218 data_max = math.sqrt(x*x + y*y) 204 219 205 220 box_description= wx.StaticBox(self, -1, 'Data') 206 221 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 207 222 #---------------------------------------------------------- 208 sizer_data = wx. GridSizer(3, 3,5, 5)223 sizer_data = wx.BoxSizer(wx.HORIZONTAL) 209 224 #Filling the sizer containing data related fields 210 DataSource =wx.StaticText(self, -1,str(self.data.name)) 211 225 #self.dataSource = wx.StaticText(self, -1,str(self.data.name)) 226 self.dataSource = wx.TextCtrl(self, -1) 227 self.dataSource.SetValue(str(data_name)) 228 self.dataSource.SetEditable(False) 229 self.dataSource.SetMinSize((_DATA_BOX_WIDTH, -1)) 212 230 sizer_data.Add(wx.StaticText(self, -1, 'Source Name : ')) 213 sizer_data.Add( DataSource )231 sizer_data.Add(self.dataSource ) 214 232 sizer_data.Add( (0,5) ) 215 233 216 234 #---------sizer 2 draw-------------------------------- 217 #set maximum range for x in linear scale 218 if not hasattr(self.data,"data"): #Display only for 1D data fit 219 # Minimum value of data 220 data_min = min(self.data.x) 221 # Maximum value of data 222 data_max = max(self.data.x) 223 text4_3 = wx.StaticText(self, -1, 'Total Q Range (1/A)', 224 style=wx.ALIGN_LEFT) 225 sizer_data.Add( text4_3 ) 226 sizer_data.Add(wx.StaticText(self, -1, "Min : %s"%str(data_min))) 227 sizer_data.Add(wx.StaticText(self, -1, "Max : %s"%str(data_max))) 228 229 else: 230 ## Minimum value of data 231 data_min= 0 232 x= max(math.fabs(self.data.xmin), math.fabs(self.data.xmax)) 233 y= max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) 234 ## Maximum value of data 235 data_max = math.sqrt(x*x + y*y) 236 237 #For qmin and qmax, do not use format_number 238 #.(If do, qmin and max could be different from what is in the data.) 239 text4_3 = wx.StaticText(self, -1, "Total Q Range (1/A)", 240 style=wx.ALIGN_LEFT) 241 sizer_data.Add( text4_3 ) 242 sizer_data.Add(wx.StaticText(self, -1, "Min : %s"%str(data_min))) 243 sizer_data.Add(wx.StaticText(self, -1, "Max : %s"%str(data_max))) 235 text4_3 = wx.StaticText(self, -1, 'Total Q Range (1/A)', 236 style=wx.ALIGN_LEFT) 237 sizer_range = wx.BoxSizer(wx.HORIZONTAL) 238 sizer_range.Add( text4_3 ,0, wx.RIGHT, 10) 239 self.minimum_q = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20)) 240 self.minimum_q.SetValue(str(data_min)) 241 self.minimum_q.SetEditable(False) 242 self.maximum_q = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 243 self.maximum_q.SetValue(str(data_max)) 244 self.maximum_q.SetEditable(False) 245 sizer_range.Add(wx.StaticText(self, -1, "Min: "),0, wx.LEFT, 10) 246 sizer_range.Add(self.minimum_q,0, wx.LEFT, 10) 247 sizer_range.Add(wx.StaticText(self, -1, "Max: "),0, wx.LEFT, 10) 248 sizer_range.Add(self.maximum_q,0, wx.LEFT, 10) 249 244 250 ## set q range to plot 245 self.qmin_x= data_min 246 self.qmax_x= data_max 247 248 boxsizer1.Add(sizer_data) 251 self.qmin_x = data_min 252 self.qmax_x = data_max 253 254 boxsizer1.Add(sizer_data,0, wx.ALL, 10) 255 boxsizer1.Add(sizer_range, 0 , wx.LEFT, 10) 249 256 #------------------------------------------------------------ 250 257 self.sizer0.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) … … 633 640 except: 634 641 pass 635 if self.model != None:642 if self.model != None: 636 643 try: 637 644 temp_smear= None … … 642 649 ## error occured on chisqr computation 643 650 pass 644 ## set smearing value whether or not the data contain the smearing info 645 self.manager.set_smearer(smearer=temp_smear, qmin= float(self.qmin_x), 651 if self.data is not None: 652 ## set smearing value whether or not the data contain the smearing info 653 self.manager.set_smearer(smearer=temp_smear, qmin= float(self.qmin_x), 646 654 qmax= float(self.qmax_x)) 647 655 evt = ModelEventbox(model=self.model) … … 828 836 829 837 830 def set_data(self, data 838 def set_data(self, data): 831 839 """ 832 840 reset the current data 833 841 """ 834 if data ==None: 835 return 836 self.data =data 837 self.state.data= data 838 self._fill_datainfo_sizer() 842 self.data = data 843 if self.data is None: 844 data_min = "" 845 data_max = "" 846 data_name = "" 847 else: 848 data_name = self.data.name 849 #set maximum range for x in linear scale 850 if not hasattr(self.data,"data"): #Display only for 1D data fit 851 # Minimum value of data 852 data_min = min(self.data.x) 853 # Maximum value of data 854 data_max = max(self.data.x) 855 else: 856 ## Minimum value of data 857 data_min = 0 858 x = max(math.fabs(self.data.xmin), math.fabs(self.data.xmax)) 859 y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) 860 ## Maximum value of data 861 data_max = math.sqrt(x*x + y*y) 862 863 self.dataSource.SetValue(data_name) 864 self.minimum_q.SetValue(str(data_min)) 865 self.maximum_q.SetValue(str(data_max)) 866 self.qmin_x = data_min 867 self.qmax_x = data_max 868 self.state.data = data, data_max 869 print "set_data",data_min 839 870 840 871 def reset_page(self, state,first=False): … … 1023 1054 self._lay_out() 1024 1055 #PostStatusEvent 1025 msg ="Fit completed! "1056 msg = "Fit completed! " 1026 1057 wx.PostEvent(self.manager.parent, StatusEvent(status=msg)) 1027 1058 -
sansview/perspectives/fitting/fitpanel.py
r09ef7d22 r9237df4 167 167 self.Bind(basepage.EVT_PREVIOUS_STATE, self._onUndo) 168 168 self.Bind(basepage.EVT_NEXT_STATE, self._onRedo) 169 169 170 #add default page 171 from hint_fitpage import HintFitPage 172 panel = HintFitPage(self) 173 self.AddPage(page=panel, caption="Hint") 170 174 # increment number for model name 171 175 self.count=0 -
sansview/perspectives/fitting/fitting.py
r1a2dc10 r9237df4 261 261 """ 262 262 self.parent.set_perspective(self.perspective) 263 264 263 265 264 def post_init(self): 266 265 """ … … 272 271 pass 273 272 274 273 def get_tools(self): 274 """ 275 Returns a set of menu entries for tools 276 """ 277 id = wx.NewId() 278 sld_help = "Provides computation related to Scattering Length density" 279 return [("SLD Calculator", sld_help, self.on_calculate_sld)] 280 275 281 def copy_data(self, item, dy=None): 276 282 """ … … 510 516 time.sleep(0.4) 511 517 518 def on_calculate_sld(self, event): 519 """ 520 Compute the scattering length density of molecula 521 """ 522 523 import sld_panel 524 frame = sld_panel.SldWindow(base=self.parent) 525 frame.Show(True) 526 527 512 528 def _onEVT_SLICER_PANEL(self, event): 513 529 """ … … 524 540 self.parent._mgr.Update() 525 541 526 527 542 def _compute_invariant(self, event): 528 543 """ … … 534 549 if plottable.name == self.panel.graph.selected_plottable: 535 550 data = self.copy_data(item= plottable, dy=plottable.dy) 536 537 print "_compute_invariant",data._yaxis 538 print "_compute_invariant" ,data._yunit 551 539 552 from invariant_panel import InvariantWindow 540 553 frame = InvariantWindow(base=self.parent, data=plottable, graph=self.panel.graph) 541 554 frame.Show(True) 542 #from invariant_panel import InvariantDialog 543 #self.invariant_dlg = InvariantDialog(base=self.parent, 544 # data=plottable) 545 #if self.invariant_dlg.ShowModal() == wx.ID_OK: 546 # pass 547 #self.invariant_dlg.Destroy() 548 555 549 556 def _closed_fitpage(self, event): 550 557 """ … … 553 560 """ 554 561 self.fit_panel._close_fitpage(event.data) 555 556 562 557 563 def _add_page_onmenu(self, name,fitproblem=None): … … 712 718 try: 713 719 page = self.fit_panel.add_fit_page(data) 720 page.set_data(data) 714 721 # add data associated to the page created 715 if page != None:722 if page != None: 716 723 #create a fitproblem storing all link to data,model,page creation 717 724 if not page in self.page_finder.keys(): … … 767 774 768 775 cpage.onsetValues(result.fitness,param_name, result.pvec,result.stderr) 769 """ 770 ## plot the current model with new param 771 metadata = self.page_finder[cpage].get_fit_data() 772 model = self.page_finder[cpage].get_model() 773 qmin, qmax= self.page_finder[cpage].get_range() 774 smearer =self.page_finder[cpage].get_smearer() 775 #Replot models 776 msg= "Single Fit completed. plotting... %s:"%model.name 777 wx.PostEvent(self.parent, StatusEvent(status="%s " % msg)) 778 self.draw_model( model=model, data= metadata, smearer= smearer, 779 qmin= qmin, qmax= qmax) 780 """ 776 781 777 except: 782 778 raise … … 939 935 model = evt.model 940 936 941 if model == None:937 if model == None: 942 938 return 943 939 model.origin_name = model.name -
sansview/perspectives/fitting/invariant_panel.py
r1a2dc10 r9237df4 137 137 #Compute qstar extrapolated to low q range 138 138 #Clear the previous extrapolated plot 139 139 print "low_q, high_q",low_q, high_q 140 140 if low_q: 141 141 try: … … 218 218 @param name: Data's name to use for the legend 219 219 """ 220 print "went here " 220 221 plottable = self.graph.get_plottable(name=name) 221 222 if plottable is not None: 222 223 self.graph.delete(plottable) 224 print "name--->",name 223 225 # Create a plottable data 224 226 new_plot = Data1D(x=[], y=[], dx=None, dy=None)
Note: See TracChangeset
for help on using the changeset viewer.