-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake_horace.m
79 lines (62 loc) · 1.76 KB
/
make_horace.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%% directories
par_file = '~/Desktop/YBCF_data_80meV/ARCS_2x1_grouping.par';
sqw_file = '~/Desktop/YBCF_data_80meV/ybcf_80meV.sqw';
tmpdir = '~/Desktop/YBCF_data_80meV/horace_tmp/';
indir = '~/Desktop/YBCF_data_80meV/';
%% crystal parameters
%direct geometry
emode = 1;
alatt = [3.875 3.875 7.679];
angdeg = [90,90,90];
% vector || incident beam
u = [1 0 0];
% vector perpendicular to the incident beam,
% pointing towards the large angle detectors on Merlin in the horizontal plane
v = [0 1 0];
%offset angles in case of crystal misorientation (see the Horace manual for details)
omega = 0.0;
%dpsi = 0.0;
%gl = 0.0;
%gs = 0.0;
% Corrected values
dpsi = -2.64;
gl = -0.87;
gs = -1.31;
%% Ei = 80 meV, normalized
fName = dir([indir '*.nxspe']);
fName = {fName.name};
% convert data to sqw
nfiles = numel(fName);
psi = zeros(nfiles,1);
efix = zeros(nfiles,1);
spe_file = cell(nfiles,1);
for idx = 1:nfiles
spe_file{idx} = [indir fName{idx}];
efix(idx) = h5read(spe_file{idx},'/data/NXSPE_info/fixed_energy');
%psi(idx) = h5read(spe_file{idx},'/data/NXSPE_info/psi');
[~,tName] = fileparts(fName{idx});
temp = sscanf(strrep(strrep(tName(13:end),'p','.'),'_',' '),'%f %f %f');
T(idx) = temp(2);
psi(idx) = temp(3);
end
fprintf('Number of files ready to convert: %d.\n',nfiles);
t1 = clock;
gen_sqw(spe_file,par_file,sqw_file,efix,emode,alatt,angdeg,u,v,psi,omega,dpsi,gl,gs);
t2 = clock;
etime(t2,t1)
%% bin
proj.uoffset = [0 0 0];
proj.type = 'ppr';
% (H,K,0) scattering plane
proj.u = [1 0 0];
proj.v = [0 1 0];
% symmetrize all data
Q1 = [-2 0.04 2];
Q2 = [-2 0.04 2];
Q3 = [-6 6];
E0 = [20 25];
t1 = clock;
dat1s = cut_sqw(sqw_file,proj,Q1,Q2,Q3,E0);
t2 = clock;
etime(t2,t1)
% 16s s