Package reflectometry :: Package reduction :: Module anglecor

Source Code for Module reflectometry.reduction.anglecor

 1  # This program is public domain 
 2  """ 
 3  Alignment correction. 
 4   
 5  Sometimes the sample alignment is not perfect, and the sample may 
 6  be slightly rotated.  The net effect of this is that the Q values 
 7  stored in the data file are not correct.  The angle correction 
 8  allows you to adjust Q as if the data were taken at a slightly 
 9  different angle. 
10   
11  Note that this adjustment will fail to properly account for the change 
12  in intensity due to the neutrons at the unexpected reflection angle 
13  being filtered by the back slits, or due to the unexpected sample 
14  footprint poorly estimating the beam spill.  Whether these effects are 
15  significant depends on the details of the experiment geometry. 
16   
17  Usage 
18  ===== 
19   
20      data.appy(AdjustAlignment(offset=0.01) 
21  """ 
22  from reflectometry.reduction.correction import Correction 
23   
24 -class AdjustAlignment(Correction):
25 """ 26 Adjust Q if there is reason to believe either the detector 27 or the sample is rotated. 28 """ 29 properties = ["offset"] 30 offset = 0. # degrees 31
32 - def __init__(self, offset=0.):
33 """Define the angle offset correction for the data. 34 angle: rotation in degrees away from the beam 35 """ 36 self.offset = offset
37
38 - def apply(self, data):
39 """Apply the angle correction to the data""" 40 assert not data.ispolarized(), "need unpolarized data" 41 42 data.sample.angle_x += self.offset 43 data.detector.angle_x -= self.offset 44 data.resetQ()
45
46 - def __str__(self):
47 return "AdjustAlignment(offset=%g)"%offset
48