Irish Water Quality Index (IEWQI) - Full implementation (Uddin et al. 2022 & 2023)/ For details visit at https://scholar.google.com/citations?user=g6xaAOkAAAAJ&hl=en
Project description
IEWQImodel
IEWQImodel is a Python package for computing the Irish Water Quality Index (IEWQI) and related comparative water quality indices for transitional and coastal waters.
The package implements:
- IEWQI / WQM-WQI (Weighted Quadratic Mean)
- RMS-WQI (Root Mean Square)
- AM-WQI (Arithmetic Mean)
- Sub-index (SI) computation
- Salinity-adjusted thresholds
- Classification
- Eclipsing detection
- Ambiguity detection
- Export-ready outputs
Author
Dr Md Galal Uddin School of Engineering, University of Galway, Ireland Email: jalaluddinbd1987@gmail.com
Scientific References
If you use this package, please cite:
-
Uddin, M.G. et al. (2022) A comprehensive method for improvement of water quality index (WQI) models for coastal water quality assessment Water Research DOI: https://doi.org/10.1016/j.watres.2022.118532
-
Uddin, M.G. et al. (2023) A sophisticated model for rating water quality Science of the Total Environment DOI: https://doi.org/10.1016/j.scitotenv.2023.161614
Google Scholar https://scholar.google.com/citations?user=g6xaAOkAAAAJ&hl=en
Features
-
Compute IEWQI / WQM-WQI
-
Compute RMS-WQI
-
Compute AM-WQI
-
Compute Sub-index (SI) values
-
Apply salinity-adjusted thresholds
-
Classify water quality into:
- Good
- Fair
- Marginal
- Poor
-
Diagnose:
- Eclipsing
- Ambiguity
-
Export results to Excel or CSV
Installation
pip install IEWQImodel==2.3.6
Required Input Columns
The model requires the following input variables.
Accepted internal required columns
["bod5", "dox", "din", "mrp", "ph", "sal", "temp", "ton", "tran"]
Typical user-facing input names
| Variable | Description |
|---|---|
| BOD5 | Biological Oxygen Demand |
| DOX | Dissolved Oxygen (%) |
| DIN | Dissolved Inorganic Nitrogen |
| MRP | Molybdate Reactive Phosphorus |
| pH | Acidity / alkalinity |
| SAL | Salinity |
| TEMP | Water Temperature |
| TON | Total Organic Nitrogen |
| TRAN | Transparency |
Important notes
-
SAL is mandatory because the package derives moving thresholds for:
- DOX
- DIN
- MRP
-
Thresholds are computed from the median salinity of the input dataset unless you manually provide
sal_median.
Example Input File
The input file should contain these columns (case-insensitive aliases are supported internally):
| BOD5 | DOX | DIN | MRP | pH | SAL | TEMP | TON | TRAN |
|---|---|---|---|---|---|---|---|---|
| 2.1 | 96 | 0.35 | 0.021 | 8.1 | 31.2 | 16.5 | 0.85 | 1.4 |
| 4.3 | 88 | 0.52 | 0.030 | 7.9 | 29.8 | 18.1 | 1.10 | 1.1 |
Quick Start
Example 1 — Compute from a Python dictionary
from IEWQImodel import IEWQI
model = IEWQI()
data = {
"BOD5": 2.3,
"DOX": 95,
"DIN": 0.4,
"MRP": 0.02,
"pH": 8.1,
"SAL": 30,
"TEMP": 15,
"TON": 0.8,
"TRAN": 1.5
}
result = model.compute(data)
print(result)
Basic Usage with Excel File
import pandas as pd
from IEWQImodel import IEWQI
# Input and output paths
input_file = "/content/data_WQ25.xlsx"
output_file = "IEWQI_results45.xlsx"
# Load dataset
df = pd.read_excel(input_file)
# Initialize model
model = IEWQI()
# Compute:
# - IEWQI (WQM-WQI)
# - RMS-WQI
# - AM-WQI
# - Sub-index (SI) values
# - Water quality classes
# - Eclipsing and ambiguity diagnostics
results = model.compute(df)
# Export results
results.to_excel(output_file, index=False)
# Preview
print(results.head())
Optional: Use a Fixed Salinity Median
By default, the package computes thresholds using the median SAL from the dataset.
If needed, you can manually specify a fixed salinity median:
import pandas as pd
from IEWQImodel import IEWQI
df = pd.read_excel("/content/data_WQ25.xlsx")
model = IEWQI()
results = model.compute(df, sal_median=30.5)
print(results.head())
Optional: Strict Validation
Strict validation ensures that all:
- Sub-index (SI) values remain within 0–100
- Final WQI scores remain within 0–100
import pandas as pd
from IEWQImodel import IEWQI
df = pd.read_excel("/content/data_WQ25.xlsx")
model = IEWQI(strict_validation=True)
results = model.compute(df)
print(results.head())
Direct Export Example
You can export results directly without manually reading/writing files:
from IEWQImodel import IEWQI
model = IEWQI()
model.export_results(
data="/content/data_WQ25.xlsx",
output_path="IEWQI_results45.xlsx"
)
You can also export to CSV:
from IEWQImodel import IEWQI
model = IEWQI()
model.export_results(
data="/content/data_WQ25.xlsx",
output_path="IEWQI_results45.csv"
)
Output
The package returns a results table containing the original variables, thresholds used, sub-index values, final scores, classification, and diagnostics.
Original variables
BOD5DOXDINMRPpHSALTEMPTONTRAN
Thresholds used
SAL_Median_UsedBOD5_L,BOD5_UDOX_L,DOX_UDIN_L,DIN_UMRP_L,MRP_UpH_L,pH_UTEMP_UTON_L,TON_UTRAN_L
Sub-index values
SI_BOD5SI_DOXSI_DINSI_MRPSI_pHSI_TEMPSI_TONSI_TRAN
Final scores
IEWQI_scoreRMS_WQI_scoreAM_WQI_score
Water quality classes
IEWQI_ClassRMS_WQI_ClassAM_WQI_Class
Diagnostics
Breach_CountBreach_IndicatorsIEWQI_EclipsingRMS_WQI_EclipsingAM_WQI_EclipsingIEWQI_AmbiguityRMS_WQI_AmbiguityAM_WQI_Ambiguity
Summary columns
Min_SIMax_SI
Classification Scheme
| Score Range | Water Quality Class |
|---|---|
| 80–100 | Good |
| 50–79 | Fair |
| 30–49 | Marginal |
| 0–29 | Poor |
Scientific Notes
IEWQI / WQM-WQI
The package computes the Irish Water Quality Index (IEWQI) using the Weighted Quadratic Mean (WQM) formulation:
[ WQM = \sqrt{\sum_{i=1}^{n} w_i s_i^2} ]
where:
- (w_i) = normalized indicator weights
- (s_i) = sub-index values on a 0–100 scale
- (n) = number of indicators included in the computation
The implemented default weights correspond to the published IEWQI structure.
RMS-WQI
The Root Mean Square Water Quality Index (RMS-WQI) is computed as:
[ RMS = \sqrt{\frac{1}{n}\sum_{i=1}^{n} s_i^2} ]
This provides an unweighted comparison index that is more sensitive to lower-performing sub-indices than a simple arithmetic mean.
AM-WQI
The Arithmetic Mean Water Quality Index (AM-WQI) is computed as:
[ AM = \frac{1}{n}\sum_{i=1}^{n} s_i ]
This is the simplest comparative aggregation and is useful for benchmarking against WQM- and RMS-based scores.
Sub-index (SI) scaling
All indicators are first converted into sub-index (SI) values on a 0–100 scale before aggregation.
- 0 = worst water quality condition
- 100 = best water quality condition
The package uses:
- monotonic decreasing SI functions for indicators where lower values are better (e.g., BOD5, DIN, MRP, TON)
- band-based SI functions for indicators such as DOX and pH
- binary threshold logic for indicators such as TEMP and TRAN
Salinity-adjusted thresholds
The package uses SAL (salinity) to derive moving thresholds for:
- DOX
- DIN
- MRP
This follows the published IEWQI methodology where salinity is used to obtain water-quality standards for transitional and coastal systems.
Classification
Final index scores are interpreted using the following four-class system:
- Good: 80–100
- Fair: 50–79
- Marginal: 30–49
- Poor: 0–29
Eclipsing and ambiguity diagnostics
The package includes diagnostic checks for:
- Eclipsing: whether aggregated scores mask the number of breached indicators
- Ambiguity: whether the final class appears inconsistent with the severity of the worst-performing sub-indices
These diagnostics are intended to help users compare the behavior of different aggregation approaches.
Score bounding and validity
To preserve scientific consistency:
- all sub-index values are constrained to 0–100
- all final WQI scores are constrained to 0–100
- negative values are automatically converted to 0
- values above 100 are automatically converted to 100
This prevents invalid scores caused by input anomalies or computational overflow.
Citation
If you use this package in academic work, please cite:
Uddin, M.G. et al. (2023) A sophisticated model for rating water quality Science of the Total Environment https://doi.org/10.1016/j.scitotenv.2023.161614
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iewqimodel-2.3.6.tar.gz.
File metadata
- Download URL: iewqimodel-2.3.6.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62101b1d4c99eccdfc44d6f4a5c31509b8e997203dba1e87781c57457d573be7
|
|
| MD5 |
37f85fccf92c4f0b5c89cbcfb2c121d8
|
|
| BLAKE2b-256 |
7c10ee6189bd5a0e7c4da24d4c0ae4005b9f13e143668a9d035c58a7ada4b516
|
File details
Details for the file iewqimodel-2.3.6-py3-none-any.whl.
File metadata
- Download URL: iewqimodel-2.3.6-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
901bd80e4d34dec6b3aac684344e84774f627a0dca43350ff4d617d0e3900951
|
|
| MD5 |
ff6336fa03450778112473aee6cc68af
|
|
| BLAKE2b-256 |
00874df39ae34f08514d00af6b1a83c112b31f8092af2fee3094c7fb2bf02759
|