本文整理汇总了Python中PyMca5.PyMcaPhysics.Elements.getMaterialMassFractions方法的典型用法代码示例。如果您正苦于以下问题:Python Elements.getMaterialMassFractions方法的具体用法?Python Elements.getMaterialMassFractions怎么用?Python Elements.getMaterialMassFractions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyMca5.PyMcaPhysics.Elements
的用法示例。
在下文中一共展示了Elements.getMaterialMassFractions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setFitConfiguration
# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialMassFractions [as 别名]
def setFitConfiguration(self, fitConfiguration):
# obtain the peak families fitted
_peakList = _getPeakList(fitConfiguration)
if not len(_peakList):
raise ValueError("No peaks to fit!!!!")
matrixDescription = _getMatrixDescription(fitConfiguration)
layerList = list(matrixDescription.keys())
layerList.sort()
materialList = list(Elements.Material.keys())
materialList.sort()
a = ["-"]
for key in materialList:
a.append(key)
# Material options
self._materialOptions.setOptions(a)
self._table.setMaterialOptions(a)
# If only one layer, all the elements are selectable
layerPeaks = {}
if len(layerList) == 1:
layerPeaks[layerList[0]] = _peakList
else:
inAllLayers = []
toDeleteFromAllLayers = []
toForgetAbout = []
for layer in layerList:
layerPeaks[layer] = []
for peak in _peakList:
element = peak.split()[0]
layersPresent = []
for layer in layerList:
material = matrixDescription[layer][0]
if element in Elements.getMaterialMassFractions(\
[material],
[1.0]).keys():
layersPresent.append(layer)
if len(layersPresent) == 1:
layerPeaks[layersPresent[0]].append(peak)
oldOption = qt.safe_str(self._layerOptions.currentText())
self._layerOptions.clear()
for item in layerList:
self._layerOptions.addItem(item)
self._layerList = layerList
if oldOption not in layerList:
oldOption = layerList[0]
self._layerOptions.setCurrentIndex(layerList.index(oldOption))
self._layerList = layerList
self._layerPeaks = layerPeaks
self._table.setLayerPeakFamilies(layerPeaks[oldOption])
strategy = fitConfiguration["fit"].get("strategy", "SingleLayerStrategy")
if strategy in fitConfiguration:
self.setParameters(fitConfiguration["SingleLayerStrategy"])
示例2: setParameters
# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialMassFractions [as 别名]
def setParameters(self, ddict):
layer = ddict.get("layer", "Auto")
if layer not in self._layerList:
if layer.upper() != "AUTO":
raise ValueError("Layer %s not among fitted layers" % layer)
else:
layerList = self._layerList + ["Auto"]
self._layerOptions.clear()
for item in layerList:
self._layerOptions.addItem(item)
self._layerList = layerList
nIterations = ddict.get("iterations", 3)
self._nIterations.setValue(nIterations)
layerList = self._layerList
layerPeaks = self._layerPeaks
self._layerOptions.setCurrentIndex(layerList.index(layer))
if layer in layerPeaks:
self._table.setLayerPeakFamilies(layerPeaks[layer])
completer = ddict.get("completer", "-")
self._materialOptions.setCurrentText(completer)
flags = ddict["flags"]
families = ddict["peaks"]
materials = ddict["materials"]
nItem = 0
for i in range(len(flags)):
doIt = 0
if (flags[i] in [1, True, "1", "True"]) and (layer in layerPeaks):
flag = 1
if families[i] in layerPeaks[layer]:
if materials[i] in ["-"]:
doIt = 1
else:
element = families[i].split()[0]
if element in Elements.getMaterialMassFractions( \
[materials[i]], [1.0]):
doIt = 1
if doIt:
self._table.setData(nItem, flag, families[i], materials[i])
else:
self._table.setData(nItem, flag, families[i], element)
else:
self._table.setData(nItem, 0, "-", "-")
nItem += 1
示例3: __updateMaterialOptions
# 需要导入模块: from PyMca5.PyMcaPhysics import Elements [as 别名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialMassFractions [as 别名]
def __updateMaterialOptions(self, ddict):
row = ddict['row']
col = ddict['col']
text = ddict['text']
element = text.split()[0]
materialItem = self.cellWidget(row, col + 1)
associatedMaterial = str(materialItem.currentText())
goodCandidates = [element]
for i in range(materialItem.count()):
material = str(materialItem.itemText(i))
if material not in ["-", element]:
if element in Elements.getMaterialMassFractions([material],
[1.0]):
goodCandidates.append(material)
materialItem.clear()
materialItem.setOptions(goodCandidates)
if associatedMaterial in goodCandidates:
materialItem.setCurrentIndex(goodCandidates.index(associatedMaterial))
else:
materialItem.setCurrentIndex(0)