-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathH5OINA_Convert.m
83 lines (69 loc) · 2.34 KB
/
H5OINA_Convert.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
function [ebsdtemp] = H5OINA_Convert(ebsd_data,header_data,file_dset,phase_names,phase_colors)
%H5OINA_CONVERT Convert the output from the HFOINA_Read function into a
%MTEX EBSD container
%
% Ben Britton - Feb 2024
%
% Adapted from load_h5oina
slice_name=['s' file_dset];
CS{1}='notIndexed';
num_phases=numel(header_data.(slice_name).phase);
for n=1:num_phases
phaseN=1+n;
Space_Group=double(header_data.(['s' file_dset]).phase{n}.Space_Group);
Lattice_Dimensions=double(header_data.(['s' file_dset]).phase{n}.Lattice_Dimensions);
if nargin >= 4
Mineral=phase_names{n};
else
Mineral=char(header_data.(['s' file_dset]).phase{1}.Phase_Name);
end
Lattice_Angles=double(header_data.(['s' file_dset]).phase{n}.Lattice_Angles);
% round(
if nargin < 5
CS{phaseN} = crystalSymmetry('SpaceId',Space_Group, ...
Lattice_Dimensions,...
Lattice_Angles,...
'Mineral',Mineral);
else
CS{phaseN} = crystalSymmetry('SpaceId',Space_Group, ...
Lattice_Dimensions,...
Lattice_Angles,...
'Mineral',Mineral,'Color',phase_colors{n});
end
end
rc = rotation.byEuler(double(header_data.(slice_name).Specimen_Orientation_Euler(:)')*degree); % what definition? Bunge?
% set up EBSD data
rot = rc*rotation.byEuler(ebsd_data.(slice_name).Euler');
phase = ebsd_data.(slice_name).Phase;
opt=struct;
% read some fields
EBSD_fieldnames=fieldnames(ebsd_data.(slice_name));
num_fields=size(EBSD_fieldnames,1);
for n = 1: num_fields
s=ebsd_data.(slice_name).(EBSD_fieldnames{n});
if size(s,2) == 1 && size(s,1) == numel(phase)
try
opt.(EBSD_fieldnames{n})=double(s);
catch
try
opt.(EBSD_fieldnames{n})=s;
catch
end
end
end
end
%not put the Euler angles in the options too
if isfield(ebsd_data.(slice_name),'Euler')
opt.euler1=double(ebsd_data.(slice_name).Euler(1,:)');
opt.euler2=double(ebsd_data.(slice_name).Euler(2,:)');
opt.euler3=double(ebsd_data.(slice_name).Euler(3,:)');
end
try
opt.x=opt.Beam_Position_X;
opt.y=opt.Beam_Position_Y;
catch
error('Beam Positions Not Loaded - was this a pattern match file?')
end
ebsdtemp = EBSD(rot,phase,CS,opt,'unitCell',calcUnitCell([opt.x,opt.y]));
ebsdtemp.opt.Header = header_data.(slice_name);
end