本文整理汇总了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
示例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_()