# hyperspy.misc.material module

hyperspy.misc.material._atomic_to_weight(atomic_percent, elements)

Convert atomic percent to weight percent.

Parameters
• atomic_percent (array) – The atomic fractions (composition) of the sample.

• elements (list of str) – A list of element abbreviations, e.g. [‘Al’,’Zn’]

Returns

weight_percent – composition in weight percent.

Return type

array of float

Examples

Calculate the weight percent of modern bronze given its atomic percent: >>> hs.material.atomic_to_weight([93.2, 6.8], (“Cu”, “Sn”)) array([ 88.00501989, 11.99498011])

hyperspy.misc.material._density_of_mixture(weight_percent, elements, mean='harmonic')

Calculate the density a mixture of elements.

The density of the elements is retrieved from an internal database. The calculation is only valid if there is no interaction between the components.

Parameters
• weight_percent (array) – A list of weight percent for the different elements. If the total is not equal to 100, each weight percent is divided by the sum of the list (normalization).

• elements (list of str) – A list of element symbols, e.g. [‘Al’, ‘Zn’]

• mean ('harmonic' or 'weighted') – The type of mean use to estimate the density

Returns

density

Return type

The density in g/cm3.

Examples

Calculate the density of modern bronze given its weight percent: >>> hs.material.density_of_mixture([88, 12],[‘Cu’, ‘Sn’]) 8.6903187973131466

hyperspy.misc.material._mass_absorption_mixture(weight_percent, elements, energies)

Calculate the mass absorption coefficient for X-ray absorbed in a mixture of elements.

The mass absorption coefficient is calculated as a weighted mean of the weight percent and is retrieved from the database of Chantler2005.

Parameters
• weight_percent (np.array) – The composition of the absorber(s) in weight percent. The first dimension of the matrix corresponds to the elements.

• elements (list of str) – The list of element symbol of the absorber, e.g. [‘Al’,’Zn’].

• energies (float or list of float or str or list of str) – The energy or energies of the X-ray in keV, or the name of the X-rays, e.g. ‘Al_Ka’.

Examples

```>>> hs.material.mass_absorption_mixture(
>>>     elements=['Al','Zn'], weight_percent=[50,50], energies='Al_Ka')
2587.4161643905127
```
Returns

• float or array of float

• mass absorption coefficient(s) in cm^2/g

`mass_absorption()`

Note

See http://physics.nist.gov/ffast Chantler, C.T., Olsen, K., Dragoset, R.A., Kishore, A.R., Kotochigova, S.A., and Zucker, D.S. (2005), X-Ray Form Factor, Attenuation and Scattering Tables (version 2.1).

hyperspy.misc.material._weight_to_atomic(weight_percent, elements)

Convert weight percent (wt%) to atomic percent (at.%).

Parameters
• weight_percent (array of float) – The weight fractions (composition) of the sample.

• elements (list of str) – A list of element abbreviations, e.g. [‘Al’,’Zn’]

Returns

• atomic_percent (array of float) – Composition in atomic percent.

• Calculate the atomic percent of modern bronze given its weight percent

• >>> hs.material.weight_to_atomic((88, 12), (“Cu”, “Sn”))

• array([ 93.19698614, 6.80301386])

hyperspy.misc.material.atomic_to_weight(atomic_percent, elements='auto')

Convert atomic percent to weight percent.

Parameters
• atomic_percent (list of float or list of signals) – The atomic fractions (composition) of the sample.

• elements (list of str) – A list of element abbreviations, e.g. [‘Al’,’Zn’]. If elements is ‘auto’, take the elements in en each signal metadata of the atomic_percent list.

Returns

weight_percent – composition in weight percent.

Return type

as atomic_percent

Examples

Calculate the weight percent of modern bronze given its atomic percent: >>> hs.material.atomic_to_weight([93.2, 6.8], (“Cu”, “Sn”)) array([ 88.00501989, 11.99498011])

hyperspy.misc.material.density_of_mixture(weight_percent, elements='auto', mean='harmonic')

Calculate the density of a mixture of elements.

The density of the elements is retrieved from an internal database. The calculation is only valid if there is no interaction between the components.

Parameters
• weight_percent (list of float or list of signals) – A list of weight percent for the different elements. If the total is not equal to 100, each weight percent is divided by the sum of the list (normalization).

• elements (list of str) – A list of element symbols, e.g. [‘Al’, ‘Zn’]. If elements is ‘auto’, take the elements in en each signal metadata of the weight_percent list.

• mean ('harmonic' or 'weighted') – The type of mean use to estimate the density

Returns

density

Return type

The density in g/cm3.

Examples

Calculate the density of modern bronze given its weight percent: >>> hs.material.density_of_mixture([88, 12],[‘Cu’, ‘Sn’]) 8.6903187973131466

hyperspy.misc.material.mass_absorption_coefficient(element, energies)

Mass absorption coefficient (mu/rho) of a X-ray absorbed in a pure material.

Parameters
• element (str) – The element symbol of the absorber, e.g. ‘Al’.

• energies (float or list of float or str or list of str) – The energy or energies of the X-ray in keV, or the name of the X-rays, e.g. ‘Al_Ka’.

Return type

mass absorption coefficient(s) in cm^2/g

Examples

```>>> hs.material.mass_absorption_coefficient(
>>>     element='Al', energies=['C_Ka','Al_Ka'])
array([ 26330.38933818,    372.02616732])
```

`mass_absorption_mixture()`

Note

See http://physics.nist.gov/ffast Chantler, C.T., Olsen, K., Dragoset, R.A., Kishore, A.R., Kotochigova, S.A., and Zucker, D.S. (2005), X-Ray Form Factor, Attenuation and Scattering Tables (version 2.1).

hyperspy.misc.material.mass_absorption_mixture(weight_percent, elements='auto', energies='auto')

Calculate the mass absorption coefficient for X-ray absorbed in a mixture of elements.

The mass absorption coefficient is calculated as a weighted mean of the weight percent and is retrieved from the database of Chantler2005.

Parameters
• weight_percent (list of float or list of signals) – The composition of the absorber(s) in weight percent. The first dimension of the matrix corresponds to the elements.

• elements (list of str or 'auto') – The list of element symbol of the absorber, e.g. [‘Al’,’Zn’]. If elements is ‘auto’, take the elements in each signal metadata of the weight_percent list.

• energies (list of float or list of str or 'auto') – The energy or energies of the X-ray in keV, or the name of the X-rays, e.g. ‘Al_Ka’. If ‘auto’, take the lines in each signal metadata of the weight_percent list.

Examples

```>>> hs.material.mass_absorption_mixture(
>>>     elements=['Al','Zn'], weight_percent=[50,50], energies='Al_Ka')
2587.41616439
```
Returns

• float or array of float

• mass absorption coefficient(s) in cm^2/g

`mass_absorption_coefficient()`

Note

See http://physics.nist.gov/ffast Chantler, C.T., Olsen, K., Dragoset, R.A., Kishore, A.R., Kotochigova, S.A., and Zucker, D.S. (2005), X-Ray Form Factor, Attenuation and Scattering Tables (version 2.1).

hyperspy.misc.material.weight_to_atomic(weight_percent, elements='auto')

Convert weight percent (wt%) to atomic percent (at.%).

Parameters
• weight_percent (list of float or list of signals) – The weight fractions (composition) of the sample.

• elements (list of str) – A list of element abbreviations, e.g. [‘Al’,’Zn’]. If elements is ‘auto’, take the elements in en each signal metadata of th weight_percent list.

Returns

atomic_percent – Composition in atomic percent.

Return type

as weight_percent

Examples

Calculate the atomic percent of modern bronze given its weight percent: >>> hs.material.weight_to_atomic((88, 12), (“Cu”, “Sn”)) array([ 93.19698614, 6.80301386])