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

Uploaded Source

Built Distributions

fisx-1.1.3-py2.7-win-amd64.egg (5.9 MB view details)

Uploaded Source

fisx-1.1.3-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.3-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.3-cp27-none-win_amd64.whl (5.9 MB view details)

Uploaded CPython 2.7 Windows x86-64

fisx-1.1.3-cp27-cp27m-win32.whl (5.8 MB view details)

Uploaded CPython 2.7m Windows x86

fisx-1.1.3-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.3.tar.gz.

File metadata

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

File hashes

Hashes for fisx-1.1.3.tar.gz
Algorithm Hash digest
SHA256 cac3924cb667e0c212332c8a0f7970b20a7e8d32b7cc4a8cc67dbb25584b4e1c
MD5 878ecc14cc43233d2920181ee37007e9
BLAKE2b-256 da7f6941cfd3e424fb4d08d7a455a044db51d18b0a991018a0316f647624f373

See more details on using hashes here.

File details

Details for the file fisx-1.1.3-py2.7-win-amd64.egg.

File metadata

File hashes

Hashes for fisx-1.1.3-py2.7-win-amd64.egg
Algorithm Hash digest
SHA256 1e91f709850f39a1edf9f3e248be4ed5b58545592c79a4c1ccb97dc0632894b7
MD5 69d5f5a7d6c967ddb561e7e38c42c5ed
BLAKE2b-256 f2836df8ae97cbe8245fc539ea6ba70a7c1f5339d1ec0d2a09e41909bde76e25

See more details on using hashes here.

File details

Details for the file fisx-1.1.3-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.3-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 e1ced8ac82c66eb3df5a2b4ba967e9b3e20f56fe8a84224e304a1f2c73694b25
MD5 d7ce979b35373baf74cd6d49f5fa0be4
BLAKE2b-256 7768223e7bd7c174dee2d4744743724813919b7b36724b452303427126f7cb13

See more details on using hashes here.

File details

Details for the file fisx-1.1.3-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.3-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 4d9c3080ce9b61d23d387cfb9666ad20afca23f2291451883bce44a61729d5a1
MD5 463b95da6c818cb758ce378c15ade8c3
BLAKE2b-256 99a1a245274f3173e7e7a92ec46eb57ccb36589c5b1fb1e67e256124238eb947

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fisx-1.1.3-cp27-none-win_amd64.whl
Algorithm Hash digest
SHA256 2bd88c3f60491b9dca24ed17ddf58e87f8d0baef8156395b60b587137b2f37fd
MD5 2e27dc670c4c80f5221f6aa2c39d103f
BLAKE2b-256 511ff8701eb4060721a48303efa8b059db80d660129a3efb7ddf1efb0322845b

See more details on using hashes here.

File details

Details for the file fisx-1.1.3-cp27-cp27m-win32.whl.

File metadata

File hashes

Hashes for fisx-1.1.3-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 7a23598edb31de6b68f6f1de1a1969aa9ba99437812566dc11aba03920679429
MD5 a5799c9491523d822d57c6c06e0a998b
BLAKE2b-256 eccc19c9eb7b53ac2f57462c4c67b64a9548c1ce02425c72aad3c75db8978160

See more details on using hashes here.

File details

Details for the file fisx-1.1.3-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.3-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 e06ba802c0c8cac42e6538f273a044986559b952813697c268fd80331a3dabbb
MD5 5dc4c45a3e4832eea1def4339262a3dd
BLAKE2b-256 b82dc25393f93c50202294cc5b107a1972ae40d829593fd6407f96b985e0465a

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