當前位置: 首頁>>代碼示例>>Python>>正文


Python Elements.getMaterialMassFractions方法代碼示例

本文整理匯總了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"])
開發者ID:maurov,項目名稱:pymca,代碼行數:59,代碼來源:StrategyHandler.py

示例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
開發者ID:maurov,項目名稱:pymca,代碼行數:51,代碼來源:StrategyHandler.py

示例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)
開發者ID:maurov,項目名稱:pymca,代碼行數:23,代碼來源:StrategyHandler.py


注:本文中的PyMca5.PyMcaPhysics.Elements.getMaterialMassFractions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。