Update qspace.py

This commit is contained in:
2022-04-13 13:20:00 +00:00
parent 8e8e5de83e
commit a98728b924

View File

@ -20,15 +20,16 @@ INDICES = {
class QSpace3D(Device):
def __init__(self, ID, eta, chi, phi, wavelength, **kwargs): # if the diffcalc objects need some initial parameters, add them here and fill them in below...
def __init__(self, ID, mu, chi, phi, nu, wavelength, **kwargs): # if the diffcalc objects need some initial parameters, add them here and fill them in below...
super().__init__(ID, **kwargs)
# collect the motors in a device for nicer printing
self.motors = motors = SimpleDevice(
ID,
eta = eta,
mu = mu,
chi = chi,
phi = phi
phi = phi,
nu = nu
)
self.wavelength = wavelength
@ -54,7 +55,24 @@ class QSpace3D(Device):
# it might be nice (but optional) to add some shortcuts like this:
def set_lattice(self, *args, **kwargs):
self.dc.ub.set_lattice(*args, **kwargs)
self.dc.ub.calc_ub() # not sure whether this needs to be called explicitly?
def add_orientation(self, *args, **kwargs):
self.dc.ub.add_orientation(*args, **kwargs)
def del_orientation(self, *args):
self.dc.ub.del_orientation(*args)
def add_reflection(self, *args, **kwargs):
self.dc.ub.add_reflection(*args, **kwargs)
def del_reflection(self, *args):
self.dc.ub.del_reflection(*args)
def calc_ub(self, *args):
self.dc.ub.calc_ub(*args) # not sure whether this needs to be called explicitly?
def fit_ub(self, *args, **kwargs):
self.dc.ub.fit_ub(*args, **kwargs)
# if I understand the examples/code correctly, then some more method calls are mandatory?
# those should probably all get shortcuts...
@ -88,7 +106,7 @@ class QSpace1D(Adjustable):
def is_moving(self):
ms = self.motors
return ms.eta.moving or ms.chi.moving or ms.phi.moving
return ms.mu.moving or ms.chi.moving or ms.phi.moving
# some helpful things:
@ -117,24 +135,26 @@ class QSpace1D(Adjustable):
def _get_angles(self):
ms = self.motors
eta = ms.eta.get_current_value()
mu = ms.mu.get_current_value()
chi = ms.chi.get_current_value()
phi = ms.phi.get_current_value()
return eta, chi, phi
nu = ms.nu.get_current_value()
return mu, chi, phi, nu
def _set_angles(self, eta, chi, phi):
def _set_angles(self, mu, chi, phi, nu):
ms = self.motors
t_eta = ms.eta.set_target_value(eta)
t_mu = ms.mu.set_target_value(mu)
t_chi = ms.chi.set_target_value(chi)
t_phi = ms.phi.set_target_value(phi)
t_nu = ms.nu.set_target_value(nu)
# wait for all motors to arrive
tasks = (t_eta, t_chi, t_phi)
tasks = (t_mu, t_chi, t_phi, t_nu)
for t in tasks:
t.wait()
def _calc_hkl(self, eta, chi, phi):
def _calc_hkl(self, mu, chi, phi, nu):
wl = self.get_wavelength()
pos = Position(eta=eta, chi=chi, phi=phi)
pos = Position(mu=mu, chi=chi, phi=phi, nu=nu)
hkl = self.dc.hkl.get_hkl(pos, wl)
return hkl
@ -143,22 +163,23 @@ class QSpace1D(Adjustable):
pos, _virtual_angles = next(iter(
self.dc.hkl.get_position(h, k, l, wl)
))
return pos.eta, pos.chi, pos.phi
return pos.mu, pos.chi, pos.phi, pos.nu
# these point to the different motors
eta = Motor("SOMETHING:ETA")
chi = Motor("SOMETHING:CHI")
phi = Motor("SOMETHING:PHI")
mu = Motor("SATES30-RIXS:MOT_SRY.VAL")
chi = Motor("SATES30-RIXS:MOT_SRZ.VAL")
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")
# put it all together:
q = QSpace3D("SOMETHING:Q", eta, chi, phi, wl)
q = QSpace3D("SOMETHING:Q", mu, chi, phi, nu, wl)
## in ipython
#q.set_lattice("SiO2", 4.913, 5.405)