本文整理汇总了Python中mantid.geometry.SpaceGroupFactory类的典型用法代码示例。如果您正苦于以下问题:Python SpaceGroupFactory类的具体用法?Python SpaceGroupFactory怎么用?Python SpaceGroupFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpaceGroupFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]
示例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
示例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
示例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()
示例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))
示例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
示例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))
示例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)
示例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)
示例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)
示例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())
示例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)
示例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())
示例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)
示例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()