Changeset ffd23b5 in sasview for guiframe/local_perspectives/plotting/boxSlicer.py
- Timestamp:
- Jan 19, 2009 11:39:18 AM (15 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:
- 48112ab
- Parents:
- a2c38de
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/boxSlicer.py
raa1b747 rffd23b5 13 13 import math 14 14 15 #from Plotter1D import AddPlotEvent15 from sans.guicomm.events import NewPlotEvent, StatusEvent 16 16 import SlicerParameters 17 17 import wx … … 28 28 self.markers = [] 29 29 self.axes = axes 30 self.qmax = self.base. qmax30 self.qmax = self.base.data2D.xmax 31 31 self.connect = self.base.connect 32 32 self.x= x_max … … 35 35 self.theta2= math.pi/3 36 36 ## Number of points on the plot 37 self.nbins = 2037 self.nbins = 30 38 38 self.count=0 39 39 self.error=0 40 40 self.averager=None 41 41 self.left_line = VerticalLine(self, self.base.subplot,color='blue', 42 42 zorder=zorder, … … 45 45 xmin= -self.x, 46 46 xmax= -self.x) 47 self.left_line.qmax = self. base.qmax47 self.left_line.qmax = self.qmax 48 48 49 49 self.right_line= VerticalLine(self, self.base.subplot,color='black', … … 53 53 xmin= self.x, 54 54 xmax= self.x) 55 self.right_line.qmax = self. base.qmax55 self.right_line.qmax = self.qmax 56 56 57 57 self.top_line= HorizontalLine(self, self.base.subplot,color='green', … … 61 61 ymin= self.y, 62 62 ymax= self.y) 63 self.top_line.qmax= self. base.qmax63 self.top_line.qmax= self.qmax 64 64 65 65 self.bottom_line= HorizontalLine(self, self.base.subplot,color='gray', … … 69 69 ymin= -self.y, 70 70 ymax= -self.y) 71 self.bottom_line.qmax= self. base.qmax71 self.bottom_line.qmax= self.qmax 72 72 73 73 self.update() … … 104 104 105 105 def clear(self): 106 self.averager=None 106 107 self.clear_markers() 107 108 self.left_line.clear() … … 171 172 self.top_line.save(ev) 172 173 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 174 228 def _post_data(self): 175 229 # Compute data … … 220 274 params["x_max"]= math.fabs(self.right_line.x1) 221 275 params["y_max"]= math.fabs(self.top_line.y1) 222 276 params["nbins"]= self.nbins 223 277 params["errors"] = self.error 224 278 params["count"]= self.count … … 229 283 self.x = float(math.fabs(params["x_max"])) 230 284 self.y = float(math.fabs(params["y_max"] )) 231 285 self.nbins=params["nbins"] 232 286 self.left_line.update(xmin= -1*self.x, 233 287 xmax = -1*self.x, … … 249 303 ymax= -1*self.y) 250 304 251 self. _post_data()305 self.post_data( nbins=None) 252 306 def freeze_axes(self): 253 307 self.base.freeze_axes() … … 503 557 504 558 505 559 class 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 569 class 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.