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

gtReadSpaceGroup : improve speed by using cellfun (back to version 005)


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

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@800 4c865b51-4357-4376-afb4-474e03ccb993
parent 76c0e810
No related branches found
No related tags found
No related merge requests found
function [lattice, crystal, herm] = gtReadSpaceGroup(sg)
% GTREADSPACEGROUP Read the spacegroup and give the hermann_mauguin symbol
% [lattice, crystal, table] = gtReadSpaceGroup(sg)
% ------------------------------------------------
% [lattice, crystal, herm] = gtReadSpaceGroup(sg)
% -----------------------------------------------
%
% INPUT:
% sg = spacegroup to look at <double>
......@@ -9,11 +9,18 @@ function [lattice, crystal, herm] = gtReadSpaceGroup(sg)
% OUTPUT:
% lattice = lattice system for this spacegroup
% crystal = crystal system for this spacegroup
% herm = hermann-mauguin symbol
%
% Version 005 24/09/2012 by AKing
% Version 007 25-09-2012 by LNervo
% Improve speed and use cellfun (back to version 005)
%
% Version 006 24/09/2012 by AKing
% Remove the unused hashtable, fix the logic for trigonal
% spacegroups, return harmann-mauguin symbol
%
% Version 005 21-09-2012 by LNervo
% Removed mhashtable
%
% Version 004 20-09-2012 by YGuilhem
% Now using GT_MATLAB_HOME to determine path to spacegroups.dat
%
......@@ -22,15 +29,16 @@ function [lattice, crystal, herm] = gtReadSpaceGroup(sg)
global GT_MATLAB_HOME
fid=fopen( fullfile(GT_MATLAB_HOME, 'zUtil_Cryst', 'spacegroups.dat' ),'r');
C=textscan(fid,'%s %d','delimiter','\t','commentstyle','matlab');
fid = fopen( fullfile(GT_MATLAB_HOME, 'zUtil_Cryst', 'spacegroups.dat' ),'r');
C = textscan(fid,'%s %*d','delimiter','\t','commentstyle','matlab');
fclose(fid);
spacegroup=uint8(C{2});
hermann=C{1};
% read the hermann mauguin
herm=hermann{find(spacegroup==sg)};
% clean the cell structure
index = cellfun(@(num) ~isempty(strfind(num, '%')), C{:});
C{:}(index) = [];
% get the hermann-mauguin symbol list, by removing the space at the end of each cell string
hermann = cellfun(@(num) strtrim(num), C{:},'UniformOutput', false);
if between(sg,1,2)
crystal = 'triclinic'; % a ~= b ~= c; alpha ~= beta ~= gamma ~= 90
......@@ -54,11 +62,11 @@ end
if between(sg,143,167)
crystal = 'trigonal';
if ~isempty(strfind(herm,'P')) % hexagonal lattice
if ~isempty(strfind(hermann{sg},'P')) % hexagonal lattice
% a1 = a2 = a3 ~= c; alpha = beta = 90; gamma = 120
lattice = 'hexagonal';
elseif ~isempty(strfind(herm,'R')) % rhombohedral lattice
elseif ~isempty(strfind(hermann{sg},'R')) % rhombohedral lattice
% a = b = c; alpha = beta = gamma ~= 90
lattice = 'rhombohedral';
end
......@@ -72,8 +80,10 @@ end
if between(sg,195,230)
crystal = 'cubic'; % a = b = c; alpha = beta = gamma = 90
lattice = 'cubic';
end
if nargout == 3
herm = hermann{sg};
end
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