Changeset d15c0202 in sasview


Ignore:
Timestamp:
Jan 13, 2009 5:52:02 PM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
e8d1066
Parents:
e4032d64
Message:

model page change on interface

Location:
sansview/perspectives/fitting
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/fitpage1D.py

    rdb709e4 rd15c0202  
    181181        self.model_list_box={} 
    182182        self.data = data 
    183          
     183        ## Q range 
     184        self.qmin= 0.001 
     185        self.qmax= 0.1 
    184186        """ 
    185187        bs = wx.BoxSizer(wx.VERTICAL) 
     
    536538        print "went here",len(self.parameters) ,self.model 
    537539        if len(self.parameters) !=0 and self.model !=None: 
     540            # Flag to register when a parameter has changed. 
     541            is_modified = False 
    538542            for item in self.parameters: 
    539543                try: 
     
    543547                    name=str(item[0].GetLabelText()) 
    544548                    value= float(item[1].GetValue()) 
    545                     self.model.setParam(name,value)  
     549                    # If the value of the parameter has changed, 
     550                    # update the model and set the is_modified flag 
     551                    if value != self.model.getParam(name): 
     552                        self.model.setParam(name,value) 
     553                        is_modified = True  
    546554                except: 
    547555                     wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 
    548556                            "Drawing  Error:wrong value entered : %s"% sys.exc_value)) 
    549             
    550                 is_modified = False 
    551                 if self.xmin.IsModified(): 
    552                     is_modified = True 
    553                 if self.xmax.IsModified(): 
    554                     is_modified = True 
    555                  
    556                 try:  
    557                      
    558                     if item[1].IsModified() or is_modified: 
    559                         print str(item[0].GetLabelText()),item[1].IsModified() 
    560                         item[1].SetModified(False) 
    561                         name=str(item[0].GetLabelText()) 
    562                         value= float(item[1].GetValue()) 
    563                         self.model.setParam(name,value) 
    564                         self.xmin.SetModified(False) 
    565                         self.xmax.SetModified(False) 
    566                         is_modified=False 
    567                          
    568                         self.manager.redraw_model( 
    569                         float(self.xmin.GetValue()), 
    570                         float(self.xmax.GetValue())  )     
    571              
    572                 except: 
    573                      wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 
    574                             "Model Drawing  Error:wrong value entered : %s"% sys.exc_value)) 
    575              
     557            # Here we should check whether the boundaries have been modified. 
     558            # If qmin and qmax have been modified, update qmin and qmax and  
     559            # set the is_modified flag to True 
     560            if float(self.xmin.GetValue()) != self.qmin: 
     561                self.qmin = float(self.xmin.GetValue()) 
     562                is_modified = True 
     563            if float(self.xmax.GetValue()) != self.qmax: 
     564                self.qmax = float(self.xmax.GetValue()) 
     565                is_modified = True 
     566             
     567            if is_modified: 
     568                self.manager.redraw_model( 
     569                                        qmin=self.qmin, qmax=self.qmax, 
     570                                        ) 
     571            #self.manager.draw_model(self,model,description=None, 
     572            # enable1D=True,qmin=None,qmax=None, qstep=None) 
    576573            
    577574    def select_all_param(self,event):  
  • sansview/perspectives/fitting/fitpage2D.py

    rdb709e4 rd15c0202  
    7272        self.vbox.Add(self.sizer4) 
    7373        self.vbox.Add(self.sizer1) 
     74        ## Q range 
     75        self.qmin= 0.001 
     76        self.qmax= 0.1 
    7477         
    7578        id = wx.NewId() 
     
    496499            and the reset model according to paramaters changes 
    497500        """ 
     501        print "went here",len(self.parameters) ,self.model 
    498502        if len(self.parameters) !=0 and self.model !=None: 
     503            # Flag to register when a parameter has changed. 
     504            is_modified = False 
    499505            for item in self.parameters: 
    500                  
    501                 is_modified = False 
    502                 if self.xmin.IsModified(): 
    503                     is_modified = True 
    504                 if self.xmax.IsModified(): 
    505                     is_modified = True 
    506                  
    507                 try:  
    508                      
    509                     if item[1].IsModified() or is_modified: 
    510                         print str(item[0].GetLabelText()),item[1].IsModified() 
    511                         item[1].SetModified(False) 
    512                         name=str(item[0].GetLabelText()) 
    513                         value= float(item[1].GetValue()) 
     506                try: 
     507                    item[2].Hide() 
     508                    item[3].Clear() 
     509                    item[3].Hide() 
     510                    name=str(item[0].GetLabelText()) 
     511                    value= float(item[1].GetValue()) 
     512                    # If the value of the parameter has changed, 
     513                    # update the model and set the is_modified flag 
     514                    if value != self.model.getParam(name): 
    514515                        self.model.setParam(name,value) 
    515                         self.xmin.SetModified(False) 
    516                         self.xmax.SetModified(False) 
    517                         is_modified=False 
    518                          
    519                         self.manager.redraw_model( 
    520                         float(self.xmin.GetValue()), 
    521                         float(self.xmax.GetValue())  )     
    522              
     516                        is_modified = True  
    523517                except: 
    524518                     wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 
    525                             "Model Drawing  Error:wrong value entered : %s"% sys.exc_value)) 
     519                            "Drawing  Error:wrong value entered : %s"% sys.exc_value)) 
     520            # Here we should check whether the boundaries have been modified. 
     521            # If qmin and qmax have been modified, update qmin and qmax and  
     522            # set the is_modified flag to True 
     523            if float(self.xmin.GetValue()) != self.qmin: 
     524                self.qmin = float(self.xmin.GetValue()) 
     525                is_modified = True 
     526            if float(self.xmax.GetValue()) != self.qmax: 
     527                self.qmax = float(self.xmax.GetValue()) 
     528                is_modified = True 
    526529             
     530            if is_modified: 
     531                 
     532                self.manager.redraw_model(  
     533                                        qmin=self.qmin, qmax=self.qmax, 
     534                                        ) 
     535                #self.manager.draw_model(self,model,description=None, 
     536                # enable1D=True,qmin=None,qmax=None, qstep=None) 
    527537            
    528538    def select_all_param(self,event):  
  • sansview/perspectives/fitting/fitpanel.py

    r86c1832 rd15c0202  
    122122            @param page_title: the name of the page 
    123123        """ 
    124         print "page_title fitpanel", page_title 
     124        #print "page_title fitpanel", page_title 
    125125        if  self.draw_model_name ==None: 
    126126             
  • sansview/perspectives/fitting/fitting.py

    rdb709e4 rd15c0202  
    611611                qmax= 1.0 
    612612            if qstep ==None: 
    613                 qstep =0.001 
     613                qstep =100 
    614614            
    615615            #print "x in data1D",qmin,qmax 
    616             x = numpy.arange(qmin, qmax, qstep)         
     616            #x = numpy.arange(qmin, qmax, qstep)   
     617            x=  numpy.linspace(start= qmin, 
     618                               stop= qmax, 
     619                               num= qstep, 
     620                               endpoint=True 
     621                               )       
    617622            xlen= len(x) 
    618623            y = numpy.zeros(xlen) 
     
    620625                for i in range(xlen): 
    621626                    y[i] = model.run(x[i]) 
    622          
     627                 
    623628                try: 
    624629                    new_plot = Theory1D(x, y) 
     
    635640                for i in range(xlen): 
    636641                    y[i] = model.run(x[i]) 
    637                      
     642                #print x, y    
    638643                try: 
    639644                    new_plot = Theory1D(x, y) 
     
    655660        wx.PostEvent(self.parent, StatusEvent(status="Calc \ 
    656661        complete in %g sec" % elapsed)) 
    657                             
    658         print "complete",output, model,qmin, qmax 
     662        #print "complete",output, model,qmin, qmax 
    659663        data = output 
    660664        theory= Data2D(data) 
     665        #print data.detector 
     666        #theory.detector= data.detector 
     667        from DataLoader.data_info import Detector, Source 
     668         
     669        detector = Detector() 
     670        theory.detector=[] 
     671        theory.detector.append(detector) 
     672             
     673        theory.detector[0].pixel_size.x= 5.0 
     674        theory.detector[0].pixel_size.y= 5.0 
     675        theory.source= Source() 
     676        theory.source.wavelength= 8.4 
     677        theory.detector[0].beam_center.x= 0 
     678        theory.detector[0].beam_center.y= 0 
     679        theory.detector[0].distance= 13705.0 
     680         
    661681        theory.name= model.name 
    662682        theory.group_id ="Model" 
    663683        theory.id ="Model" 
    664         theory.xmin= qmin 
     684        theory.xmin= -qmax 
    665685        theory.xmax= qmax 
    666         theory.ymin= qmin 
     686        theory.ymin= -qmax 
    667687        theory.ymax= qmax 
     688        print "model draw comptele xmax",theory.xmax 
    668689        wx.PostEvent(self.parent, NewPlotEvent(plot=theory, 
    669690                         title="Analytical model 2D %s" %str(model.name))) 
     
    673694    def _draw_model2D(self,model,description=None, enable2D=False,qmin=None,qmax=None, qstep=None): 
    674695        if qmin==None: 
    675             qmin= -0.05 
     696            qmin= 0.0 
    676697        if qmax==None: 
    677698            qmax= 0.05 
    678699        if qstep ==None: 
    679             qstep =0.001 
    680         x = numpy.arange(qmin,qmax, qstep) 
    681         y = numpy.arange(qmin,qmax,qstep) 
     700            qstep =100 
     701        
     702        x=  numpy.linspace(start= -1*qmax, 
     703                               stop= qmax, 
     704                               num= qstep, 
     705                               endpoint=True )   
     706        y = numpy.linspace(start= -1*qmax, 
     707                               stop= qmax, 
     708                               num= qstep, 
     709                               endpoint=True ) 
     710        
    682711        lx = len(x) 
    683712        #print x 
     
    686715        if enable2D: 
    687716            from model_thread import Calc2D 
    688             self.calc_thread = Calc2D(parent =self.parent,x=x, y=y,model= self.model, qmin=qmin,qmax=qmax, 
     717            self.calc_thread = Calc2D(parent =self.parent,x=x, 
     718                                       y=y,model= self.model,  
     719                                       qmin=qmin, 
     720                                       qmax=qmax, 
    689721                            completefn=self.complete, 
    690722                            updatefn=self.update) 
  • sansview/perspectives/fitting/model_thread.py

    rdb709e4 rd15c0202  
    125125        y = self.y 
    126126        output = numpy.zeros((len(x),len(y))) 
     127        """ 
    127128        if self.qmin *self.qmax >=0: 
    128129            print "same signe plotting" 
     
    134135                center_y= (self.qmax -self.qmin)/2 
    135136        else: 
    136             center_x=0 
    137             center_y=0 
     137        """ 
     138        center_x=0 
     139        center_y=0 
    138140        #print "center_x , center_y",center_x , center_y 
    139141        #print "x ",len(x) 
     
    143145        lx = len(self.x) 
    144146        
    145         for i_x in range(int(len(self.x)/2)+1): 
    146             
    147             # Check whether we need to bail out 
    148             self.update(output=output) 
    149             self.isquit() 
    150              
    151             for i_y in range(int(len(self.y)/2)+1): 
     147        for i_x in range(len(self.x)): 
     148            
     149            # Check whether we need to bail out 
     150            self.update(output=output) 
     151            self.isquit() 
     152             
     153            for i_y in range(int(len(self.y))): 
    152154                try: 
    153                     value1 = self.model.runXY([self.x[i_x]-center_x, self.y[i_y]-center_y]) 
    154                     value2 = self.model.runXY([self.x[i_x]-center_x, self.y[lx-i_y-1]-center_y]) 
    155                     value3 = self.model.runXY([self.x[lx-i_x-1]-center_x, self.y[i_y]-center_y]) 
    156                     value4 = self.model.runXY([self.x[lx-i_x-1]-center_x, self.y[lx-i_y-1]-center_y]) 
     155                    if (self.x[i_x]*self.x[i_x]+self.y[i_y]*self.y[i_y]) \ 
     156                    < self.qmin * self.qmin: 
     157                        output[i_x] [i_y]=0 
     158                          
     159                    else: 
     160                        value1 = self.model.runXY([self.x[i_x]-center_x, self.y[i_y]-center_y]) 
     161                        
     162                         
     163                        output[i_x] [i_y]=value1  
     164                        
    157165                     
    158                     output[i_x] [i_y]=value1  
    159                     output[lx-i_x-1][lx-i_y-1] =value4  
    160                     output[i_x] [lx-i_y-1]= value2  
    161                     output[lx-i_x-1][i_y] = value3  
    162                      
    163                    
    164166                except: 
    165167                     wx.PostEvent(self.parent, StatusEvent(status=\ 
  • sansview/perspectives/fitting/modelpage.py

    ra5aaec9 rd15c0202  
    7373        self.sizer4.Add(wx.StaticText(self, -1, 'Min'),(iy, ix),(1,1),\ 
    7474                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    75         ix += 2 
     75        ix += 1 
    7676        self.sizer4.Add(wx.StaticText(self, -1, 'Max'),(iy, ix),(1,1),\ 
     77                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     78        ix += 1 
     79        self.sizer4.Add(wx.StaticText(self, -1, 'Npts'),(iy, ix),(1,1),\ 
    7780                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    7881        ix = 0 
     
    8386        self.qmin= 0.001 
    8487        self.qmax= 0.1 
     88        self.num_points= 100 
    8589         
    8690        ix += 1 
     
    9397         
    9498        
    95         ix += 2 
     99        ix += 1 
    96100        self.xmax    = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 
    97101        self.xmax.SetValue(format_number(self.qmax)) 
     
    99103        self.xmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
    100104        self.xmax.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) 
     105        self.sizer4.Add(self.xmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     106        ix += 1 
     107        self.npts    = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 
     108        self.npts.SetValue(format_number(self.num_points)) 
     109        self.npts.SetToolTipString("Number of point to plot.") 
     110        self.npts.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 
     111        self.npts.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter) 
    101112        
    102         self.sizer4.Add(self.xmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
     113        self.sizer4.Add(self.npts,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    103114        ix = 0 
    104115        iy += 1 
     
    134145        # preview selected model name 
    135146        self.prevmodel_name=name 
    136         print "model view prev_model",name 
     147        #print "model view prev_model",name 
    137148        self.modelbox.SetValue(self.prevmodel_name) 
    138149        # flag to check if the user has selected a new model in the combox box 
     
    388399                self.qmax = float(self.xmax.GetValue()) 
    389400                is_modified = True 
     401            if float(self.npts.GetValue()) !=  self.num_points: 
     402                self.qmax = float(self.npts.GetValue()) 
     403                is_modified = True 
    390404             
    391405            if is_modified: 
    392406                self.manager.draw_model(self.model, self.model.name,  
    393407                                        qmin=self.qmin, qmax=self.qmax, 
     408                                        qstep= self.num_points, 
    394409                                        enable2D=self.enable2D) 
    395410            #self.manager.draw_model(self,model,description=None, 
Note: See TracChangeset for help on using the changeset viewer.