This commit is contained in:
@@ -106,4 +106,6 @@ eta=ch.psi.pshell.device.DummyMotor||||true
|
|||||||
chi=ch.psi.pshell.device.DummyMotor||||true
|
chi=ch.psi.pshell.device.DummyMotor||||true
|
||||||
phi=ch.psi.pshell.device.DummyMotor||||true
|
phi=ch.psi.pshell.device.DummyMotor||||true
|
||||||
sixc=ch.psi.pshell.device.MotorGroupBase|mu delta gam eta chi phi|||
|
sixc=ch.psi.pshell.device.MotorGroupBase|mu delta gam eta chi phi|||
|
||||||
|
fivec=ch.psi.pshell.device.MotorGroupBase|delta gam eta chi phi|||
|
||||||
|
fourc=ch.psi.pshell.device.MotorGroupBase|delta eta chi phi|||
|
||||||
en=ch.psi.pshell.device.DummyPositioner||||true
|
en=ch.psi.pshell.device.DummyPositioner||||true
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
#Mon Apr 16 15:45:44 CEST 2018
|
#Wed Apr 18 09:33:05 CEST 2018
|
||||||
precision=-1
|
precision=4
|
||||||
|
|||||||
Binary file not shown.
@@ -16,10 +16,12 @@
|
|||||||
###################################################################################################
|
###################################################################################################
|
||||||
|
|
||||||
#1- Create a MontorGroup with the diffractometer motors
|
#1- Create a MontorGroup with the diffractometer motors
|
||||||
# e.g named 'sixc', containing mu, delta, gam, eta, chi, phi motors
|
# e.g. 'sixc', containing mu, delta, gam, eta, chi, phi motors
|
||||||
|
# or 'fivec', containing delta, gam, eta, chi, phi motors
|
||||||
|
# or 'fourc', containing delta, eta, chi, phi motors
|
||||||
#2- Create positioner to read/set the energy in kEv, e.g. named 'en'
|
#2- Create positioner to read/set the energy in kEv, e.g. named 'en'
|
||||||
#3- Execute: run("diffutils")
|
#3- Execute: run("diffutils")
|
||||||
#4- Execute: setup_sixc(sixc, en)
|
#4- Execute: setup_diff(sixc, en)
|
||||||
|
|
||||||
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
@@ -29,15 +31,15 @@ import traceback
|
|||||||
import Jama.Matrix
|
import Jama.Matrix
|
||||||
diffcalc_path = os.path.abspath(get_context().setup.expandPath("{script}/Lib/diffcalc"))
|
diffcalc_path = os.path.abspath(get_context().setup.expandPath("{script}/Lib/diffcalc"))
|
||||||
if not diffcalc_path in sys.path:
|
if not diffcalc_path in sys.path:
|
||||||
sys.path.append('/Users/gobbo_a/dev/pshell/config/home/script/Lib/diffcalc')
|
sys.path.append(diffcalc_path)
|
||||||
|
|
||||||
import diffcalc
|
import diffcalc
|
||||||
from diffcalc import settings
|
from diffcalc import settings
|
||||||
from diffcalc.hkl.you.geometry import SixCircle
|
from diffcalc.hkl.you.geometry import SixCircle, FiveCircle, FourCircle
|
||||||
from diffcalc.hardware import HardwareAdapter
|
from diffcalc.hardware import HardwareAdapter
|
||||||
from diffcalc.ub.persistence import UbCalculationNonPersister
|
from diffcalc.ub.persistence import UbCalculationNonPersister
|
||||||
from diffcalc.gdasupport.minigda.scannable import *
|
from diffcalc.gdasupport.minigda.scannable import ScannableBase, ScannableGroup
|
||||||
from diffcalc.gdasupport.minigda import command
|
#from diffcalc.gdasupport.minigda import command
|
||||||
from diffcalc.hardware import HardwareAdapter
|
from diffcalc.hardware import HardwareAdapter
|
||||||
|
|
||||||
|
|
||||||
@@ -54,7 +56,6 @@ import ch.psi.pshell.device.Register as Register
|
|||||||
# Device mapping to difcalc
|
# Device mapping to difcalc
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
class PositionerScannable(ScannableBase):
|
class PositionerScannable(ScannableBase):
|
||||||
|
|
||||||
def __init__(self, positioner):
|
def __init__(self, positioner):
|
||||||
self.positioner = positioner
|
self.positioner = positioner
|
||||||
self.name = positioner.name
|
self.name = positioner.name
|
||||||
@@ -79,14 +80,30 @@ class PositionerScannable(ScannableBase):
|
|||||||
class PositionerScannableGroup(ScannableGroup):
|
class PositionerScannableGroup(ScannableGroup):
|
||||||
def __init__(self, name, motors):
|
def __init__(self, name, motors):
|
||||||
self.name = name
|
self.name = name
|
||||||
[mu, delta, gam, eta, chi, phi] = motors
|
if len(motors)==6:
|
||||||
self.mu = PositionerScannable(mu)
|
[mu, delta, gam, eta, chi, phi] = motors
|
||||||
self.delta = PositionerScannable(delta)
|
self.mu = PositionerScannable(mu)
|
||||||
self.gam = PositionerScannable(gam)
|
self.delta = PositionerScannable(delta)
|
||||||
self.eta = PositionerScannable(eta)
|
self.gam = PositionerScannable(gam)
|
||||||
self.chi = PositionerScannable(chi)
|
self.eta = PositionerScannable(eta)
|
||||||
self.phi = PositionerScannable(phi)
|
self.chi = PositionerScannable(chi)
|
||||||
ScannableGroup.__init__(self, self.name, [self.mu, self.delta, self.gam, self.eta, self.chi, self.phi])
|
self.phi = PositionerScannable(phi)
|
||||||
|
ScannableGroup.__init__(self, self.name, [self.mu, self.delta, self.gam, self.eta, self.chi, self.phi])
|
||||||
|
elif len(motors)==5:
|
||||||
|
[delta, gam, eta, chi, phi] = motors
|
||||||
|
self.delta = PositionerScannable(delta)
|
||||||
|
self.gam = PositionerScannable(gam)
|
||||||
|
self.eta = PositionerScannable(eta)
|
||||||
|
self.chi = PositionerScannable(chi)
|
||||||
|
self.phi = PositionerScannable(phi)
|
||||||
|
ScannableGroup.__init__(self, self.name, [self.delta, self.gam, self.eta, self.chi, self.phi])
|
||||||
|
elif len(motors)==4:
|
||||||
|
[delta, eta, chi, phi] = motors
|
||||||
|
self.delta = PositionerScannable(delta)
|
||||||
|
self.eta = PositionerScannable(eta)
|
||||||
|
self.chi = PositionerScannable(chi)
|
||||||
|
self.phi = PositionerScannable(phi)
|
||||||
|
ScannableGroup.__init__(self, self.name, [self.delta, self.eta, self.chi, self.phi])
|
||||||
|
|
||||||
class MotorGroupScannable(PositionerScannableGroup):
|
class MotorGroupScannable(PositionerScannableGroup):
|
||||||
def __init__(self, motor_group):
|
def __init__(self, motor_group):
|
||||||
@@ -125,10 +142,10 @@ class ScannableAdapter(HardwareAdapter):
|
|||||||
|
|
||||||
class MotorGroupAdapter(ScannableAdapter):
|
class MotorGroupAdapter(ScannableAdapter):
|
||||||
def __init__(self, diffractometer, energy, energy_multiplier_to_kev=1):
|
def __init__(self, diffractometer, energy, energy_multiplier_to_kev=1):
|
||||||
self.sixc = MotorGroupScannable(sixc)
|
self.diffractometer = MotorGroupScannable(diffractometer)
|
||||||
self.en = PositionerScannable(en)
|
self.energy = PositionerScannable(energy)
|
||||||
self.en.level = 3
|
self.energy.level = 3
|
||||||
ScannableAdapter.__init__(self, self.sixc, self.en, energy_multiplier_to_kev)
|
ScannableAdapter.__init__(self, self.diffractometer, self.energy, energy_multiplier_to_kev)
|
||||||
|
|
||||||
class Wavelength(RegisterBase):
|
class Wavelength(RegisterBase):
|
||||||
def doRead(self):
|
def doRead(self):
|
||||||
@@ -205,15 +222,30 @@ class HklGroup(RegisterBase, Register.RegisterArray):
|
|||||||
###################################################################################################
|
###################################################################################################
|
||||||
you = None
|
you = None
|
||||||
dc, ub, hardware, hkl = None, None, None, None
|
dc, ub, hardware, hkl = None, None, None, None
|
||||||
#en in kev
|
_motor_group = None
|
||||||
def setup_sixc(sixc, en):
|
def setup_diff(diffractometer, energy):
|
||||||
global you, dc, ub, hardware, hkl
|
"""
|
||||||
|
diffractometer: Motor group containing:
|
||||||
|
- mu, delta, gam, eta, chi, phi (six circle) or
|
||||||
|
- delta, gam, eta, chi, phi (ficve circle) or
|
||||||
|
- delta, eta, chi, phi (four circle)
|
||||||
|
energy: Positioner having energy in kev
|
||||||
|
"""
|
||||||
|
global you, dc, ub, hardware, hkl, _motor_group
|
||||||
|
_motor_group = diffractometer
|
||||||
you =None
|
you =None
|
||||||
settings.hardware = MotorGroupAdapter(sixc, en)
|
if len(diffractometer.motors) == 6:
|
||||||
settings.geometry = SixCircle()
|
settings.geometry = SixCircle()
|
||||||
|
elif len(diffractometer.motors) == 5:
|
||||||
|
settings.geometry = FiveCircle()
|
||||||
|
elif len(diffractometer.motors) == 4:
|
||||||
|
settings.geometry = FourCircle()
|
||||||
|
else:
|
||||||
|
raise Exception("Invalid motor group")
|
||||||
|
settings.hardware = MotorGroupAdapter(diffractometer, energy)
|
||||||
settings.ubcalc_persister = UbCalculationNonPersister()
|
settings.ubcalc_persister = UbCalculationNonPersister()
|
||||||
settings.axes_scannable_group = settings.hardware.sixc
|
settings.axes_scannable_group = settings.hardware.diffractometer
|
||||||
settings.energy_scannable = settings.hardware.en
|
settings.energy_scannable = settings.hardware.energy
|
||||||
settings.ubcalc_strategy = diffcalc.hkl.you.calc.YouUbCalcStrategy()
|
settings.ubcalc_strategy = diffcalc.hkl.you.calc.YouUbCalcStrategy()
|
||||||
settings.angles_to_hkl_function = diffcalc.hkl.you.calc.youAnglesToHkl
|
settings.angles_to_hkl_function = diffcalc.hkl.you.calc.youAnglesToHkl
|
||||||
from diffcalc.gdasupport import you
|
from diffcalc.gdasupport import you
|
||||||
@@ -242,10 +274,13 @@ def print_axis_setup():
|
|||||||
# Acceess functions
|
# Acceess functions
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
def get_diff():
|
def get_diff():
|
||||||
return settings.hardware.sixc
|
return settings.hardware.diffractometer
|
||||||
|
|
||||||
def get_en():
|
def get_en():
|
||||||
return settings.hardware.en
|
return settings.hardware.energy
|
||||||
|
|
||||||
|
def get_motor_group():
|
||||||
|
return _motor_group
|
||||||
|
|
||||||
def get_wl():
|
def get_wl():
|
||||||
return you.wl
|
return you.wl
|
||||||
@@ -302,7 +337,11 @@ def hklscan(vector, readables,latency = 0.0, passes = 1, **pars):
|
|||||||
for pos in vector:
|
for pos in vector:
|
||||||
#print "Writing ", pos
|
#print "Writing ", pos
|
||||||
hkl_group.write(pos)
|
hkl_group.write(pos)
|
||||||
time.sleep(1.0)
|
time.sleep(0.1) #Make sure is busy
|
||||||
|
get_motor_group().update()
|
||||||
|
get_motor_group().waitReady(-1)
|
||||||
|
time.sleep(latency)
|
||||||
|
hkl_group.update()
|
||||||
scan.append ([h.take(), k.take(), l.take()], [h.getPosition(), k.getPosition(), l.getPosition()], [readable.read() for readable in readables ])
|
scan.append ([h.take(), k.take(), l.take()], [h.getPosition(), k.getPosition(), l.getPosition()], [readable.read() for readable in readables ])
|
||||||
finally:
|
finally:
|
||||||
scan.end()
|
scan.end()
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
en.move(20.0)
|
||||||
|
delta.config.maxSpeed = 50.0
|
||||||
|
delta.speed = 50.0
|
||||||
|
delta.move(1.0)
|
||||||
|
|
||||||
|
run("diffcalc/diffutils")
|
||||||
|
###################################################################################################\
|
||||||
|
#Setup
|
||||||
|
###################################################################################################
|
||||||
|
|
||||||
|
setup_diff(fivec, en)
|
||||||
|
# Set some limits
|
||||||
|
setup_axis('gam', 0, 179)
|
||||||
|
setup_axis('delta', 0, 179)
|
||||||
|
setup_axis('delta', min=0)
|
||||||
|
setup_axis('phi', cut=-180.0)
|
||||||
|
|
||||||
|
print_axis_setup()
|
||||||
|
|
||||||
|
###################################################################################################\
|
||||||
|
#Orientation
|
||||||
|
###################################################################################################
|
||||||
|
help(ub.ub)
|
||||||
|
ub.listub()
|
||||||
|
|
||||||
|
# Create a new ub calculation and set lattice parameters
|
||||||
|
ub.newub('test')
|
||||||
|
ub.setlat('cubic', 1, 1, 1, 90, 90, 90)
|
||||||
|
|
||||||
|
# Add 1st reflection (demonstrating the hardware adapter)
|
||||||
|
settings.hardware.wavelength = 1
|
||||||
|
ub.c2th([1, 0, 0]) # energy from hardware
|
||||||
|
settings.hardware.position = 0, 60, 0, 30, 0, 0
|
||||||
|
ub.addref([1, 0, 0])# energy and position from hardware
|
||||||
|
|
||||||
|
# Add 2nd reflection (this time without the harware adapter)
|
||||||
|
ub.c2th([0, 1, 0], 12.39842)
|
||||||
|
ub.addref([0, 1, 0], [60, 0, 30, 0, 90], 12.39842)
|
||||||
|
|
||||||
|
# check the state
|
||||||
|
ub.ub()
|
||||||
|
ub.checkub()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###################################################################################################\
|
||||||
|
#Constraints
|
||||||
|
###################################################################################################
|
||||||
|
help(hkl.con)
|
||||||
|
hkl.con('qaz', 90)
|
||||||
|
hkl.con('a_eq_b')
|
||||||
|
hkl.con()
|
||||||
|
|
||||||
|
###################################################################################################\
|
||||||
|
#Motion
|
||||||
|
###################################################################################################
|
||||||
|
print angles_to_hkl((60., 0., 30., 0., 0.))
|
||||||
|
print hkl_to_angles(1, 0, 0)
|
||||||
|
fivec.write([60, 0, 30, 90, 0])
|
||||||
|
print "fivec=" , fivec.position
|
||||||
|
wl.write(1.0)
|
||||||
|
print "wl = ", wl.read()
|
||||||
|
|
||||||
|
# Load the last ub calculation used
|
||||||
|
ub.lastub()
|
||||||
|
ub.setu ([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
|
||||||
|
ub.showref()
|
||||||
|
ub.swapref(1,2)
|
||||||
|
|
||||||
|
#print you.hkl
|
||||||
|
#pos(get_hkl())
|
||||||
|
hkl_group.read()
|
||||||
|
#you.hkl.simulateMoveTo([0,1,1])
|
||||||
|
#sim(get_hkl(), [0,1,1])
|
||||||
|
hkl_group.sim([0.0,1.0,1.0])
|
||||||
|
#pos(get_hkl(), [0,1,1])
|
||||||
|
hkl_group.write([0.0,1.0,1.0])
|
||||||
|
|
||||||
|
|
||||||
|
###################################################################################################\
|
||||||
|
#Scans
|
||||||
|
###################################################################################################
|
||||||
|
lscan(l, [sin], 1.0, 1.5, 0.1)
|
||||||
|
ascan([k,l], [sin], [1.0, 1.0], [1.2, 1.3], [0.1, 0.1], zigzag=True, parallel_positioning = False)
|
||||||
|
vector = [[1.0,1.0,1.0], [1.0,1.0,1.1], [1.0,1.0,1.2], [1.0,1.0,1.4]]
|
||||||
|
hklscan(vector, [sin, arr], 0.9)
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
en.move(20.0)
|
||||||
|
delta.config.maxSpeed = 50.0
|
||||||
|
delta.speed = 50.0
|
||||||
|
delta.move(1.0)
|
||||||
|
|
||||||
|
run("diffcalc/diffutils")
|
||||||
|
###################################################################################################\
|
||||||
|
#Setup
|
||||||
|
###################################################################################################
|
||||||
|
|
||||||
|
setup_diff(fourc, en)
|
||||||
|
# Set some limits
|
||||||
|
setup_axis('delta', 0, 179)
|
||||||
|
setup_axis('delta', min=0)
|
||||||
|
setup_axis('phi', cut=-180.0)
|
||||||
|
|
||||||
|
print_axis_setup()
|
||||||
|
|
||||||
|
###################################################################################################\
|
||||||
|
#Orientation
|
||||||
|
###################################################################################################
|
||||||
|
help(ub.ub)
|
||||||
|
ub.listub()
|
||||||
|
|
||||||
|
# Create a new ub calculation and set lattice parameters
|
||||||
|
ub.newub('test')
|
||||||
|
ub.setlat('cubic', 1, 1, 1, 90, 90, 90)
|
||||||
|
|
||||||
|
# Add 1st reflection (demonstrating the hardware adapter)
|
||||||
|
settings.hardware.wavelength = 1
|
||||||
|
ub.c2th([1, 0, 0]) # energy from hardware
|
||||||
|
settings.hardware.position = 0, 60, 0, 30, 0, 0
|
||||||
|
ub.addref([1, 0, 0])# energy and position from hardware
|
||||||
|
|
||||||
|
# Add 2nd reflection (this time without the harware adapter)
|
||||||
|
ub.c2th([0, 1, 0], 12.39842)
|
||||||
|
ub.addref([0, 1, 0], [60, 30, 0, 90], 12.39842)
|
||||||
|
|
||||||
|
# check the state
|
||||||
|
ub.ub()
|
||||||
|
ub.checkub()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
###################################################################################################\
|
||||||
|
#Constraints
|
||||||
|
###################################################################################################
|
||||||
|
help(hkl.con)
|
||||||
|
hkl.con('a_eq_b')
|
||||||
|
hkl.con()
|
||||||
|
|
||||||
|
###################################################################################################\
|
||||||
|
#Motion
|
||||||
|
###################################################################################################
|
||||||
|
print angles_to_hkl((60., 30., 0., 0.))
|
||||||
|
print hkl_to_angles(1, 0, 0)
|
||||||
|
fourc.write([60, 30, 90, 0])
|
||||||
|
print "fourc=" , fourc.position
|
||||||
|
wl.write(1.0)
|
||||||
|
print "wl = ", wl.read()
|
||||||
|
|
||||||
|
# Load the last ub calculation used
|
||||||
|
ub.lastub()
|
||||||
|
ub.setu ([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
|
||||||
|
ub.showref()
|
||||||
|
ub.swapref(1,2)
|
||||||
|
|
||||||
|
#print you.hkl
|
||||||
|
#pos(get_hkl())
|
||||||
|
hkl_group.read()
|
||||||
|
#you.hkl.simulateMoveTo([0,1,1])
|
||||||
|
#sim(get_hkl(), [0,1,1])
|
||||||
|
hkl_group.sim([0.0,1.0,1.0])
|
||||||
|
#pos(get_hkl(), [0,1,1])
|
||||||
|
hkl_group.write([0.0,1.0,1.0])
|
||||||
|
|
||||||
|
|
||||||
|
###################################################################################################\
|
||||||
|
#Scans
|
||||||
|
###################################################################################################
|
||||||
|
#lscan(l, [sin], 1.0, 1.5, 0.1)
|
||||||
|
#ascan([k,l], [sin], [1.0, 1.0], [1.2, 1.3], [0.1, 0.1], zigzag=True, parallel_positioning = False)
|
||||||
|
vector = [[1.0,1.0,1.0], [1.0,1.0,1.1], [1.0,1.0,1.2], [1.0,1.0,1.4]]
|
||||||
|
hklscan(vector, [sin, arr])
|
||||||
@@ -8,7 +8,7 @@ run("diffcalc/diffutils")
|
|||||||
#Setup
|
#Setup
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
|
|
||||||
setup_sixc(sixc, en)
|
setup_diff(sixc, en)
|
||||||
# Set some limits
|
# Set some limits
|
||||||
setup_axis('gam', 0, 179)
|
setup_axis('gam', 0, 179)
|
||||||
setup_axis('delta', 0, 179)
|
setup_axis('delta', 0, 179)
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
|
import traceback
|
||||||
|
|
||||||
THETA_RANGE = (0.0, 5.0)
|
THETA_RANGE = (0.0, 5.0)
|
||||||
THETA_STEP = 1.0
|
THETA_STEP = 1.0
|
||||||
PHI_RANGE = (-160.0, +160.0)
|
PHI_RANGE = (-160.0, +160.0)
|
||||||
PHI_STEP = 40.0
|
PHI_STEP = 160.0 #40.0
|
||||||
|
|
||||||
LATENCY = 0.0
|
LATENCY = 0.0
|
||||||
ZIGZAG = True
|
ZIGZAG = True
|
||||||
@@ -30,21 +31,21 @@ print "phi_positions: ", phi_positions
|
|||||||
|
|
||||||
def before_pass(pass_num, scan):
|
def before_pass(pass_num, scan):
|
||||||
print "Initializing pass ", pass_num
|
print "Initializing pass ", pass_num
|
||||||
phi = phi_positions[pass_num]
|
phi = phi_positions[pass_num-1]
|
||||||
inp.write(phi)
|
inp.write(phi)
|
||||||
print "phi = ", phi
|
|
||||||
|
|
||||||
#phi = phi_positions[record.index/THETA_NSTEPS]
|
|
||||||
#ManipulatorPhi.write(phi)
|
|
||||||
#print "phi = ", phi
|
#print "phi = ", phi
|
||||||
#ManipulatorPhi.waitValueInRange(phi, 1.0, 100)
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cscan(MOTORS, SENSORS, THETA_RANGE[0], THETA_RANGE[1], THETA_NSTEPS - 1, time=theta_time, passes = len(phi_positions), zigzag = ZIGZAG, before_pass=before_pass)
|
while(True):
|
||||||
|
cscan(MOTORS, SENSORS, THETA_RANGE[0], THETA_RANGE[1], THETA_NSTEPS - 1, latency=0.1, time=theta_time, passes = len(phi_positions), zigzag = ZIGZAG, before_pass=before_pass, check_positions = False)
|
||||||
except Exception:
|
except Exception:
|
||||||
print sys.exc_info()[1]
|
#print sys.exc_info()
|
||||||
|
traceback.print_exc()
|
||||||
|
traceback.print_stack()
|
||||||
|
print "Caught"
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if ENDSCAN:
|
if ENDSCAN:
|
||||||
|
|||||||
Reference in New Issue
Block a user