Ignore:
Timestamp:
Jan 19, 2009 11:39:18 AM (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:
48112ab
Parents:
a2c38de
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/local_perspectives/plotting/boxSlicer.py

    raa1b747 rffd23b5  
    1313import math 
    1414 
    15 #from Plotter1D import AddPlotEvent 
     15from sans.guicomm.events import NewPlotEvent, StatusEvent 
    1616import SlicerParameters 
    1717import wx 
     
    2828        self.markers = [] 
    2929        self.axes = axes 
    30         self.qmax = self.base.qmax 
     30        self.qmax = self.base.data2D.xmax 
    3131        self.connect = self.base.connect 
    3232        self.x= x_max 
     
    3535        self.theta2= math.pi/3 
    3636        ## Number of points on the plot 
    37         self.nbins = 20 
     37        self.nbins = 30 
    3838        self.count=0 
    3939        self.error=0 
    40          
     40        self.averager=None 
    4141        self.left_line = VerticalLine(self, self.base.subplot,color='blue',  
    4242                                      zorder=zorder, 
     
    4545                                        xmin= -self.x, 
    4646                                        xmax= -self.x) 
    47         self.left_line.qmax = self.base.qmax 
     47        self.left_line.qmax = self.qmax 
    4848         
    4949        self.right_line= VerticalLine(self, self.base.subplot,color='black',  
     
    5353                                     xmin= self.x, 
    5454                                     xmax= self.x) 
    55         self.right_line.qmax = self.base.qmax 
     55        self.right_line.qmax = self.qmax 
    5656         
    5757        self.top_line= HorizontalLine(self, self.base.subplot,color='green',  
     
    6161                                      ymin= self.y, 
    6262                                      ymax= self.y) 
    63         self.top_line.qmax= self.base.qmax 
     63        self.top_line.qmax= self.qmax 
    6464         
    6565        self.bottom_line= HorizontalLine(self, self.base.subplot,color='gray',  
     
    6969                                      ymin= -self.y, 
    7070                                      ymax= -self.y) 
    71         self.bottom_line.qmax= self.base.qmax 
     71        self.bottom_line.qmax= self.qmax 
    7272         
    7373        self.update() 
     
    104104         
    105105    def clear(self): 
     106        self.averager=None 
    106107        self.clear_markers() 
    107108        self.left_line.clear() 
     
    171172        self.top_line.save(ev) 
    172173        self.bottom_line.save(ev) 
    173  
     174    def _post_data(self): 
     175        pass 
     176         
     177     
     178    def post_data(self,new_slab=None , nbins=None): 
     179        """ post data averaging in Q""" 
     180        x_min= min(self.left_line.x1, self.right_line.x1) 
     181        x_max= max(self.left_line.x1, self.right_line.x1) 
     182         
     183        y_min= min(self.top_line.y1, self.bottom_line.y1) 
     184        y_max= max(self.top_line.y1, self.bottom_line.y1)   
     185         
     186        if nbins !=None: 
     187            self.nbins 
     188        if self.averager==None: 
     189            if new_slab ==None: 
     190                raise ValueError,"post data:cannot average , averager is empty" 
     191            self.averager= new_slab 
     192        bin_width= (x_max + math.fabs(x_min))/self.nbins 
     193         
     194        box = self.averager( x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, 
     195                         bin_width=bin_width) 
     196         
     197        boxavg = box(self.base.data2D) 
     198         
     199        from sans.guiframe.dataFitting import Data1D 
     200        if hasattr(boxavg,"dxl"): 
     201            dxl= boxavg.dxl 
     202        else: 
     203            dxl= None 
     204        if hasattr(boxavg,"dxw"): 
     205            dxw=boxavg.dxw 
     206        else: 
     207            dxw= None 
     208        
     209        new_plot = Data1D(x=boxavg.x,y=boxavg.y,dy=boxavg.dy,dxl=dxl,dxw=dxw) 
     210        new_plot.name = str(self.averager.__name__) +"("+ self.base.data2D.name+")" 
     211         
     212        
     213 
     214        new_plot.source=self.base.data2D.source 
     215        new_plot.info=self.base.data2D.info 
     216        new_plot.interactive = True 
     217        #print "loader output.detector",output.source 
     218        new_plot.detector =self.base.data2D.detector 
     219        # If the data file does not tell us what the axes are, just assume... 
     220        new_plot.xaxis("\\rm{Q}", 'rad') 
     221        new_plot.yaxis("\\rm{Intensity} ","cm^{-1}") 
     222        new_plot.group_id = str(self.averager.__name__)+self.base.data2D.name 
     223        new_plot.id = str(self.averager.__name__) 
     224        wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot, 
     225                                                 title=str(self.averager.__name__) )) 
     226         
     227         
    174228    def _post_data(self): 
    175229        # Compute data 
     
    220274        params["x_max"]= math.fabs(self.right_line.x1) 
    221275        params["y_max"]= math.fabs(self.top_line.y1) 
    222          
     276        params["nbins"]= self.nbins 
    223277        params["errors"] = self.error 
    224278        params["count"]= self.count 
     
    229283        self.x = float(math.fabs(params["x_max"])) 
    230284        self.y = float(math.fabs(params["y_max"] )) 
    231          
     285        self.nbins=params["nbins"] 
    232286        self.left_line.update(xmin= -1*self.x, 
    233287                              xmax = -1*self.x, 
     
    249303                                 ymax= -1*self.y) 
    250304        
    251         self._post_data() 
     305        self.post_data( nbins=None) 
    252306    def freeze_axes(self): 
    253307        self.base.freeze_axes() 
     
    503557         
    504558 
    505          
     559class BoxInteractorX(BoxInteractor): 
     560    def __init__(self,base,axes,color='black', zorder=3): 
     561        BoxInteractor.__init__(self, base, axes, color=color) 
     562        self.base=base 
     563        self._post_data() 
     564    def _post_data(self): 
     565        from DataLoader.manipulations import SlabX 
     566        self.post_data(SlabX )    
     567         
     568 
     569class BoxInteractorY(BoxInteractor): 
     570    def __init__(self,base,axes,color='black', zorder=3): 
     571        BoxInteractor.__init__(self, base, axes, color=color) 
     572        self.base=base 
     573        self._post_data() 
     574    def _post_data(self): 
     575        from DataLoader.manipulations import SlabY 
     576        self.post_data(SlabY )    
     577         
     578         
Note: See TracChangeset for help on using the changeset viewer.