def testEPDL97MuVersusPyMcaEPDL97Mu(self): from PyMca5.PyMca import PyMcaEPDL97 from fisx import DataDir dirname = DataDir.FISX_DATA_DIR epdl = self.epdl97(dirname) x = numpy.linspace(1.0, 80., 157) for j in range(1, 100): pymca = PyMcaEPDL97.getElementCrossSections(getSymbol(j), x) cpp = epdl.getMassAttenuationCoefficients(j, x) for key in cpp: for i in range(len(x)): if key == "photoelectric": delta = cpp[key][i] - pymca["photo"][i] else: delta = cpp[key][i] - pymca[key][i] if cpp[key][i] > 0: delta = 100. * (abs(delta)/cpp[key][i]) tol = 1.0e-5 else: delta = abs(delta) tol = 1.0e-7 self.assertTrue(delta < tol, "z = %d, effect = %s, energy = %f, delta = %f" %\ (j, key, x[i], delta)) epdl = None
def testEPDL97MuVersusPyMcaEPDL97Mu(self): from PyMca5.PyMca import PyMcaEPDL97 from fisx import DataDir dirname = DataDir.FISX_DATA_DIR epdl = self.epdl97(dirname) x = numpy.linspace(1.0, 80., 157) for j in range(1, 100): pymca = PyMcaEPDL97.getElementCrossSections(getSymbol(j), x) cpp = epdl.getMassAttenuationCoefficients(j, x) for key in cpp: for i in range(len(x)): if key == "photoelectric": delta = cpp[key][i] - pymca["photo"][i] else: delta = cpp[key][i] - pymca[key][i] if cpp[key][i] > 0: delta = 100. * (abs(delta) / cpp[key][i]) tol = 1.0e-5 else: delta = abs(delta) tol = 1.0e-7 self.assertTrue(delta < tol, "z = %d, effect = %s, energy = %f, delta = %f" %\ (j, key, x[i], delta)) epdl = None
def testEPDL97PartialVersusPyMcaPartial(self): from PyMca5.PyMca import PyMcaEPDL97 from fisx import DataDir dirname = DataDir.FISX_DATA_DIR epdl = self.epdl97(dirname) pymca = PyMcaEPDL97.getElementCrossSections('Pb') idx = numpy.nonzero((pymca['energy'] > 1.0) & \ (pymca['energy'] < 100))[0] x = pymca['energy'][idx] # test partial photoelectric cross sections shellList = [ "K", "L1", "L2", "L3", "M1", "M2", "M3", "M4", "M5", "all other" ] for j in range(1, 100): cpp = epdl.getPhotoelectricWeights(j, x) for i in range(len(x)): pymca = PyMcaEPDL97.getPhotoelectricWeights( getSymbol(j), shellList, x[i]) for ikey in range(len(shellList)): key = shellList[ikey] delta = abs(pymca[ikey] - cpp[key][i]) tol = 1.0e-7 self.assertTrue(delta < tol, "Default E, z = %d, shell = %s, energy = %f, delta = %f" %\ (j, key, x[i], delta)) print("\nPhotoelectric weights OK at default energies") x += 0.123 for j in range(1, 100): cpp = epdl.getPhotoelectricWeights(j, x) for i in range(len(x)): if x[i] < 1.0: continue pymca = PyMcaEPDL97.getPhotoelectricWeights( getSymbol(j), shellList, x[i]) for ikey in range(len(shellList)): key = shellList[ikey] delta = abs(pymca[ikey] - cpp[key][i]) tol = 1.0e-7 self.assertTrue(delta < tol, "z = %d, shell = %s, energy = %f, delta = %f" %\ (j, key, x[i], delta)) print("Photoelectric weights OK at any energy")
def testEPDL97PartialVersusPyMcaPartial(self): from PyMca5.PyMca import PyMcaEPDL97 from fisx import DataDir dirname = DataDir.FISX_DATA_DIR epdl = self.epdl97(dirname) pymca = PyMcaEPDL97.getElementCrossSections('Pb') idx = numpy.nonzero((pymca['energy'] > 1.0) & \ (pymca['energy'] < 100))[0] x = pymca['energy'][idx] # test partial photoelectric cross sections shellList = ["K", "L1", "L2", "L3", "M1", "M2", "M3", "M4", "M5", "all other"] for j in range(1, 100): cpp = epdl.getPhotoelectricWeights(j, x) for i in range(len(x)): pymca = PyMcaEPDL97.getPhotoelectricWeights(getSymbol(j), shellList, x[i]) for ikey in range(len(shellList)): key = shellList[ikey] delta = abs(pymca[ikey]- cpp[key][i]) tol = 1.0e-7 self.assertTrue(delta < tol, "Default E, z = %d, shell = %s, energy = %f, delta = %f" %\ (j, key, x[i], delta)) print("\nPhotoelectric weights OK at default energies") x += 0.123 for j in range(1, 100): cpp = epdl.getPhotoelectricWeights(j, x) for i in range(len(x)): if x[i] < 1.0: continue pymca = PyMcaEPDL97.getPhotoelectricWeights(getSymbol(j), shellList, x[i]) for ikey in range(len(shellList)): key = shellList[ikey] delta = abs(pymca[ikey]- cpp[key][i]) tol = 1.0e-7 self.assertTrue(delta < tol, "z = %d, shell = %s, energy = %f, delta = %f" %\ (j, key, x[i], delta)) print("Photoelectric weights OK at any energy")