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

gtCrystCalculateReflections : modified output (now as structure) with all the...

gtCrystCalculateReflections : modified output (now as structure) with all the info inside (to be imported in cryst), remove 'typelist' from input arguments (the calculation is made for both the unique and full lists of reflections)

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

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@960 4c865b51-4357-4376-afb4-474e03ccb993
parent 4a0c17a0
No related branches found
No related tags found
No related merge requests found
function [hkl, theta, hkil, sintheta] = gtCrystCalculateReflections(latticepar, mintheta, maxtheta, sg, typelist, filename) function list = gtCrystCalculateReflections(latticepar, mintheta, maxtheta, sg, filename)
% GTCRYSTCALCULATEREFLECTIONS Calculate the reflections list using python % GTCRYSTCALCULATEREFLECTIONS Calculate the reflections list using python
% from xfab library in fable % from xfab library in fable
% [hkl, theta, hkil, sintheta] = gtCrystCalculateReflections(latticepar, mintheta, maxtheta, sg, typelist, filename) % list = gtCrystCalculateReflections(latticepar, mintheta, maxtheta, sg, filename)
% ------------------------------------------------------------------------------------------------------------------ % --------------------------------------------------------------------------------
% %
% INPUT: % INPUT:
% latticepar = lattice parameters <double 1x6> % latticepar = lattice parameters <double 1x6>
...@@ -10,15 +10,21 @@ function [hkl, theta, hkil, sintheta] = gtCrystCalculateReflections(latticepar, ...@@ -10,15 +10,21 @@ function [hkl, theta, hkil, sintheta] = gtCrystCalculateReflections(latticepar,
% maxtheta = maximum sin(theta)/lambda allowed <double> % maxtheta = maximum sin(theta)/lambda allowed <double>
% sg = spacegroup number <int> % sg = spacegroup number <int>
% typelist = type of list <string> [{'all'}/'unique'] % typelist = type of list <string> [{'all'}/'unique']
% filename = filename for output <string>
% %
% OUTPUT: % OUTPUT:
% hkl = reflection list <double> % list = structure with fields (the same with 'sp' for the full lists)
% theta = theta value for each reflection <double> % .hkl = reflection list <double>
% hkil = hkil indexes if needed <double> % .hkil = hkil indexes if needed <double>
% sintheta = sind(theta)/lambda <double> % .theta = theta value for each reflection <double>
% .thetatype = theta type <double>
% .sintheta = sind(theta)/lambda <double>
% .dspacing = d-spacing <double>
% .mult = multiplicity of each reflections <double>
% %
% %
% Version 002 12-12-2012 by LNervo
% Compact output as a structure
%
% Version 001 03-12-2012 by LNervo % Version 001 03-12-2012 by LNervo
...@@ -39,49 +45,78 @@ if ~exist('sg','var') || isempty(sg) ...@@ -39,49 +45,78 @@ if ~exist('sg','var') || isempty(sg)
load parameters; load parameters;
sg = parameters.cryst(1).spacegroup; sg = parameters.cryst(1).spacegroup;
end end
if ~exist('typelist','var') || isempty(typelist)
typelist = 'all';
end
if ~exist('filename','var') || isempty(filename) if ~exist('filename','var') || isempty(filename)
filename = 'reflections_'; filename = 'reflections_';
end end
latticepar_str = sprintf('%f ', latticepar); parameters = [];
load('parameters.mat');
energy = parameters.acq.energy;
latticepar_str = sprintf('%f ',latticepar);
latticepar_str = strtrim(latticepar_str);
% python script to be used
script_file = fullfile('/users/',getenv('USER'),'matlabDCT','zUtil_Python','reflections_list.py'); script_file = fullfile('/users/',getenv('USER'),'matlabDCT','zUtil_Python','reflections_list.py');
% run the command for all the reflections
cmd = sprintf('python26 %s %s %f %f %d %s %s',... cmd = sprintf('python26 %s %s %f %f %d %s %s',...
script_file,latticepar_str,mintheta,maxtheta,sg,typelist,filename); script_file,latticepar_str,mintheta,maxtheta,sg,'all',filename);
[~,msg]=unix(cmd); [~,msg]=unix(cmd); disp(msg)
disp(msg)
[C,Cmat] = gtReadTextFile([filename typelist '.txt'],'%f %f %f %f','\n','#',[1 3]); % run the command for only the reflections unique
hkl = Cmat(:,1:3); cmd = sprintf('python26 %s %s %f %f %d %s %s',...
sinth = Cmat(:,4); script_file,latticepar_str,mintheta,maxtheta,sg,'unique',filename);
[~,msg]=unix(cmd); disp(msg)
if nargout > 1 % read the full list of reflections
load parameters; [~,Cmat] = gtReadTextFile([filename 'all.txt'],'%f %f %f %f','\n','#',[1 3]);
energy = parameters.acq.energy;
theta = asind(sinth)*gtConvEnergyToWavelength(energy);
if nargout > 2
% for planes with Miller Indexes hkl -> hkil
hkil = hkl;
hkil(:,4) = hkl(:,3);
hkil(:,3) = -hkil(:,1)-hkil(:,2);
disp(' h k i l theta') % extracting information
disp('-------------------------') hklsp = Cmat(:,1:3);
for ii=1:size(hkl,1) sinthetasp = Cmat(:,4);
fprintf('%3d %3d %3d %3d %7.3f\n',hkil(ii,:),theta(ii)) % getting 4-indexes notation
end hkilsp = hklsp;
if nargout > 3 hkilsp(:,4) = hkilsp(:,3);
sintheta = sinth; hkilsp(:,3) = -hkilsp(:,1)-hkilsp(:,2);
end
end % extracting theta
else thetasp = asind(sinthetasp)*gtConvEnergyToWavelength(energy);
disp(' h k l sin(theta)/lambda') % calculation of d-spacing
disp('---------------------------------') Bmat = gtCrystHKL2CartesianMatrix(latticepar);
for ii=1:size(hkl,1) dspacingsp = gtCrystDSpacing(hklsp',Bmat)';
fprintf('%3d %3d %3d %7.3f\n',hkl(ii,:),sinth(ii)) % calculation of the multiplicity
end [sintheta,ind,thetatypesp] = unique(sinthetasp,'stable');
mult = [ind(2:end)',length(thetatypesp)+1]-ind';
hkl = hklsp(ind,:);
theta = thetasp(ind);
hkil = hkilsp(ind,:);
thetatype = thetatypesp(ind);
dspacing = dspacingsp(ind);
disp(' h k i l theta thetatype mult d-spacing')
disp('----------------------------------------------------------')
for ii=1:size(ind,1)
fprintf( '%3d %3d %3d %3d %9.3f %5d %10d %10.3f\n',hkilsp(ind(ii),:),thetasp(ind(ii)),thetatypesp(ind(ii)),mult(ii),dspacingsp(ind(ii)) )
end end
% creating the output
list.latticepar = latticepar;
list.spacegroup = sg;
list.energy = energy;
list.hkl = hkl';
list.hklsp = hklsp';
list.hkil = hkil';
list.hkilsp = hkilsp';
list.theta = theta';
list.thetasp = thetasp';
list.thetatype = thetatype';
list.thetatypesp = thetatypesp';
list.sintheta = sintheta';
list.sinthetasp = sinthetasp';
list.dspacing = dspacing';
list.dspacingsp = dspacingsp';
list.mult = mult;
end % end of function end % end of function
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