Skip to main content

Torch-based Vegetation Radiative Transfer Model library (PROSPECT, SAIL, SMAC)

Project description

TorchRTM: A PyTorch-based Radiative Transfer Modeling Toolkit

PyPI version

TorchRTM is a GPU-accelerated, modular, and research-ready radiative transfer modeling (RTM) library built on top of PyTorch. It implements the full soil–leaf–canopy–atmosphere modelling chain (PROSPECT, 4SAIL, and SMAC) as native PyTorch tensor operations, enabling seamless integration with deep learning workflows.

This repository accompanies the paper:

TorchRTM: A high-performance vegetation RTM framework for deep learning integration

Installation

pip install torchrtm

Requires Python ≥ 3.9 and PyTorch ≥ 2.0.

Quick Start

Leaf Reflectance (PROSPECT)

import torch
from torchrtm.leaf.prospect import prospect5b, prospectd

# PROSPECT-5B: traits = [Cab, Car, Cbrown, Cw, Cm]
traits = torch.tensor([[40.0, 8.0, 0.0, 0.01, 0.009]])
N = torch.tensor([1.5])  # leaf structure parameter
rho, tau = prospect5b(traits, N)
# rho: leaf reflectance (1, 2101), tau: transmittance (1, 2101)

# PROSPECT-D: traits = [Cab, Car, Canth, Cbrown, Cw, Cm]
traits_d = torch.tensor([[40.0, 8.0, 0.0, 0.0, 0.01, 0.009]])
rho_d, tau_d = prospectd(traits_d, N)

Canopy Reflectance (PROSAIL)

from torchrtm.models.models import prosail

n = 100  # batch size
traits = torch.tensor([[40.0, 8.0, 0.0, 0.01, 0.009]] * n)
N       = torch.tensor([1.5] * n)
LIDFa   = torch.tensor([-0.35] * n)
LIDFb   = torch.tensor([-0.15] * n)
lai     = torch.tensor([3.0] * n)
q       = torch.tensor([0.01] * n)
tts     = torch.tensor([30.0] * n)  # solar zenith
tto     = torch.tensor([10.0] * n)  # view zenith
psi     = torch.tensor([0.0] * n)   # relative azimuth
alpha   = torch.tensor([40.0] * n)
psoil   = torch.tensor([1.0] * n)

result = prosail(traits, N, LIDFa, LIDFb, lai, q,
                 tts, tto, psi, alpha, psoil,
                 batch_size=n, prospect_type='prospect5b')
# result shape: (7, 2101, n) — 7 reflectance components

Atmospheric Correction (SMAC)

from torchrtm.atmosphere.smac import smac
from torchrtm.data_loader import load_smac_sensor

coefs, wl = load_smac_sensor("Sentinel2A-MSI")
tts = torch.tensor([30.0])
tto = torch.tensor([10.0])
psi = torch.tensor([0.0])
Ta_s, Ta_o, T_g, ra_dd, ra_so, ta_ss, ta_sd, ta_oo, ta_do = smac(tts, tto, psi, coefs)

LUT-based Retrieval

from torchrtm.retrival.fastLUT import Torchlut_pred

# xb: LUT spectra (N, D), y: LUT parameters (N, P), xq: query spectra (M, D)
preds = Torchlut_pred(xb, xq, y, k=5, device="cpu", agg="weighted")

Available Sensors (SMAC)

Sentinel2A-MSI, Sentinel2B-MSI, Sentinel3A-OLCI, Sentinel3B-OLCI, LANDSAT4-TM, LANDSAT5-TM, LANDSAT7-ETM, LANDSAT8-OLI, TerraAqua-MODIS

Testing

Install test dependencies and run:

pip install pytest
python -m pytest tests/test_torchrtm.py -v

The test suite covers data loaders, PROSPECT (5B/D/PRO), PROSAIL, SMAC, LUT retrieval, Inverse Net, math utilities, and full integration pipelines.

Supplementary Code

  • Start_Tutorial/ — Reproduces the examples in the paper. Open In Colab

  • Translation_Fidelity/ — Evaluates consistency of TorchRTM outputs against other RTM implementations.

Citation

If you use TorchRTM in your research, please cite:

Peng Sun, Peter van Bodegom, Marco Visser. TorchRTM: A high-performance vegetation RTM package for deep learning integration. Authorea. 15 January 2026.
DOI: https://doi.org/10.22541/au.176849838.80131044/v1

License

MIT

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

torchrtm-1.5.2.tar.gz (89.4 MB view details)

Uploaded Source

Built Distribution

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

torchrtm-1.5.2-py3-none-any.whl (89.4 MB view details)

Uploaded Python 3

File details

Details for the file torchrtm-1.5.2.tar.gz.

File metadata

  • Download URL: torchrtm-1.5.2.tar.gz
  • Upload date:
  • Size: 89.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for torchrtm-1.5.2.tar.gz
Algorithm Hash digest
SHA256 f35f4249f34a9a67705bd77e203e0115fef2044751f86b5df5ca873b0040971f
MD5 91e7b6e53c6fa970e307f3fdec366f62
BLAKE2b-256 165cd9f608697f4a159b7c9964fd843cc305c9a8dfec9ef95e1eb13517582c8f

See more details on using hashes here.

File details

Details for the file torchrtm-1.5.2-py3-none-any.whl.

File metadata

  • Download URL: torchrtm-1.5.2-py3-none-any.whl
  • Upload date:
  • Size: 89.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.18

File hashes

Hashes for torchrtm-1.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 989e58d4d80b62ddd96248411f393e3a86816cb58d04388c86da18bdc191042b
MD5 c0a3a0035d7804c785ebf3dcf92f0914
BLAKE2b-256 23aa7948b37e4825400b5a1b85b86fa9950b585fb4ce912e0ec2ccbcc017419b

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