openmicroanalysis / pyxray

Definitions and properties of X-ray transitions
MIT License
6 stars 4 forks source link
microanalysis periodic-table-of-elements x-ray x-ray-spectroscopy

pyxray

.. image:: https://img.shields.io/pypi/v/pyxray.svg :target: https://pypi.python.org/pypi/pyxray

.. image:: https://img.shields.io/github/workflow/status/openmicroanalysis/pyxray/CI :target: https://github.com/openmicroanalysis/pyxray/actions :alt: GitHub Workflow Status

.. image:: https://img.shields.io/codecov/c/github/openmicroanalysis/pyxray.svg :target: https://codecov.io/github/openmicroanalysis/pyxray

.. image:: https://readthedocs.org/projects/pyxray/badge/?version=latest :target: https://pyxray.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

pyxray is a Python library that defines basic object to specify atomic subshells and X-ray transitions. The objects also provide critical information as the energy, existence and different notations of the X-ray transitions.

pyxray supports 3.6+ (no Python 2.x support).

Installation

Easiest way to install using pip::

pip install pyxray

For development installation from the git repository::

git clone git@github.com/openmicroanalysis/pyxray.git
cd pyxray
pip install -e .
pre-commit install

See development section below

Methods

All methods below are accessed by importing pyxray:

.. code:: python

import pyxray

Variables of the methods are defined as follows

Element properties

Properties associated with an element, defined as the ground state of an atom where the number of protons equal the number of electrons.

Atomic shell properties

Properties associated with an atomic shell <https://en.wikipedia.org/wiki/Electron_shell>_, defined by its principal quantum number.

Atomic subshell properties

Properties associated with an atomic subshell <https://en.wikipedia.org/wiki/Electron_shell#Subshells>_, a subdivision of atomic shells.

X-ray transition properties

Properties associated with an electron transition, relaxation process of an electron between quantum states leading to X-rays emission.

X-ray line

Object to represent an x-ray transition and its properties.

.. code:: python

xrayline = pyxray.xray_line(14, 'Ka1') xrayline.atomic_number #=> 14 xrayline.transition #=> XrayTransition(2, 1, 3, 1, 0, 1) xrayline.iupac #=> Si K–L3 xrayline.siegbahn #=> Si Kα1 xrayline.energy_eV #=> 1740.0 xrayline.probability #=> 0.031705199999999996 xrayline.relative_weight #=> 1.0

As any other descriptors, X-ray line objects are immutable and hashable so they can be used as keys of a dictionary.

.. code:: python

xrayline1 = pyxray.xray_line(13, 'Ka1') xrayline2 = pyxray.xray_line('Al', 'Ka1') xrayline1 == xrayline2 #=> True pyxray.xray_line(13, 'Ka1') == pyxray.xray_line(13, 'Ka') #=> False

To sort X-ray lines, use one of their properties:

.. code:: python

from operator import attrgetter lines = [pyxray.xray_line(14, 'Ka1'), pyxray.xray_line(13, 'Ka1'), pyxray.xray_line(14, 'Ll')] sorted(lines, key=attrgetter('energy_eV')) #=> [XrayLine(Si L3–M1), XrayLine(Al K–L3), XrayLine(Si K–L3)]

Composition

Defines a composition of a compound.

To create a composition, use the class methods:

Use the following attributes to access the composition values:

The composition object is immutable, i.e. it cannot be modified once created. Equality can be checked. It is hashable. It can be pickled or copied.

Release notes

1.7

1.6.1

1.6

1.5

1.4

1.3.4

1.3.3

1.3.2

1.3.1

1.2.1

1.2.0

Contributors

Development

pyxray stores all data for the above functions in a SQLite database. The database is constructed during the build process of the Python package (i.e. python setup.py build) using registered parsers. The provided parsers are located in the package pyxray.parser, but external parsers can be provided by registering to the entry point pyxray.parser. In short, the database is not provide in the source code, only in the distributed version. It is therefore necessary to build the SQLite database when running pyxray in development mode. Building the database will take several minutes. In short, in the pyxray folder, run

.. code:: shell

pip install -e .[develop] python3 setup.py build

Build the documentation:

.. code-block:: console

$ cd docs
$ make html

Add or modify the API documentation:

.. code-block:: console

$ cd docs
$ sphinx-apidoc -o source/api -e -f -P ../pyxray
$ make html

License

The library is provided under the MIT license.

pyxray was partially developed as part of the doctorate thesis project of Philippe T. Pinard at RWTH Aachen University (Aachen, Germany) under the supervision of Dr. Silvia Richter.

Copyright (c) 2015-2016/06 Philippe Pinard and Silvia Richter

Copyright (c) 2016/06-2020 Philippe Pinard