Skip to main content

Temporal disaggregation of daily precipitation into hourly using Q-CODA.

Project description

pyqcoda

pyqcoda is a Python library for temporal disaggregation of daily precipitation into hourly time series using a combination of comonotonicity transformation and an iterative adjusted k-nearest neighbors (KNN) algorithm. It is tailored for hydrological and climate data processing tasks where hourly data is required but only daily observations are available.


🌧️ Overview

  • Input:

    • train_data.csv: Hourly precipitation data with columns datetime (hourly resolution) and precipitation (mm).
    • test_data.csv: Daily precipitation data with the same column names but daily resolution (datetime at 00:00:00 for each day).
  • Output:

    • A pandas DataFrame (or CSV) with hourly precipitation disaggregated from the daily values in test_data, using statistical patterns learned from train_data.

✨ Features

  • Disaggregates daily totals into 24-hour precipitation series.
  • Preserves sub-daily maxima in reconstructed data.
  • Season-aware (DJF, MAM, JJA, SON) to capture seasonal variability.
  • Combines comonotonicity with KNN-based iterative adjustments.
  • Suitable for hydrological modeling and climate studies.

📦 Installation

From PyPI (recommended)

pip install pyqcoda

From Github

git clone https://github.com/carloscorreag/pyqcoda.git
cd pyqcoda
pip install .

🚀 Usage example

import pandas as pd
from pyqcoda import pyqcoda

# 1. Load your training (hourly) and testing (daily) datasets
df_train = pd.read_csv("train_data.csv", index_col=0, parse_dates=True)
df_test = pd.read_csv("test_data.csv", index_col=0, parse_dates=True)

# 2. Instantiate pyqcoda and disaggregate
qc = pyqcoda()
simulated_series = qc.disaggregate(df_train, df_test)

# 3. Convert results to hourly DataFrame
df_hourly = qc.get_hourly_dataframe(simulated_series)

# 4. Save output
df_hourly.to_csv("disaggregated_output.csv")
print("Hourly disaggregated precipitation saved to disaggregated_output.csv")

🔧 Requirements

  • Python 3.7+
  • pandas ≥ 1.2.4
  • numpy ≥ 1.21.6
  • scikit-learn ≥ 1.0.2

📄 License

This project is licensed under the MIT License — see the LICENSE file for details.


📖 Citation

Correa Guinea, C. (2025). pyqcoda: Temporal disaggregation of daily precipitation into hourly using Q-CODA. DOI:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyqcoda-1.0.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyqcoda-1.0.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file pyqcoda-1.0.0.tar.gz.

File metadata

  • Download URL: pyqcoda-1.0.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.4

File hashes

Hashes for pyqcoda-1.0.0.tar.gz
Algorithm Hash digest
SHA256 88da9f5bfd8dc61c844317d9724f2502a66df03c81f7368136c568337895b028
MD5 d38aef67659875b20ff4316c520e0a96
BLAKE2b-256 d6fd1fd7ff6663e0eb91598d68c6620ed71bce5f9dc3bb84c4f3117d5db358ac

See more details on using hashes here.

File details

Details for the file pyqcoda-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyqcoda-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.4

File hashes

Hashes for pyqcoda-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d7fb13a6817d42db4dbd6b42993293b4401ae2cff6f4a49118559d40015b3e7
MD5 2a2ada960d914575f1a65aa55e31ef3e
BLAKE2b-256 a31a842e24e8313f6ad4125c430750419e8cef79950bfb1c7db34f61533dde5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page