Skip to content
Snippets Groups Projects
Commit 513ccb08 authored by Laura Nervo's avatar Laura Nervo Committed by Nicola Vigano
Browse files

Taper data : updated and improved the conversion from Fable output to DCT object.


Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@970 4c865b51-4357-4376-afb4-474e03ccb993
parent e2ecdea8
No related branches found
No related tags found
No related merge requests found
function grain = gtTaperConvertFableOutputToDCT(pathtofile)
% grain = gtTaperConvertFableOutputToDCT(pathtofile)
function grain = gtTaperConvertFableOutputToDCT(pathtofiles,map_file,detector_par)
% grain = gtTaperConvertFableOutputToDCT(pathtofiles,map_file,detector_par)
if exist(pathtofile,'file') && ~isempty(pathtofile)
[fable_dir, map_file, ext] = fileparts(pathtofile);
map_file = [map_file ext];
else
fable_dir = 'workspace/grid';
map_file = 'all_smalls_fitted_2.map';
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
bash_script = fullfile('/users',getenv('USER'),'matlabDCT','zUtil_Taper','script_generate_files.sh');
cmd = [bash_script ' ' fullfile(fable_dir,map_file)];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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(fable_dir,'rodrigues.txt'));
C = textscan(fid, '%*s %f %f %f');
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);
A = cell2mat(C);
gff = cell2mat(C);
fid = fopen(fullfile(fable_dir,'centers.txt'));
C = textscan(fid, '%*s %f %f %f');
fclose(fid);
A2 = 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
fid = fopen(fullfile(fable_dir,'npeaks.txt'));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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(fable_dir,'sum_of_all.txt'));
fid = fopen(fullfile(pathtofiles,'sum_of_all.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A4 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'medians.txt'));
fid = fopen(fullfile(pathtofiles,'medians.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A5 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'mins.txt'));
fid = fopen(fullfile(pathtofiles,'mins.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A6 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'maxs.txt'));
fid = fopen(fullfile(pathtofiles,'maxs.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A7 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'means.txt'));
fid = fopen(fullfile(pathtofiles,'means.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A8 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'stds.txt'));
fid = fopen(fullfile(pathtofiles,'stds.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A9 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'ns.txt'));
fid = fopen(fullfile(pathtofiles,'ns.txt'));
C = textscan(fid, '%d');
fclose(fid);
A10 = cell2mat(C);
......@@ -70,11 +91,9 @@ A10 = cell2mat(C);
grain = [];
for ii = 1:length(A)
grain{ii}.ind = ii;
grain{ii}.R_vector = A(ii,:);
grain{ii}.g = Rod2g( grain{ii}.R_vector );
grain{ii}.angles = gtMathsRod2Euler( grain{ii}.R_vector );
grain{ii}.center = A2(ii,:);
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);
......@@ -87,6 +106,13 @@ for ii = 1:length(A)
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,[]);
......
......@@ -35,8 +35,8 @@ then
cd $DPATH
less $FILE | grep Rod > rodrigues.txt
less $FILE | grep trans > centers.txt
#less $FILE | grep Rod > rodrigues.txt
#less $FILE | grep trans > centers.txt
less $FILE | grep npks > npeaks.txt
less $FILE | grep intensity > intensities.txt
less intensities.txt | awk -F", " '{print $1}' | awk -F"= " '{print $2}' > sum_of_all.txt
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment