56 lines
1.6 KiB
Python
56 lines
1.6 KiB
Python
###################################################################################################
|
|
# Deployment specific global definitions - executed after startup.py
|
|
###################################################################################################
|
|
|
|
BEAMLINE_XNAME = "X06DA"
|
|
|
|
dtor = math.pi /180.0
|
|
|
|
def a2e(t,h=1.0,k=1.0,l=1.0, deg =True, ln = False):
|
|
lncorr= 2.e-4 if ln else 0.0
|
|
d0=2 * 5.43102 * (1.0-lncorr) / math.sqrt(h**2+k**2+l**2)
|
|
tt= (t * dtor) if (deg or (t>1.0)) else t
|
|
return 12.39842 / (d0*math.sin(tt))
|
|
|
|
def angle(e,h=1.0,k=1.0,l=1.0, deg =True, ln = False,bent = False):
|
|
lncorr = 2.e-4 if ln else 0.0
|
|
d0 =2 * 5.43102 * (1.0-lncorr) / math.sqrt(h**2+k**2+l**2)
|
|
a = math.asin(12.39842/d0/e)
|
|
if bent:
|
|
rho = 2*19.65*8.35/28*math.sin(a)
|
|
dt = 0.2e-3/rho*0.279
|
|
d0 = 2*5.43102*(1+dt)/math.sqrt(h**2+k**2+l**2)
|
|
a = math.asin(12.39842/d0/e)
|
|
a = a/dtor if deg else a
|
|
return a
|
|
|
|
def get_energy(debug_msg = True):
|
|
t2 = caget("X06DA-OP-MO1:ROX2.RBV",'d')
|
|
e = a2e(abs(t2))
|
|
if debug_msg:
|
|
print 'Energy [keV]:'+ str(e) + ' Wavelength [A]:' + str(12.39842/e)
|
|
return e
|
|
|
|
run("fit")
|
|
run("rock")
|
|
#run("sete")
|
|
#run("seteq")
|
|
|
|
|
|
|
|
def fbm():
|
|
"""
|
|
"""
|
|
run("fbm")
|
|
|
|
def rocknroll():
|
|
"""
|
|
"""
|
|
run("rocknroll")
|
|
|
|
|
|
import ch.psi.pshell.device.ReadonlyRegisterBase as ReadonlyRegisterBase
|
|
class EnergyReader(ReadonlyRegisterBase):
|
|
def doRead(self):
|
|
return get_energy(False)
|
|
|
|
add_device(EnergyReader("energy"), True) |