-
Signed-off-by:
Laura Nervo <laura.nervo@esrf.fr> git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@970 4c865b51-4357-4376-afb4-474e03ccb993
Signed-off-by:
Laura Nervo <laura.nervo@esrf.fr> git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@970 4c865b51-4357-4376-afb4-474e03ccb993
gtTaperConvertFableOutputToDCT.m 3.65 KiB
function grain = gtTaperConvertFableOutputToDCT(pathtofiles,map_file,detector_par)
% grain = gtTaperConvertFableOutputToDCT(pathtofiles,map_file,detector_par)
if ~exist(pathtofiles,'dir') || isempty(pathtofiles)
disp(['directory ' pathtofiles ' does not exist...'])
return
end
if ~exist(fullfile(pathtofiles,map_file),'file')
disp(['file ' map_file ' does not exist...'])
return
end
if ~exist(fullfile(pathtofiles,detector_par),'file')
disp(['file ' detector_par ' does not exist...'])
return
end
output_gff = [map_file(1:end-4) '.gff'];
% to be run in the analsysis directory
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% convert ubi file into gff file
% grainno x y z rodx rody rodz
% ... U11 U12 U13 U21 U22 U23 U31 U32 U33
% ... eps11 eps22 eps33 eps23 eps13 eps12
cmd=['ubi_to_gff.py ' fullfile(pathtofiles,map_file) ' ' ...
fullfile(pathtofiles,detector_par) ' ' ...
fullfile(pathtofiles,output_gff)];
[~,msg]=unix(cmd);
disp(msg)
fid = fopen(fullfile(pathtofiles,output_gff));
C = textscan(fid, '%*d %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f','Headerlines',1);
fclose(fid);
gff = cell2mat(C);
rod = gff(:,4:6); % rx ry rz
cen = gff(:,1:3); % x y z
U = gff(:,7:15); % ... U11 U12 U13 U21 U22 U23 U31 U32 U33
eps = gff(:,16:end); % ... eps11 eps22 eps33 eps23 eps13 eps12
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% generate txt files from ubi file and save all into grain
bash_script = fullfile('/users',getenv('USER'),'matlabDCT','zUtil_Taper','script_generate_files.sh');
cmd = [bash_script ' ' fullfile(pathtofiles,map_file)];
[~,msg]=unix(cmd);
disp(msg)
fid = fopen(fullfile(pathtofiles,'npeaks.txt'));
C = textscan(fid, '%*s %d');
fclose(fid);
A3 = cell2mat(C);
format longg
fid = fopen(fullfile(pathtofiles,'sum_of_all.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A4 = cell2mat(C);
fid = fopen(fullfile(pathtofiles,'medians.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A5 = cell2mat(C);
fid = fopen(fullfile(pathtofiles,'mins.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A6 = cell2mat(C);
fid = fopen(fullfile(pathtofiles,'maxs.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A7 = cell2mat(C);
fid = fopen(fullfile(pathtofiles,'means.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A8 = cell2mat(C);
fid = fopen(fullfile(pathtofiles,'stds.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A9 = cell2mat(C);
fid = fopen(fullfile(pathtofiles,'ns.txt'));
C = textscan(fid, '%d');
fclose(fid);
A10 = cell2mat(C);
grain = [];
for ii = 1:length(A)
grain{ii}.id = ii;
grain{ii}.center = cen(ii,:);
grain{ii}.R_vector = rod(ii,:);
grain{ii}.npeaks = A3(ii);
grain{ii}.allint = A4(ii);
grain{ii}.median = A5(ii);
grain{ii}.min = A6(ii);
grain{ii}.max = A7(ii);
grain{ii}.mean = A8(ii);
grain{ii}.std = A9(ii);
grain{ii}.n = A10(ii);
grain{ii}.stat.intmean = double(grain{ii}.allint);
grain{ii}.stat.bbxsmean = 1;
grain{ii}.stat.bbysmean = 1;
grain{ii}.R_onedge = false;
grain{ii}.g = Rod2g( grain{ii}.R_vector );
grain{ii}.euler = gtMathsRod2Euler( grain{ii}.R_vector );
grain{ii}.U = [U(ii,1:3);U(ii,4:6);U(ii,7:9)];
grain{ii}.eps = eps(ii,:);
grain{ii}.strainT = [eps(ii,1) eps(ii,6) eps(ii,5); ...
eps(ii,6) eps(ii,2) eps(ii,4); ...
eps(ii,5) eps(ii,4) eps(ii,3)];
end
rvec = gtIndexAllGrainValues(grain,'R_vector',[],1:3,[]);
rotmat = gtMathsRod2RotMat( rvec );
for ii=1:length(grain)
grain{ii}.rotmat = rotmat{ii};
end
end % end of function