Skip to main content

A PyTorch-based tool to downscale spatiotemporal data

Project description

xdownscale

xdownscale logo

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 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, ssresnet, 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.1.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.1-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xdownscale-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 73aebf422f165bece960fed83ff42b962f9f56676885dc095e04d4c4ddbadc9c
MD5 d62642dcc6d81edfa83b3b05e662104d
BLAKE2b-256 e9ede52bcc32cef28f73ff092597fd4f6b59cd4bae58ea50f72ab7026504d416

See more details on using hashes here.

Provenance

The following attestation bundles were made for xdownscale-1.0.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: xdownscale-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 23.0 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 927fce49f1ecca0d498de66f46c78e8248a8744af979714d0ddac61d76fef906
MD5 d5640b7658a7c7b353d9ace4ee58d136
BLAKE2b-256 d40447ab7271382e5a9ac587c9eafb5971eea873f44c9876569cc9f6198aecaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for xdownscale-1.0.1-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