Update qspace.py
This commit is contained in:
55
qspace.py
55
qspace.py
@ -20,15 +20,16 @@ INDICES = {
|
|||||||
|
|
||||||
class QSpace3D(Device):
|
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)
|
super().__init__(ID, **kwargs)
|
||||||
|
|
||||||
# collect the motors in a device for nicer printing
|
# collect the motors in a device for nicer printing
|
||||||
self.motors = motors = SimpleDevice(
|
self.motors = motors = SimpleDevice(
|
||||||
ID,
|
ID,
|
||||||
eta = eta,
|
mu = mu,
|
||||||
chi = chi,
|
chi = chi,
|
||||||
phi = phi
|
phi = phi,
|
||||||
|
nu = nu
|
||||||
)
|
)
|
||||||
|
|
||||||
self.wavelength = wavelength
|
self.wavelength = wavelength
|
||||||
@ -54,7 +55,24 @@ class QSpace3D(Device):
|
|||||||
# it might be nice (but optional) to add some shortcuts like this:
|
# it might be nice (but optional) to add some shortcuts like this:
|
||||||
def set_lattice(self, *args, **kwargs):
|
def set_lattice(self, *args, **kwargs):
|
||||||
self.dc.ub.set_lattice(*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?
|
# if I understand the examples/code correctly, then some more method calls are mandatory?
|
||||||
# those should probably all get shortcuts...
|
# those should probably all get shortcuts...
|
||||||
@ -88,7 +106,7 @@ class QSpace1D(Adjustable):
|
|||||||
|
|
||||||
def is_moving(self):
|
def is_moving(self):
|
||||||
ms = self.motors
|
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:
|
# some helpful things:
|
||||||
@ -117,24 +135,26 @@ class QSpace1D(Adjustable):
|
|||||||
|
|
||||||
def _get_angles(self):
|
def _get_angles(self):
|
||||||
ms = self.motors
|
ms = self.motors
|
||||||
eta = ms.eta.get_current_value()
|
mu = ms.mu.get_current_value()
|
||||||
chi = ms.chi.get_current_value()
|
chi = ms.chi.get_current_value()
|
||||||
phi = ms.phi.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
|
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_chi = ms.chi.set_target_value(chi)
|
||||||
t_phi = ms.phi.set_target_value(phi)
|
t_phi = ms.phi.set_target_value(phi)
|
||||||
|
t_nu = ms.nu.set_target_value(nu)
|
||||||
# wait for all motors to arrive
|
# 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:
|
for t in tasks:
|
||||||
t.wait()
|
t.wait()
|
||||||
|
|
||||||
def _calc_hkl(self, eta, chi, phi):
|
def _calc_hkl(self, mu, chi, phi, nu):
|
||||||
wl = self.get_wavelength()
|
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)
|
hkl = self.dc.hkl.get_hkl(pos, wl)
|
||||||
return hkl
|
return hkl
|
||||||
|
|
||||||
@ -143,22 +163,23 @@ class QSpace1D(Adjustable):
|
|||||||
pos, _virtual_angles = next(iter(
|
pos, _virtual_angles = next(iter(
|
||||||
self.dc.hkl.get_position(h, k, l, wl)
|
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
|
# these point to the different motors
|
||||||
eta = Motor("SOMETHING:ETA")
|
mu = Motor("SATES30-RIXS:MOT_SRY.VAL")
|
||||||
chi = Motor("SOMETHING:CHI")
|
chi = Motor("SATES30-RIXS:MOT_SRZ.VAL")
|
||||||
phi = Motor("SOMETHING:PHI")
|
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...)
|
# 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 = PVAdjustable("MACHINE:WAVELENGTH")
|
||||||
|
|
||||||
# put it all together:
|
# put it all together:
|
||||||
q = QSpace3D("SOMETHING:Q", eta, chi, phi, wl)
|
q = QSpace3D("SOMETHING:Q", mu, chi, phi, nu, wl)
|
||||||
|
|
||||||
## in ipython
|
## in ipython
|
||||||
#q.set_lattice("SiO2", 4.913, 5.405)
|
#q.set_lattice("SiO2", 4.913, 5.405)
|
||||||
|
Reference in New Issue
Block a user