[1]:
%matplotlib inline

Open In Colab

View Source on GitHub

Global River Water Quality

[2]:
import ai4water
from easy_mpl import plot
import matplotlib.pyplot as plt
from ai4water.datasets import GRQA
from ai4water.utils.utils import get_version_info

for lib, ver in get_version_info().items():
    print(lib, ver)

**********Tensorflow models could not be imported **********

python 3.8.12 | packaged by conda-forge | (default, Oct 12 2021, 21:19:05) [MSC v.1916 64 bit (AMD64)]
os nt
ai4water 1.06
easy_mpl 0.21.3
SeqMetrics 1.3.3
numpy 1.22.2
pandas 1.4.0
matplotlib 3.5.1
h5py 3.6.0
joblib 1.2.0
sklearn 1.2.1
xarray 0.21.1
netCDF4 1.5.8
seaborn 0.12.0
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\sklearn\experimental\enable_hist_gradient_boosting.py:16: UserWarning: Since version 1.0, it is not needed to import enable_hist_gradient_boosting anymore. HistGradientBoostingClassifier and HistGradientBoostingRegressor are now stable and can be normally imported from sklearn.ensemble.
  warnings.warn(
[3]:
ds = GRQA()
Title: Global River Water Quality Archive (GRQA)
Keywords: water quality, hydrology, geospatial
Publication date: 2022-09-07
DOI: 10.5281/zenodo.7056647
Total size: 1107.4 MB

Link: https://zenodo.org/api/files/db17e5e9-9776-49df-96ef-006005396c56/GRQA_data_v1.3.zip   size: 1094.4 MB
0% of 1147.59 MB downloaded
8% of 1147.59 MB downloaded
16% of 1147.59 MB downloaded
39% of 1147.59 MB downloaded
47% of 1147.59 MB downloaded
55% of 1147.59 MB downloaded
78% of 1147.59 MB downloaded
86% of 1147.59 MB downloaded
94% of 1147.59 MB downloaded
100% of 1147.59 MB downloaded
Checksum is correct. (bee508b73a581c47691d976a3f8f17da)

Link: https://zenodo.org/api/files/db17e5e9-9776-49df-96ef-006005396c56/GRQA_meta.zip   size: 13.0 MB
0% of 13.65 MB downloaded
100% of 13.65 MB downloaded
Checksum is correct. (99d4f5bacea7f9fd8c11321ae97c8dcf)
All files have been downloaded.
unzipping D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\data\GRQA\GRQA_data_v1.3.zip to D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\data\GRQA\GRQA_data_v1.3
unzipping D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\data\GRQA\GRQA_meta.zip to D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\data\GRQA\GRQA_meta
[4]:
print(ds.parameters)
['BOD5', 'BOD7', 'BOD', 'CODCr', 'CODMn', 'COD', 'DC', 'DIC', 'DIN', 'DIP', 'DKN', 'DOC', 'DON', 'DOP', 'DOSAT', 'DO', 'NH4N', 'NO2N', 'NO3N', 'PC', 'pH', 'PIC', 'PN', 'POC', 'PON', 'POP', 'TAN', 'TC', 'TDN', 'TDP', 'TEMP', 'TIC', 'TIN', 'TIP', 'TKN', 'TN', 'TOC', 'TON', 'TOP', 'TPP', 'TP', 'TSS']

Pakistan

[5]:
country = "Pakistan"
len(ds.fetch_parameter('TEMP', country=country))
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
[5]:
1324
[6]:
params = []
for param in ds.parameters:
    if len(ds.fetch_parameter(param, country=country))>1:
        params.append(param)

print(params)
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,10,13,18,29,30,31,32) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (29,31,32) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (29,31,32) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,10,11,23,29,30,31,32,33,34,35,36,37) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (6,11,18,29,30,31,32,33,34,35) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (6,11,29,30,31,32,33,34,35) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,10,11,13,18,23,29,30,31,32,33,36) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (6,11,18,23,29,30,31,32,33,34,35,36,37) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,22,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (11,13,18,29,30,31,32,33,34,35) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,29,30,31,32,33,34,35,36,37) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (11,13,18) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (11,13,18,29,30,31,32,33,34,35) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (6,11,30,31,32,33,34,35) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (6,11,18,23,29,30,31,32,33,34,35,36,37) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,10,11,13,18,23,29,30,31,32,33,34,35,36,38) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
['BOD', 'COD', 'DON', 'DOSAT', 'DO', 'NH4N', 'pH', 'TDP', 'TEMP', 'TKN', 'TP', 'TSS']
[7]:
df = ds.fetch_parameter("TEMP", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(1324, 38)
../../_images/_notebooks_datasets_grqa_8_2.png
[8]:
df = ds.fetch_parameter("NH4N", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (6,11,18,23,29,30,31,32,33,34,35,36,37) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(28, 36)
../../_images/_notebooks_datasets_grqa_9_2.png
[9]:
df = ds.fetch_parameter("DO", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
(1327, 38)
../../_images/_notebooks_datasets_grqa_10_1.png
[10]:
df = ds.fetch_parameter("COD", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
(1317, 32)
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (29,31,32) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
../../_images/_notebooks_datasets_grqa_11_2.png
[11]:
df = ds.fetch_parameter("BOD", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
(1326, 32)
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (29,31,32) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
../../_images/_notebooks_datasets_grqa_12_2.png
[12]:
df = ds.fetch_parameter("DON", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,10,11,13,18,23,29,30,31,32,33,36) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(123, 36)
../../_images/_notebooks_datasets_grqa_13_2.png
[13]:
df = ds.fetch_parameter("DOSAT", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(221, 38)
../../_images/_notebooks_datasets_grqa_14_2.png
[14]:
df = ds.fetch_parameter("TDP", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(92, 36)
../../_images/_notebooks_datasets_grqa_15_2.png
[15]:
df = ds.fetch_parameter("TKN", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (6,11,18,23,29,30,31,32,33,34,35,36,37) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(58, 36)
../../_images/_notebooks_datasets_grqa_16_2.png
[16]:
df = ds.fetch_parameter("TSS", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(1293, 38)
../../_images/_notebooks_datasets_grqa_17_2.png
[17]:
df = ds.fetch_parameter("TP", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(249, 38)
../../_images/_notebooks_datasets_grqa_18_2.png
[18]:
df = ds.fetch_parameter("pH", country=country)
print(df.shape)
for grp_name, grp in df.groupby('site_name'):
    plot(grp['obs_value'], '--.', label=grp_name, show=False,
         ax_kws=dict(figsize=(18,7)))
plt.show()
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,22,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(1285, 38)
../../_images/_notebooks_datasets_grqa_19_2.png

Germany

[19]:
country = "Germany"
temp = ds.fetch_parameter('TEMP', country=country)
print(temp.shape)
D:\C\Anaconda3\envs\ai4w_dataset\lib\site-packages\ai4water\datasets\_grqa.py:119: DtypeWarning: Columns (5,6,10,11,13,18,23,29,30,31,32,33,34,35,36,37,38,39) have mixed types. Specify dtype option on import or set low_memory=False.
  return pd.read_csv(fname, sep=";")
(111223, 38)
[28]:
len(temp['site_name'].unique())
[28]:
712
[27]:

[27]:
712