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


Python Elements.getMaterialMassAttenuationCoefficients方法代碼示例

本文整理匯總了Python中PyMca5.PyMcaPhysics.Elements.getMaterialMassAttenuationCoefficients方法的典型用法代碼示例。如果您正苦於以下問題:Python Elements.getMaterialMassAttenuationCoefficients方法的具體用法?Python Elements.getMaterialMassAttenuationCoefficients怎麽用?Python Elements.getMaterialMassAttenuationCoefficients使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyMca5.PyMcaPhysics.Elements的用法示例。


在下文中一共展示了Elements.getMaterialMassAttenuationCoefficients方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: importFile

# 需要導入模塊: from PyMca5.PyMcaPhysics import Elements [as 別名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialMassAttenuationCoefficients [as 別名]
 def importFile(self, filename):
     if not os.path.exists(filename):
         qt.QMessageBox.critical(self, "ERROR opening file",
                                 "File %s not found" % filename)
         return 1
     Elements.Material.read(filename)
     error = 0
     for material in list(Elements.Material.keys()):
         keys = list(Elements.Material[material].keys())
         compoundList = []
         if "CompoundList" in  keys:
             compoundList = Elements.Material[material]["CompoundList"]
         if "CompoundFraction" in  keys:
             compoundFraction = Elements.Material[material]["CompoundFraction"]
         if  (compoundList == []) or (compoundFraction == []):
             #no message?
             error = 1
             del Elements.Material[material]
             continue
         #I should try to calculate the attenuation at one energy ...
         try:
             Elements.getMaterialMassAttenuationCoefficients(compoundList,
                                                             compoundFraction,
                                                             energy = 10.0)
         except:
             #no message?
             error = 1
             del Elements.Material[material]
             if _logger.getEffectiveLevel() == logging.DEBUG:
                 raise
             continue
     return error
開發者ID:vasole,項目名稱:pymca,代碼行數:34,代碼來源:MaterialEditor.py

示例2: _massAttenuationSlot

# 需要導入模塊: from PyMca5.PyMcaPhysics import Elements [as 別名]
# 或者: from PyMca5.PyMcaPhysics.Elements import getMaterialMassAttenuationCoefficients [as 別名]
 def _massAttenuationSlot(self, ddict):
     try:
         compoundList = ddict['CompoundList']
         fractionList = ddict['CompoundFraction']
         energy = numpy.arange(1, 100, 0.1)
         data=Elements.getMaterialMassAttenuationCoefficients(compoundList,
                                                              fractionList,
                                                              energy)
         addButton = False
         if self.graph is None:
             # probably dead code (ScanWindow.ScanWindow not imported)
             self.graphDialog = qt.QDialog(self)
             self.graphDialog.mainLayout = qt.QVBoxLayout(self.graphDialog)
             self.graphDialog.mainLayout.setContentsMargins(0, 0, 0, 0)
             self.graphDialog.mainLayout.setSpacing(0)
             #self.graph = ScanWindow.ScanWindow(self.graphDialog)
             self.graph = ScanWindow(self.graphDialog)
             self.graphDialog.mainLayout.addWidget(self.graph)
             self.graph._togglePointsSignal()
             self.graph.graph.crossPicker.setEnabled(False)
             addButton = True
         if addButton:
             self._addGraphDialogButton()
         self.graph.setGraphTitle(ddict['Comment'])
         legend = 'Coherent'
         self.graph.addCurve(energy, numpy.array(data[legend.lower()]),
                             legend=legend,
                             xlabel='Energy (keV)',
                             ylabel='Mass Att. (cm2/g)',
                             replace=True,
                             replot=False)
         for legend in ['Compton', 'Photo','Total']:
             self.graph.addCurve(energy, numpy.array(data[legend.lower()]),
                                 legend=legend,
                                 xlabel='Energy (keV)',
                                 ylabel='Mass Att. (cm2/g)',
                                 replace=False,
                                 replot=False)
         self.graph.setActiveCurve(legend+' '+'Mass Att. (cm2/g)')
         self.graph.setGraphTitle(ddict['Comment'])
         if self.graphDialog is not None:
             self.graphDialog.exec_()
     except:
         msg=qt.QMessageBox(self)
         msg.setIcon(qt.QMessageBox.Critical)
         msg.setInformativeText(str(sys.exc_info()[1]))
         msg.setDetailedText(traceback.format_exc())
         msg.exec_()
開發者ID:vasole,項目名稱:pymca,代碼行數:50,代碼來源:MaterialEditor.py


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