app.model.lib.conversion#

Attributes#

MEASUREMENT_RATIOS

A conversion table for the ratios between pairs of units

CELL_COUNT_UNITS

Units that measure number of cells per volume

CFU_COUNT_UNITS

Units that measure number of CFUs per volume

METABOLITE_UNITS

Units for metabolites, both molar and mass concentration

Functions#

convert_df_units(df, source_units, target_units[, ...])

Converts the "value" and "std" columns of a dataframe from the source units

convert_measurement_units(value, source_units, ...[, mass])

Convert an individual value (or a numpy array) from the given source unit

convert_time(time, source, target)

Converts the given time value from the source units to the target units by

Module Contents#

app.model.lib.conversion.MEASUREMENT_RATIOS[source]#

A conversion table for the ratios between pairs of units

app.model.lib.conversion.CELL_COUNT_UNITS = ('Cells/mL', 'Cells/μL')[source]#

Units that measure number of cells per volume

app.model.lib.conversion.CFU_COUNT_UNITS = ('CFUs/mL', 'CFUs/μL')[source]#

Units that measure number of CFUs per volume

app.model.lib.conversion.METABOLITE_UNITS = ('mM', 'μM', 'nM', 'pM', 'g/L', 'mg/L')[source]#

Units for metabolites, both molar and mass concentration

app.model.lib.conversion.convert_df_units(df, source_units, target_units, metabolite_mass=None)[source]#

Converts the “value” and “std” columns of a dataframe from the source units to the target units, if possible.

Returns the target units on success, or the source units if the requested target units are incompatible (e.g. Cells/mL and CFUs/mL).

app.model.lib.conversion.convert_measurement_units(value, source_units, target_units, mass=None)[source]#

Convert an individual value (or a numpy array) from the given source unit to the given target unit. Returns None if the units are incompatible (e.g. Cells/mL and CFUs/mL).

There is special handling for molar concentrations and mass concentrations for metabolites, where the function expects the mass of the metabolite to perform the conversion. If the mass is not given in this case, the function returns None.

app.model.lib.conversion.convert_time(time, source, target)[source]#

Converts the given time value from the source units to the target units by converting the input to seconds first and then to the given target. The minimum resolution supported is “s” for seconds.