-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostProcessing_template.m
174 lines (140 loc) · 8.56 KB
/
postProcessing_template.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
close all;
clear;
% Enter all path without slash in the end
% ADD DEPENDENCIES - VERY IMPORTANT TO SETUP AT NEW PLACE
code_location = '/home/dzhigd/Software/preprocessing';
addpath(fullfile(code_location,'functions'));
addpath(fullfile(code_location,'classDef'));
code_location = '/home/dzhigd/Software/phasor';
% add class definitions and functions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
addpath(genpath(fullfile(code_location,'functions')));
addpath(genpath(fullfile(code_location,'classDef')));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
scan_number = {'622-630'}; % list of changing string ids for each scan. Example: scan_number = {'1', '2', 'test'};
twin = {}; % list of changing string ids for twinned reconstruction. Can be empty. Example: twin = {'1', '2', 'test'};
for ii = 1:numel(scan_number) % loop through scan/scans
% Path to reconstruction folder with changing string ids in the place
% of %s
input_param.pre_path = sprintf('/home/dzhigd/work/projects/InZrO_TCO_films/Experiments/APS-34IDC/19112020/analysis/cohere/19112020_%s/prep/reconstructionRec-A--GAHIOlr-BST-sS-5-3-620-NM-SW',scan_number{ii});
% Path to experimental parameters.
% For the case of NanoMAX it is the path to scan file. For example:
% input_param.experimental_parameters_path = sprintf('scan_%s_merlin.mat',scan_number{ii});
input_param.experimental_parameters_path = sprintf('/home/dzhigd/work/projects/InZrO_TCO_films/Experiments/APS-34IDC/19112020/analysis/cohere/19112020_%s/conf',scan_number{ii});
% Prefix generated by the phase retrieval program
file_prefix = 'Rec-A--GAHIOlr-BST-sS-5-3-620-NM-SW-';
% SPECIFY THE BEAMLINE HERE! Options: '34idc', 'p10', 'nanomax'
input_param.experiment.beamline = '34idc';
detector_amp_reconstruction_path = [file_prefix, 'AMP.mat'];
detector_ph_reconstruction_path = [file_prefix, 'PH.mat'];
load(fullfile(input_param.pre_path,detector_amp_reconstruction_path));
a = array;
load(fullfile(input_param.pre_path,detector_ph_reconstruction_path));
% reconstructed object
input_param.object = a.*exp(1j*array);
clear array;
% Default for now
input_param.object_sampling = [1,1,1];
switch input_param.experiment.beamline
case '34idc'
% 34 ID-C, APS, Argonne
configdisp = importfile_cohere_disp(fullfile(input_param.experimental_parameters_path,'config_disp'), [2, Inf]);
% Fill it in manually otherwise
% input_param.experiment.data_path = '/home/dzhigd/work/projects/CsPbBr3_NC_BCDI_NanoMAX/data/sample0609_442/Data-A-1X1.mat';
input_param.experiment.energy = configdisp{1,3}*1000; % [eV]
input_param.experiment.sample_detector_d = configdisp{4,3}/1000; % [m]
input_param.experiment.detector_pitch = 55e-6; % [m]
input_param.experiment.angular_step = configdisp{9,3}; % [degree]
input_param.experiment.energy_step = []; % [eV]
input_param.experiment.delta = configdisp{2,3}; %
input_param.experiment.gamma = configdisp{3,3}; %
input_param.experiment.theta = configdisp{5,3}; %
input_param.experiment.chi = configdisp{6,3}; %
input_param.experiment.phi = configdisp{7,3}; %scan.motor_positions.phi(63);
input_param.experiment.mu = 0.0;
input_param.experiment.rocking_motor = 'dtheta';
input_param.experiment.d_spacing = 0e-10; % interplanar spacing for desired reflection
% Minimum requirement for imput: complex valued array, real space pitch,
% experimental parameters (for coordinate conversion)
postPhasor = PostPhasor(input_param);
postPhasor.flip(1);
case 'p10'
fioParam = getinfoFio(input_param.experimental_parameters_path);
% input_param.experiment.data_path = '/home/dzhigd/work/projects/CsPbBr3_NC_BCDI_NanoMAX/data/sample0609_442/Data-A-1X1.mat';
input_param.experiment.energy = fioParam.motorVals(2); % [eV]
input_param.experiment.sample_detector_d = fioParam.motorVals(1)/1000; % [m]
input_param.experiment.detector_pitch = 75e-6; % [m]
input_param.experiment.angular_step = (fioParam.Vector(2)-fioParam.Vector(1)); % [degree]
input_param.experiment.energy_step = []; % [eV]
input_param.experiment.beamline = 'p10';
input_param.experiment.delta = fioParam.motorVals(4); %
input_param.experiment.gamma = fioParam.motorVals(5); %
input_param.experiment.phi = fioParam.motorVals(7); %
input_param.experiment.chi = fioParam.motorVals(3); %
input_param.experiment.omega = fioParam.motorVals(6); %scan.motor_positions.phi(63);
input_param.experiment.mu = 0.0;
input_param.experiment.rocking_motor = fioParam.fastMotorName;
input_param.experiment.d_spacing = 0e-10; % interplanar spacing for desired reflection
input_param.binning = params.binning;
% Minimum requirement for imput: complex valued array, real space pitch,
% experimental parameters (for coordinate conversion)
postPhasor = PostPhasor(input_param);
postPhasor.flip(1);
postPhasor.flip(2);
case 'nanomax'
load(input_param.experimental_parameters_path);
input_param.experiment.energy = scan.motor_positions.energy; % [eV]
input_param.experiment.sample_detector_d = scan.motor_positions.radius/1e3; % [m]
input_param.experiment.detector_pitch = 55e-6; % [m]
input_param.experiment.angular_step = abs(scan.rocking_angles(2)-scan.rocking_angles(1)); % [degree]
input_param.experiment.energy_step = []; % [eV
input_param.experiment.delta = scan.motor_positions.delta;
input_param.experiment.gamma = scan.motor_positions.gamma;
input_param.experiment.gontheta = scan.motor_positions.gontheta;
input_param.experiment.chi = 90; %
input_param.experiment.gonphi = scan.motor_positions.gonphi;
input_param.experiment.rocking_motor = scan.rocking_motor;
input_param.experiment.d_spacing = 0e-10; % interplanar spacing for desired reflection
postPhasor = PostPhasor(input_param);
warning('Flipping was not tested for NanoMAX, be carefull!')
postPhasor.flip(1);
postPhasor.flip(2);
end
%% Analysis of the reconstruction
if ismember(scan_number{ii},twin)
postPhasor.twin_object;
end
% Angular corrections with respect to the center of the detector.
% Define the position of the Bragg peak
postPhasor.experiment.delta_correction = 0;
postPhasor.experiment.gamma_correction = 0;
% Angular corrections with respect to the center of the detector.
postPhasor.experiment.theta_correction = 0;
postPhasor.experiment.phi_correction = 0;
% Transformation of the phasing result to the lab coordinate system:
% x - outboard, y - up, z - along the incoming beam
% should be used to calculate strain along the measured Q-vector
postPhasor.transform2lab;
% Transformation of the phasing result to the sample coordinate system:
% x - 2nd index, y - 1st index, z - 3rd index of the array
% should be used to evaluate morphology and for easier visualzation
% postPhasor.transform2sample; % for morphology evaluation
close;
zoom_value = [2.5, 1.5, 1.5];
postPhasor.center_object;
postPhasor.create_mask(0.25);
postPhasor.calculate_displacement;
postPhasor.calculate_qVectorLab;
postPhasor.iso3dObject;
postPhasor.plot_amplitude_slice(zoom_value);
postPhasor.plot_phase_slice(zoom_value);
postPhasor.plot_displacement_slice(zoom_value);
postPhasor.calculate_strainLab;
postPhasor.iso3dStrainLab(1);
% postPhasor.slice3d_object
postPhasor.plot_strain_slice(zoom_value);
%% Saving results
% postPhasor.save_vtk;
% postPhasor.save_instance;
% postPhasor.save_all(zoom_value)
end
%%% END OF FILE %%%