本文整理汇总了Python中mantid.geometry.SpaceGroupFactory类的典型用法代码示例。如果您正苦于以下问题:Python SpaceGroupFactory类的具体用法?Python SpaceGroupFactory怎么用?Python SpaceGroupFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpaceGroupFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _generate_UBList
def _generate_UBList(self):
CreateSingleValuedWorkspace(OutputWorkspace='__ub')
LoadIsawUB('__ub',self.getProperty("UBMatrix").value)
ub=mtd['__ub'].sample().getOrientedLattice().getUB().copy()
DeleteWorkspace(Workspace='__ub')
symOps = self.getProperty("SymmetryOps").value
if symOps:
try:
symOps = SpaceGroupFactory.subscribedSpaceGroupSymbols(int(symOps))[0]
except ValueError:
pass
if SpaceGroupFactory.isSubscribedSymbol(symOps):
symOps = SpaceGroupFactory.createSpaceGroup(symOps).getSymmetryOperations()
else:
symOps = SymmetryOperationFactory.createSymOps(symOps)
logger.information('Using symmetries: '+str([sym.getIdentifier() for sym in symOps]))
ub_list=[]
for sym in symOps:
UBtrans = np.zeros((3,3))
UBtrans[0] = sym.transformHKL([1,0,0])
UBtrans[1] = sym.transformHKL([0,1,0])
UBtrans[2] = sym.transformHKL([0,0,1])
UBtrans=np.matrix(UBtrans.T)
ub_list.append(ub*UBtrans)
return ub_list
else:
return [ub]
开发者ID:stuartcampbell,项目名称:mantid,代码行数:29,代码来源:SingleCrystalDiffuseReduction.py
示例2: validateInputs
def validateInputs(self):
issues = dict()
inWS = self.getProperty("InputWorkspace").value
dimX=inWS.getXDimension()
dimY=inWS.getYDimension()
dimZ=inWS.getZDimension()
if dimX.name != '[H,0,0]' or dimY.name != '[0,K,0]' or dimZ.name != '[0,0,L]':
issues['InputWorkspace'] = 'dimensions must be [H,0,0], [0,K,0] and [0,0,L]'
for d in range(inWS.getNumDims()):
dim = inWS.getDimension(d)
if not np.isclose(dim.getMaximum(), -dim.getMinimum(), atol=1e-5):
issues['InputWorkspace'] = 'dimensions must be centered on zero'
if self.getProperty("Convolution").value and self.getProperty("Method").value == 'Punch and fill':
try:
import astropy # noqa
except ImportError:
issues["Convolution"] = 'python-astropy required to do convolution'
size = self.getProperty("Size").value
if len(size) != 1 and len(size) != 3:
issues["Size"] = 'Must provide 1 or 3 sizes'
if self.getProperty("SpaceGroup").value:
space_group=self.getProperty("SpaceGroup").value
try:
if not SpaceGroupFactory.isSubscribedNumber(int(space_group)):
issues["SpaceGroup"] = 'Space group number is not valid'
except ValueError:
if not SpaceGroupFactory.isSubscribedSymbol(space_group):
issues["SpaceGroup"] = 'Space group name is not valid'
sphereMin = self.getProperty("SphereMin").value
if len(sphereMin) != 1 and len(sphereMin) != 3:
issues["SphereMin"] = 'Must provide 1 or 3 diameters'
sphereMax = self.getProperty("SphereMax").value
if len(sphereMax) != 1 and len(sphereMax) != 3:
issues["SphereMax"] = 'Must provide 1 or 3 diameters'
if self.getProperty("WindowFunction").value == 'Tukey':
try:
ssignal.tukey
except AttributeError:
issues["WindowFunction"] = 'Tukey window requires scipy >= 0.16.0'
return issues
开发者ID:mantidproject,项目名称:mantid,代码行数:50,代码来源:DeltaPDF3D.py
示例3: validateInputs
def validateInputs(self):
issues = dict()
if self.getProperty("SymmetryOps").value:
syms=self.getProperty("SymmetryOps").value
try:
if not SpaceGroupFactory.isSubscribedNumber(int(syms)):
issues["SymmetryOps"] = 'Space group number '+syms+' is not valid'
except ValueError:
if not SpaceGroupFactory.isSubscribedSymbol(syms):
for sym in syms.split(';'):
if not SymmetryOperationFactory.exists(sym):
issues["SymmetryOps"] = sym+' is not valid symmetry or space group name'
return issues
开发者ID:stuartcampbell,项目名称:mantid,代码行数:15,代码来源:SingleCrystalDiffuseReduction.py
示例4: _getSpaceGroupFromNumber
def _getSpaceGroupFromNumber(self, cifData):
spaceGroupNumber = [int(cifData[x]) for x in
[u'_space_group_it_number', u'_symmetry_int_tables_number'] if
x in cifData.keys()]
if len(spaceGroupNumber) == 0:
raise RuntimeError('No space group symbol in CIF.')
possibleSpaceGroupSymbols = SpaceGroupFactory.subscribedSpaceGroupSymbols(spaceGroupNumber[0])
if len(possibleSpaceGroupSymbols) != 1:
raise RuntimeError(
'Can not use space group number to determine space group for no. {0}'.format(spaceGroupNumber))
return SpaceGroupFactory.createSpaceGroup(possibleSpaceGroupSymbols[0]).getHMSymbol()
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:15,代码来源:LoadCIF.py
示例5: test_isAllowedUnitCell_cubic
def test_isAllowedUnitCell_cubic(self):
cubic = UnitCell(6, 6, 6)
tetragonal = UnitCell(6, 6, 6.01)
sg = SpaceGroupFactory.createSpaceGroup('P m -3')
self.assertTrue(sg.isAllowedUnitCell(cubic))
self.assertFalse(sg.isAllowedUnitCell(tetragonal))
开发者ID:rosswhitfield,项目名称:mantid,代码行数:7,代码来源:SpaceGroupTest.py
示例6: _punch_and_fill
def _punch_and_fill(self, signal, dimX, dimY, dimZ): # noqa
Xmin, Xmax, _, Xwidth = self._get_dim_params(dimX)
Ymin, Ymax, _, Ywidth = self._get_dim_params(dimY)
Zmin, Zmax, _, Zwidth = self._get_dim_params(dimZ)
X, Y, Z = self._get_XYZ_ogrid(dimX, dimY, dimZ)
size = self.getProperty("Size").value
if len(size)==1:
size = np.repeat(size, 3)
size/=2.0 # We want radii or half box width
cut_shape = self.getProperty("Shape").value
space_group = self.getProperty("SpaceGroup").value
if space_group:
check_space_group = True
try:
space_group=SpaceGroupFactory.subscribedSpaceGroupSymbols(int(space_group))[0]
except ValueError:
pass
logger.information('Using space group: '+space_group)
sg=SpaceGroupFactory.createSpaceGroup(space_group)
else:
check_space_group = False
if cut_shape == 'cube':
for h in range(int(np.ceil(Xmin)), int(Xmax)+1):
for k in range(int(np.ceil(Ymin)), int(Ymax)+1):
for l in range(int(np.ceil(Zmin)), int(Zmax)+1):
if not check_space_group or sg.isAllowedReflection([h,k,l]):
signal[int((h-size[0]-Xmin)/Xwidth+1):int((h+size[0]-Xmin)/Xwidth),
int((k-size[1]-Ymin)/Ywidth+1):int((k+size[1]-Ymin)/Ywidth),
int((l-size[2]-Zmin)/Zwidth+1):int((l+size[2]-Zmin)/Zwidth)]=np.nan
else: # sphere
mask=((X-np.round(X))**2/size[0]**2 + (Y-np.round(Y))**2/size[1]**2 + (Z-np.round(Z))**2/size[2]**2 < 1)
# Unmask invalid reflections
if check_space_group:
for h in range(int(np.ceil(Xmin)), int(Xmax)+1):
for k in range(int(np.ceil(Ymin)), int(Ymax)+1):
for l in range(int(np.ceil(Zmin)), int(Zmax)+1):
if not sg.isAllowedReflection([h,k,l]):
mask[int((h-0.5-Xmin)/Xwidth+1):int((h+0.5-Xmin)/Xwidth),
int((k-0.5-Ymin)/Ywidth+1):int((k+0.5-Ymin)/Ywidth),
int((l-0.5-Zmin)/Zwidth+1):int((l+0.5-Zmin)/Zwidth)]=False
signal[mask]=np.nan
return signal
开发者ID:mantidproject,项目名称:mantid,代码行数:47,代码来源:DeltaPDF3D.py
示例7: test_isAllowedUnitCell_trigonal
def test_isAllowedUnitCell_trigonal(self):
rhombohedral = UnitCell(5, 5, 5, 80, 80, 80)
hexagonal = UnitCell(5, 5, 4, 90, 90, 120)
sgRh = SpaceGroupFactory.createSpaceGroup('R -3 c :r')
sgHex = SpaceGroupFactory.createSpaceGroup('R -3 c')
sgP6m = SpaceGroupFactory.createSpaceGroup('P 6/m')
self.assertTrue(sgRh.isAllowedUnitCell(rhombohedral))
self.assertFalse(sgRh.isAllowedUnitCell(hexagonal))
self.assertTrue(sgHex.isAllowedUnitCell(hexagonal))
self.assertFalse(sgHex.isAllowedUnitCell(rhombohedral))
self.assertTrue(sgP6m.isAllowedUnitCell(hexagonal))
self.assertFalse(sgP6m.isAllowedUnitCell(rhombohedral))
开发者ID:rosswhitfield,项目名称:mantid,代码行数:17,代码来源:SpaceGroupTest.py
示例8: test_interface
def test_interface(self):
spaceGroup = SpaceGroupFactory.createSpaceGroup("P -1")
self.assertEquals(spaceGroup.getHMSymbol(), "P -1")
self.assertEquals(spaceGroup.getOrder(), 2)
symOpStrings = spaceGroup.getSymmetryOperationStrings()
self.assertEqual(len(symOpStrings), 2)
self.assertTrue("x,y,z" in symOpStrings)
self.assertTrue("-x,-y,-z" in symOpStrings)
开发者ID:rosswhitfield,项目名称:mantid,代码行数:10,代码来源:SpaceGroupTest.py
示例9: test_equivalentPositions_Monoclinic
def test_equivalentPositions_Monoclinic(self):
wyckoffs = [([0.3, 0.4, 0.45], 8),
([0.0, 0.4, 0.25], 4),
([0.25, 0.25, 0.5], 4),
([0.25, 0.25, 0.0], 4),
([0.0, 0.5, 0.0], 4),
([0.0, 0.0, 0.0], 4)]
spaceGroup = SpaceGroupFactory.createSpaceGroup("C 1 2/c 1")
self.checkWyckoffPositions(spaceGroup, wyckoffs)
开发者ID:rosswhitfield,项目名称:mantid,代码行数:10,代码来源:SpaceGroupTest.py
示例10: test_equivalentPositions_Trigonal
def test_equivalentPositions_Trigonal(self):
wyckoffs = [([0.3, 0.4, 0.45], 36),
([0.3, 0.0, 0.25], 18),
([0.5, 0.0, 0.0], 18),
([0.0, 0.0, 0.45], 12),
([0.0, 0.0, 0.0], 6),
([0.0, 0.0, 0.25], 6)]
spaceGroup = SpaceGroupFactory.createSpaceGroup("R -3 c")
self.checkWyckoffPositions(spaceGroup, wyckoffs)
开发者ID:rosswhitfield,项目名称:mantid,代码行数:10,代码来源:SpaceGroupTest.py
示例11: test_creationFromPythonList
def test_creationFromPythonList(self):
spaceGroup = SpaceGroupFactory.createSpaceGroup("P 63/m m c")
# Construct python list of only certain symmetry operations
symOps = [x for x in spaceGroup.getSymmetryOperations() if x.getOrder() == 6]
group = Group(symOps)
self.assertEqual(group.getOrder(), len(symOps))
# But the constructed group is not actually a group
self.assertFalse(group.isGroup())
开发者ID:mantidproject,项目名称:mantid,代码行数:11,代码来源:GroupTest.py
示例12: test_equivalentPositions_Tetragonal
def test_equivalentPositions_Tetragonal(self):
wyckoffs = [([0.3, 0.4, 0.45], 32),
([0.3, 0.3, 0.25], 16),
([0.25, 0.4, 0.125], 16),
([0.0, 0.0, 0.45], 16),
([0.0, 0.25, 0.125], 16),
([0.0, 0.0, 0.25], 8),
([0.0, 0.0, 0.0], 8)]
spaceGroup = SpaceGroupFactory.createSpaceGroup("I 41/a c d")
self.checkWyckoffPositions(spaceGroup, wyckoffs)
开发者ID:rosswhitfield,项目名称:mantid,代码行数:11,代码来源:SpaceGroupTest.py
示例13: test_to_string
def test_to_string(self):
spaceGroup = SpaceGroupFactory.createSpaceGroup("F -4 3 c")
expected_str = "Space group with Hermann-Mauguin symbol: "\
"F -4 3 c"
expected_repr = "SpaceGroupFactory.createSpaceGroup(\"F -4 3 c\")"
self.assertEqual(expected_str, str(spaceGroup))
self.assertEqual(expected_repr, spaceGroup.__repr__())
newSpaceGroup = eval(spaceGroup.__repr__())
self.assertEqual(spaceGroup.getHMSymbol(), newSpaceGroup.getHMSymbol())
开发者ID:DanNixon,项目名称:mantid,代码行数:12,代码来源:SpaceGroupTest.py
示例14: test_equivalentPositions_Cubic
def test_equivalentPositions_Cubic(self):
wyckoffs = [([0.3, 0.4, 0.45], 96),
([0.3, 0.25, 0.25], 48),
([0.3, 0.0, 0.0], 48),
([0.3, 0.3, 0.3], 32),
([0.25, 0.0, 0.0], 24),
([0.0, 0.25, 0.25], 24),
([0.25, 0.25, 0.25], 8),
([0.0, 0.0, 0.0], 8)]
spaceGroup = SpaceGroupFactory.createSpaceGroup("F -4 3 c")
self.checkWyckoffPositions(spaceGroup, wyckoffs)
开发者ID:rosswhitfield,项目名称:mantid,代码行数:12,代码来源:SpaceGroupTest.py
示例15: _getSpaceGroupFromString
def _getSpaceGroupFromString(self, cifData):
# Try two possibilities for space group symbol. If neither is present, throw a RuntimeError.
rawSpaceGroupSymbol = [str(cifData[x]) for x in
[u'_space_group_name_h-m_alt', u'_symmetry_space_group_name_h-m'] if
x in cifData.keys()]
if len(rawSpaceGroupSymbol) == 0:
raise RuntimeError('No space group symbol in CIF.')
cleanSpaceGroupSymbol = self._getCleanSpaceGroupSymbol(rawSpaceGroupSymbol[0])
# If the symbol is not registered, throw as well.
return SpaceGroupFactory.createSpaceGroup(cleanSpaceGroupSymbol).getHMSymbol()
开发者ID:Mantid-Test-Account,项目名称:mantid,代码行数:13,代码来源:LoadCIF.py
示例16: test_equivalentPositions_Triclinic
def test_equivalentPositions_Triclinic(self):
wyckoffs = [([0.3, 0.4, 0.45], 2),
([0.5, 0.5, 0.5], 1),
([0.0, 0.5, 0.5], 1),
([0.5, 0.0, 0.5], 1),
([0.5, 0.5, 0.0], 1),
([0.5, 0.0, 0.0], 1),
([0.0, 0.5, 0.0], 1),
([0.0, 0.0, 0.5], 1),
([0.0, 0.0, 0.0], 1)]
spaceGroup = SpaceGroupFactory.createSpaceGroup("P -1")
self.checkWyckoffPositions(spaceGroup, wyckoffs)
开发者ID:rosswhitfield,项目名称:mantid,代码行数:13,代码来源:SpaceGroupTest.py
示例17: test_equivalentPositions_Orthorhombic
def test_equivalentPositions_Orthorhombic(self):
wyckoffs = [([0.3, 0.4, 0.45], 16),
([0.3, 0.25, 0.45], 8),
([0.0, 0.4, 0.45], 8),
([0.25, 0.4, 0.25], 8),
([0.3, 0.0, 0.0], 8),
([0.0, 0.25, 0.45], 4),
([0.25, 0.25, 0.75], 4),
([0.25, 0.25, 0.25], 4),
([0.0, 0.0, 0.5], 4),
([0.0, 0.0, 0.0], 4)]
spaceGroup = SpaceGroupFactory.createSpaceGroup("I m m a")
self.checkWyckoffPositions(spaceGroup, wyckoffs)
开发者ID:rosswhitfield,项目名称:mantid,代码行数:14,代码来源:SpaceGroupTest.py
示例18: test_equivalentPositions_Hexagonal
def test_equivalentPositions_Hexagonal(self):
wyckoffs = [([0.3, 0.4, 0.45], 24),
([0.3, 0.6, 0.45], 12),
([0.3, 0.4, 0.25], 12),
([0.3, 0.0, 0.0], 12),
([0.3, 0.6, 0.25], 6),
([0.5, 0.0, 0.0], 6),
([1. / 3., 2. / 3., 0.45], 4),
([0.0, 0.0, 0.45], 4),
([1. / 3, 2. / 3., 0.75], 2),
([1. / 3, 2. / 3., 0.25], 2),
([0.0, 0.0, 0.25], 2),
([0.0, 0.0, 0.0], 2)]
spaceGroup = SpaceGroupFactory.createSpaceGroup("P 63/m m c")
self.checkWyckoffPositions(spaceGroup, wyckoffs)
开发者ID:rosswhitfield,项目名称:mantid,代码行数:16,代码来源:SpaceGroupTest.py
示例19: LoadIsawUB
from mantid.simpleapi import *
from mantid.geometry import SymmetryOperationFactory, SpaceGroupFactory
import numpy as np
#symOps = SymmetryOperationFactory.createSymOps("x,y,z; -y,x-y,z+1/3; -x+y,-x,z+2/3; y,x,-z; x-y,-y,-z+2/3; -x,-x+y,-z+1/3")
ws=CreateSingleValuedWorkspace()
LoadIsawUB(ws,"/SNS/users/rwp/benzil/benzil_Hexagonal.mat")
sg=SpaceGroupFactory.createSpaceGroup("P 31 2 1")
symOps = sg.getSymmetryOperations()
ub=ws.sample().getOrientedLattice().getUB()
print("Starting UB :")
print(ub)
for sym in symOps:
symTrans = np.array([sym.transformHKL([1,0,0]),
sym.transformHKL([0,1,0]),
sym.transformHKL([0,0,1])])
symTrans=np.matrix(symTrans.T)
print("Symmetry transform for "+sym.getIdentifier())
print(symTrans)
print("New UB:")
newUB = ub*symTrans
print(newUB)
print("To use SetUB(ws, UB=newUB)")
开发者ID:rosswhitfield,项目名称:corelli_files,代码行数:29,代码来源:symmetryOps.py
示例20: PyExec
def PyExec(self): # noqa
progress = Progress(self, 0.0, 1.0, 5)
inWS = self.getProperty("InputWorkspace").value
signal = inWS.getSignalArray().copy()
dimX=inWS.getXDimension()
dimY=inWS.getYDimension()
dimZ=inWS.getZDimension()
Xmin=dimX.getMinimum()
Ymin=dimY.getMinimum()
Zmin=dimZ.getMinimum()
Xmax=dimX.getMaximum()
Ymax=dimY.getMaximum()
Zmax=dimZ.getMaximum()
Xbins=dimX.getNBins()
Ybins=dimY.getNBins()
Zbins=dimZ.getNBins()
Xwidth=dimX.getBinWidth()
Ywidth=dimY.getBinWidth()
Zwidth=dimZ.getBinWidth()
X=np.linspace(Xmin,Xmax,Xbins+1)
Y=np.linspace(Ymin,Ymax,Ybins+1)
Z=np.linspace(Zmin,Zmax,Zbins+1)
X, Y, Z = np.ogrid[(dimX.getX(0)+dimX.getX(1))/2:(dimX.getX(Xbins)+dimX.getX(Xbins-1))/2:Xbins*1j,
(dimY.getX(0)+dimY.getX(1))/2:(dimY.getX(Ybins)+dimY.getX(Ybins-1))/2:Ybins*1j,
(dimZ.getX(0)+dimZ.getX(1))/2:(dimZ.getX(Zbins)+dimZ.getX(Zbins-1))/2:Zbins*1j]
if self.getProperty("RemoveReflections").value:
progress.report("Removing Reflections")
size = self.getProperty("Size").value
if len(size)==1:
size = np.repeat(size, 3)
size/=2.0 # We want radii or half box width
cut_shape = self.getProperty("Shape").value
space_group = self.getProperty("SpaceGroup").value
if space_group:
check_space_group = True
try:
space_group=SpaceGroupFactory.subscribedSpaceGroupSymbols(int(space_group))[0]
except ValueError:
pass
logger.information('Using space group: '+space_group)
sg=SpaceGroupFactory.createSpaceGroup(space_group)
else:
check_space_group = False
if cut_shape == 'cube':
for h in range(int(np.ceil(Xmin)), int(Xmax)+1):
for k in range(int(np.ceil(Ymin)), int(Ymax)+1):
for l in range(int(np.ceil(Zmin)), int(Zmax)+1):
if not check_space_group or sg.isAllowedReflection([h,k,l]):
signal[int((h-size[0]-Xmin)/Xwidth+1):int((h+size[0]-Xmin)/Xwidth),
int((k-size[1]-Ymin)/Ywidth+1):int((k+size[1]-Ymin)/Ywidth),
int((l-size[2]-Zmin)/Zwidth+1):int((l+size[2]-Zmin)/Zwidth)]=np.nan
else: # sphere
mask=((X-np.round(X))**2/size[0]**2 + (Y-np.round(Y))**2/size[1]**2 + (Z-np.round(Z))**2/size[2]**2 < 1)
# Unmask invalid reflections
if check_space_group:
for h in range(int(np.ceil(Xmin)), int(Xmax)+1):
for k in range(int(np.ceil(Ymin)), int(Ymax)+1):
for l in range(int(np.ceil(Zmin)), int(Zmax)+1):
if not sg.isAllowedReflection([h,k,l]):
mask[int((h-0.5-Xmin)/Xwidth+1):int((h+0.5-Xmin)/Xwidth),
int((k-0.5-Ymin)/Ywidth+1):int((k+0.5-Ymin)/Ywidth),
int((l-0.5-Zmin)/Zwidth+1):int((l+0.5-Zmin)/Zwidth)]=False
signal[mask]=np.nan
if self.getProperty("CropSphere").value:
progress.report("Cropping to sphere")
sphereMin = self.getProperty("SphereMin").value
if sphereMin[0] < Property.EMPTY_DBL:
if len(sphereMin)==1:
sphereMin = np.repeat(sphereMin, 3)
signal[X**2/sphereMin[0]**2 + Y**2/sphereMin[1]**2 + Z**2/sphereMin[2]**2 < 1]=np.nan
sphereMax = self.getProperty("SphereMax").value
if sphereMax[0] < Property.EMPTY_DBL:
if len(sphereMax)==1:
sphereMax = np.repeat(sphereMax, 3)
if self.getProperty("FillValue").value == Property.EMPTY_DBL:
fill_value = np.nan
else:
fill_value = self.getProperty("FillValue").value
signal[X**2/sphereMax[0]**2 + Y**2/sphereMax[1]**2 + Z**2/sphereMax[2]**2 > 1]=fill_value
if self.getProperty("Convolution").value:
progress.report("Convoluting signal")
signal = self._convolution(signal)
if self.getPropertyValue("IntermediateWorkspace"):
cloneWS_alg = self.createChildAlgorithm("CloneMDWorkspace", enableLogging=False)
cloneWS_alg.setProperty("InputWorkspace",inWS)
cloneWS_alg.execute()
#.........这里部分代码省略.........
开发者ID:samueljackson92,项目名称:mantid,代码行数:101,代码来源:DeltaPDF3D.py
注:本文中的mantid.geometry.SpaceGroupFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论