Changeset 917850d in sasview
- Timestamp:
- Dec 2, 2008 10:02:04 AM (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:
- 45c1a35
- Parents:
- a92d51b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/SectorSlicer.py
rb06ef8c r917850d 13 13 import math 14 14 15 15 from sans.guicomm.events import NewPlotEvent, StatusEvent 16 16 import SlicerParameters 17 17 import wx … … 54 54 theta=math.pi/2) 55 55 self.update() 56 #self._post_data()56 self._post_data() 57 57 58 58 # Bind to slice parameter events … … 67 67 self.base.update() 68 68 69 69 70 def update_and_post(self): 70 71 self.update() 71 72 self._post_data() 73 72 74 73 75 def save_data(self, path, image, x, y): … … 87 89 def clear(self): 88 90 self.clear_markers() 89 #self.outer_circle.clear()91 self.outer_circle.clear() 90 92 self.inner_circle.clear() 91 93 #self.base.connect.disconnect() 92 self.base.parent.Unbind(SlicerParameters.EVT_SLICER_PARS)94 #self.base.parent.Unbind(SlicerParameters.EVT_SLICER_PARS) 93 95 94 96 def update(self): … … 102 104 r1=self.inner_circle.get_radius() 103 105 r2=self.outer_circle.get_radius() 104 print"annulus update",r1, r2106 #print"annulus update",r1, r2 105 107 if self.inner_radius.update(r1,r2)==1: 106 print "went here"108 #print "went here" 107 109 self.inner_circle.update(theta1=self.inner_radius.get_radius(), theta2=None) 108 110 self.outer_circle.update(theta1=self.inner_radius.get_radius(),theta2=None) 109 if self.outer_radius.update(r1,r2)==1:110 111 112 if self.outer_radius.update(r1,r2)==1:#self.outer_circle.update(self.outer_radius.get_radius()) 111 113 self.inner_circle.update(theta1=None, theta2=self.outer_radius.get_radius()) 112 114 self.outer_circle.update(theta1=None,theta2=self.outer_radius.get_radius()) 113 def get_data(self, image, x, y): 114 """ 115 Return a 1D vector corresponding to the slice 116 @param image: data matrix 117 @param x: x matrix 118 @param y: y matrix 119 """ 120 # If we have no data, just return 121 if image == None: 122 return 123 124 nbins = self.nbins 125 126 data_x = nbins*[0] 127 data_y = nbins*[0] 128 counts = nbins*[0] 129 length = len(image) 130 131 132 for i_x in range(length): 133 for i_y in range(length): 134 135 q = math.sqrt(x[i_x]*x[i_x] + y[i_y]*y[i_y]) 136 if (q>self.inner_circle._inner_mouse_x \ 137 and q<self.outer_circle._inner_mouse_x) \ 138 or (q<self.inner_circle._inner_mouse_x \ 139 and q>self.outer_circle._inner_mouse_x): 140 141 i_bin = int(math.ceil(nbins*(math.atan2(y[i_y], x[i_x])+math.pi)/(2.0*math.pi)) - 1) 142 143 144 #data_y[i_bin] += math.exp(image[i_x][i_y]) 145 data_y[i_bin] += image[i_y][i_x] 146 counts[i_bin] += 1.0 147 148 for i in range(nbins): 149 data_x[i] = (1.0*i+0.5)*2.0*math.pi/nbins 150 if counts[i]>0: 151 data_y[i] = data_y[i]/counts[i] 152 153 return data_x, data_y 115 154 116 155 117 def save(self, ev): … … 160 122 self.base.freeze_axes() 161 123 self.inner_circle.save(ev) 162 #self.outer_circle.save(ev)124 self.outer_circle.save(ev) 163 125 164 126 def _post_data(self): 165 # Compute data 166 data = self.base.get_corrected_data() 167 # If we have no data, just return 168 if data == None: 169 return 170 171 data_x, data_y = self.get_data(data, self.base.x, self.base.y) 172 173 name = "Ring" 174 if hasattr(self.base, "name"): 175 name += " %s" % self.base.name 176 177 wx.PostEvent(self.base.parent, AddPlotEvent(name=name, 178 x = data_x, 179 y = data_y, 180 qmin = self.inner_circle._inner_mouse_x, 181 qmax = self.outer_circle._inner_mouse_x, 182 yscale = 'log', 183 variable = 'ANGLE', 184 ylabel = "\\rm{Intensity} ", 185 yunits = "cm^{-1}", 186 xlabel = "\\rm{\phi}", 187 xunits = "rad", 188 parent = self.base.__class__.__name__)) 189 127 """ post data""" 128 rmin=self.inner_circle.get_radius() 129 rmax=self.outer_circle.get_radius() 130 phimin=self.inner_radius.get_radius() 131 phimax=self.outer_radius.get_radius() 132 from DataLoader.manipulations import SectorQ, SectorPhi 133 sectQ = SectorQ(r_min=rmin, r_max=rmax, phi_min=phimin, phi_max=phimax) 134 sectorQ = sectQ(self.base.data2D) 135 136 sectPhi = SectorPhi(r_min=rmin, r_max=rmax, phi_min=phimin, phi_max=phimax) 137 sectorPhi = sectPhi(self.base.data2D) 138 from sans.guiframe.dataFitting import Data1D 139 if hasattr(sectorQ,"dxl"): 140 dxl= sectorQ.dxl 141 else: 142 dxl= None 143 if hasattr(sectorQ,"dxw"): 144 dxw= sectorQ.dxw 145 else: 146 dxw= None 147 148 new_plot1 = Data1D(x=sectorQ.x,y=sectorQ.y,dy=sectorQ.dy,dxl=dxl,dxw=dxw) 149 new_plot1.name = "SectorQ ("+ self.base.data2D.name+")" 150 if hasattr(sectorPhi,"dxl"): 151 dxl= sectorPhi.dxl 152 else: 153 dxl= None 154 if hasattr(sectorPhi,"dxw"): 155 dxw= sectorPhi.dxw 156 else: 157 dxw= None 158 new_plot2 = Data1D(x=sectorPhi.x,y=sectorPhi.y,dy=sectorPhi.dy,dxl=dxl,dxw=dxw) 159 new_plot2.name = "SectorPhi ("+ self.base.data2D.name+")" 160 self.plot_data( new_plot1) 161 self.plot_data( new_plot2) 162 163 164 def plot_data(self, new_plot): 165 """ 166 plot a new data 1D corresponding to the phi and Q sector average 167 """ 168 new_plot.source=self.base.data2D.source 169 new_plot.info=self.base.data2D.info 170 new_plot.interactive = True 171 #print "loader output.detector",output.source 172 new_plot.detector =self.base.data2D.detector 173 # If the data file does not tell us what the axes are, just assume... 174 new_plot.xaxis(self.base.data2D._xaxis,self.base.data2D._xunit) 175 new_plot.yaxis(self.base.data2D._yaxis,self.base.data2D._yunit) 176 new_plot.group_id = "sector"+self.base.data2D.name 177 wx.PostEvent(self.base.parent, NewPlotEvent(plot=new_plot, title=new_plot.name)) 178 190 179 191 180 def moveend(self, ev): … … 226 215 227 216 inner = params["inner_radius"] 228 #outer = params["outer_radius"]217 outer = params["outer_radius"] 229 218 self.nbins = int(params["nbins"]) 230 219 self.inner_circle.set_cursor(inner, self.inner_circle._inner_mouse_y) 231 #self.outer_circle.set_cursor(outer, self.outer_circle._inner_mouse_y)232 self._post_data()220 self.outer_circle.set_cursor(outer, self.outer_circle._inner_mouse_y) 221 #self._post_data() 233 222 234 223 def freeze_axes(self):
Note: See TracChangeset
for help on using the changeset viewer.