Table utils

The espm.table_utils module implements some methods to manipulate the tables produces by the emtables package.

Using this module it is possible to load the tables and to import custom k-factors into the tables.

Note

The emtables package can be found here: https://github.com/adriente/emtables

espm.tables_utils.get_k_factor(table, mdata, element, line, range=0.5, ref_elt='14', ref_line='KL3', ref_range=0.5)[source]

Obtain the k-factor of a line from an emtables, X-ray emission cross section table.

Parameters:
tabledict

The table of the X-ray emission cross sections.

mdatadict

The metadata of the table.

elementint

The atomic number of the element to use.

linestr

The regex of the line to use. It has to correspond to IUPAC notation.

rangefloat

The energy range to use for the integration of the cross section of the line. For example, if range = 0.5, the integration will be done between the energy of the line - 0.5 and the energy of the line + 0.5. We do so that when you select the “KL3” line, it integrates around it and make it correspond to the K-alpha bunch of lines.

ref_eltint

The atomic number of the element to use as a reference for the k-factor. The default reference line is Si “KL3” with an integration range of 0.5.

ref_linestr

The regex of the line to use as a reference for the k-factor. It has to correspond to IUPAC notation.

ref_rangefloat

The energy range to use for the integration of the cross section of the reference line.

Returns:
k_factorfloat

The k-factor of the line. It does not take into account the absorption correction.

espm.tables_utils.import_k_factors(table, mdata, k_factors_names, k_factors_values, ref_name)[source]

Modify the X-ray emission cross-sections of the input table using the k-factors input, i.e. imposing cross-sections ratios to correspond to the k-factors. The metadata are modified too to keep track of the modifications.

Parameters:
tabledict

The table of the X-ray emission cross sections.

mdatadict

The metadata of the table.

k_factors_nameslist

The list of the names of the k-factors to import. It has to correspond to the nomenclature of the hyperspy X-ray lines.

k_factors_valueslist

The list of the values of the k-factors to import. It has to have the same length and ordering as k_factors_names.

ref_namestr

The name of the X-ray line to use as a reference for the k-factors. It has to correspond to the nomenclature of the hyperspy X-ray lines.

Returns:
new_tabledict

The modified table of the X-ray emission cross sections.

new_mdatadict

The modified metadata of the table.

espm.tables_utils.load_table(db_name)[source]

Load the table and metadata of a json table generated by emtables.

Parameters:
db_namestr

The file name of the table to load.

Returns:
tabledict

The table of the cross sections.

metadatadict

The metadata of the table.

Notes

Call espm.conf.DB_PATH to get the folder of the tables.

espm.tables_utils.modify_table_lines(table, mdata, elements, line, coeff)[source]

Modify the cross section of the lines of the selected elements in the input table.

Parameters:
tabledict

The table of the X-ray emission cross sections.

mdatadict

The metadata of the table.

elementslist

The list of the atomic numbers of the elements to modify.

linestr

The regex of the line to modify. It has to correspond to IUPAC notation.

coefffloat

The coefficient to multiply the cross section of the selected lines.

Returns:
new_tabledict

The modified table of the X-ray emission cross sections.

new_mdatadict

The modified metadata of the table.

Notes

X-ray line regex examples : input “L” will modify all the L lines, input “L3” will modifiy all the L3 lines, input “L3M2” will modify the “L3M2” line.

espm.tables_utils.save_table(filename, table, mdata)[source]

Saves a table and its metadata in a json file. The structure of the json file is compliant with espm.