[Python-modules-commits] [python-fisx] 03/07: New upstream version 1.1.4
Frédéric-Emmanuel Picca
picca at moszumanska.debian.org
Sat Nov 25 17:05:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
picca pushed a commit to branch master
in repository python-fisx.
commit 11014d2c7d3b283ef2025afc371039a9e637cc70
Author: Picca Frédéric-Emmanuel <picca at debian.org>
Date: Sat Nov 25 13:42:57 2017 +0100
New upstream version 1.1.4
---
PKG-INFO | 4 +-
changelog.txt | 19 +
python/cython/Detector.pxd | 16 +-
python/cython/Elements.pxd | 23 +-
python/cython/Layer.pxd | 4 +-
python/cython/Math.pxd | 4 +-
python/cython/PyDetector.pyx | 23 +-
python/cython/PyEPDL97.pyx | 5 +-
python/cython/PyElements.pyx | 94 +-
python/cython/PyLayer.pyx | 28 +-
python/cython/PyMath.pyx | 18 +-
python/cython/_fisx.pyx | 168 +-
python/cython/default/_fisx.cpp | 14744 +++++++++++++++-------------
python/fisx.egg-info/PKG-INFO | 150 -
python/fisx.egg-info/SOURCES.txt | 112 -
python/fisx.egg-info/dependency_links.txt | 1 -
python/fisx.egg-info/requires.txt | 1 -
python/fisx.egg-info/top_level.txt | 1 -
setup.cfg | 5 -
setup.py | 4 +-
src/fisx_detector.cpp | 12 +-
src/fisx_detector.h | 13 +
src/fisx_element.cpp | 313 +-
src/fisx_element.h | 39 +
src/fisx_elements.cpp | 275 +-
src/fisx_elements.h | 81 +-
src/fisx_multilayer.cpp | 136 +-
src/fisx_version.h | 4 +-
src/fisx_xrf.cpp | 8 +-
src/fisx_xrf.h | 39 +-
src/fisx_xrfconfig.cpp | 2 +-
src/fisx_xrfconfig.h | 2 +-
32 files changed, 9317 insertions(+), 7031 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index 29c51a3..0aca946 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
Metadata-Version: 1.1
Name: fisx
-Version: 1.1.2
+Version: 1.1.4
Summary: Quantitative X-Ray Fluorescence Analysis Support Library
Home-page: https://github.com/vasole/fisx
Author: V. Armando Solé
Author-email: sole at esrf.fr
License: MIT
-Download-URL: https://github.com/vasole/fisx/archive/v1.1.2.tar.gz
+Download-URL: https://github.com/vasole/fisx/archive/v1.1.4.tar.gz
Description: ====
fisx
====
diff --git a/changelog.txt b/changelog.txt
index f2959f4..44a7d7d 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,22 @@
+VERSION 1.1.4
+
+Correct bug in getMultilayerFluorescence affecting the calculation of escape
+peaks.
+
+Implement a cache for calculation of escape peaks.
+
+Introduce the "ratio" key in escape lines to provide the escape ratio.
+
+VERSION 1.1.3
+
+Implement a calculation cache.
+
+Implement a configurable threshold on emission rate of an x-ray line to
+consider secondary excitation originated from that emission line.
+
+Correct problem calculating partial photoelectric cross sections in the
+vicinity of absoprtion edges.
+
VERSION 1.1.2
Correct inconsistency on M-shell data
diff --git a/python/cython/Detector.pxd b/python/cython/Detector.pxd
index 941ed0b..a014e21 100644
--- a/python/cython/Detector.pxd
+++ b/python/cython/Detector.pxd
@@ -2,7 +2,7 @@
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -56,3 +56,17 @@ cdef extern from "fisx_detector.h" namespace "fisx":
std_map[std_string, std_map[std_string, double]] getEscape(double, Elements, std_string, int) except +
void setMaximumNumberOfEscapePeaks(int) except +
+
+ double getEscapePeakEnergyThreshold()
+
+ double getEscapePeakIntensityThreshold()
+
+ int getEscapePeakNThreshold()
+
+ double getEscapePeakAlphaIn()
+
+ double getThickness()
+
+ double getDensity()
+
+ std_map[std_string, double] getComposition(Elements) except +
diff --git a/python/cython/Elements.pxd b/python/cython/Elements.pxd
index 13bae48..29d5474 100644
--- a/python/cython/Elements.pxd
+++ b/python/cython/Elements.pxd
@@ -2,7 +2,7 @@
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -99,6 +99,11 @@ cdef extern from "fisx_elements.h" namespace "fisx":
std_map[std_string, std_map [std_string, double]] getEscape(std_map[std_string, double],\
double, double, double, int, double, double) except +
+ void updateEscapeCache(std_map[std_string, double],\
+ std_vector[double], double, double, int, double, double) except +
+
+ std_map[std_string, double] getEmittedXRayLines(std_string, double) except +
+
std_map[std_string, double] getRadiativeTransitions(std_string, std_string) except +
std_map[std_string, double] getNonradiativeTransitions(std_string, std_string) except +
@@ -109,4 +114,20 @@ cdef extern from "fisx_elements.h" namespace "fisx":
void emptyElementCascadeCache(std_string) except +
+ void fillCache(std_string, std_vector[double]) except +
+
+ void updateCache(std_string, std_vector[double]) except +
+
+ void setCacheEnabled(std_string, int) except +
+
+ void clearCache(std_string) except +
+
+ int isCacheEnabled(std_string) except +
+
+ int isEscapeCacheEnabled() except +
+
+ void setEscapeCacheEnabled(int) except+
+
+ int getCacheSize(std_string) except+
+
void removeMaterials()
diff --git a/python/cython/Layer.pxd b/python/cython/Layer.pxd
index 4aa714f..f40c34c 100644
--- a/python/cython/Layer.pxd
+++ b/python/cython/Layer.pxd
@@ -2,7 +2,7 @@
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -41,6 +41,8 @@ cdef extern from "fisx_layer.h" namespace "fisx":
cdef cppclass Layer:
Layer(std_string, double, double, double)
+ std_map[std_string, double] getComposition(Elements)
+
std_vector[double] getTransmission(std_vector[double], Elements, double)
void setMaterial(Material)
diff --git a/python/cython/Math.pxd b/python/cython/Math.pxd
index 461d956..84a5622 100644
--- a/python/cython/Math.pxd
+++ b/python/cython/Math.pxd
@@ -2,7 +2,7 @@
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -43,6 +43,8 @@ cdef extern from "fisx_math.h" namespace "fisx":
double deBoerL0(double, double, double, double, double) except +
+ double deBoerX(double, double, double, double, double, double, double) except +
+
double erf(double)
double erfc(double)
diff --git a/python/cython/PyDetector.pyx b/python/cython/PyDetector.pyx
index 83e2085..ca0826f 100644
--- a/python/cython/PyDetector.pyx
+++ b/python/cython/PyDetector.pyx
@@ -2,7 +2,7 @@
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -84,3 +84,24 @@ cdef class PyDetector:
return toStringKeysAndValues(self.thisptr.getEscape(energy, deref(elementsLib.thisptr), label, 1))
else:
return toStringKeysAndValues(self.thisptr.getEscape(energy, deref(elementsLib.thisptr), label, 0))
+
+ def getEscapePeakEnergyThreshold(self):
+ return self.thisptr.getEscapePeakEnergyThreshold()
+
+ def getEscapePeakIntensityThreshold(self):
+ return self.thisptr.getEscapePeakIntensityThreshold()
+
+ def getEscapePeakNThreshold(self):
+ return self.thisptr.getEscapePeakNThreshold()
+
+ def getEscapePeakAlphaIn(self):
+ return self.thisptr.getEscapePeakAlphaIn()
+
+ def getThickness(self):
+ return self.thisptr.getThickness()
+
+ def getDensity(self):
+ return self.thisptr.getDensity()
+
+ def getComposition(self, PyElements elementsLib):
+ return self.thisptr.getComposition(deref(elementsLib.thisptr))
diff --git a/python/cython/PyEPDL97.pyx b/python/cython/PyEPDL97.pyx
index 4bb65ce..3ef487b 100644
--- a/python/cython/PyEPDL97.pyx
+++ b/python/cython/PyEPDL97.pyx
@@ -38,7 +38,10 @@ from EPDL97 cimport *
cdef class PyEPDL97:
cdef EPDL97 *thisptr
- def __cinit__(self, name):
+ def __cinit__(self, name=None):
+ if name is None:
+ from fisx import DataDir
+ name = DataDir.FISX_DATA_DIR
self.thisptr = new EPDL97(toBytes(name))
def __dealloc__(self):
diff --git a/python/cython/PyElements.pyx b/python/cython/PyElements.pyx
index f954b0a..d17e3dc 100644
--- a/python/cython/PyElements.pyx
+++ b/python/cython/PyElements.pyx
@@ -2,7 +2,7 @@
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -219,6 +219,18 @@ cdef class PyElements:
return toStringKeys(self.thisptr.getMassAttenuationCoefficients(element, energy))
def getMassAttenuationCoefficients(self, name, energy=None):
+ """
+ name can be an element, a formula or a material composition given as a dictionary:
+ key is the element name
+ fraction is the mass fraction of the element.
+
+ WARNING: The library renormalizes in order to make sure the sum of mass
+ fractions is 1.
+
+ It gives back the mass attenuation coefficients at the given energies as a map where
+ the keys are the different physical processes and the values are lists of the
+ calculated values via log-log interpolation in the internal table.
+ """
if hasattr(name, "keys"):
return self._getMaterialMassAttenuationCoefficients(toBytes(name), energy)
elif energy is None:
@@ -230,6 +242,12 @@ cdef class PyElements:
return self._getMultipleMassAttenuationCoefficients(toBytes(name), [energy])
def getExcitationFactors(self, name, energy, weight=None):
+ """
+ getExcitationFactors(name, energy, weight=None)
+ Given energy(s) and (optional) weight(s), for the specfified element, this method returns
+ the emitted X-ray already corrected for cascade and fluorescence yield.
+ It is the equivalent of the excitation factor in D.K.G. de Boer's paper.
+ """
if hasattr(energy, "__len__"):
if weight is None:
weight = [1.0] * len(energy)
@@ -271,6 +289,12 @@ cdef class PyElements:
return [toStringKeysAndValues(x) for x in self.thisptr.getExcitationFactors(element, energies, weights)]
def getPeakFamilies(self, nameOrVector, energy):
+ """
+ getPeakFamilies(nameOrVector, energy)
+
+ Given an energy and a reference to an elements library return dictionarys.
+ The key is the peak family ("Si K", "Pb L1", ...) and the value the binding energy.
+ """
if type(nameOrVector) in [type([]), type(())]:
if sys.version < "3.0":
return sorted(self._getPeakFamiliesFromVectorOfElements(nameOrVector, energy), key=itemgetter(1))
@@ -305,12 +329,26 @@ cdef class PyElements:
return self.thisptr.getEscape(composition, energy, energyThreshold, intensityThreshold, nThreshold,
alphaIn, thickness)
+ def updateEscapeCache(self, std_map[std_string, double] composition, std_vector[double] energyList, double energyThreshold=0.010,
+ double intensityThreshold=1.0e-7,
+ int nThreshold=4 ,
+ double alphaIn=90.,
+ double thickness=0.0):
+ self.thisptr.updateEscapeCache(composition, energyList, energyThreshold, intensityThreshold, nThreshold,
+ alphaIn, thickness)
+
def getShellConstants(self, elementName, subshell):
if sys.version < "3.0":
return self.thisptr.getShellConstants(elementName, subshell)
else:
return toStringKeys(self.thisptr.getShellConstants(toBytes(elementName), toBytes(subshell)))
+ def getEmittedXRayLines(self, elementName, double energy=1000.):
+ if sys.version < "3.0":
+ return self.thisptr.getEmittedXRayLines(elementName, energy)
+ else:
+ return toStringKeys(self.thisptr.getEmittedXRayLines(toBytes(elementName), energy))
+
def getRadiativeTransitions(self, elementName, subshell):
if sys.version < "3.0":
return self.thisptr.getRadiativeTransitions(elementName, subshell)
@@ -329,6 +367,60 @@ cdef class PyElements:
def emptyElementCascadeCache(self, elementName):
self.thisptr.emptyElementCascadeCache(toBytes(elementName))
+ def fillCache(self, elementName, std_vector[double] energy):
+ """
+ Optimization methods to keep the calculations at a set of energies
+ in cache.
+ Clear the calculation cache of given element and fill it at the
+ selected energies
+ """
+ self.thisptr.fillCache(toBytes(elementName), energy)
+
+ def updateCache(self, elementName, std_vector[double] energy):
+ """
+ Update the element cache with those energy values not already present.
+ The existing values will be kept.
+ """
+ self.thisptr.updateCache(toBytes(elementName), energy)
+
+ def setCacheEnabled(self, elementName, int flag = 1):
+ """
+ Enable or disable the use of the stored calculations (if any).
+ It does not clear the cache when disabling.
+ """
+ self.thisptr.setCacheEnabled(toBytes(elementName), flag)
+
+ def setEscapeCacheEnabled(self, int flag = 1):
+ """
+ Enable or disable the use of the stored calculations (if any).
+ It does not clear the cache when disabling.
+ """
+ self.thisptr.setEscapeCacheEnabled(flag)
+
+ def clearCache(self, elementName):
+ """
+ Clear the calculation cache
+ """
+ self.thisptr.clearCache(toBytes(elementName))
+
+ def isCacheEnabled(self, elementName):
+ """
+ Return 1 or 0 if the calculation cache is enabled or not
+ """
+ return self.thisptr.isCacheEnabled(toBytes(elementName))
+
+ def isEscapeCacheEnabled(self):
+ """
+ Return 1 or 0 if the calculation cache is enabled or not
+ """
+ return self.thisptr.isEscapeCacheEnabled()
+
+ def getCacheSize(self, elementName):
+ """
+ Return the number of energies for which the calculations are stored
+ """
+ return self.thisptr.getCacheSize(toBytes(elementName))
+
def removeMaterials(self):
self.thisptr.removeMaterials()
diff --git a/python/cython/PyLayer.pyx b/python/cython/PyLayer.pyx
index e0c3c00..22a93a9 100644
--- a/python/cython/PyLayer.pyx
+++ b/python/cython/PyLayer.pyx
@@ -2,7 +2,7 @@
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -49,15 +49,41 @@ cdef class PyLayer:
def __dealloc__(self):
del self.thisptr
+ def getComposition(self, PyElements elementsLib):
+ """
+ getComposition(elementsLib)
+
+ Given a reference to an elements library, it gives back a dictionary where the keys are the
+ elements and the values the mass fractions.
+ """
+ return self.thisptr.getComposition(deref(elementsLib.thisptr))
+
def getTransmission(self, energies, PyElements elementsLib, double angle=90.):
+ """
+ getTransmission(energies, ElementsLibraryInstance, angle=90.)
+
+ Given a list of energies and a reference to an elements library returns
+ the layer transmission according to the incident angle (default 90.)
+ """
if not hasattr(energies, "__len__"):
energies = numpy.array([energies], numpy.float)
return self.thisptr.getTransmission(energies, deref(elementsLib.thisptr), angle)
def setMaterial(self, PyMaterial material):
+ """
+ setMaterial(MaterialInstance)
+
+ Set the material of the layer. It has to be an instance!
+ """
self.thisptr.setMaterial(deref(material.thisptr))
def getPeakFamilies(self, double energy, PyElements elementsLib):
+ """
+ getPeakFamilies(energy, ElementsLibraryInstance)
+
+ Given an energy and a reference to an elements library return dictionarys.
+ The key is the peak family ("Si K", "Pb L1", ...) and the value the binding energy.
+ """
tmpResult = self.thisptr.getPeakFamilies(energy, deref(elementsLib.thisptr))
return sorted(tmpResult, key=itemgetter(1))
diff --git a/python/cython/PyMath.pyx b/python/cython/PyMath.pyx
index e6a9e3d..5237007 100644
--- a/python/cython/PyMath.pyx
+++ b/python/cython/PyMath.pyx
@@ -2,7 +2,7 @@
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -57,6 +57,22 @@ cdef class PyMath:
"""
return self.thisptr.deBoerL0(mu1, mu2, muj, density, thickness)
+ def deBoerX(self, double p, double q, double d1, double d2, double mu_1_j, double mu_2_j, double mu_b_d_t = 0.0):
+ """
+ static double deBoerX(const double & p, const double & q, \
+ const double & d1, const double & d2, \
+ const double & mu_1_j, const double & mu_2_j, \
+ const double & mu_b_j_d_t = 0.0);
+ For multilayers
+ p and q following article
+ d1 is the product density * thickness of fluorescing layer
+ d2 is the product density * thickness of layer j originating the secondary excitation
+ mu_1_j is the mass attenuation coefficient of fluorescing layer at j excitation energy
+ mu_2_j is the mass attenuation coefficient of layer j at j excitation energy
+ mu_b_d_t is the sum of the products mu * density * thickness of layers between layer i and j
+ """
+ return self.thisptr.deBoerX(p, q, d1, d2, mu_1_j, mu_2_j, mu_b_d_t)
+
def erf(self, double x):
"""
Calculate the error function erf(x)
diff --git a/python/cython/_fisx.pyx b/python/cython/_fisx.pyx
index bcbd5f0..69dcdaf 100644
--- a/python/cython/_fisx.pyx
+++ b/python/cython/_fisx.pyx
@@ -2,7 +2,7 @@
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -84,6 +84,27 @@ cdef class PyDetector:
return toStringKeysAndValues(self.thisptr.getEscape(energy, deref(elementsLib.thisptr), label, 1))
else:
return toStringKeysAndValues(self.thisptr.getEscape(energy, deref(elementsLib.thisptr), label, 0))
+
+ def getEscapePeakEnergyThreshold(self):
+ return self.thisptr.getEscapePeakEnergyThreshold()
+
+ def getEscapePeakIntensityThreshold(self):
+ return self.thisptr.getEscapePeakIntensityThreshold()
+
+ def getEscapePeakNThreshold(self):
+ return self.thisptr.getEscapePeakNThreshold()
+
+ def getEscapePeakAlphaIn(self):
+ return self.thisptr.getEscapePeakAlphaIn()
+
+ def getThickness(self):
+ return self.thisptr.getThickness()
+
+ def getDensity(self):
+ return self.thisptr.getDensity()
+
+ def getComposition(self, PyElements elementsLib):
+ return self.thisptr.getComposition(deref(elementsLib.thisptr))
#/*##########################################################################
#
# The fisx library for X-Ray Fluorescence
@@ -207,7 +228,7 @@ cdef class PyElement:
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -424,6 +445,18 @@ cdef class PyElements:
return toStringKeys(self.thisptr.getMassAttenuationCoefficients(element, energy))
def getMassAttenuationCoefficients(self, name, energy=None):
+ """
+ name can be an element, a formula or a material composition given as a dictionary:
+ key is the element name
+ fraction is the mass fraction of the element.
+
+ WARNING: The library renormalizes in order to make sure the sum of mass
+ fractions is 1.
+
+ It gives back the mass attenuation coefficients at the given energies as a map where
+ the keys are the different physical processes and the values are lists of the
+ calculated values via log-log interpolation in the internal table.
+ """
if hasattr(name, "keys"):
return self._getMaterialMassAttenuationCoefficients(toBytes(name), energy)
elif energy is None:
@@ -435,6 +468,12 @@ cdef class PyElements:
return self._getMultipleMassAttenuationCoefficients(toBytes(name), [energy])
def getExcitationFactors(self, name, energy, weight=None):
+ """
+ getExcitationFactors(name, energy, weight=None)
+ Given energy(s) and (optional) weight(s), for the specfified element, this method returns
+ the emitted X-ray already corrected for cascade and fluorescence yield.
+ It is the equivalent of the excitation factor in D.K.G. de Boer's paper.
+ """
if hasattr(energy, "__len__"):
if weight is None:
weight = [1.0] * len(energy)
@@ -476,6 +515,12 @@ cdef class PyElements:
return [toStringKeysAndValues(x) for x in self.thisptr.getExcitationFactors(element, energies, weights)]
def getPeakFamilies(self, nameOrVector, energy):
+ """
+ getPeakFamilies(nameOrVector, energy)
+
+ Given an energy and a reference to an elements library return dictionarys.
+ The key is the peak family ("Si K", "Pb L1", ...) and the value the binding energy.
+ """
if type(nameOrVector) in [type([]), type(())]:
if sys.version < "3.0":
return sorted(self._getPeakFamiliesFromVectorOfElements(nameOrVector, energy), key=itemgetter(1))
@@ -510,12 +555,26 @@ cdef class PyElements:
return self.thisptr.getEscape(composition, energy, energyThreshold, intensityThreshold, nThreshold,
alphaIn, thickness)
+ def updateEscapeCache(self, std_map[std_string, double] composition, std_vector[double] energyList, double energyThreshold=0.010,
+ double intensityThreshold=1.0e-7,
+ int nThreshold=4 ,
+ double alphaIn=90.,
+ double thickness=0.0):
+ self.thisptr.updateEscapeCache(composition, energyList, energyThreshold, intensityThreshold, nThreshold,
+ alphaIn, thickness)
+
def getShellConstants(self, elementName, subshell):
if sys.version < "3.0":
return self.thisptr.getShellConstants(elementName, subshell)
else:
return toStringKeys(self.thisptr.getShellConstants(toBytes(elementName), toBytes(subshell)))
+ def getEmittedXRayLines(self, elementName, double energy=1000.):
+ if sys.version < "3.0":
+ return self.thisptr.getEmittedXRayLines(elementName, energy)
+ else:
+ return toStringKeys(self.thisptr.getEmittedXRayLines(toBytes(elementName), energy))
+
def getRadiativeTransitions(self, elementName, subshell):
if sys.version < "3.0":
return self.thisptr.getRadiativeTransitions(elementName, subshell)
@@ -534,6 +593,60 @@ cdef class PyElements:
def emptyElementCascadeCache(self, elementName):
self.thisptr.emptyElementCascadeCache(toBytes(elementName))
+ def fillCache(self, elementName, std_vector[double] energy):
+ """
+ Optimization methods to keep the calculations at a set of energies
+ in cache.
+ Clear the calculation cache of given element and fill it at the
+ selected energies
+ """
+ self.thisptr.fillCache(toBytes(elementName), energy)
+
+ def updateCache(self, elementName, std_vector[double] energy):
+ """
+ Update the element cache with those energy values not already present.
+ The existing values will be kept.
+ """
+ self.thisptr.updateCache(toBytes(elementName), energy)
+
+ def setCacheEnabled(self, elementName, int flag = 1):
+ """
+ Enable or disable the use of the stored calculations (if any).
+ It does not clear the cache when disabling.
+ """
+ self.thisptr.setCacheEnabled(toBytes(elementName), flag)
+
+ def setEscapeCacheEnabled(self, int flag = 1):
+ """
+ Enable or disable the use of the stored calculations (if any).
+ It does not clear the cache when disabling.
+ """
+ self.thisptr.setEscapeCacheEnabled(flag)
+
+ def clearCache(self, elementName):
+ """
+ Clear the calculation cache
+ """
+ self.thisptr.clearCache(toBytes(elementName))
+
+ def isCacheEnabled(self, elementName):
+ """
+ Return 1 or 0 if the calculation cache is enabled or not
+ """
+ return self.thisptr.isCacheEnabled(toBytes(elementName))
+
+ def isEscapeCacheEnabled(self):
+ """
+ Return 1 or 0 if the calculation cache is enabled or not
+ """
+ return self.thisptr.isEscapeCacheEnabled()
+
+ def getCacheSize(self, elementName):
+ """
+ Return the number of energies for which the calculations are stored
+ """
+ return self.thisptr.getCacheSize(toBytes(elementName))
+
def removeMaterials(self):
self.thisptr.removeMaterials()
@@ -577,7 +690,10 @@ from EPDL97 cimport *
cdef class PyEPDL97:
cdef EPDL97 *thisptr
- def __cinit__(self, name):
+ def __cinit__(self, name=None):
+ if name is None:
+ from fisx import DataDir
+ name = DataDir.FISX_DATA_DIR
self.thisptr = new EPDL97(toBytes(name))
def __dealloc__(self):
@@ -624,7 +740,7 @@ cdef class PyEPDL97:
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -671,15 +787,41 @@ cdef class PyLayer:
def __dealloc__(self):
del self.thisptr
+ def getComposition(self, PyElements elementsLib):
+ """
+ getComposition(elementsLib)
+
+ Given a reference to an elements library, it gives back a dictionary where the keys are the
+ elements and the values the mass fractions.
+ """
+ return self.thisptr.getComposition(deref(elementsLib.thisptr))
+
def getTransmission(self, energies, PyElements elementsLib, double angle=90.):
+ """
+ getTransmission(energies, ElementsLibraryInstance, angle=90.)
+
+ Given a list of energies and a reference to an elements library returns
+ the layer transmission according to the incident angle (default 90.)
+ """
if not hasattr(energies, "__len__"):
energies = numpy.array([energies], numpy.float)
return self.thisptr.getTransmission(energies, deref(elementsLib.thisptr), angle)
def setMaterial(self, PyMaterial material):
+ """
+ setMaterial(MaterialInstance)
+
+ Set the material of the layer. It has to be an instance!
+ """
self.thisptr.setMaterial(deref(material.thisptr))
def getPeakFamilies(self, double energy, PyElements elementsLib):
+ """
+ getPeakFamilies(energy, ElementsLibraryInstance)
+
+ Given an energy and a reference to an elements library return dictionarys.
+ The key is the peak family ("Si K", "Pb L1", ...) and the value the binding energy.
+ """
tmpResult = self.thisptr.getPeakFamilies(energy, deref(elementsLib.thisptr))
return sorted(tmpResult, key=itemgetter(1))
@@ -751,7 +893,7 @@ cdef class PyMaterial:
#
# The fisx library for X-Ray Fluorescence
#
-# Copyright (c) 2014-2016 European Synchrotron Radiation Facility
+# Copyright (c) 2014-2017 European Synchrotron Radiation Facility
#
# This file is part of the fisx X-ray developed by V.A. Sole
#
@@ -806,6 +948,22 @@ cdef class PyMath:
"""
return self.thisptr.deBoerL0(mu1, mu2, muj, density, thickness)
+ def deBoerX(self, double p, double q, double d1, double d2, double mu_1_j, double mu_2_j, double mu_b_d_t = 0.0):
+ """
+ static double deBoerX(const double & p, const double & q, \
+ const double & d1, const double & d2, \
+ const double & mu_1_j, const double & mu_2_j, \
+ const double & mu_b_j_d_t = 0.0);
+ For multilayers
+ p and q following article
+ d1 is the product density * thickness of fluorescing layer
+ d2 is the product density * thickness of layer j originating the secondary excitation
+ mu_1_j is the mass attenuation coefficient of fluorescing layer at j excitation energy
+ mu_2_j is the mass attenuation coefficient of layer j at j excitation energy
+ mu_b_d_t is the sum of the products mu * density * thickness of layers between layer i and j
+ """
+ return self.thisptr.deBoerX(p, q, d1, d2, mu_1_j, mu_2_j, mu_b_d_t)
+
def erf(self, double x):
"""
Calculate the error function erf(x)
diff --git a/python/cython/default/_fisx.cpp b/python/cython/default/_fisx.cpp
index 6553bad..25b7ab2 100644
--- a/python/cython/default/_fisx.cpp
+++ b/python/cython/default/_fisx.cpp
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.23.4 */
+/* Generated by Cython 0.24 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -7,10 +7,10 @@
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
#error Cython requires Python 2.6+ or Python 3.2+.
#else
-#define CYTHON_ABI "0_23_4"
+#define CYTHON_ABI "0_24"
#include <stddef.h>
#ifndef offsetof
-#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
+ #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
#ifndef __stdcall
@@ -36,17 +36,23 @@
#define Py_HUGE_VAL HUGE_VAL
#endif
#ifdef PYPY_VERSION
-#define CYTHON_COMPILING_IN_PYPY 1
-#define CYTHON_COMPILING_IN_CPYTHON 0
+ #define CYTHON_COMPILING_IN_PYPY 1
+ #define CYTHON_COMPILING_IN_CPYTHON 0
#else
-#define CYTHON_COMPILING_IN_PYPY 0
-#define CYTHON_COMPILING_IN_CPYTHON 1
+ #define CYTHON_COMPILING_IN_PYPY 0
+ #define CYTHON_COMPILING_IN_CPYTHON 1
#endif
#if !defined(CYTHON_USE_PYLONG_INTERNALS) && CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x02070000
-#define CYTHON_USE_PYLONG_INTERNALS 1
+ #define CYTHON_USE_PYLONG_INTERNALS 1
+#endif
+#if CYTHON_USE_PYLONG_INTERNALS
+ #include "longintrepr.h"
+ #undef SHIFT
+ #undef BASE
+ #undef MASK
#endif
#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
-#define Py_OptimizeFlag 0
+ #define Py_OptimizeFlag 0
#endif
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
@@ -82,6 +88,7 @@
#define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
+ #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
#else
#define CYTHON_PEP393_ENABLED 0
#define __Pyx_PyUnicode_READY(op) (0)
@@ -90,6 +97,7 @@
#define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
#define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
#define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
+ #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
#endif
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
@@ -102,6 +110,14 @@
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
#define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
#endif
+#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
+ #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
+#endif
+#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
+ #define PyObject_Malloc(s) PyMem_Malloc(s)
+ #define PyObject_Free(p) PyMem_Free(p)
+ #define PyObject_Realloc(p) PyMem_Realloc(p)
+#endif
#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if PY_MAJOR_VERSION >= 3
@@ -109,6 +125,9 @@
#else
#define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
#endif
+#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
+ #define PyObject_ASCII(o) PyObject_Repr(o)
+#endif
#if PY_MAJOR_VERSION >= 3
#define PyBaseString_Type PyUnicode_Type
#define PyStringObject PyUnicodeObject
@@ -227,6 +246,11 @@ static CYTHON_INLINE float __PYX_NAN() {
#endif
+#define __PYX_ERR(f_index, lineno, Ln_error) \
+{ \
+ __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
+}
+
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
@@ -294,7 +318,7 @@ static CYTHON_INLINE float __PYX_NAN() {
# define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
-typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
+typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
@@ -368,7 +392,7 @@ static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
-static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#if CYTHON_COMPILING_IN_CPYTHON
@@ -377,6 +401,12 @@ static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#endif
#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
+#if PY_MAJOR_VERSION >= 3
+#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
+#else
+#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
+#endif
+#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
static int __Pyx_sys_getdefaultencoding_not_ascii;
static int __Pyx_init_sys_getdefaultencoding_params(void) {
@@ -467,6 +497,7 @@ static PyObject *__pyx_d;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
+static PyObject *__pyx_empty_unicode;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
@@ -491,7 +522,7 @@ struct __pyx_obj_4fisx_5_fisx_PySimpleIni;
struct __pyx_obj_4fisx_5_fisx_PySimpleSpecfile;
struct __pyx_obj_4fisx_5_fisx_PyXRF;
-/* "python\cython\_fisx.pyx":41
+/* "python/cython/_fisx.pyx":41
* from FisxCythonTools import toBytes, toBytesKeys, toBytesKeysAndValues, toString, toStringKeys, toStringKeysAndValues, toStringList
*
* cdef class PyDetector: # <<<<<<<<<<<<<<
@@ -504,7 +535,7 @@ struct __pyx_obj_4fisx_5_fisx_PyDetector {
};
-/* "python\cython\_fisx.pyx":122
+/* "python/cython/_fisx.pyx":143
* from Element cimport *
*
* cdef class PyElement: # <<<<<<<<<<<<<<
@@ -517,7 +548,7 @@ struct __pyx_obj_4fisx_5_fisx_PyElement {
};
-/* "python\cython\_fisx.pyx":256
+/* "python/cython/_fisx.pyx":277
*
* """
* cdef class PyElements: # <<<<<<<<<<<<<<
@@ -530,7 +561,7 @@ struct __pyx_obj_4fisx_5_fisx_PyElements {
};
-/* "python\cython\_fisx.pyx":577
+/* "python/cython/_fisx.pyx":690
* from EPDL97 cimport *
*
* cdef class PyEPDL97: # <<<<<<<<<<<<<<
@@ -543,7 +574,7 @@ struct __pyx_obj_4fisx_5_fisx_PyEPDL97 {
};
-/* "python\cython\_fisx.pyx":665
+/* "python/cython/_fisx.pyx":781
* from Layer cimport *
*
* cdef class PyLayer: # <<<<<<<<<<<<<<
@@ -556,7 +587,7 @@ struct __pyx_obj_4fisx_5_fisx_PyLayer {
};
-/* "python\cython\_fisx.pyx":723
+/* "python/cython/_fisx.pyx":865
* from Material cimport *
*
* cdef class PyMaterial: # <<<<<<<<<<<<<<
@@ -569,7 +600,7 @@ struct __pyx_obj_4fisx_5_fisx_PyMaterial {
};
-/* "python\cython\_fisx.pyx":785
+/* "python/cython/_fisx.pyx":927
* from Math cimport *
*
* cdef class PyMath: # <<<<<<<<<<<<<<
@@ -582,7 +613,7 @@ struct __pyx_obj_4fisx_5_fisx_PyMath {
};
-/* "python\cython\_fisx.pyx":856
+/* "python/cython/_fisx.pyx":1014
* from Shell cimport *
*
* cdef class PyShell: # <<<<<<<<<<<<<<
@@ -595,7 +626,7 @@ struct __pyx_obj_4fisx_5_fisx_PyShell {
};
-/* "python\cython\_fisx.pyx":938
+/* "python/cython/_fisx.pyx":1096
* from SimpleIni cimport *
... 28323 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-fisx.git
More information about the Python-modules-commits
mailing list