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

Added gtIndexAddInfo.

parent d057a47b
No related branches found
No related tags found
No related merge requests found
function grain = gtIndexAddInfo(grain, phaseid, parameters)
% GTINDEXADDINFO Adds additional diff. spot info to the indexed grains to
% be used in the geometry and strain fitting.
%
% grain = gtIndexAddInfo(grain, phasid, parameters)
if ~exist('phaseid','var') || isempty(phaseid)
phaseid = 1;
end
if ~exist('parameters','var') || isempty(parameters)
disp('Loading parameters file...')
parameters = load('parameters.mat');
parameters = parameters.parameters;
end
fprintf('\nTreating phase #%d ...\n',phaseid)
difspottable = [parameters.acq.name 'difspot'];
pairtable = parameters.acq.pair_tablename;
% B matrix
Bmat = gtCrystHKL2CartesianMatrix(parameters.cryst(phaseid).latticepar);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Difspot info
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tic
% Get pair ID-s
disp('Connecting to database...')
gtDBConnect
% Get spot and pair data
% /use of mysql multiple rows seems unstable -> done one-by-one/
fprintf('Loading diff. spot data from difspottable %s ...\n', difspottable)
[difID_spot, centU, centV, centim] = mym(sprintf('SELECT difspotID,CentroidX,CentroidY,CentroidImage FROM %s',difspottable));
fprintf('Loading Friedel pair data from pairtable %s ...\n', pairtable)
[pairID, omegaA, omegaB, etaA, etaB] = mym(sprintf('SELECT pairID,omega,omegaB,eta,etaB FROM %s',pairtable));
disp('Adding diff. spot data to grains...')
parfor ii = 1:length(grain)
% Coordinates of the plane normals in the Cartesian Crystal system
grain{ii}.plref = gtCrystHKL2Cartesian(grain{ii}.hklsp, Bmat);
% Strain
if ~isfield(grain{ii},'strain') || ~isfield(grain{ii}.strain,'strainT')
grain{ii}.strain.strainT = NaN(3,3);
end
% Spot centers A and B
grain{ii}.centA = zeros(2,length(grain{ii}.difspotidA));
grain{ii}.centB = grain{ii}.centA;
grain{ii}.centimA = zeros(1,length(grain{ii}.difspotidA));
grain{ii}.centimB = grain{ii}.centimA;
grain{ii}.omegaA = zeros(1,length(grain{ii}.difspotidA));
grain{ii}.omegaB = grain{ii}.omegaA;
grain{ii}.etaA = zeros(1,length(grain{ii}.difspotidA));
grain{ii}.etaB = grain{ii}.etaA;
for jj = 1:length(grain{ii}.difspotidA)
ind = find(grain{ii}.difspotidA(jj) == difID_spot, 1, 'first');
grain{ii}.centA(:,jj) = [centU(ind) centV(ind)];
grain{ii}.centimA(jj) = centim(ind);
ind = find(grain{ii}.difspotidB(jj) == difID_spot, 1, 'first');
grain{ii}.centB(:,jj) = [centU(ind) centV(ind)];
grain{ii}.centimB(jj) = centim(ind);
ind = find(grain{ii}.pairid(jj) == pairID, 1, 'first');
grain{ii}.omegaA(1,jj) = omegaA(ind);
grain{ii}.omegaB(1,jj) = omegaB(ind);
grain{ii}.etaA(1,jj) = etaA(ind);
grain{ii}.etaB(1,jj) = etaB(ind);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Other info
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Equivalent pairs in each grain
disp('Searching equivalent pairs...')
grain = gtIndexEquivalentPairs(grain);
% Add unique plane normals
grain = gtIndexUniqueReflections(grain, parameters.cryst(phaseid).dspacing,...
parameters.acq.energy);
% Forward simulation
disp('Forward simulating indexed reflections...')
omstep = 180/parameters.acq.nproj;
labgeo = parameters.labgeo;
labgeo.detorig = gtGeoDetOrig(labgeo);
labgeo.detnorm = cross(labgeo.detdiru, labgeo.detdirv);
grain = gtIndexFwdSimPairs(grain, labgeo, parameters.samgeo,...
[], parameters.cryst(phaseid).latticepar, omstep, parameters.acq.energy);
toc
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