XASutils module

The xasutils module offers the following XAFS utility functions :

Function

Description

etok()

Converts photo-electron energy to wavenumber.

ktoe()

Converts photo-electron wavenumber to energy.

get_mapped_data()

Returns data mapped to a common domain in a collection.

araucaria.xas.xasutils.etok(energy)[source]

Converts photo-electron energy to wavenumber.

Parameters

energy (ndarray) – Array of photo-electron energies (eV).

Return type

ndarray

Returns

Array of photo-electron wavenumbers (\(Å^{-1}\)).

Notes

Conversion is performed considering the non-relativistic approximation:

\[k = \frac{\sqrt{2mE}}{\hbar}\]

Where

  • \(k\): photo-electron wavenumber.

  • \(E\): kinetic energy of the photo-electron.

  • \(m\): electron mass.

  • \(\hbar\): reduced Planck constant.

Example

>>> from araucaria.xas import etok
>>> e = 400      # eV
>>> k = etok(e)  # A^{-1}
>>> print('%1.5f' % k)
10.24633
araucaria.xas.xasutils.ktoe(k)[source]

Converts photo-electron wavenumber to energy.

Parameters

k (ndarray) – Array with photo-electron wavenumbers (\(Å^{-1}\)).

Return type

ndarray

Returns

Array with photo-electron energies (eV).

See also

etok

Converts photo-electron energy to wavenumber.

Example

>>> from araucaria.xas import ktoe
>>> k = 10      # A^{-1}
>>> e = ktoe(k)  # eV
>>> print('%1.5f' % e)
380.99821
araucaria.xas.xasutils.get_mapped_data(collection, taglist=['all'], region='xanes', domain=None, range=[- inf, inf], kweight=2)[source]

Returns data mapped to a common domain in a collection.

Parameters
  • collection (Collection) – Collection with group datasets.

  • taglist (List[str]) – List with keys to filter groups based on their tags attributes in the Collection. The default is [‘all’].

  • region (str) – XAS region to perform mapping. Accepted values are ‘dxanes’, ‘xanes’, ‘exafs’. The default is ‘xanes’.

  • domain (Optional[ndarray]) – Domain values to perform mapping. Energy units are expected for ‘dxanes’ or ‘xanes’, while wavenumber (k) units are expected for ‘exafs’. It overrides the range parameter.

  • range (list) – Domain range in absolute values. Energy units are expected for ‘dxanes’ or ‘xanes’, while wavenumber (k) units are expected for ‘exafs’. The default is [-inf, inf].

  • kweight (int) – Exponent for weighting chi(k) by k^kweight. Only valid for region='exafs'. The default is 2.

Return type

Tuple[ndarray, ndarray]

Returns

  • 1-D array containing the domain values for mapping.

  • Array containing in each column the mapped values of groups.

Raises
  • TypeError – If collection is not a valid Collection instance.

  • AttributeError – If collection has no tags attribute.

  • AttributeError – If groups in collection have no energy or norm attribute. Only verified if region=dxanes or region=xanes.

  • AttributeError – If groups in collection have no k or chi attribute. Only verified if region='exafs'.

  • KeyError – If items in taglist are not keys of the tags attribute.

  • ValueError – If region is not recognized.

  • ValueError – If range or domain is outside the domain of a group in collection.

Notes

Exploratory data analysis assumes that data is mapped to a common domain range. However, datasets in a Collection are often mapped to different domain ranges.

get_mapped_data() establishes a common domain based on the specified region and range variables, and returns an array with the interpolated values.

Alternatively, if a domain array is provided, get_mapped_data() returns an array with the interpolated values.

Example

>>> from numpy import allclose
>>> from araucaria.testdata import get_testpath
>>> from araucaria.xas import pre_edge
>>> from araucaria.stats import get_mapped_data
>>> from araucaria.io import read_collection_hdf5
>>> fpath      = get_testpath('Fe_database.h5')
>>> collection = read_collection_hdf5(fpath)
>>> collection.apply(pre_edge)
>>> ener, data = get_mapped_data(collection, region='xanes')
>>> allclose(ener.shape[0], data.shape[0])
True
>>> # passing a domain argument
>>> nener, ndata = get_mapped_data(collection, region='xanes',
...                                domain=ener)
>>> allclose(data, ndata)
True