Tools for postprocessing¶
Tools are available for postprocessing the dataframes.
Unit Conversion¶
For all of the input and output dataframes (such as u_nk
, dHdl
,
Estimator.delta_f_
, Estimator.d_delta_f_
), the metadata is stored as pandas.DataFrame.attrs
. The unit of the data
can be converted to \(kT\), kJ/mol or kcal/mol via the functions
to_kT()
,
to_kJmol()
,
to_kcalmol()
.
Unit Conversion Functions¶
Unit conversion and constants |
Constants and auxiliary functions¶
The postprocessing functions can make use of the following auxiliary functions,
which in turn may use constants defined alchemlyb.postprocessors.units
.
Scientific constants¶
Common scientific constants based on scipy.constants
and are provided
for use across alchemlyb.
- alchemlyb.postprocessors.units.kJ2kcal = 0.2390057361376673¶
conversion factor from kJ to kcal, based on
scipy.constants.calorie
inscipy.constants
- alchemlyb.postprocessors.units.R_kJmol = 0.008314462618¶
gas constant \(R\) in kJ/(mol K), based on
scipy.constants.R
inscipy.constants
Unit conversion developer information¶
The function alchemlyb.postprocessors.units.get_unit_converter()
provides
the relevant converter for unit conversion via a built-in dispatch table:
>>> from alchemlyb.postprocessors.units import get_unit_converter
>>> get_unit_converter('kT')
<function to_kT>
>>> get_unit_converter('kJ/mol')
<function to_kJmol>
>>> get_unit_converter('kcal/mol')
<function to_kcalmol>
For unit conversion to work, the dataframes must maintain the energy_unit
and temperature metadata in pandas.DataFrame.attrs
as described
under A note on units.
When implementing code then ensure that the metadata are maintained by using alchemlyb.concat()
in place of pandas.concat()
and use the alchemlyb.pass_attrs()
decorator to copy metadata from an
input dataframe to an output dataframe.