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

Reflections list calculation for any spacegroup : lattice parameters,...

Reflections list calculation for any spacegroup : lattice parameters, spacegroup and maximum sin(theta)/lambda are needed.

Content of the commit:

  zUtil_Cryst/gtCrystCalculateReflections :
      function to generate the reflection list for any spacegroup (using fable package xfab) and convert it from text file to matlab matrix
  zUtil_Cryst/gtCrystGetReflections :
      function to read output from gtCrystCalculateReflections and convert in matlab matrices
  zUtil_Python/create_reflections_list.py :
      python script for the calculation using xfab package

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

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@943 4c865b51-4357-4376-afb4-474e03ccb993
parent 4cf980ad
No related branches found
No related tags found
No related merge requests found
function [hkl, theta, output_file] = gtCrystCalculateReflections(latticepar, mintheta, maxtheta, sg, typelist, filename)
% GTCRYSTCALCULATEREFLECTIONS Calculate the reflections list using python
% from fable library (genhkl_all or genhkl_unique
% scripts)
% [hkl, theta, output_file] = gtCrystCalculateReflections(latticepar, mintheta, maxtheta, sg, typelist, filename)
% ---------------------------------------------------------------------------------------------------------------
%
% INPUT:
% latticepar = lattice parameters <double 1x6>
% mintheta = minimum sin(theta)/lambda allowed <double> {0.0001}
% maxtheta = maximum sin(theta)/lambda allowed <double>
% sg = spacegroup number <int>
% typelist = type of list <string> [{'all'}/'unique]
% filename = filename for output <string>
%
% OUTPUT:
% hkl = reflection list <double>
% theta = theta value for each reflection <double>
% output_file = path to the output filename <string>
%
%
% Version 001 03-12-2012 by LNervo
if ~exist('latticepar','var') || isempty(latticepar)
load parameters;
latticepar = parameters.cryst(1).latticepar;
end
if ~exist('mintheta','var') || isempty(mintheta)
mintheta = 0.0001;
end
if ~exist('maxtheta','var') || isempty(maxtheta)
load parameters;
tmp = parameters.labgeo.detanglemax;
maxtheta = sind(tmp)/gtConvEnergyToWavelength(parameters.acq.energy);
clear tmp
end
if ~exist('sg','var') || isempty(sg)
load parameters;
sg = parameters.cryst(1).spacegroup;
end
if ~exist('typelist','var') || isempty(typelist)
typelist = 'all';
end
if ~exist('filename','var') || isempty(filename)
filename = 'reflections.txt';
end
latticepar_str = sprintf('%f ', latticepar);
script_file = fullfile('/users/',getenv('USER'),'matlabDCT','zUtil_Python','create_reflections_list.py');
cmd = sprintf('python26 %s %s %f %f %d %s %s',...
script_file,latticepar_str,mintheta,maxtheta,sg,typelist,filename);
[~,msg]=unix(cmd);
disp(msg)
[hkl,sintheta] = gtCrystGetReflections(filename);
if nargout > 1
load parameters;
energy = parameters.acq.energy;
theta = asind(sintheta)*gtConvEnergyToWavelength(energy);
if nargout == 3
output_file = fullfile(pwd(),filename);
end
end
end % end of function
function [hkl, sintheta] = gtCrystGetReflections(filename)
% GTCRYSTGETREFLECTIONS Reads output file from gtCrystCalculateReflections
%
% [hkl, sintheta] = gtCrystGetReflections(filename)
% -------------------------------------------------
%
% INPUT:
% filename = output file from gtCrystCalculateReflections <string>
%
% OUTPUT:
% hkl = generated reflections <double>
% sintheta = sin(theta)/lambda <double>
%
%
% Version 001 03-12-2012 by LNervo
fid = fopen(filename,'r');
C = textscan(fid,'%f %f %f %f',...
'Delimiter','\n',...
'CommentStyle','#');
fclose(fid);
hkl = cell2mat(C(:,1:3));
if nargout == 2
sintheta = cell2mat(C(:,4));
end
end % end of function
#!/usr/bin/python26
'''
Created on Dec 03, 2012
@author: lnervo
'''
import sys, os, numpy as np
from xfab import *
from xfab import symmetry
from xfab.symmetry import *
from xfab.symmetry import tools
index = 1;
_a = float(sys.argv[index])
_b = float(sys.argv[index+1])
_c = float(sys.argv[3])
_alpha = float(sys.argv[4])
_beta = float(sys.argv[5])
_gamma = float(sys.argv[6])
_mintheta = float(sys.argv[7])
_maxtheta = float(sys.argv[8])
_sgno = int(sys.argv[9])
_type = sys.argv[10]
_output = sys.argv[11]
print("")
print(" *** Input data ***")
print(" lattice parameters: (%f,%f,%f,%f,%f,%f)"
% (_a, _b, _c, _alpha, _beta, _gamma))
print(" sin(theta)/lambda range: %f,%f" % (_mintheta, _maxtheta))
print(" spacegroup: %s" % _sgno)
print(" type: %s" % _type)
print("")
print("Reflections list calculation...")
if _type == 'all':
list = symmetry.tools.genhkl_all([_a,_b,_c,_alpha,_beta,_gamma],
_mintheta,_maxtheta,sgno=_sgno,
output_stl=True)
elif _type == 'unique':
list = symmetry.tools.genhkl_unique([_a,_b,_c,_alpha,_beta,_gamma],
_mintheta,_maxtheta,sgno=_sgno,
output_stl=True)
else:
print("Type not known...Existing")
list = None
if list is not None:
print("...done!")
print("Saving reflections list in:\n %s..." % _output)
with file(_output,'w') as outfile:
outfile.write('# Reflection list: {0}\n'.format(list.shape))
for data_hkl in list:
np.savetxt(outfile, data_hkl)
outfile.write('# New reflection\n')
print("...done!")
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