mescla.prep.units.to_meq_per_l¶
- mescla.prep.units.to_meq_per_l(table, on_unknown='raise')[source]¶
Convert concentrations to milliequivalents per litre:
C / equivalent weight.Only species whose unit is not already meq/L are touched, and only those with a charge can be: an equivalent weight is molar mass divided by charge, so a neutral species has none.
- Parameters:
table (array_like, DataFrame or ChemTable)
on_unknown ({"raise", "skip", "drop"}, default "raise") –
What to do about species that cannot be converted – electrical conductivity, silica, isotope ratios, organic compounds.
"raise"(the default) refuses rather than returning a table that is silently part-converted."skip"keeps them with their own unit untouched, which is honest because units are tracked per species."drop"removes them.
- Returns:
ChemTable – With the converted species relabelled
"meq/L"individually, so a part-converted table describes itself accurately.- Return type:
See also
conversion_factorsthe factors this applies, and why a species is refused.
Examples
>>> import mescla as ms >>> w = ms.WaterChemistry([[40.078, 96.06]], species=["Ca", "SO4"]) >>> to_meq_per_l(w).data.round(3) array([[2., 2.]])
A species with no equivalent weight is refused rather than passed through:
>>> w = ms.WaterChemistry([[40.078, 500.0]], species=["Ca", "EC"]) >>> to_meq_per_l(w) ValueError: cannot convert to meq/L: 'EC': not a recognised ion ... >>> to_meq_per_l(w, on_unknown="skip").units_dict() {'Ca': 'meq/L', 'EC': 'mg/L'}