Skip to content
Snippets Groups Projects
Commit 203eb63f authored by Peter Reischig's avatar Peter Reischig Committed by Nicola Vigano
Browse files

Added gtIndexEquivalentPairs and gtIndexUniqueReflections.


Functions to find and average equivalent Friedel pairs in grains (pairs that belong to the same plane normal).

Signed-off-by: default avatarPeter Reischig <peter.reischig@esrf.fr>
parent 55576c97
No related branches found
No related tags found
No related merge requests found
function grain = gtIndexEquivalentPairs(grain)
% GTINDEXEQUIVALENTPAIRS Finds the equivalent Friedel pairs (two pairs
% that originate from the same plane) in all grains.
%
% grain = gtIndexEquivalentPairs(grain)
%
% ------------------------------------------------------------
%
% INPUT
% grain - all grain data as in index.mat
%
% OUTPUT
% grain.equipair - linear indices of the corresponding Friedel pairs;
% zero if no corresponding pair was found.
% grain.equilist - list of equivalent Friedel pair indices
for ii = 1:length(grain)
grain{ii}.equipair = zeros(1,length(grain{ii}.hklind));
grain{ii}.equilist = [];
% Loop through Friedel pairs of the grain
for jj = 1:length(grain{ii}.hklind);
% Check which linear indices of {hkl} and (hkl) match
inds1 = (grain{ii}.hklind == grain{ii}.hklind(jj));
inds2 = (grain{ii}.shklind == grain{ii}.shklind(jj));
inds2(jj) = false;
% Index of equivalent pair
equiind = find(inds1 & inds2);
if ~isempty(equiind)
% Maximum one equivalent pair can exist
if (length(equiind) > 1)
msg = sprintf('More than two equivalent Friedel pairs found for pair #%d in grain #%d', jj, ii);
warning(msg)
disp('The equivalent pair with the lower index was selected.')
end
grain{ii}.equipair(jj) = equiind(1);
if (jj < grain{ii}.equipair(jj))
grain{ii}.equilist(end+1,:) = [jj grain{ii}.equipair(jj)];
end
end
end
end
end % of function
\ No newline at end of file
function grain = gtIndexUniqueReflections(grain, dspref, energy)
% GTINDEXUNIQUEREFLECTIONS Unique list of Friedel pairs for all grains.
% Data is averaged when two Friedel pairs are indexed for a (hkl) plane.
%
% grain = gtIndexUniqueReflections(grain, dspref, energy)
%
% -------------------------------------------------------
%
% Creates a unique list of the indexed Friedel pairs in which each (hkl)
% plane is present maximum once using the pair equivalence info in
% grain{}.equilist.
%
% INPUT
% grain - all grain data as in index.mat
% dspref - list of reference d-spacings for the {hkl} families as in
% parameters.cryst.dspacing
% energy - beam energy in keV
%
% OUTPUT
% grain.uni. - unique reflections list and (averaged) measured properties:
% .pl - plane normals
% .plref - plane normals in reference crystal (unstrained,
% theoretical)
% .hklind - linear indices of the {hkl} families (=thetaype)
% .theta - theta Bragg angles
% .elo - elongations along 'pl'
% .dang - angular deviations (between two Friedel pairs)
% .dth - theta deviations (between two Friedel pairs)
% .delo - elongation deviations (between two Friedel pairs)
lambda = gtConvEnergyToWavelength(energy);
for ii = 1:length(grain)
uni.pl = [];
uni.plref = [];
uni.hklind = [];
uni.theta = [];
uni.elo = [];
uni.dang = [];
uni.dth = [];
uni.delo = [];
if ~isempty(grain{ii}.equilist)
i1 = grain{ii}.equilist(:,1);
i2 = grain{ii}.equilist(:,2);
spl = sign(sum(grain{ii}.pl(:,i1) .* grain{ii}.pl(:,i2), 1));
pl = 0.5*(grain{ii}.pl(:,i1) + spl([1 1 1],:).*grain{ii}.pl(:,i2));
pln = sqrt(sum(pl.^2,1));
uni.pl = pl./pln([1 1 1],:);
uni.plref = grain{ii}.plref(:,i1);
uni.hklind = grain{ii}.hklind(i1);
uni.theta = 0.5*(grain{ii}.theta(i1) + grain{ii}.theta(i2));
uni.elo = (0.5*lambda./sind(uni.theta))./dspref(grain{ii}.hklind(i1));
uni.dang = gtMathsVectorsAngles(grain{ii}.pl(:,i1), ...
grain{ii}.pl(:,i2), 1);
%uni.dom = (grain{ii}.centimB - grain{ii}.centimA)*omstep - 180;
uni.dth = abs(grain{ii}.theta(i1) - grain{ii}.theta(i2));
uni.delo = abs(((0.5*lambda./sind(grain{ii}.theta(i1))) - ...
(0.5*lambda./sind(grain{ii}.theta(i2))))./dspref(grain{ii}.hklind(i1)));
end
ind = (grain{ii}.equipair == 0);
uni.pl = [uni.pl, grain{ii}.pl(:,ind)];
uni.plref = [uni.plref, grain{ii}.plref(:,ind)];
uni.hklind = [uni.hklind, grain{ii}.hklind(ind)];
uni.theta = [uni.theta, grain{ii}.theta(ind)];
uni.elo = [uni.elo, (0.5*lambda./sind(grain{ii}.theta(ind)))./dspref(grain{ii}.hklind(ind));];
grain{ii}.uni = uni;
end
end % of function
\ No newline at end of file
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