From 0743679f7d1b2ab2ca16fcf150da19638dc4b574 Mon Sep 17 00:00:00 2001 From: gac-x04sa Date: Fri, 17 Aug 2018 11:07:01 +0200 Subject: [PATCH] Startup --- script/test/TestFourcv.py | 114 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 script/test/TestFourcv.py diff --git a/script/test/TestFourcv.py b/script/test/TestFourcv.py new file mode 100644 index 0000000..354ff67 --- /dev/null +++ b/script/test/TestFourcv.py @@ -0,0 +1,114 @@ +en.move(20.0) +delta.config.maxSpeed = 50.0 +delta.speed = 50.0 +delta.move(1.0) + +run("diffcalc/diffutils") +###################################################################################################\ +#Setup +################################################################################################### + +class FourCircleX04SA_V(YouGeometry): + """For a diffractometer with angles: + mu, delta, nu, eta + """ + def __init__(self): + YouGeometry.__init__(self, 'fourcv', {'phi': 0, 'chi': 0}) + + def physical_angles_to_internal_position(self, physical_angle_tuple): + # mu, delta, nu, eta, chi, phi + mu, delta, nu, eta = physical_angle_tuple + return YouPosition(mu, delta, nu, eta, 0, 0) + + def internal_position_to_physical_angles(self, internal_position): + mu, delta, nu, eta, _, _ = internal_position.totuple() + return mu, delta, nu, eta + + + + +###################################################################################################\ +#Setup +################################################################################################### + +#alp, del, gam, ov +FourCircleX04SA_V() +setup_diff(fourcv, en, FourCircleX04SA_V()) + +# Set some limits +setup_axis('delta', 0, 90) +setup_axis('delta', min=0) +#setup_axis('gam', 0, 180) +#setup_axis('eta', 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') + + +###################################################################################################\ +#Motion +################################################################################################### +print angles_to_hkl((0.0, 60., 0.0, 30.)) +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], 0.5, 1.0, 0.1) +ascan([k,l], [sin], [1.0, 1.0], [1.2, 1.3], [0.1, 0.1], latency=0.5, 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]) + + +