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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m macOS 10.6+ intel

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

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m macOS 10.6+ intel

fisx-1.1.5-cp27-none-win_amd64.whl (6.0 MB view details)

Uploaded CPython 2.7 Windows x86-64

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

Uploaded CPython 2.7m Windows x86-64

fisx-1.1.5-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.5.tar.gz.

File metadata

  • Download URL: fisx-1.1.5.tar.gz
  • Upload date:
  • Size: 5.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fisx-1.1.5.tar.gz
Algorithm Hash digest
SHA256 9b153f0ccb5f2ff3c6033b9b18a7f4bfe2a4a1761b59faf12e64dbd8532748dc
MD5 f141a345a500edd7d6891133baefd2c4
BLAKE2b-256 42b25b877cdd1f970a62c9bc7d98809a94d99d787c85f51057ce6ddae9c22bdc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fisx-1.1.5-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 47a4f45bae6be7a4c6afac024538a721421e4b7ab194da0c553c5db2deb90648
MD5 aad73b339ac47449280b3ce3b0eb85c5
BLAKE2b-256 feeebdd3e93ee8b890ae856bfd50174ed596bb2c84a4d9f4c88181b2ac8c77a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fisx-1.1.5-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 ec58b8e01bbc5f9327e2c9e5f2e6e54cdd13de8b0df945a83eb4fd2a3eee160c
MD5 2bfbca9835e89b86322c15a234973e33
BLAKE2b-256 b36ba3184b1dc0f4dba06a9023fa8b342c875562f5ec67416e86313497c2e2c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fisx-1.1.5-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f7d6ecf869a0670adb3047cd78bd1bd22534df45bfe666147b21a824153f8231
MD5 99092044ff83ad956ee450caed2c0f22
BLAKE2b-256 acdc01a3d0feca28cb4d62b5da0eb37ec0d421f9a5bbede3f89f0b7c7c702386

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fisx-1.1.5-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.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.1 CPython/3.6.5

File hashes

Hashes for fisx-1.1.5-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 48c725c9e965901815347b2e9d636ecd1843edcad116bbd60718dfbffe983413
MD5 3c5366e4959a040cf103b31df30d4533
BLAKE2b-256 2acffa131446053d537e1ec1528bfc7225ea2f4c736893d8c3f63400ea910932

See more details on using hashes here.

File details

Details for the file fisx-1.1.5-cp27-none-win_amd64.whl.

File metadata

File hashes

Hashes for fisx-1.1.5-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 20823f5c60f33c9d971be1b2c191667f8d84fd7a9954a8607ce5b04362c41110
MD5 4cec6443f96ef701ee6ca7d9149eaf3f
BLAKE2b-256 d8e1a7702440ac386b5dd2313b824ff18ac2332a3565001215e5c16ff09a00b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fisx-1.1.5-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 0b1782e9905f06373868d1aa389b8d1c797e67d8507d33bd1bc362d168358d43
MD5 ed1de401a924d913fa67fe8551e56c97
BLAKE2b-256 88ab6bffeef08afc75bcfeb15837d68de1fc3311ac5effe5bc555e8e372b024b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fisx-1.1.5-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 f585bf33c6e61ea07ace405d62713ec1fed4254febaf7c409c5c44f605f93053
MD5 6a2481a1b86dbc82c92a8afed8f08f0b
BLAKE2b-256 ca080f6f979156f69a59a3b922edffe134b8e510c47a0cf871584ce919cc119a

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