Skip to main content

A PyTorch-based tool to downscale spatiotemporal data

Project description

xdownscale

xdownscale logo

Project Status: Active PyPI version License: MIT PyPI Downloads

xdownscale is a Python package for super-resolution downscaling of gridded datasets using deep learning. It supports a wide range of applications, including satellite observations, reanalysis data, and climate model outputs. Built with PyTorch and xarray, it enables efficient mapping from coarse-to-fine-resolution grids in just a few lines of code.


Installation

To install from PyPI, we recommend using a conda environment

conda create -n xdownscale python=3.10
conda activate xdownscale
conda install -c conda-forge pytorch cudatoolkit=11.8 cudnn
pip install xdownscale

To install from source:

git clone https://github.com/manmeet3591/xdownscale.git
cd xdownscale
pip install .

Or install from a zipped archive:

unzip xdownscale_package.zip
cd xdownscale
pip install .

Usage

import xarray as xr
import numpy as np
from xdownscale import Downscaler

# Create dummy coarse-resolution input and fine-resolution target
x = np.random.rand(128, 128).astype(np.float32)
y = (x + np.random.normal(0, 0.01, size=x.shape)).astype(np.float32)

input_da = xr.DataArray(x, dims=["lat", "lon"])
target_da = xr.DataArray(y, dims=["lat", "long"])

# Initialize the downscaler
ds = Downscaler(input_da, target_da, model_name="fsrcnn")

# Predict high-resolution output
result = ds.predict(input_da)
result.plot()

Available models:
srcnn, fsrcnn, lapsr, carnm, falsra, falsrb, srresnet, carn, oisrrk2, mdsr, san, rcan, unet, dlgsanet, dpmn, safmn, dpt, distgssr, swin


Description

xdownscale performs patch-wise training using PyTorch’s DataLoader and returns predictions as xarray.DataArray objects. It is designed to work with any gridded dataset and provides a flexible interface for model selection, training, and inference.


Sample Data

Sample input and target data are provided in the data/ directory for testing and demonstrations.


Development

To extend or customize the package:

  • Modify model architectures in xdownscale/model.py
  • Add training logic in xdownscale/core.py
  • Customize patch extraction and utilities in xdownscale/utils.py

License

This project is licensed under the MIT License.

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

xdownscale-1.0.2.tar.gz (5.6 MB view details)

Uploaded Source

Built Distribution

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

xdownscale-1.0.2-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file xdownscale-1.0.2.tar.gz.

File metadata

  • Download URL: xdownscale-1.0.2.tar.gz
  • Upload date:
  • Size: 5.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for xdownscale-1.0.2.tar.gz
Algorithm Hash digest
SHA256 4773a9502e8628e618860ed22b874898526295da32f7801cbe67bcb7904102bf
MD5 cc467908644d3c2a21ad23cc6768e0c2
BLAKE2b-256 635a8ab2955fec6044b8925e928ca30a66d2b41141b52158fd716782f59fceb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for xdownscale-1.0.2.tar.gz:

Publisher: publish.yml on manmeet3591/xdownscale

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file xdownscale-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: xdownscale-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for xdownscale-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3948f1b92f81ef840816c76b1c951fed01a703e7c03271cf48e241ee77668a9
MD5 778795914678ccfe4470068c1c8811b2
BLAKE2b-256 b380522d7b88597f5fc4c36a4a3c01150eaec552fda0729d5ec8f7def6ac315e

See more details on using hashes here.

Provenance

The following attestation bundles were made for xdownscale-1.0.2-py3-none-any.whl:

Publisher: publish.yml on manmeet3591/xdownscale

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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