Changeset 38224f10 in sasview
- Timestamp:
- Dec 18, 2008 10:56:38 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:
- b319def8
- Parents:
- 5554566
- Location:
- guiframe/local_perspectives/plotting
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/Plotter2D.py
ref0c170 r38224f10 203 203 wx.EVT_MENU(self, id, self.onSectorPhi) 204 204 205 id = wx.NewId() 206 slicerpop.Append(id, '&Box averaging') 207 wx.EVT_MENU(self, id, self.onBoxavg) 205 208 206 209 id = wx.NewId() … … 367 370 wx.PostEvent(self.parent, InternalEvent(slicer= AnnulusInteractor)) 368 371 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() 370 384 def onClearSlicer(self, event): 371 385 """ -
guiframe/local_perspectives/plotting/boxSlicer.py
r2d107b8 r38224f10 8 8 9 9 # Debug printout 10 from config import printEVT10 #from config import printEVT 11 11 from BaseInteractor import _BaseInteractor 12 12 from copy import deepcopy 13 13 import math 14 14 15 from Plotter1D import AddPlotEvent15 #from Plotter1D import AddPlotEvent 16 16 import SlicerParameters 17 17 import wx 18 18 19 class AnnulusInteractor(_BaseInteractor):19 class BoxInteractor(_BaseInteractor): 20 20 """ 21 21 Select an annulus through a 2D plot 22 22 """ 23 def __init__(self,base,axes,color='black', zorder=3, x_min=0.0 25, 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): 24 24 25 25 _BaseInteractor.__init__(self, base, axes, color=color) … … 28 28 self.qmax = self.base.qmax 29 29 self.connect = self.base.connect 30 self.xmin=x min31 self.ymin=y min32 self.xmax=x max33 self.ymax=y max30 self.xmin=x_min 31 self.ymin=y_min 32 self.xmax=x_max 33 self.ymax=y_max 34 34 ## Number of points on the plot 35 35 self.nbins = 20 36 36 self.count=0 37 self.error=0 37 38 #self.theta3= 2*self.theta2 -self.theta1 38 39 # Inner circle … … 59 60 60 61 61 #self.update()62 self._post_data()62 self.update() 63 #self._post_data() 63 64 64 65 # Bind to slice parameter events … … 67 68 68 69 def _onEVT_SLICER_PARS(self, event): 69 printEVT("AnnulusSlicer._onEVT_SLICER_PARS")70 #printEVT("AnnulusSlicer._onEVT_SLICER_PARS") 70 71 event.Skip() 71 72 if event.type == self.__class__.__name__: … … 93 94 def clear(self): 94 95 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() 97 100 #self.base.connect.disconnect() 98 101 self.base.parent.Unbind(SlicerParameters.EVT_SLICER_PARS) … … 103 106 resetting the widgets. 104 107 """ 108 self.left_line.update() 109 self.right_line.update() 110 self.top_line.update() 111 self.bottom_line.update() 105 112 if self.left_line.has_move: 106 113 print "left has moved" … … 135 142 self.right_line.update(ymin= self.bottom_line.y ,ymax= self.top_line.y) 136 143 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 179 145 def save(self, ev): 180 146 """ … … 188 154 def _post_data(self): 189 155 # 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 215 168 def moveend(self, ev): 216 169 self.base.thaw_axes() … … 242 195 def get_params(self): 243 196 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 248 203 return params 249 204 250 205 def set_params(self, params): 251 206 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"] 254 211 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) 258 217 self._post_data() 259 260 218 def freeze_axes(self): 261 219 self.base.freeze_axes()
Note: See TracChangeset
for help on using the changeset viewer.