Guides

Water quality vocabulary

Look up water quality parameters, their units and labels, resolve CAS numbers, and use the WHO, EU and Brazilian limit sets that @welldot/core ships as data.

Water quality results in a .well file name their parameter by a code and a vocabulary, and take their unit from the code (parameter vocabulary). @welldot/core publishes the welldot vocabulary as versioned data, together with drinking water limit sets that are deliberately kept out of the files.

Parameters

import { getParameterDefinition, getParameterLabel } from '@welldot/core';

getParameterDefinition({ code: 'nitrate_as_n', vocabulary: 'welldot' });
// {
//   code: 'nitrate_as_n', group: 'nutrient', label: 'Nitrate as N',
//   labels: { pt: 'Nitrato como N' }, unit: { symbol: 'mg/L', ucum: 'mg/L' },
//   form: 'value', molar_mass: 14.007, charge: -1
// }

getParameterLabel({ code: 'nitrate_as_n', vocabulary: 'welldot' }, 'pt'); // 'Nitrato como N'

Each ParameterDefinition carries the code, its group (physical, major_ion, metal, nutrient, microbiology, …), the English label and translations, the canonical unit (display symbol and UCUM code), the form of a result (value, presence or text), the CAS number when there is one, and molar mass and charge for ions used in ion balance and hydrochemical diagrams.

ExportDescription
WATER_QUALITY_PARAMETERSThe 98 welldot parameter definitions.
WATER_QUALITY_VOCABULARY_VERSIONVersion of the published vocabulary.
WATER_QUALITY_UNITSThe canonical units the vocabulary uses.
getParameterDefinition(param)Looks up a { code, vocabulary }; a cas code resolves to its welldot entry.
getParameterLabel(param, locale)Display name; unknown codes are returned as they are.
parameterKey(param)One identity for a welldot code and its CAS equivalent, for grouping and duplicate detection.
isKnownParameter(param)false only for a welldot code this vocabulary version does not know.

CAS numbers

Substances can be identified by their CAS registry number (vocabulary rules). The library resolves the ones that have a welldot equivalent:

import { getParameterDefinition, parameterKey } from '@welldot/core';

getParameterDefinition({ code: '14808-79-8', vocabulary: 'cas' })?.code; // 'sulfate'
parameterKey({ code: '14808-79-8', vocabulary: 'cas' }); // 'sulfate'
parameterKey({ code: 'sulfate', vocabulary: 'welldot' }); // 'sulfate', the same key

Limit sets

Limits are not stored in .well files: a file records what was measured, and the reader decides which standard to compare it with (limit sets are not part of the file). The package ships three sets:

ExportSourceid
WHO_GDWQ_2022WHO Guidelines for Drinking-water Quality (2022)who_gdwq_2022
EU_2020_2184EU Drinking Water Directive 2020/2184eu_2020_2184
BR_GM_MS_888_2021Brazil, Portaria GM/MS 888/2021br_gm_ms_888_2021

WATER_QUALITY_LIMIT_SETS lists them in display order, and getLimitSet(id) finds one by id. A set has a name, a jurisdiction, its source and a list of limits, each with a parameter code, a min and/or max in the parameter's canonical unit and a basis.

import { getLimitSet } from '@welldot/core';

getLimitSet('who_gdwq_2022')?.limits.find(l => l.code === 'arsenic');
// { code: 'arsenic', max: 0.01, basis: 'health', note: 'provisional' }

To compare a sample with a set, use getExceedances from @welldot/utils, which handles censored values, presence limits and turbidity comparability.

The limit values are transcribed from the cited documents. Check them against the official text before any regulatory use.