Changeset 38224f10 in sasview


Ignore:
Timestamp:
Dec 18, 2008 10:56:38 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:
b319def8
Parents:
5554566
Message:

add boxdialog need to be remove

Location:
guiframe/local_perspectives/plotting
Files:
1 added
2 edited

Legend:

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

    ref0c170 r38224f10  
    203203        wx.EVT_MENU(self, id, self.onSectorPhi)  
    204204       
     205        id = wx.NewId() 
     206        slicerpop.Append(id, '&Box averaging') 
     207        wx.EVT_MENU(self, id, self.onBoxavg)  
    205208         
    206209        id = wx.NewId() 
     
    367370        wx.PostEvent(self.parent, InternalEvent(slicer= AnnulusInteractor)) 
    368371         
    369         
     372    def onBoxavg(self,event): 
     373        from boxSlicer import BoxInteractor 
     374        self.onClearSlicer(event) 
     375        wx.PostEvent(self.parent, InternalEvent(slicer= BoxInteractor)) 
     376        print "onboxavg",self.slicer 
     377        if self.slicer !=None: 
     378            from SlicerParameters import SlicerParameterPanel 
     379            dialog = SlicerParameterPanel(self.parent, -1, "Slicer Parameters") 
     380            dialog.set_slicer(self.slicer.__class__.__name__, 
     381                            self.slicer.get_params()) 
     382            if dialog.ShowModal() == wx.ID_OK: 
     383                dialog.Destroy()  
    370384    def onClearSlicer(self, event): 
    371385        """ 
  • guiframe/local_perspectives/plotting/boxSlicer.py

    r2d107b8 r38224f10  
    88 
    99# Debug printout 
    10 from config import printEVT 
     10#from config import printEVT 
    1111from BaseInteractor import _BaseInteractor 
    1212from copy import deepcopy 
    1313import math 
    1414 
    15 from Plotter1D import AddPlotEvent 
     15#from Plotter1D import AddPlotEvent 
    1616import SlicerParameters 
    1717import wx 
    1818 
    19 class AnnulusInteractor(_BaseInteractor): 
     19class BoxInteractor(_BaseInteractor): 
    2020    """ 
    2121         Select an annulus through a 2D plot 
    2222    """ 
    23     def __init__(self,base,axes,color='black', zorder=3, x_min=0.025, x_max=0.025, y_min=0.025, y_max=0.025): 
     23    def __init__(self,base,axes,color='black', zorder=3, x_min=0.0025, x_max=0.0025, y_min=0.0025, y_max=0.0025): 
    2424         
    2525        _BaseInteractor.__init__(self, base, axes, color=color) 
     
    2828        self.qmax = self.base.qmax 
    2929        self.connect = self.base.connect 
    30         self.xmin=xmin 
    31         self.ymin=ymin 
    32         self.xmax=xmax 
    33         self.ymax=ymax 
     30        self.xmin=x_min 
     31        self.ymin=y_min 
     32        self.xmax=x_max 
     33        self.ymax=y_max 
    3434        ## Number of points on the plot 
    3535        self.nbins = 20 
    36          
     36        self.count=0 
     37        self.error=0 
    3738        #self.theta3= 2*self.theta2 -self.theta1 
    3839        # Inner circle 
     
    5960         
    6061                       
    61         #self.update() 
    62         self._post_data() 
     62        self.update() 
     63        #self._post_data() 
    6364         
    6465        # Bind to slice parameter events 
     
    6768 
    6869    def _onEVT_SLICER_PARS(self, event): 
    69         printEVT("AnnulusSlicer._onEVT_SLICER_PARS") 
     70        #printEVT("AnnulusSlicer._onEVT_SLICER_PARS") 
    7071        event.Skip() 
    7172        if event.type == self.__class__.__name__: 
     
    9394    def clear(self): 
    9495        self.clear_markers() 
    95         self.outer_circle.clear() 
    96         self.inner_circle.clear() 
     96        self.left_line.clear() 
     97        self.right_line.clear() 
     98        self.top_line.clear() 
     99        self.bottom_line.clear() 
    97100        #self.base.connect.disconnect() 
    98101        self.base.parent.Unbind(SlicerParameters.EVT_SLICER_PARS) 
     
    103106        resetting the widgets. 
    104107        """ 
     108        self.left_line.update() 
     109        self.right_line.update() 
     110        self.top_line.update() 
     111        self.bottom_line.update() 
    105112        if self.left_line.has_move: 
    106113            print "left has moved" 
     
    135142            self.right_line.update(ymin= self.bottom_line.y ,ymax= self.top_line.y) 
    136143             
    137     def get_data(self, image, x, y): 
    138         """  
    139             Return a 1D vector corresponding to the slice 
    140             @param image: data matrix 
    141             @param x: x matrix 
    142             @param y: y matrix 
    143         """ 
    144         # If we have no data, just return 
    145         if image == None: 
    146             return         
    147          
    148         nbins = self.nbins 
    149          
    150         data_x = nbins*[0] 
    151         data_y = nbins*[0] 
    152         counts = nbins*[0] 
    153         length = len(image) 
    154         print "length x , y , image", len(x), len(y), length 
    155          
    156         for i_x in range(length): 
    157             for i_y in range(length): 
    158                          
    159                 q = math.sqrt(x[i_x]*x[i_x] + y[i_y]*y[i_y]) 
    160                 if (q>self.inner_circle._inner_mouse_x \ 
    161                     and q<self.outer_circle._inner_mouse_x) \ 
    162                     or (q<self.inner_circle._inner_mouse_x \ 
    163                     and q>self.outer_circle._inner_mouse_x): 
    164                              
    165                     i_bin = int(math.ceil(nbins*(math.atan2(y[i_y], x[i_x])+math.pi)/(2.0*math.pi)) - 1) 
    166                      
    167                      
    168                     #data_y[i_bin] += math.exp(image[i_x][i_y]) 
    169                     data_y[i_bin] += image[i_y][i_x] 
    170                     counts[i_bin] += 1.0 
    171                      
    172         for i in range(nbins): 
    173             data_x[i] = (1.0*i+0.5)*2.0*math.pi/nbins 
    174             if counts[i]>0: 
    175                 data_y[i] = data_y[i]/counts[i] 
    176          
    177         return data_x, data_y 
    178  
     144     
    179145    def save(self, ev): 
    180146        """ 
     
    188154    def _post_data(self): 
    189155        # Compute data 
    190         data = self.base.get_corrected_data() 
    191         # If we have no data, just return 
    192         if data == None: 
    193             return 
    194  
    195         data_x, data_y = self.get_data(data, self.base.x, self.base.y) 
    196          
    197         name = "Ring" 
    198         if hasattr(self.base, "name"): 
    199             name += " %s" % self.base.name 
    200          
    201         wx.PostEvent(self.base.parent, AddPlotEvent(name=name, 
    202                                                x = data_x, 
    203                                                y = data_y, 
    204                                                qmin = self.inner_circle._inner_mouse_x, 
    205                                                qmax = self.outer_circle._inner_mouse_x, 
    206                                                yscale = 'log', 
    207                                                variable = 'ANGLE', 
    208                                                ylabel = "\\rm{Intensity} ", 
    209                                                yunits = "cm^{-1}", 
    210                                                xlabel = "\\rm{\phi}", 
    211                                                xunits = "rad", 
    212                                                parent = self.base.__class__.__name__)) 
    213                                                 
    214          
     156        data = self.base.data2D 
     157        from DataLoader.manipulations import  Boxavg 
     158        radius = math.sqrt(math.pow(self.qmax,2)+math.pow(self.qmax,2)) 
     159        x_min= self.left_line.x  
     160        x_max= self.right_line.x  
     161        y_min= self.bottom_line.y 
     162        y_max= self.top_line.y 
     163        box =  Boxavg (x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max) 
     164        
     165        self.count, self.error= box(self.base.data2D) 
     166                       
     167                                        
    215168    def moveend(self, ev): 
    216169        self.base.thaw_axes() 
     
    242195    def get_params(self): 
    243196        params = {} 
    244         #params["main_phi"] = self.right_line.get_radius() 
    245         #params["left_phi"] = self.left_line.get_radius() 
    246          
    247         params["nbins"] = self.nbins 
     197        params["x_min"] = self.left_line.x  
     198        params["x_max"] = self.right_line.x  
     199        params["y_min"] = self.bottom_line.y 
     200        params["y_max"] = self.top_line.y 
     201        params["count"] = self.count 
     202        params["error"] = self.error 
    248203        return params 
    249204     
    250205    def set_params(self, params): 
    251206         
    252         main = params["main_phi"]  
    253         left = params["left_phi"]  
     207        x_min = params["x_min"]  
     208        x_max = params["x_max"]  
     209        y_min = params["y_min"] 
     210        y_max = params["y_max"]  
    254211        
    255         self.nbins = int(params["nbins"]) 
    256         #self.main_line.set_cursor(inner, self.inner_circle._inner_mouse_y) 
    257         #self.outer_circle.set_cursor(outer, self.outer_circle._inner_mouse_y) 
     212         
     213        self.left_line.update(ymin= y_min ,ymax= y_max) 
     214        self.right_line.update(ymin= y_min ,ymax= y_max) 
     215        self.top_line.update( xmin= x_min ,xmax= xmax) 
     216        self.bottom_line.update(xmin= xmin ,xmax= xmax) 
    258217        self._post_data() 
    259          
    260218    def freeze_axes(self): 
    261219        self.base.freeze_axes() 
Note: See TracChangeset for help on using the changeset viewer.