@welldot/utils

getIonBalance

Charge balance of a sample. Concentrations (mg/L) are converted to meq/L with the vocabulary molar mass and charge (mg/L ÷ (M / |z|)).

getIonBalance(sample): IonBalance | undefined

Charge balance of a sample. Concentrations (mg/L) are converted to meq/L with the vocabulary molar mass and charge (mg/L ÷ (M / |z|)).

Cations: Ca, Mg, Na, K, Li, Fe (as Fe²⁺), Mn, NH₄⁺ (ammonia_as_n). Anions: HCO₃⁻ + CO₃²⁻ (falling back to alkalinity_total_as_caco3), Cl⁻, SO₄²⁻, F⁻, PO₄³⁻, NO₃⁻ and NO₂⁻ (the _as_no3/_as_no2 code preferred over _as_n, never both). Rejected and censored (<, >, not_detected) results are left out.

error_pct = (Σcat − Σan) / (Σcat + Σan) × 100. Returns undefined without at least one measured cation and one measured anion.

Parameters

sample

WaterSample

Returns

IonBalance | undefined