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.1.tar.gz (5.9 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.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyqcoda-1.0.1.tar.gz
  • Upload date:
  • Size: 5.9 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.1.tar.gz
Algorithm Hash digest
SHA256 05ac68528e28c41026c6f197fd3d9b9e71e2a90659e14c2637da35d8668640a6
MD5 b4d05626f70f0fabc812d778931a624c
BLAKE2b-256 af64e3a3028c620068153352ac490ecd96a163a1d10a77d5481bf30b123424bb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyqcoda-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 72a0ec5c61d2ae6f67b5885b034450c61d4c332741faecc5bc3aff749e033b30
MD5 453b0a23965245ffea3a3463d414fe03
BLAKE2b-256 329c7793a7e550d823fa70c82ab2196e9d4643a5e7f8d4337bc631b8a2e36ad8

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