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.6.tar.gz (5.7 MB view details)

Uploaded Source

Built Distributions

fisx-1.1.6-cp37-cp37m-win_amd64.whl (6.0 MB view details)

Uploaded CPython 3.7m Windows x86-64

fisx-1.1.6-cp37-cp37m-macosx_10_6_intel.whl (6.5 MB view details)

Uploaded CPython 3.7m macOS 10.6+ intel

fisx-1.1.6-cp36-cp36m-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.6m Windows x86-64

fisx-1.1.6-cp36-cp36m-macosx_10_6_intel.whl (6.6 MB view details)

Uploaded CPython 3.6m macOS 10.6+ intel

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

Uploaded CPython 2.7m Windows x86-64

fisx-1.1.6-cp27-cp27m-macosx_10_6_intel.whl (6.5 MB view details)

Uploaded CPython 2.7m macOS 10.6+ intel

File details

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

File metadata

  • Download URL: fisx-1.1.6.tar.gz
  • Upload date:
  • Size: 5.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/40.2.0 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.6.4 Windows/7

File hashes

Hashes for fisx-1.1.6.tar.gz
Algorithm Hash digest
SHA256 c9dea8b6573e643cc966474a034fc6e916729fb9cba5cf361b5ec9a176dbc043
MD5 53a0cd68ed58f07a5a3e9fcf4d520bf8
BLAKE2b-256 ff4823594f9aed03eef512c0908b38f4c7e685755d7df13e46a1f7d21c017e05

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fisx-1.1.6-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 6.0 MB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.0

File hashes

Hashes for fisx-1.1.6-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 99e392e90bcb141af019bd1eb03295a3000731536b4a871a568662c00eba57d5
MD5 a45260d6e212e24cd3757bb3c46c4729
BLAKE2b-256 4783f7a5c70c189ec1a6b98c1d44b5cf9bab40ad9641e4aa89de8c6968d3bdf2

See more details on using hashes here.

File details

Details for the file fisx-1.1.6-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: fisx-1.1.6-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 6.5 MB
  • Tags: CPython 3.7m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.7.0

File hashes

Hashes for fisx-1.1.6-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 40eff10b93cb33a29dd05222f6d2455727b5255e5800840a0aa88c0281dc891a
MD5 b9c7cb8e6d9309bc1867b0ae765c3102
BLAKE2b-256 dd4342f8923687e69d7f4dff4ec114f4962a11d0adfcc7c89d614a36e6d43cf7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fisx-1.1.6-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 5.9 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/40.2.0 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.6.4 Windows/7

File hashes

Hashes for fisx-1.1.6-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 70cb949d0e1e986c1cdda43b96def8a6e36fff81b12c511e0b2194e0f9cdb0ef
MD5 6e2ce61de3723f15e321f3c03946dcc9
BLAKE2b-256 dbcb4cf3ab3d6f3f1b1bf8603fa11331b6e78c1ce696c85d02c88caf908c956d

See more details on using hashes here.

File details

Details for the file fisx-1.1.6-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: fisx-1.1.6-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 6.6 MB
  • Tags: CPython 3.6m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/40.2.0 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.6.4 Windows/7

File hashes

Hashes for fisx-1.1.6-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 32d557364826f42fe81ad9cde79541590deee7c7cd1655db29242f0628b5d2c3
MD5 d8c6ab3dd2548280b083f4ea6520c477
BLAKE2b-256 9c3c3e0c62d1425b80c0d364a3670d13f9670e20b45b94c61fb9876c1086d239

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fisx-1.1.6-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/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/40.2.0 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.6.4 Windows/7

File hashes

Hashes for fisx-1.1.6-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 9ff4dc0954ca3657202fdbda1e4e816564c74697b0cbc3fa31a4221442e56d0a
MD5 876bdb0257e9491a3c8021f58d86085b
BLAKE2b-256 e84d6a65ddea6db8f8325f0ba333f2bd274cf110dca6e346f02ef281ff9c259b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fisx-1.1.6-cp27-cp27m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 6.5 MB
  • Tags: CPython 2.7m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.8.1 pkginfo/1.4.1 requests/2.13.0 setuptools/40.2.0 requests-toolbelt/0.7.0 clint/0.5.1 CPython/3.6.4 Windows/7

File hashes

Hashes for fisx-1.1.6-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 7225705d6c93c45275d0a7992df124c6742a337bb94ea81caa6b8fa2afec8c89
MD5 0ea8f5f052872a12d0fa03353b3e4367
BLAKE2b-256 e62f443443bdbff2c6eec8847cf959639957c56fdb29dc18c7d9a91ae5f59226

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