###
# Copyright 2008-2011 Diamond Light Source Ltd.
# This file is part of Diffcalc.
#
# Diffcalc is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Diffcalc is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Diffcalc.  If not, see <http://www.gnu.org/licenses/>.
###


reffile('cubic') 
latt([1,1,1,90,90,90])
pos mywl 1
c2th([0,0,1])
#60
pos euler [1 1 30 0 60 0] # delta + gam not moved
pos delta 60
pos gam 0
saveref('100',[1, 0, 0])
pos chi 91                      <-->  
saveref('001',[0, 0, 1]) ; showref()
ubm('100','001')
# array('d', [0.9996954135095477, -0.01745240643728364, -0.017449748351250637, 0.01744974835125045, 0.9998476951563913, -0.0003045864904520898, 0.017452406437283505, -1.1135499981271473e-16, 0.9998476951563912])

############################################################################################
mode euler 1

scan mywl .9 1.1 .02 hkl [1 0 0] euler psi 
#0.900000	1.0000	0.0000	-0.0000	1.0000	1.0000	26.744	0.0000	53.487	0.0000 90.000
#0.920000	1.0000	0.0000	-0.0000	1.0000	1.0000	27.387	0.0000	54.774	0.0000 90.000
#0.940000	1.0000	-0.0000	-0.0000	1.0000	1.0000	28.034	0.0000	56.069	0.0000 90.000
#0.960000	1.0000	0.0000	-0.0000	1.0000	1.0000	28.685	0.0000	57.371	0.0000 90.000
#0.980000	1.0000	-0.0000	-0.0000	1.0000	1.0000	29.341	0.0000	58.681	0.0000 90.000
#1.000000	1.0000	-0.0000	-0.0000	1.0000	1.0000	30.000	0.0000	60.000	0.0000 90.000
#1.020000	1.0000	-0.0000	-0.0000	1.0000	1.0000	30.664	0.0000	61.328	0.0000 90.000
#1.040000	1.0000	0.0000	-0.0000	1.0000	1.0000	31.332	0.0000	62.665	0.0000 90.000
#1.060000	1.0000	-0.0000	-0.0000	1.0000	1.0000	32.005	0.0000	64.011	0.0000 90.000
#1.080000	1.0000	0.0000	-0.0000	1.0000	1.0000	32.684	0.0000	65.367	0.0000 90.000
#1.100000	1.0000	0.0000	-0.0000	1.0000	1.0000	33.367	0.0000	66.734	0.0000 90.000

pos mywl 2
pos hkl [0 1 0]
psi()
# 179.00

pos hkl [0 0 1]
psi()
# 90.000

pos hkl [1 0 0]
#Warning::Vector and Azimuthal reference //, azimuthal reference not used
#Move completed: hkl : h: 1.0000 k: 0.0000 l: -0.0000
psi()
90.000


pos mywl 2
mode euler 2
scan phi -19 21 2 hkl [0 0 1] euler
#Writing data to file:/home/zrb13439/gda/dev/config-i16/users_test/data/4.dat
#  value	     h	     k	     l	    phi	   chi	   eta	    mu	 delta	 gamma
#-19.000	0.0000	0.0000	1.0000	-19.000	90.940	29.658	0.0000	60.000	0.0000
#-17.000	-0.0000	0.0000	1.0000	-17.000	90.951	29.691	0.0000	60.000	0.0000
#-15.000	-0.0000	0.0000	1.0000	-15.000	90.961	29.724	0.0000	60.000	0.0000
#-13.000	0.0000	-0.0000	1.0000	-13.000	90.970	29.758	0.0000	60.000	0.0000
#-11.000	-0.0000	-0.0000	1.0000	-11.000	90.978	29.792	0.0000	60.000	0.0000
#-9.0000	-0.0000	-0.0000	1.0000	-9.0000	90.985	29.826	0.0000	60.000	0.0000
#-7.0000	0.0000	0.0000	1.0000	-7.0000	90.990	29.861	0.0000	60.000	0.0000
#-5.0000	-0.0000	0.0000	1.0000	-5.0000	90.995	29.895	0.0000	60.000	0.0000
#-3.0000	-0.0000	-0.0000	1.0000	-3.0000	90.998	29.930	0.0000	60.000	0.0000
#-1.0000	0.0000	0.0000	1.0000	-1.0000	90.999	29.965	0.0000	60.000	0.0000
#1.0000	0.0000	0.0000	1.0000	1.0000	91.000	30.000	0.0000	60.000	0.0000
#3.0000	0.0000	-0.0000	1.0000	3.0000	90.999	30.035	0.0000	60.000	0.0000
#5.0000	-0.0000	-0.0000	1.0000	5.0000	90.998	30.070	0.0000	60.000	0.0000
#7.0000	-0.0000	0.0000	1.0000	7.0000	90.995	30.105	0.0000	60.000	0.0000
#9.0000	-0.0000	0.0000	1.0000	9.0000	90.990	30.139	0.0000	60.000	0.0000
#11.000	-0.0000	0.0000	1.0000	11.000	90.985	30.174	0.0000	60.000	0.0000
#13.000	-0.0000	-0.0000	1.0000	13.000	90.978	30.208	0.0000	60.000	0.0000
#15.000	0.0000	0.0000	1.0000	15.000	90.970	30.242	0.0000	60.000	0.0000
#17.000	0.0000	-0.0000	1.0000	17.000	90.961	30.276	0.0000	60.000	0.0000
#19.000	-0.0000	0.0000	1.0000	19.000	90.951	30.309	0.0000	60.000	0.0000
#21.000	0.0000	-0.0000	1.0000	21.000	90.940	30.342	0.0000	60.000	0.0000

scan phi -19 21 2 hkl [0 0 1] euler psi
#Writing data to file:/home/zrb13439/gda/dev/config-i16/users_test/data/16.dat
#  value	     h	     k	     l	    phi	   chi	   eta	    mu	 delta	 gamma	  value
#-19.000	0.0000	0.0000	1.0000	-19.000	90.940	29.658	0.0000	60.000	0.0000	-70.003
#-17.000	-0.0000	0.0000	1.0000	-17.000	90.951	29.691	0.0000	60.000	0.0000	-72.003
#-15.000	-0.0000	0.0000	1.0000	-15.000	90.961	29.724	0.0000	60.000	0.0000	-74.002
#-13.000	0.0000	-0.0000	1.0000	-13.000	90.970	29.758	0.0000	60.000	0.0000	-76.002
#-11.000	-0.0000	-0.0000	1.0000	-11.000	90.978	29.792	0.0000	60.000	0.0000	-78.002
#-9.0000	-0.0000	-0.0000	1.0000	-9.0000	90.985	29.826	0.0000	60.000	0.0000	-80.001
#-7.0000	0.0000	0.0000	1.0000	-7.0000	90.990	29.861	0.0000	60.000	0.0000	-82.001
#-5.0000	-0.0000	0.0000	1.0000	-5.0000	90.995	29.895	0.0000	60.000	0.0000	-84.001
#-3.0000	-0.0000	-0.0000	1.0000	-3.0000	90.998	29.930	0.0000	60.000	0.0000	-86.001
#-1.0000	0.0000	0.0000	1.0000	-1.0000	90.999	29.965	0.0000	60.000	0.0000	-88.000
#1.0000	0.0000	0.0000	1.0000	1.0000	91.000	30.000	0.0000	60.000	0.0000	-90.000
#3.0000	0.0000	-0.0000	1.0000	3.0000	90.999	30.035	0.0000	60.000	0.0000	-92.000
#5.0000	-0.0000	-0.0000	1.0000	5.0000	90.998	30.070	0.0000	60.000	0.0000	-93.999
#7.0000	-0.0000	0.0000	1.0000	7.0000	90.995	30.105	0.0000	60.000	0.0000	-95.999
#9.0000	-0.0000	0.0000	1.0000	9.0000	90.990	30.139	0.0000	60.000	0.0000	-97.999
#11.000	-0.0000	0.0000	1.0000	11.000	90.985	30.174	0.0000	60.000	0.0000	-99.999
#13.000	-0.0000	-0.0000	1.0000	13.000	90.978	30.208	0.0000	60.000	0.0000	-102.00
#15.000	0.0000	0.0000	1.0000	15.000	90.970	30.242	0.0000	60.000	0.0000	-104.00
#17.000	0.0000	-0.0000	1.0000	17.000	90.961	30.276	0.0000	60.000	0.0000	-106.00
#19.000	-0.0000	0.0000	1.0000	19.000	90.951	30.309	0.0000	60.000	0.0000	-108.00
#21.000	0.0000	-0.0000	1.0000	21.000	90.940	30.342	0.0000	60.000	0.0000	-110.00

####################################################################################
mode euler 3
scan psic -19 21 2 hkl [0 0 1] euler psi
#Writing data to file:/home/zrb13439/gda/dev/config-i16/users_test/data/18.dat
#value	     h	      k	     l	    phi	   chi	   eta	    mu	 delta	 gamma	  value
#  -19	0.0000	-0.0000	1.0000	-70.003	90.326	29.054	0.0000	60.000	0.0000	-19.000
#-17.000	0.0000	-0.0000	1.0000	-72.002	90.292	29.044	0.0000	60.000	0.0000	-17.000
#-15.000	0.0000	-0.0000	1.0000	-74.002	90.259	29.034	0.0000	60.000	0.0000	-15.000
#-13.000	-0.0000	-0.0000	1.0000	-76.002	90.225	29.026	0.0000	60.000	0.0000	-13.000
#-11.000	-0.0000	-0.0000	1.0000	-78.002	90.191	29.018	0.0000	60.000	0.0000	-11.000
#-9.0000	-0.0000	0.0000	1.0000	-80.001	90.156	29.012	0.0000	60.000	0.0000	-9.0000
#-7.0000	0.0000	0.0000	1.0000	-82.001	90.122	29.007	0.0000	60.000	0.0000	-7.0000
#-5.0000	0.0000	-0.0000	1.0000	-84.001	90.087	29.004	0.0000	60.000	0.0000	-5.0000
#-3.0000	-0.0000	0.0000	1.0000	-86.000	90.052	29.001	0.0000	60.000	0.0000	-3.0000
#-1.0000	-0.0000	0.0000	1.0000	-88.000	90.017	29.000	0.0000	60.000	0.0000	-1.0000
#1.0000	0.0000	-0.0000	1.0000	-90.000	89.983	29.000	0.0000	60.000	0.0000	1.0000
#3.0000	-0.0000	-0.0000	1.0000	268.00	89.948	29.001	0.0000	60.000	0.0000	3.0000
#5.0000	0.0000	-0.0000	1.0000	266.00	89.913	29.004	0.0000	60.000	0.0000	5.0000
#7.0000	0.0000	0.0000	1.0000	264.00	89.878	29.007	0.0000	60.000	0.0000	7.0000
#9.0000	-0.0000	-0.0000	1.0000	262.00	89.844	29.012	0.0000	60.000	0.0000	9.0000
#11.000	0.0000	0.0000	1.0000	260.00	89.809	29.018	0.0000	60.000	0.0000	11.000
#13.000	-0.0000	0.0000	1.0000	258.00	89.775	29.026	0.0000	60.000	0.0000	13.000
#15.000	-0.0000	0.0000	1.0000	256.00	89.741	29.034	0.0000	60.000	0.0000	15.000
#17.000	0.0000	-0.0000	1.0000	254.00	89.708	29.044	0.0000	60.000	0.0000	17.000
#19.000	0.0000	-0.0000	1.0000	252.00	89.674	29.054	0.0000	60.000	0.0000	19.000
#21.000	-0.0000	-0.0000	1.0000	250.00	89.642	29.066	0.0000	60.000	0.0000	21.000
#Scan complete.

##########################################################################################
# Move gamma and mu and read back hkl positions
mode euler 1
pos hkl [1 0 0]
#Warning::Vector and Azimuthal reference //, azimuthal reference not used
#Move completed: hkl : h: 1.0000 k: -0.0000 l: -0.0000
hkl()
#[0.9999999999999998, -3.8988661640799736e-17, -1.457167719820518e-16]
euler()
#[0.9999999999999994, 0.9999999999999912, 30.000000000000007, 0.0, 60.00000000000001, 0.0]
pos gam 10
euler()
#[0.9999999999999994, 0.9999999999999912, 30.000000000000007, 0.0, 60.00000000000001, 10.0]
hkl()
#[1.0037980617469482, -0.006578435915997894, 0.08682408883346501]

>>>pos mu 10
Move completed: mu : 10.000
>>>hkl()
[0.996201938253052, 0.006578435915997645, 0.08682408883346503]


# arbitrary position:
>>>euler()
[1.9, 2.9, 30.9, 0.9, 60.9, 2.9]

>>>hkl()
[1.0117418909164064, 0.02368622807445844, 0.06627361269425353]

>>>az.getAzimuthalReference().array
array([D, [array('d', [1.0]), array('d', [0.0]), array('d', [0.0])])

>>>az.calcN_L()
[0.8494223227931345, -0.5260858416846694, -0.04141744462963532]

>>>az.calcPsi()
[-109.75394072042344, -109.7539407204235]

>>>az.getAlpha()
31.741370382777166

>>>az.getBeta()
29.055463912559212

>>>az.getPhi_az()
-87.20849481167566

>>>az.calcPsi()
[-109.75394072042344, -109.7539407204235]

>>>az.getTau()
0.06945050942570621

