Ignore:
Timestamp:
Dec 17, 2008 4:29:39 PM (16 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:
169460a
Parents:
cd84dca
Message:

working on model2D view

File:
1 edited

Legend:

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

    rd250f7d rdc317d1  
    44 
    55from copy import deepcopy  
    6 from danse.common.plottools.plottables import Data1D, Theory1D,Data2D,Theory2D 
     6from danse.common.plottools.plottables import Data1D, Theory1D,Data2D 
    77from danse.common.plottools.PlotPanel import PlotPanel 
    88from sans.guicomm.events import NewPlotEvent, StatusEvent   
     
    9494                return [["Select data  for Fitting",\ 
    9595                          "Dialog with fitting parameters ", self._onSelect]]  
    96             #elif item.__class__.__name__ is "Theory2D": 
    97             #     return [["Line Slicer [Q-view]","Sector Averaging as a function of Q", 
    98             #             self.onLineSlicer], 
    99             #             ["Annulus Slicer [Phi-view]","Sector Averaging as a function of Phi", 
    100             #             self.onLineSlicer]] 
    10196            else: 
    10297                if item.name==graph.selected_plottable and\ 
     
    532527                 
    533528            else: 
    534                 theory=Theory2D(data.data, data.err_data) 
    535                 #theory=Theory2D(data.image, data.err_image) 
     529                theory=Data2D(data.data, data.err_data) 
     530                 
    536531                theory.x_bins= data.x_bins 
    537532                theory.y_bins= data.y_bins 
     
    635630                except: 
    636631                    raise 
    637                  
    638                  
    639                  
    640632    def _draw_model2D(self,model,description=None, enable2D=False,qmin=None,qmax=None, qstep=None): 
    641633        if qmin==None: 
     
    647639        x = numpy.arange(qmin,qmax, qstep) 
    648640        y = numpy.arange(qmin,qmax,qstep) 
    649          
     641        lx = len(x) 
     642        data=numpy.zeros([len(x),len(y)]) 
     643        if enable2D: 
     644            """ 
     645            for i_x in range(int(len(x)/2)): 
     646                if i_x%2==1: 
     647                    continue 
     648            for i_y in range(len(y)): 
     649                try: 
     650                    value = model.runXY([x[i_x], y[i_y]]) 
     651                    #output[i_x][i_y] = value 
     652                    #output[lx-i_x-1][lx-i_y-1] = value 
     653                    data[i_y][i_x] = value 
     654                    data[lx-i_y-1][lx-i_x-1] = value 
     655                except: 
     656                     wx.PostEvent(self.parent, StatusEvent(status="\ 
     657                        Error computing %s at [%g,%g] :%s" %(model.name,x[i_x],y[i_y], sys.exc_value))) 
     658                     
     659            if lx%2==1: 
     660                i_x = int(len(x)/2) 
     661                for i_y in range(len(y)): 
     662                    try: 
     663                        value = model.runXY([x[i_x],y[i_y]]) 
     664                        #output[i_x][i_y] = value 
     665                        data[i_y][i_x] = value 
     666                    except: 
     667                         wx.PostEvent(self.parent, StatusEvent(status="\ 
     668                        Error computing %s at [%g,%g] :%s" %(model.name,x[i_x],y[i_y], sys.exc_value))) 
     669                        
     670            """ 
     671            for i_x in range(int(len(x)/2)): 
     672                """ 
     673                if not i_x%2==1: 
     674                    continue 
     675                """ 
     676                for i_y in range(len(y)): 
     677                    try: 
     678                        value = model.runXY([x[i_x],y[i_y]]) 
     679                        #output[i_x][i_y] = value 
     680                        #output[lx-i_x-1][lx-i_y-1] = value 
     681                        data[i_y][i_x] = value 
     682                        data[lx-i_y-1][lx-i_x-1] = value 
     683                    except: 
     684                         wx.PostEvent(self.parent, StatusEvent(status="\ 
     685                        Error computing %s at [%g,%g] :%s" %(model.name,x[i_x],y[i_y], sys.exc_value))) 
     686                        
     687           
     688 
     689            theory = (data)   
     690            theory.group_id =str(model.name)+" 2D" 
     691            theory.xmin= qmin 
     692            theory.xmax= qmax 
     693            theory.ymin= qmin 
     694            theory.ymax= qmax 
     695            wx.PostEvent(self.parent, NewPlotEvent(plot=theory, title="Analytical model 2D")) 
     696              
     697                 
     698                 
     699    def H_draw_model2D(self,model,description=None, enable2D=False,qmin=None,qmax=None, qstep=None): 
     700        if qmin==None: 
     701            qmin= -0.05 
     702        if qmax==None: 
     703            qmax= 0.05 
     704        if qstep ==None: 
     705            qstep =0.001 
     706        x = numpy.arange(qmin,qmax, qstep) 
     707        y = numpy.arange(qmin,qmax,qstep) 
     708        lx = len(self.x) 
    650709        if enable2D: 
    651710            data=numpy.zeros([len(x),len(y)]) 
     
    657716                         wx.PostEvent(self.parent, StatusEvent(status="\ 
    658717                        Model 2D cannot be plot %g %s %s" %(data[i][j],model.name, sys.exc_value))) 
    659             theory = Theory2D(data)   
     718            theory = Data2D(data)   
    660719            theory.group_id =str(model.name)+" 2D" 
    661720            theory.xmin= qmin 
     
    664723            theory.ymax= qmax 
    665724            wx.PostEvent(self.parent, NewPlotEvent(plot=theory, title="Analytical model 2D")) 
     725     
     726     
    666727    def on_draw_model2D(self, event): 
    667728        """ 
Note: See TracChangeset for help on using the changeset viewer.