summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCHANGELOG.md6
-rwxr-xr-x[-rw-r--r--]src/sardana/macroserver/macros/hkl.py248
2 files changed, 128 insertions, 126 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c0cb0fe..f69e64e8 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,7 +34,7 @@ This file follows the formats and conventions from [keepachangelog.com]
#1009)
- Possibility to define macros with optional parameters. These must be the last
ones in the definition (#285, #876, #943, #941, #955)
-- Possibility to pass values of repeat paramters with just one member without
+- Possibility to pass values of repeat parameters with just one member without
the need to encapsulate them in square brackets (spock syntax) or list
(macro API) (#781, #983)
- Possibility to change data format (shape) of of pseudo counter values (#986)
@@ -48,6 +48,8 @@ This file follows the formats and conventions from [keepachangelog.com]
- Document remote connection to MacroServer Python process (RConsolePort Tango
property) (#984)
- sardana.taurus.qt.qtgui.macrolistener (moved from taurus.qt.qtgui.taurusgui)
+- Documentation on differences between `Hookable.hooks` and `Hookable.appendHook`
+ (#962, #1013)
### Fixed
- Do not read 1D and 2D experimental channels during software acquisition loop
@@ -71,6 +73,8 @@ This file follows the formats and conventions from [keepachangelog.com]
- Spock considers passing supernumerary parameters as errors (#438, #781)
- MacroServer starts without the Qt library installed (#781, #907, #908)
- Make `Description` an optional part of controller's properties definition (#976)
+- Correcting bug in hkl macros introduced when extending macros for new
+ diffractometer types: angle order was switched
### Changed
- MacroButton stops macros instead of aborting them (#931, #943)
diff --git a/src/sardana/macroserver/macros/hkl.py b/src/sardana/macroserver/macros/hkl.py
index 515848af..4dbfc452 100644..100755
--- a/src/sardana/macroserver/macros/hkl.py
+++ b/src/sardana/macroserver/macros/hkl.py
@@ -47,7 +47,7 @@ import os
import re
import numpy as np
-from sardana.macroserver.macro import *
+from sardana.macroserver.macro import Macro, iMacro, Type
from sardana.macroserver.macros.scan import aNscan
from sardana.macroserver.msexception import UnknownEnv
@@ -107,25 +107,12 @@ class _diffrac:
self.angle_names.append("delta")
if self.nb_motors == 4:
- self.labelmotor = {'Omega': self.angle_names[0],
- 'Chi': self.angle_names[1],
- 'Phi': self.angle_names[2],
- 'Tth': self.angle_names[3]}
+ self.labelmotor = {'Omega': "omega",
+ 'Chi': "chi", 'Phi': "phi", 'Tth': "tth"}
elif self.nb_motors == 6:
- self.labelmotor = {'Mu': self.angle_names[0],
- 'Theta': self.angle_names[1],
- 'Chi': self.angle_names[2],
- 'Phi': self.angle_names[3],
- 'Gamma': self.angle_names[4],
- 'Delta': self.angle_names[5]}
- elif self.nb_motors == 7:
- self.labelmotor = {'Omega_t': self.angle_names[0],
- 'Mu': self.angle_names[1],
- 'Omega': self.angle_names[2],
- 'Chi': self.angle_names[3],
- 'Phi': self.angle_names[4],
- 'Gamma': self.angle_names[5],
- 'Delta': self.angle_names[6]}
+ self.labelmotor = {'Mu': "mu", 'Theta': "omega", 'Chi': "chi",
+ 'Phi': "phi", 'Gamma': "gamma",
+ 'Delta': "delta"}
prop = self.diffrac.get_property(['DiffractometerType'])
for v in prop['DiffractometerType']:
@@ -375,17 +362,22 @@ class _ca(Macro, _diffrac):
str_pos[self.labelmotor["Chi"]],
str_pos[self.labelmotor["Phi"]]))
elif self.nb_motors == 7:
- self.output("%10s %11s %12s %11s %10s %11s %11s" %
- ("Omega_t", "Mu", "Omega", "Chi",
- "Phi", "Gamma", "Delta"))
- self.output("%10s %11s %12s %11s %10s %11s %11s" %
- (str_pos[self.labelmotor["Omega_t"]],
- str_pos[self.labelmotor["Mu"]],
- str_pos[self.labelmotor["Omega"]],
- str_pos[self.labelmotor["Chi"]],
- str_pos[self.labelmotor["Phi"]],
- str_pos[self.labelmotor["Gamma"]],
- str_pos[self.labelmotor["Delta"]]))
+ self.output("%10s %11s %12s %11s %11s %11s %11s" %
+ (self.angle_names[0],
+ self.angle_names[1],
+ self.angle_names[2],
+ self.angle_names[3],
+ self.angle_names[4],
+ self.angle_names[5],
+ self.angle_names[6]))
+ self.output("%10s %11s %12s %11s %11s %11s %11s" %
+ (str_pos[self.angle_names[0]],
+ str_pos[self.angle_names[1]],
+ str_pos[self.angle_names[2]],
+ str_pos[self.angle_names[3]],
+ str_pos[self.angle_names[4]],
+ str_pos[self.angle_names[5]],
+ str_pos[self.angle_names[6]]))
@@ -439,18 +431,25 @@ class ci(Macro, _diffrac):
['phi', Type.Float, None, "Phi value"],
['gamma', Type.Float, -999, "Gamma value"],
['delta', Type.Float, -999, "Delta value"],
+ ['omega_t', Type.Float, -999, "Omega_t value"],
]
- def prepare(self, mu, theta, chi, phi, gamma, delta):
+ def prepare(self, mu, theta, chi, phi, gamma, delta, omega_t):
_diffrac.prepare(self)
- def run(self, mu, theta, chi, phi, gamma, delta):
+ def run(self, mu, theta, chi, phi, gamma, delta, omega_t):
if delta == -999 and self.nb_motors == 6:
self.error("Six angle values are need as argument")
+ elif omega_t == -999 and self.nb_motors == 7:
+ msg = ("Seven angle values are need as argument (omega_t is "
+ "missed - last argument)")
+ self.error(msg)
else:
-
- angles = [mu, theta, chi, phi, gamma, delta]
+ if self.nb_motors != 7:
+ angles = [mu, theta, chi, phi, gamma, delta]
+ else:
+ angles = [omega_t, mu, theta, chi, phi, gamma, delta]
self.diffrac.write_attribute("computehkl", angles)
@@ -639,9 +638,7 @@ class wh(Macro, _diffrac):
str_pos6 = "%7.5f" % self.getDevice(
self.angle_device_names[self.labelmotor["Gamma"]]).Position
self.output("%10s %11s %12s %11s %10s %11s" %
- (self.labelmotor["Delta"], self.labelmotor["Theta"],
- self.labelmotor["Chi"], self.labelmotor["Phi"],
- self.labelmotor["Mu"], self.labelmotor["Gamma"]))
+ ("Delta", "Theta", "Chi", "Phi", "Mu", "Gamma"))
self.output("%10s %11s %12s %11s %10s %11s" %
(str_pos1, str_pos2, str_pos3, str_pos4, str_pos5,
str_pos6))
@@ -655,33 +652,41 @@ class wh(Macro, _diffrac):
str_pos4 = "%7.5f" % self.getDevice(
self.angle_device_names[self.labelmotor["Phi"]]).Position
self.output("%10s %11s %12s %11s" %
- (self.labelmotor["Tth"], self.labelmotor["Omega"],
- self.labelmotor["Chi"], self.labelmotor["Phi"]))
+ ("Tth", "Omega", "Chi", "Phi"))
self.output("%10s %11s %12s %11s" %
(str_pos1, str_pos2, str_pos3, str_pos4))
elif self.nb_motors == 7:
str_pos1 = "%7.5f" % self.getDevice(
- self.angle_device_names[self.labelmotor["Omega_t"]]).Position
+ self.angle_device_names[self.angles_names[0]]).Position
str_pos2 = "%7.5f" % self.getDevice(
- self.angle_device_names[self.labelmotor["Mu"]]).Position
+ self.angle_device_names[self.angles_names[1]]).Position
str_pos3 = "%7.5f" % self.getDevice(
- self.angle_device_names[self.labelmotor["Omega"]]).Position
+ self.angle_device_names[self.angles_names[2]]).Position
str_pos4 = "%7.5f" % self.getDevice(
- self.angle_device_names[self.labelmotor["Chi"]]).Position
+ self.angle_device_names[self.angles_names[3]]).Position
str_pos5 = "%7.5f" % self.getDevice(
- self.angle_device_names[self.labelmotor["Phi"]]).Position
+ self.angle_device_names[self.angles_names[4]]).Position
str_pos6 = "%7.5f" % self.getDevice(
- self.angle_device_names[self.labelmotor["Gamma"]]).Position
+ self.angle_device_names[self.angles_names[5]]).Position
str_pos7 = "%7.5f" % self.getDevice(
- self.angle_device_names[self.labelmotor["Delta"]]).Position
- self.output("%10s %11s %12s %11s %10s %11s %11s" %
- (self.labelmotor["Omega_t"], self.labelmotor["Mu"],
- self.labelmotor["Omega"], self.labelmotor["Chi"],
- self.labelmotor["Phi"], self.labelmotor["Gamma"],
- self.labelmotor["Delta"]))
- self.output("%10s %11s %12s %11s %10s %11s %11s" %
- (str_pos1, str_pos2, str_pos3, str_pos4, str_pos5,
- str_pos6, str_pos7))
+ self.angle_device_names[self.angles_names[6]]).Position
+ self.output("%10s %11s %12s %11s %11s %11s %11s" %
+ (self.angle_names[0],
+ self.angle_names[1],
+ self.angle_names[2],
+ self.angle_names[3],
+ self.angle_names[4],
+ self.angle_names[5],
+ self.angle_names[6]))
+ self.output("%10s %11s %12s %11s %11s %11s %11s" %
+ (str_pos1,
+ str_pos2,
+ str_pos3,
+ str_pos4,
+ str_pos5,
+ str_pos6,
+ str_pos7))
+
self.setEnv('Q', [self.h_device.position, self.k_device.position,
self.l_device.position, self.diffrac.WaveLength])
@@ -913,80 +918,96 @@ class or1(Macro, _diffrac):
class setor0(Macro, _diffrac):
- """Set primary orientation reflection choosing hkl and angle values"""
+ """Set primary orientation reflection choosing hkl and angle values.
+ Run it without any argument to see the order real positions"""
param_def = [
['H', Type.Float, -999, "H value"],
['K', Type.Float, -999, "K value"],
['L', Type.Float, -999, "L value"],
- ['mu', Type.Float, -999, "Mu value"],
- ['theta', Type.Float, -999, "Theta value"],
- ['chi', Type.Float, -999, "Chi value"],
- ['phi', Type.Float, -999, "Phi value"],
- ['gamma', Type.Float, -999, "Gamma value"],
- ['delta', Type.Float, -999, "Delta value"],
+ ['ang1', Type.Float, -999, "Real position"],
+ ['ang2', Type.Float, -999, "Real position"],
+ ['ang3', Type.Float, -999, "Real position"],
+ ['ang4', Type.Float, -999, "Real position"],
+ ['ang5', Type.Float, -999, "Real position"],
+ ['ang6', Type.Float, -999, "Real position"],
+ ['ang7', Type.Float, -999, "Real position"],
]
- def prepare(self, H, K, L, mu, theta, chi, phi, gamma, delta):
+ def prepare(self, H, K, L, ang1, ang2, ang3, ang4, ang5, ang6, ang7):
_diffrac.prepare(self)
- def run(self, H, K, L, mu, theta, chi, phi, gamma, delta):
-
+ def run(self, H, K, L, ang1, ang2, ang3, ang4, ang5, ang6, ang7):
setorn, pars = self.createMacro(
- "setorn", 0, H, K, L, mu, theta, chi, phi, gamma, delta)
+ "setorn", 0, H, K, L, ang1, ang2, ang3, ang4, ang5, ang6, ang7)
self.runMacro(setorn)
class setor1(Macro, _diffrac):
- """Set secondary orientation reflection choosing hkl and angle values"""
+ """Set secondary orientation reflection choosing hkl and angle values.
+ Run it without any argument to see the order real positions"""
param_def = [
['H', Type.Float, -999, "H value"],
['K', Type.Float, -999, "K value"],
['L', Type.Float, -999, "L value"],
- ['mu', Type.Float, -999, "Mu value"],
- ['theta', Type.Float, -999, "Theta value"],
- ['chi', Type.Float, -999, "Chi value"],
- ['phi', Type.Float, -999, "Phi value"],
- ['gamma', Type.Float, -999, "Gamma value"],
- ['delta', Type.Float, -999, "Delta value"],
+ ['ang1', Type.Float, -999, "Real position"],
+ ['ang2', Type.Float, -999, "Real position"],
+ ['ang3', Type.Float, -999, "Real position"],
+ ['ang4', Type.Float, -999, "Real position"],
+ ['ang5', Type.Float, -999, "Real position"],
+ ['ang6', Type.Float, -999, "Real position"],
+ ['ang7', Type.Float, -999, "Real position"],
]
- def prepare(self, H, K, L, mu, theta, chi, phi, gamma, delta):
+ def prepare(self, H, K, L, ang1, ang2, ang3, ang4, ang5, ang6, ang7):
+ self.output("setor1 prepare")
+ self.output(ang3)
+ self.output(ang7)
_diffrac.prepare(self)
- def run(self, H, K, L, mu, theta, chi, phi, gamma, delta):
-
+ def run(self, H, K, L, ang1, ang2, ang3, ang4, ang5, ang6, ang7):
setorn, pars = self.createMacro(
- "setorn", 1, H, K, L, mu, theta, chi, phi, gamma, delta)
+ "setorn", 1, H, K, L, ang1, ang2, ang3, ang4, ang5, ang6, ang7)
self.runMacro(setorn)
class setorn(iMacro, _diffrac):
- """Set orientation reflection indicated by the index."""
+ """Set orientation reflection indicated by the index.
+ Run it without any argument to see the order of the angles to be set"""
param_def = [
['ref_id', Type.Integer, None, "reflection index (starting at 0)"],
['H', Type.Float, -999, "H value"],
['K', Type.Float, -999, "K value"],
['L', Type.Float, -999, "L value"],
- ['mu', Type.Float, -999, "Mu value"],
- ['theta', Type.Float, -999, "Theta value"],
- ['chi', Type.Float, -999, "Chi value"],
- ['phi', Type.Float, -999, "Phi value"],
- ['gamma', Type.Float, -999, "Gamma value"],
- ['delta', Type.Float, -999, "Delta value"],
+ ['ang1', Type.Float, -999, "Real position"],
+ ['ang2', Type.Float, -999, "Real position"],
+ ['ang3', Type.Float, -999, "Real position"],
+ ['ang4', Type.Float, -999, "Real position"],
+ ['ang5', Type.Float, -999, "Real position"],
+ ['ang6', Type.Float, -999, "Real position"],
+ ['ang7', Type.Float, -999, "Real position"],
]
- def prepare(self, ref_id, H, K, L, mu, theta, chi, phi, gamma, delta):
+ def prepare(self, ref_id, H, K, L, ang1, ang2, ang3, ang4, ang5, ang6,
+ ang7):
_diffrac.prepare(self)
- def run(self, ref_id, H, K, L, mu, theta, chi, phi, gamma, delta):
+ def run(self, ref_id, H, K, L, ang1, ang2, ang3, ang4, ang5, ang6, ang7):
- if (delta == -999 and self.nb_motors == 6) or (
- phi == -999 and self.nb_motors == 4):
+ if H == -999.0:
+ msg = "Order of the real motor positions to be given as argument:"
+ self.output(msg)
+ for el in self.angle_names:
+ self.output(el)
+ return
+
+ if ((ang6 == -999 and self.nb_motors == 6)
+ or (ang4 == -999 and self.nb_motors == 4)
+ or (ang7 == -999 and self.nb_motors == 7)):
reflections = []
try:
reflections = self.diffrac.reflectionlist
@@ -1021,30 +1042,14 @@ class setorn(iMacro, _diffrac):
ref_txt = "reflection " + str(ref_id)
self.output("Enter %s angles" % ref_txt)
- if self.nb_motors == 6:
- delta = float(self.input(" Delta?", default_value=tmp_ref[
- "delta"], data_type=Type.String))
-
- theta = float(self.input(" Theta? ", default_value=tmp_ref[
- "omega"], data_type=Type.String))
- chi = float(self.input(" Chi?", default_value=tmp_ref[
- "chi"], data_type=Type.String))
- phi = float(self.input(" Phi?", default_value=tmp_ref[
- "phi"], data_type=Type.String))
- gamma = float(self.input(" Gamma?", default_value=tmp_ref[
- "gamma"], data_type=Type.String))
- mu = float(self.input(" Mu?", default_value=tmp_ref[
- "mu"], data_type=Type.String))
- if self.nb_motors == 4:
-
- omega = float(self.input(" Omega?", default_value=tmp_ref[
- "omega"], data_type=Type.String))
- chi = float(self.input(" Chi?", default_value=tmp_ref[
- "chi"], data_type=Type.String))
- phi = float(self.input(" Phi?", default_value=tmp_ref[
- "phi"], data_type=Type.String))
- tth = float(self.input(" Tth?", default_value=tmp_ref[
- "omega"], data_type=Type.String))
+ angles_to_set = []
+ for el in self.angle_names:
+ angles_to_set.append(
+ float(self.input(el+"?",
+ default_value=tmp_ref[el],
+ data_type=Type.String)
+ )
+ )
self.output("")
@@ -1056,6 +1061,11 @@ class setorn(iMacro, _diffrac):
L = float(self.input(" L?", default_value=tmp_ref[
"l"], data_type=Type.String))
self.output("")
+ else:
+ angles = [ang1, ang2, ang3, ang4, ang5, ang6, ang7]
+ angles_to_set = []
+ for i in range(0, self.nb_motors):
+ angles_to_set.append(angles[i])
# Check collinearity
@@ -1077,22 +1087,10 @@ class setorn(iMacro, _diffrac):
values = [ref_id, H, K, L]
self.diffrac.write_attribute("SubstituteReflection", values)
- # Adjust angles
-
- if self.nb_motors == 6:
- self.angle_values = {"mu": mu, "omega": theta,
- "chi": chi, "phi": phi, "gamma": gamma,
- "delta": delta}
- elif self.nb_motors == 4:
- self.angle_values = {"omega": omega, "chi": chi,
- "phi": phi, "tth": tth}
-
-
values = []
values.append(ref_id)
-
- for angle_name in self.angle_names:
- values.append(self.angle_values[angle_name])
+ for el in angles_to_set:
+ values.append(el)
self.diffrac.write_attribute("AdjustAnglesToReflection", values)