From d5f970e780d72215268bb6b4c36356d8d6d832c3 Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Sun, 3 Mar 2024 16:58:34 +0100 Subject: [PATCH] secret spacegroup number hidden option --- ImageD11/unitcell.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/ImageD11/unitcell.py b/ImageD11/unitcell.py index 6ebc5ad3..0b720f71 100644 --- a/ImageD11/unitcell.py +++ b/ImageD11/unitcell.py @@ -159,18 +159,22 @@ def __init__(self, lattice_parameters, symmetry = "P", verbose = 0 ): """ Unit cell class supply a list (tuple etc) of a,b,c,alpha,beta,gamma - optionally a symmetry, one of "P","A","B","C","I","F","R" + optionally a lattice symmetry, one of "P","A","B","C","I","F","R" + or : a space group number (integer) """ self.lattice_parameters = np.array(lattice_parameters) if self.lattice_parameters.shape[0]!=6: raise Exception("You must supply 6 lattice parameters\n"+\ " a,b,c,alpha,beta,gamma") self.symmetry = symmetry - if self.symmetry not in ["P","A","B","C","I","F","R"]: - raise Exception("Your symmetry "+self.symmetry+\ - " was not recognised") - # assigning a function here! - self.absent = outif[self.symmetry] + if isinstance( symmetry, int ): + self.symmetry = symmetry + else: + if self.symmetry not in ["P","A","B","C","I","F","R"]: + raise Exception("Your symmetry "+self.symmetry+\ + " was not recognised") + # assigning a function here! + self.absent = outif[self.symmetry] a = self.lattice_parameters[0] b = self.lattice_parameters[1] c = self.lattice_parameters[2] @@ -238,21 +242,26 @@ def tostring(self): self.symmetry) - def gethkls_xfab(self,dsmax,spg): + def gethkls_xfab(self,dsmax,spg=None): """ Generate hkl list Argument dsmax is the d* limit (eg 1/d) Argument spg is the space group name, e.g. 'R3-c' """ stl_max = dsmax/2. + if isinstance(self.symmetry, int): + sgnum = self.symmetry + else: + sgnum = None raw_peaks = tools.genhkl_all(self.lattice_parameters, 0 , stl_max, sgname=spg, + sgno = sgnum, output_stl=True) peaks = [] for i in range(len(raw_peaks)): peaks.append([raw_peaks[i,3]*2, - (raw_peaks[i,0],raw_peaks[i,1],raw_peaks[i,2])]) + (int(raw_peaks[i,0]),int(raw_peaks[i,1]),int(raw_peaks[i,2]))]) self.peaks = peaks self.limit = dsmax return peaks @@ -267,6 +276,8 @@ def gethkls(self,dsmax): """ if dsmax == self.limit and self.peaks is not None: return self.peaks + if isinstance(self.symmetry, int): + self.gethkls_xfab( dsmax, self.sgname ) h=k=0 l=1 # skip 0,0,0 hs=ks=ls=1