added wavelength wrapper adjustable

This commit is contained in:
2022-04-16 11:43:07 +02:00
parent a98728b924
commit 3c36a5685a

View File

@ -167,6 +167,30 @@ class QSpace1D(Adjustable):
h = 6.62607015e-34 # J s
c = 299792458 # m / s
e = 1.60217663e-19 # C
f = h * c / e * 1e-3 * 1e9 # E [keV] = f / lambda [nm]
class Wavelength(Adjustable):
def __init__(self, energy):
self.energy = energy
assert self.energy.units == "keV" # otherwise conversion is wrong
super().__init__(energy.ID + "_WL", name=energy.name + " as Wavelength", units="nm")
def get_current_value(self):
E = self.energy.get_current_value()
return f / E
def set_target_value(self, value):
E = f / value
return self.energy.set_target_value(E)
def is_moving(self):
return self.energy.is_moving()
# these point to the different motors
@ -176,7 +200,7 @@ phi = Motor("SATES30-RIXS:MOT_SRX.VAL")
nu = Motor("SATES30-RIXS:MOT_DRY.VAL")
# and this to the machine wavelength (maybe this needs to be calculated from the energy? then we should add a Wavelength wrapper...)
wl = PVAdjustable("MACHINE:WAVELENGTH")
wl = Wavelength(PVAdjustable("MACHINE:ENERGY"))
# put it all together:
q = QSpace3D("SOMETHING:Q", mu, chi, phi, nu, wl)