Skip to main content

Quantitative X-Ray Fluorescence Analysis Support Library

Project description

Main development website: https://github.com/vasole/fisx

https://travis-ci.org/vasole/fisx.svg?branch=master https://ci.appveyor.com/api/projects/status/github/vasole/fisx?branch=master&svg=true

This software library implements formulas to calculate, given an experimental setup, the expected x-ray fluorescence intensities. The library accounts for secondary and tertiary excitation, K, L and M shell emission lines and de-excitation cascade effects. The basic implementation is written in C++ and a Python binding is provided.

Account for secondary excitation is made via the reference:

D.K.G. de Boer, X-Ray Spectrometry 19 (1990) 145-154

with the correction mentioned in:

D.K.G. de Boer et al, X-Ray Spectrometry 22 (1993) 33-28

Tertiary excitation is accounted for via an appproximation.

The accuracy of the corrections has been tested against experimental data and Monte Carlo simulations.

License

This code is relased under the MIT license as detailed in the LICENSE file.

Installation

To install the library for Python just use pip install fisx. If you want build the library for python use from the code source repository, just use one of the pip install . or the python setup.py install approaches. It is convenient (but not mandatory) to have cython >= 0.17 installed for it.

Testing

To run the tests after installation run:

python -m fisx.tests.testAll

Example

There is a web application using this library for calculating expected x-ray count rates.

This piece of Python code shows how the library can be used via its python binding.

from fisx import Elements
from fisx import Material
from fisx import Detector
from fisx import XRF

elementsInstance = Elements()
elementsInstance.initializeAsPyMca()
# After the slow initialization (to be made once), the rest is fairly fast.
xrf = XRF()
xrf.setBeam(16.0) # set incident beam as a single photon energy of 16 keV
xrf.setBeamFilters([["Al1", 2.72, 0.11, 1.0]]) # Incident beam filters
# Steel composition of Schoonjans et al, 2012 used to generate table I
steel = {"C":  0.0445,
         "N":  0.04,
         "Si": 0.5093,
         "P":  0.02,
         "S":  0.0175,
         "V":  0.05,
         "Cr":18.37,
         "Mn": 1.619,
         "Fe":64.314, # calculated by subtracting the sum of all other elements
         "Co": 0.109,
         "Ni":12.35,
         "Cu": 0.175,
         "As": 0.010670,
         "Mo": 2.26,
         "W":  0.11,
         "Pb": 0.001}
SRM_1155 = Material("SRM_1155", 1.0, 1.0)
SRM_1155.setComposition(steel)
elementsInstance.addMaterial(SRM_1155)
xrf.setSample([["SRM_1155", 1.0, 1.0]]) # Sample, density and thickness
xrf.setGeometry(45., 45.)               # Incident and fluorescent beam angles
detector = Detector("Si1", 2.33, 0.035) # Detector Material, density, thickness
detector.setActiveArea(0.50)            # Area and distance in consistent units
detector.setDistance(2.1)               # expected cm2 and cm.
xrf.setDetector(detector)
Air = Material("Air", 0.0012048, 1.0)
Air.setCompositionFromLists(["C1", "N1", "O1", "Ar1", "Kr1"],
                            [0.0012048, 0.75527, 0.23178, 0.012827, 3.2e-06])
elementsInstance.addMaterial(Air)
xrf.setAttenuators([["Air", 0.0012048, 5.0, 1.0],
                    ["Be1", 1.848, 0.002, 1.0]]) # Attenuators
fluo = xrf.getMultilayerFluorescence(["Cr K", "Fe K", "Ni K"],
                                     elementsInstance,
                                     secondary=2,
                                     useMassFractions=1)
print("Element   Peak          Energy       Rate      Secondary  Tertiary")
for key in fluo:
    for layer in fluo[key]:
        peakList = list(fluo[key][layer].keys())
        peakList.sort()
        for peak in peakList:
            # energy of the peak
            energy = fluo[key][layer][peak]["energy"]
            # expected measured rate
            rate = fluo[key][layer][peak]["rate"]
            # primary photons (no attenuation and no detector considered)
            primary = fluo[key][layer][peak]["primary"]
            # secondary photons (no attenuation and no detector considered)
            secondary = fluo[key][layer][peak]["secondary"]
            # tertiary photons (no attenuation and no detector considered)
            tertiary = fluo[key][layer][peak].get("tertiary", 0.0)
            # correction due to secondary excitation
            enhancement2 = (primary + secondary) / primary
            enhancement3 = (primary + secondary + tertiary) / primary
            print("%s   %s    %.4f     %.3g     %.5g    %.5g" % \
                               (key, peak + (13 - len(peak)) * " ", energy,
                               rate, enhancement2, enhancement3))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fisx-1.1.9.tar.gz (5.7 MB view details)

Uploaded Source

Built Distributions

fisx-1.1.9-cp39-cp39-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.9 Windows x86-64

fisx-1.1.9-cp38-cp38-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.8 Windows x86-64

fisx-1.1.9-cp38-cp38-macosx_10_9_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

fisx-1.1.9-cp37-cp37m-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.7m Windows x86-64

fisx-1.1.9-cp37-cp37m-macosx_10_9_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

fisx-1.1.9-cp36-cp36m-win_amd64.whl (6.0 MB view details)

Uploaded CPython 3.6m Windows x86-64

fisx-1.1.9-cp36-cp36m-macosx_10_9_x86_64.whl (6.0 MB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

fisx-1.1.9-cp27-cp27m-win_amd64.whl (6.0 MB view details)

Uploaded CPython 2.7m Windows x86-64

fisx-1.1.9-cp27-cp27m-macosx_10_6_intel.whl (6.4 MB view details)

Uploaded CPython 2.7m macOS 10.6+ intel

File details

Details for the file fisx-1.1.9.tar.gz.

File metadata

  • Download URL: fisx-1.1.9.tar.gz
  • Upload date:
  • Size: 5.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.5

File hashes

Hashes for fisx-1.1.9.tar.gz
Algorithm Hash digest
SHA256 419c9558ef3de2a5bed2b8342ef47d362675cad96d554f9f180c800751cd32d9
MD5 8225f4c3225137c16bfb1a4cd1e7f88c
BLAKE2b-256 6e31e18934a0291c330df87a18e1c10d3d971078daeafec2f1eaab9a6859d330

See more details on using hashes here.

File details

Details for the file fisx-1.1.9-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: fisx-1.1.9-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 5.9 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.2

File hashes

Hashes for fisx-1.1.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bf33cb9f13d13bc38fb3aeea9ec8adfbf269f8fe993282763d79a92abec7caef
MD5 8cfc6b271684e4142938f80c92b310b9
BLAKE2b-256 8361aa00a85b3fa86d81e92a908771af8ce0a71ee98eeaed15a8b1cf88678fa2

See more details on using hashes here.

File details

Details for the file fisx-1.1.9-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: fisx-1.1.9-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 5.9 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.2

File hashes

Hashes for fisx-1.1.9-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 d799c55ec66482188b7201a052b2b821193342ad4b3a6863ae6413f12b79f1e1
MD5 dfe4ba45629685f5ab3872f36cfce3ae
BLAKE2b-256 d765c11d2d5e22c8a71391f58609836ba1f2234961c7d2d289a93a3f57d79020

See more details on using hashes here.

File details

Details for the file fisx-1.1.9-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: fisx-1.1.9-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 6.0 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.5

File hashes

Hashes for fisx-1.1.9-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f62cb22c8776ab4b9515e175f48d79f6e67dcd79d140bab6c05e629c8a34e108
MD5 cf2fd97f5b89ed951277079c96fddd97
BLAKE2b-256 275a627db5551422f96fa20f1053964f522a9937fecf062037d8dd28dc4681d7

See more details on using hashes here.

File details

Details for the file fisx-1.1.9-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: fisx-1.1.9-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 5.9 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.2

File hashes

Hashes for fisx-1.1.9-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 14d3cd661d18981aeb55095a51f2d067bfc704c7072ed7f588b6b76b60d4a75e
MD5 dffdd76840873d632260835add1f9e1b
BLAKE2b-256 b1c49a65581c64081722192ff81463856a08d8e88a49f6cd0f83f2fdab201968

See more details on using hashes here.

File details

Details for the file fisx-1.1.9-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: fisx-1.1.9-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 6.0 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.5

File hashes

Hashes for fisx-1.1.9-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6b12deaf3bf89f41515c35fe2dfc5cbd5731cc562864c818b92d419b7ec7a4c5
MD5 d24ee61f7443c1b812bcc766794905ec
BLAKE2b-256 5c500b9c23cfdef4bfb00b09a4a5746750bb722f1c3c69947240771f7fb4dd98

See more details on using hashes here.

File details

Details for the file fisx-1.1.9-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: fisx-1.1.9-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 6.0 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.2

File hashes

Hashes for fisx-1.1.9-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 dfa6ebeb41ce21bbc760c7e604d6f8a0f0e87b18c1e86e444bcbfee9cb6883c3
MD5 c6ddfeca2081460fd04851d3073275c9
BLAKE2b-256 a6e7f28008a25c576273f390244448249c1176bb92979883e2644a969e7c517d

See more details on using hashes here.

File details

Details for the file fisx-1.1.9-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: fisx-1.1.9-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 6.0 MB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.5

File hashes

Hashes for fisx-1.1.9-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ba3a1df8d15d35d48f73f869ec9453a031c7998930f59b5e3b140ca4407d3eba
MD5 4a5e9463152707d655871d5715585560
BLAKE2b-256 c0e244784286f788353db22e1d849551869e59cbb99c7c576a811110d3a5d51f

See more details on using hashes here.

File details

Details for the file fisx-1.1.9-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: fisx-1.1.9-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 6.0 MB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.2

File hashes

Hashes for fisx-1.1.9-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 99ff364ed0cad77774504f8cedea65f80b1b558653c43c60b47b77d5a60abd99
MD5 796dc3463934708bca4e83f95dddecbf
BLAKE2b-256 b4cd28f0a942b70b71cf7342957b8803e40172112bcc4833fcdce8b6ff8a304c

See more details on using hashes here.

File details

Details for the file fisx-1.1.9-cp27-cp27m-macosx_10_6_intel.whl.

File metadata

  • Download URL: fisx-1.1.9-cp27-cp27m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 6.4 MB
  • Tags: CPython 2.7m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.8.5

File hashes

Hashes for fisx-1.1.9-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 e9fc255ef47789dc79eb7890f07ee86e0774f6140c5c954b8fc6b94421b7cf90
MD5 3b9c6d6016ed17a26d473682dc2d816f
BLAKE2b-256 b160941f264bf59bd7a6e340eb2ed6ea8fbcc65bd5e4771bd07ba9019f480480

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page