Quality control for rainfall data
Project description
Provides methods for running rainfall quality control.
NOTEBOOK DEMO AVAILABLE HERE
Please email tomkee@ceh.ac.uk if you have any questions.
Installation
RainfallQC can be installed from PyPi:
pip install rainfallqc
Example use
Example 1. - Individual quality checks on single rain gauge
from rainfallqc import gauge_checks, comparison_checks
data = pl.read_csv("rain_gauge_data.csv")
intermittency_flag = gauge_checks.check_intermittency(data, target_gauge_col="rain_mm")
Example 2. - Neighbourhood quality checks for the global sub-daily rain gauge network (GSDR)
from rainfallqc import neighbourhood_checks
from rainfallqc.utils import data_readers
distance_threshold = 50 # km
n_closest = 10 # number of closest neighbours to consider
min_overlap_days = 500 # minimum overlapping days to be considered a neighbour
gsdr_obj = data_readers.GSDRNetworkReader(path_to_gsdr_dir="path/to/GSDR/data")
nearby_ids = list(
gsdr_obj.get_nearest_overlapping_neighbours_to_target(
target_id="DE_00310", distance_threshold=distance_threshold, n_closest=n_closest, min_overlap_days=min_overlap_days
)
)
nearby_ids.append(target_id)
nearby_data_paths = gsdr_obj.metadata.filter(pl.col("station_id").is_in(nearby_ids))["path"]
# Load those nearest gauges from network metadata
gsdr_network = gsdr_obj.load_network_data(data_paths=nearby_data_paths)
# Run wet neighbour check
extreme_wet_flags = neighbourhood_checks.check_wet_neighbours(
gsdr_network,
target_gauge_col="rain_mm_DE_02483",
neighbouring_gauge_cols=gsdr_network.columns[1:], # exclude time
time_res="hourly",
wet_threshold=1.0, # threshold for rainfall intensity to be considered
min_n_neighbours=5, # number of neighbours needed for comparison
n_neighbours_ignored=0, # ignore no neighbours and include all
)
Example 3. - Applying a framework of QC methods (e.g. IntenseQC)
from rainfallqc.qc_frameworks import apply_qc_framework
# 1. Decide which QC methods of IntenseQC will be run
qc_framework = "IntenseQC"
qc_methods_to_run = ["QC1", "QC8", "QC9", "QC10", "QC11", "QC12", "QC14", "QC15", "QC16"]
# 2 Decide which parameters for QC
qc_kwargs = {
"QC1": {"quantile": 5},
"QC14": {"wet_day_threshold": 1.0, "accumulation_multiplying_factor": 2.0},
"QC16": {
"neighbouring_gauge_cols": daily_gpcc_network.columns[2:],
"wet_threshold": 1.0,
"min_n_neighbours": 5,
"n_neighbours_ignored": 0,
},
# Shared defaults applied to all
"shared": {
"target_gauge_col": "rain_mm_DE_02483",
"gauge_lat": gpcc_metadata["latitude"],
"gauge_lon": gpcc_metadata["longitude"],
"time_res": "daily",
"data_resolution": 0.1,
},
}
# 3. Run QC methods on network data
qc_result = apply_qc_framework.run_qc_framework(
daily_gpcc_network, qc_framework=qc_framework, qc_methods_to_run=qc_methods_to_run, qc_kwargs=qc_kwargs
)
Other examples
Also see example Jupyter Notebooks here: https://github.com/Thomasjkeel/RainfallQC-notebooks/tree/main
Documents
Free software: GNU General Public License v3
Documentation: https://rainfallqc.readthedocs.io.
Features
25 rainfall QC methods (all from IntenseQC)
editable parameters so you can tweak thresholds, streak or accumulation lengths, and distances to neighbouring gauges
Credits
Based on the IntenseQC: https://github.com/nclwater/intense-qc/tree/master
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
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 rainfallqc-0.2.5.tar.gz.
File metadata
- Download URL: rainfallqc-0.2.5.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bcbad776012ca2f657715b4016ed6a57a973530d0789ec264091be6379d3f75
|
|
| MD5 |
0b68dbccb0f6630bf6d7d97373721c87
|
|
| BLAKE2b-256 |
347e5763e66140a96176975e71c8cd00410d7ec2c9953ccf115c7aa94e5b01fd
|
Provenance
The following attestation bundles were made for rainfallqc-0.2.5.tar.gz:
Publisher:
publish-to-pypi.yml on NERC-CEH/RainfallQC
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rainfallqc-0.2.5.tar.gz -
Subject digest:
7bcbad776012ca2f657715b4016ed6a57a973530d0789ec264091be6379d3f75 - Sigstore transparency entry: 629998105
- Sigstore integration time:
-
Permalink:
NERC-CEH/RainfallQC@377850fe22406bab7b4e73cb4084ae69b8806f02 -
Branch / Tag:
refs/tags/0.2.5 - Owner: https://github.com/NERC-CEH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@377850fe22406bab7b4e73cb4084ae69b8806f02 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rainfallqc-0.2.5-py3-none-any.whl.
File metadata
- Download URL: rainfallqc-0.2.5-py3-none-any.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07e7183063f6fdeeceb62216e3e0719a9cc7191f986feb058204d2734b2e594c
|
|
| MD5 |
667409a4ae87d3e1911bf2eea66a21f7
|
|
| BLAKE2b-256 |
d7610eee0e9d8d69c10afa3c27393296f8091b5035e2e8e95d5a6730debc7e27
|
Provenance
The following attestation bundles were made for rainfallqc-0.2.5-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on NERC-CEH/RainfallQC
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rainfallqc-0.2.5-py3-none-any.whl -
Subject digest:
07e7183063f6fdeeceb62216e3e0719a9cc7191f986feb058204d2734b2e594c - Sigstore transparency entry: 629998107
- Sigstore integration time:
-
Permalink:
NERC-CEH/RainfallQC@377850fe22406bab7b4e73cb4084ae69b8806f02 -
Branch / Tag:
refs/tags/0.2.5 - Owner: https://github.com/NERC-CEH
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@377850fe22406bab7b4e73cb4084ae69b8806f02 -
Trigger Event:
release
-
Statement type: