Changeset 2a8fac1 in sasview
- Timestamp:
- Feb 23, 2009 3:27:12 PM (16 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:
- 18eba35
- Parents:
- 700f9b4
- Location:
- sansview/perspectives/fitting
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitpanel.py
ref8b580 r2a8fac1 40 40 #Creating a page for simultaneous fitting 41 41 from simfitpage import SimultaneousFitPage 42 self.sim_page = SimultaneousFitPage(self, -1)42 self.sim_page = SimultaneousFitPage(self, id=-1) 43 43 self.AddPage(self.sim_page,"Simultaneous Fit") 44 44 45 self._mgr = wx.aui.AuiManager(self)45 self._mgr = self.GetAuiManager() 46 46 47 47 … … 60 60 self.Update() 61 61 self.Center() 62 63 62 64 def onClosePage(self, event): 63 65 self.ToggleWindowStyle(wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB) … … 102 104 except: 103 105 name = 'Fit' 104 106 105 107 if self.fit_page_name != name: 106 108 #self.about_page.Disable() -
sansview/perspectives/fitting/fitproblem.py
r9e27de9 r2a8fac1 16 16 and its name assign example [lineModel, M0] 17 17 """ 18 self. data=None18 self.fit_data=None 19 19 self.theory_name=None 20 20 self.model_list=[] … … 23 23 self.name_per_page=None 24 24 self.smearer= None 25 self.plotted_data=None 25 26 26 27 def set_smearer(self, smearer): … … 46 47 47 48 48 def add_ data(self,data):49 def add_plotted_data(self,data): 49 50 """ 50 51 save a copy of the data select to fit 51 52 @param data: data selected 52 53 """ 53 self.data = data 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 54 61 55 62 def get_model(self): … … 58 65 return self.model_list 59 66 60 def get_ data(self):67 def get_plotted_data(self): 61 68 """ @return: list of data dList""" 62 return self.data 63 64 69 return self.plotted_data 70 71 72 def get_fit_data(self): 73 return self.fit_data 74 75 65 76 def get_theory(self): 66 77 """ @return the name of theory for plotting purpose""" -
sansview/perspectives/fitting/fitting.py
rb5c537f r2a8fac1 7 7 from danse.common.plottools.PlotPanel import PlotPanel 8 8 from sans.guicomm.events import NewPlotEvent, StatusEvent 9 from sans.guicomm.events import EVT_SLICER_PANEL,EVT_MODEL2D_PANEL 9 from sans.guicomm.events import EVT_SLICER_PANEL,EVT_MODEL2D_PANEL,ERR_DATA 10 10 11 11 from sans.fit.AbstractFitEngine import Model,Data,FitData1D,FitData2D … … 49 49 self._fit_engine = 'scipy' 50 50 self.enable_model2D=False 51 51 # list of selcted data 52 self.selected_data_list=[] 52 53 # Log startup 53 54 logging.info("Fitting plug-in started") 54 55 # model 2D view 55 56 self.model2D_id=None 56 57 self.err_dy={} 58 59 def _on_data_error(self, event): 60 self.err_dy= event.err_dy 61 57 62 def populate_menu(self, id, owner): 58 63 """ … … 117 122 "Dialog with fitting parameters ", self._onSelect]] 118 123 else: 119 if item.name==graph.selected_plottable and\ 120 item.__class__.__name__ is "Data1D": 124 #if item.name==graph.selected_plottable and\ 125 # item.__class__.__name__ is "Data1D": 126 if item.name==graph.selected_plottable : 121 127 return [["Select data for Fitting", \ 122 128 "Dialog with fitting parameters ", self._onSelect]] … … 142 148 self.index_theory= 0 143 149 self.parent.Bind(EVT_SLICER_PANEL, self._on_slicer_event) 144 150 self.parent.Bind( ERR_DATA, self._on_data_error) 145 151 146 152 #create the fitting panel … … 202 208 self.panel = event.GetEventObject() 203 209 for item in self.panel.graph.plottables: 210 if item.name == self.panel.graph.selected_plottable: 211 if len(self.err_dy)>0: 212 if item.name in self.err_dy.iterkeys(): 213 dy= self.err_dy[item.name] 214 data= Data1D(x=item.x, y=item.y, dy=dy) 215 data.name=item.name 216 else: 217 if item.dy==None: 218 dy= numpy.zeros(len(item.y)) 219 dy[dy==0]=1 220 print "dy", dy 221 data= Data1D(x=item.x, y=item.y, dy=dy) 222 data.name=item.name 223 else: 224 data= Data1D(x=item.x, y=item.y, dy=item.dy) 225 data.name=item.name 204 226 if item.name == self.panel.graph.selected_plottable or\ 205 227 item.__class__.__name__ is "Data2D": 206 228 #find a name for the page created for notebook 229 print "fitting", self.panel 207 230 try: 208 231 209 page = self.fit_panel.add_fit_page(item) 232 #page = self.fit_panel.add_fit_page(item) 233 page = self.fit_panel.add_fit_page(data) 210 234 #page, model_name = self.fit_panel.add_fit_page(item) 211 235 # add data associated to the page created … … 215 239 self.page_finder[page]= FitProblem() 216 240 #self.page_finder[page].save_model_name(model_name) 217 self.page_finder[page].add_data(item) 241 self.page_finder[page].add_plotted_data(item) 242 self.page_finder[page].add_fit_data(data) 243 244 218 245 wx.PostEvent(self.parent, StatusEvent(status="Page Created")) 219 246 else: 220 247 wx.PostEvent(self.parent, StatusEvent(status="Page was already Created")) 221 248 except: 222 #raise 223 wx.PostEvent(self.parent, StatusEvent(status="Creating Fit page: %s"\ 224 %sys.exc_value)) 249 raise 250 #wx.PostEvent(self.parent, StatusEvent(status="Creating Fit page: %s"\ 251 #%sys.exc_value)) 252 253 225 254 def schedule_for_fit(self,value=0,fitproblem =None): 226 255 """ … … 400 429 # if value.get_scheduled() ==1 : 401 430 value = self.page_finder[current_pg] 402 metadata = value.get_ data()431 metadata = value.get_fit_data() 403 432 list = value.get_model() 404 433 model = list[0] … … 477 506 try: 478 507 if value.get_scheduled()==1: 479 metadata = value.get_ data()508 metadata = value.get_fit_data() 480 509 list = value.get_model() 481 510 model= list[0] … … 629 658 for page in self.page_finder.iterkeys(): 630 659 if page==currpage : 631 data=self.page_finder[page].get_ data()660 data=self.page_finder[page].get_plotted_data() 632 661 list=self.page_finder[page].get_model() 633 662 model=list[0] … … 766 795 self.redraw_model(qmin,qmax) 767 796 return 797 self._draw_model1D(model,name,model.description, enable1D,qmin,qmax, qstep) 768 798 self._draw_model2D(model=model, 769 799 description=model.description, … … 772 802 qmax=qmax, 773 803 qstep=qstep) 774 self._draw_model1D(model,name,model.description, enable1D,qmin,qmax, qstep)804 775 805 776 806 def _draw_model1D(self,model,name,description=None, enable1D=True, … … 803 833 else: 804 834 for i in range(xlen): 805 y[i] = model.run(x[i]) 806 #print x, y 835 y[i] = model.run(x[i]) 807 836 try: 808 837 new_plot = Theory1D(x, y) … … 828 857 829 858 wx.PostEvent(self.parent, StatusEvent(status="Calc \ 830 complete in %g sec" % elapsed, type="stop"))859 complete !" , type="stop")) 831 860 #print "complete",output, model,qmin, qmax 832 861 data = output … … 890 919 theory.ymax= qmax#/math.sqrt(2) 891 920 892 print "model draw comptele xmax",theory.xmax,model.name921 #print "model draw comptele xmax",theory.xmax,model.name 893 922 wx.PostEvent(self.parent, NewPlotEvent(plot=theory, 894 923 title="Analytical model 2D ", reset=True )) … … 898 927 def _draw_model2D(self,model,description=None, enable2D=False, 899 928 qmin=DEFAULT_QMIN, qmax=DEFAULT_QMAX, qstep=DEFAULT_NPTS): 900 929 901 930 x= numpy.linspace(start= -1*qmax, 902 931 stop= qmax, … … 910 939 lx = len(x) 911 940 #print x 912 data=numpy.zeros([len(x),len(y)])941 #data=numpy.zeros([len(x),len(y)]) 913 942 self.model= model 914 943 if enable2D: 915 from sans.guiframe.model_thread import Calc2D 916 self.calc_thread = Calc2D(parent =self.parent,x=x, 917 y=y,model= self.model, 918 qmin=qmin, 919 qmax=qmax, 920 qstep=qstep, 921 completefn=self.complete, 922 updatefn=None) 923 self.calc_thread.queue() 924 self.calc_thread.ready(2.5) 944 try: 945 from sans.guiframe.model_thread import Calc2D 946 print "in draw model 2d ",self.model 947 self.calc_thread = Calc2D(parent =self.parent,x=x, 948 y=y,model= self.model, 949 qmin=qmin, 950 qmax=qmax, 951 qstep=qstep, 952 completefn=self.complete, 953 updatefn=None) 954 self.calc_thread.queue() 955 self.calc_thread.ready(2.5) 956 except: 957 raise 925 958 926 959 def show_panel2D(self, id=None ):
Note: See TracChangeset
for help on using the changeset viewer.