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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.6m Windows x86-64

fisx-1.1.4-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.6m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

fisx-1.1.4-cp35-none-win_amd64.whl (5.9 MB view details)

Uploaded CPython 3.5 Windows x86-64

fisx-1.1.4-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (6.6 MB view details)

Uploaded CPython 3.5m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

fisx-1.1.4-cp27-none-win_amd64.whl (5.9 MB view details)

Uploaded CPython 2.7 Windows x86-64

fisx-1.1.4-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (6.5 MB view details)

Uploaded CPython 2.7m macOS 10.10+ intel macOS 10.10+ x86-64 macOS 10.6+ intel macOS 10.9+ intel macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for fisx-1.1.4.tar.gz
Algorithm Hash digest
SHA256 2bd151da0d068c417ca549ce419207cfbf936daa1c83828d81d79a4aa1ef5c7c
MD5 c53ca1aeae692cdbf242c2759f89f7a1
BLAKE2b-256 e15f05cf2ed11fa0e7cbb2e7be67a29bd1dceda097c52f1eed58885760aecb2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fisx-1.1.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f149b09f697f6c8a2739a5d1035b33b9457b734fb71263743ab2371bb2e6326a
MD5 515461efb3dacce6ee91bb879ba524b3
BLAKE2b-256 4a0e574b6ce3175cae0af1e64739bc86a7076cdf6cbd46ac346ac82f4db1d858

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fisx-1.1.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f22561046d979c99acac8924014022b0558d798e887cefb533c8fee0e3ac0b58
MD5 aba463a6c2804d130570ce3dc902c612
BLAKE2b-256 adddb64af6ffb11845cc704ae0cdcb17d4ffd9939fdd2ebd0fab712e10d14c4d

See more details on using hashes here.

File details

Details for the file fisx-1.1.4-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for fisx-1.1.4-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 b28721ad0e3d292c2aaedc200640e1b89c444d5804dda81e523e20394e313bf5
MD5 994cd52c1cf403e4421ce5d16a1ffb68
BLAKE2b-256 85de66beb009ed2483865c7d75c3df29b0b2753d35ccfb1d9b1d7b4d6bf028dc

See more details on using hashes here.

File details

Details for the file fisx-1.1.4-cp35-none-win_amd64.whl.

File metadata

File hashes

Hashes for fisx-1.1.4-cp35-none-win_amd64.whl
Algorithm Hash digest
SHA256 32bd9941256cfaff45731d2ef85f6f7391b4fdcfea6faec6459b48d7e1a8e750
MD5 07a633397e2264a13a46c1a03a846618
BLAKE2b-256 170ea8ad87e476d05964576e4ad97af9401b7d5c18582b7f47fc62624bf729f1

See more details on using hashes here.

File details

Details for the file fisx-1.1.4-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for fisx-1.1.4-cp35-cp35m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 90746121e09a292aabe81e98d1c18b10fb00348b3b286826e0380f9b4bb1fa59
MD5 787f6e4be3d1a14c96a940dc5e6f67fa
BLAKE2b-256 29865df33f91a6c48ba2f22b657816c552c867eff48b5c6e6428efc6266edbdf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fisx-1.1.4-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 d332bad5ca96edb68feb6d24cc5c3bfe0e5a302261ac445c2a4ae59b447c8665
MD5 916538dd4293f8dc655dd6b93f1110bf
BLAKE2b-256 b59f585227ee00541d161b428a211d9fd8076fba6f0acd94eb38a225d6018230

See more details on using hashes here.

File details

Details for the file fisx-1.1.4-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl.

File metadata

File hashes

Hashes for fisx-1.1.4-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Algorithm Hash digest
SHA256 3d0d083183aa0817f534efa68db0d118c67e0ae79e34a940955b7a086a3ef7b5
MD5 6502c9dc459dc3a4b790cf3bd095af97
BLAKE2b-256 b055094f721b9c815417a3fd0aea21f817dc154a3b63088d00d8958a9abcb020

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