Skip to main content

High-performance SOLWEIG urban microclimate model (Rust + Python)

Project description

SOLWEIG

Map how hot it feels across a city — pixel by pixel.

SOLWEIG computes Mean Radiant Temperature (Tmrt) and thermal comfort indices (UTCI, PET) for urban environments. Give it a building height model and weather data, and it produces high-resolution maps showing where people experience heat stress — and where trees, shade, and cool surfaces make a difference.

Adapted from the UMEP (Urban Multi-scale Environmental Predictor) platform by Fredrik Lindberg, Sue Grimmond, and contributors — see Lindberg et al. (2008, 2018). Re-implemented in Rust for speed, with optional GPU acceleration.

UTCI thermal comfort map DSM/DEM data: PNOA-LiDAR, Instituto Geográfico Nacional (IGN), Spain. CC BY 4.0.

Experimental: This package and QGIS plugin are released for testing and discussion purposes. The API is stabilising but may change. Feedback and bug reports welcome — open an issue.

Documentation · Installation · Quick Start · API Reference


What can you do with it?

  • Urban planning — Compare street canyon designs, tree planting scenarios, or cool-roof strategies by mapping thermal comfort before and after.
  • Heat risk assessment — Identify the hottest spots in a neighbourhood during a heatwave, hour by hour.
  • Research — Run controlled microclimate experiments at 1 m resolution with full radiation budgets.
  • Climate services — Generate thermal comfort maps for public health warnings or outdoor event planning.

How it works

SOLWEIG models the complete radiation budget experienced by a person standing in an urban environment:

  1. Shadows — Which pixels are shaded by buildings and trees at a given sun angle?
  2. Sky View Factor (SVF) — How much sky can a person see from each point? (More sky = more incoming longwave and diffuse radiation.)
  3. Surface temperatures — How hot are the ground and surrounding walls, accounting for thermal inertia across the diurnal cycle?
  4. Radiation balance — Sum shortwave (sun) and longwave (heat) radiation from all directions, using either isotropic or Perez anisotropic sky models.
  5. Tmrt — Convert total absorbed radiation into Mean Radiant Temperature.
  6. Thermal comfort — Optionally derive UTCI or PET, which combine Tmrt with air temperature, humidity, and wind.

The computation pipeline is implemented in Rust and exposed to Python via PyO3. Shadow casting and anisotropic sky calculations can optionally run on the GPU via WebGPU. Large rasters are automatically tiled to fit GPU memory constraints.


Install

pip install solweig

Requirements: Python 3.11–3.13. Pre-built wheels are available for Linux, macOS, and Windows.

From source

git clone https://github.com/UMEP-dev/solweig.git
cd solweig
pip install maturin
maturin develop --release

This compiles the Rust extension locally. A Rust toolchain is required.


Quick start

Minimal example (numpy arrays)

import numpy as np
import solweig
from datetime import datetime

# A flat surface with one 15 m building
dsm = np.full((200, 200), 2.0, dtype=np.float32)
dsm[80:120, 80:120] = 15.0

surface = solweig.SurfaceData.prepare(dsm=dsm, pixel_size=1.0)

location = solweig.Location(latitude=48.8, longitude=2.3, utc_offset=1)  # Paris
weather = solweig.Weather(
    datetime=datetime(2025, 7, 15, 14, 0),
    ta=32.0,          # Air temperature (°C)
    rh=40.0,          # Relative humidity (%)
    global_rad=850.0, # Solar radiation (W/m²)
)

summary = solweig.calculate(surface, weather=[weather], location=location, output_dir="output/")

print(f"Mean Tmrt: {summary.tmrt_mean.mean():.0f}°C")
print(f"Max UTCI:  {np.nanmax(summary.utci_max):.0f}°C")

Real-world workflow (GeoTIFFs + EPW weather)

import solweig

# 1. Load surface — prepare() computes and caches walls/SVF when missing
surface = solweig.SurfaceData.prepare(
    dsm="data/dsm.tif",
    cdsm="data/trees.tif",       # Optional: vegetation canopy heights
    working_dir="cache/",        # Expensive preprocessing cached here
)

# 2. Load weather from an EPW file (standard format from climate databases)
weather_list = solweig.Weather.from_epw(
    "data/weather.epw",
    start="2025-07-01",
    end="2025-07-03",
)
location = solweig.Location.from_epw("data/weather.epw")

# 3. Run — outputs saved as GeoTIFFs, thermal state carried between timesteps
summary = solweig.calculate(
    surface=surface,
    weather=weather_list,
    location=location,
    output_dir="output/",
    outputs=["tmrt", "shadow"],
)

# 4. Inspect results
print(summary.report())
summary.plot()

API overview

Core classes

Class Purpose
SurfaceData Holds all spatial inputs (DSM, CDSM, DEM, land cover) and precomputed arrays (walls, SVF). Use .prepare() to load GeoTIFFs with automatic caching.
Location Geographic coordinates (latitude, longitude, UTC offset). Create from coordinates, DSM CRS, or an EPW file.
Weather Per-timestep meteorological data (air temperature, relative humidity, global radiation, optional wind speed). Load from EPW files or create manually.
SolweigResult Output grids from a single timestep: Tmrt, shadow, UTCI, PET, radiation components.
TimeseriesSummary Aggregated results from a multi-timestep run: mean/max/min grids, sun hours, UTCI threshold exceedance, per-timestep scalars.
HumanParams Body parameters: posture (standing/sitting), absorption coefficients, PET body parameters (age, weight, height, etc.).
ModelConfig Runtime settings: anisotropic sky, max shadow distance, tiling workers.

Main functions

# Single timestep
summary = solweig.calculate(surface, weather=[weather], output_dir="output/")

# Multi-timestep with thermal inertia (auto-tiles large rasters)
summary = solweig.calculate(surface, weather=weather_list, output_dir="output/")

# Include UTCI and/or PET in per-timestep GeoTIFFs
summary = solweig.calculate(
    surface, weather=weather_list,
    output_dir="output/",
    outputs=["tmrt", "utci", "shadow"],
)

# Input validation
warnings = solweig.validate_inputs(surface, location, weather)

Convenience I/O

# Load/save GeoTIFFs
data, transform, crs, nodata = solweig.io.load_raster("dsm.tif")
solweig.io.save_raster("output.tif", data, transform, crs)

# Rasterise vector data (e.g., tree polygons → height grid)
raster, transform = solweig.io.rasterise_gdf(gdf, "geometry", "height", bbox=bbox, pixel_size=1.0)

# Download EPW weather data (no API key needed)
epw_path = solweig.download_epw(latitude=37.98, longitude=23.73, output_path="athens.epw")

Inputs and outputs

What you need

Input Required? What it is
DSM Yes Digital Surface Model — a height grid (metres) including buildings. GeoTIFF or numpy array.
Location Yes Latitude, longitude, and UTC offset. Can be extracted from the DSM's CRS or an EPW file.
Weather Yes Air temperature, relative humidity, and global solar radiation. Load from an EPW file or create manually.
CDSM No Canopy heights (trees). Adds vegetation shading.
DEM No Ground elevation. Separates terrain from buildings.
Land cover No Surface type grid (paved, grass, water, etc.). Affects surface temperatures.

What you get

Output Unit Description
Tmrt °C Mean Radiant Temperature — how much radiation a person absorbs.
Shadow 0–1 Shadow fraction (1 = sunlit, 0 = fully shaded).
UTCI °C Universal Thermal Climate Index — "feels like" temperature.
PET °C Physiological Equivalent Temperature — similar to UTCI with customisable body parameters.
Kdown / Kup W/m² Shortwave radiation (down and reflected up).
Ldown / Lup W/m² Longwave radiation (thermal, down and emitted up).

Timeseries summary grids

When running calculate() with a list of weather timesteps, the returned TimeseriesSummary provides aggregated grids across all timesteps:

Grid Description
tmrt_mean, tmrt_max, tmrt_min Overall Tmrt statistics
tmrt_day_mean, tmrt_night_mean Day/night Tmrt averages
utci_mean, utci_max, utci_min Overall UTCI statistics
utci_day_mean, utci_night_mean Day/night UTCI averages
sun_hours, shade_hours Hours of direct sun / shade per pixel
utci_hours_above Dict of threshold → grid of hours exceeding that UTCI value

Plus a Timeseries object with per-timestep spatial means (Tmrt, UTCI, sun fraction, air temperature, radiation, etc.) for plotting.

Don't have an EPW file? Download one

epw_path = solweig.download_epw(latitude=37.98, longitude=23.73, output_path="athens.epw")
weather_list = solweig.Weather.from_epw(epw_path)

Configuration

Human body parameters

human = solweig.HumanParams(
    posture="standing",  # or "sitting"
    abs_k=0.7,           # Shortwave absorption coefficient
    abs_l=0.97,          # Longwave absorption coefficient
    # PET-specific:
    age=35, weight=75, height=1.75, sex=1, activity=80, clothing=0.9,
)
summary = solweig.calculate(surface, weather=[weather], location=location, human=human, output_dir="output/")

Model options

Key parameters accepted by calculate():

Parameter Default Description
use_anisotropic_sky True Use Perez anisotropic sky model for more accurate diffuse radiation.
conifer False Treat trees as evergreen (skip seasonal leaf-off).
max_shadow_distance_m 1000 Maximum shadow reach in metres. Increase for mountainous terrain.
output_dir (required) Working directory for all output (summary grids, per-timestep GeoTIFFs, metadata).
outputs None Which per-timestep grids to save: "tmrt", "utci", "pet", "shadow", "kdown", "kup", "ldown", "lup".

Physics and materials

# Custom vegetation transmissivity, posture geometry, etc.
physics = solweig.load_physics("custom_physics.json")

# Custom surface materials (albedo, emissivity per land cover class)
materials = solweig.load_materials("site_materials.json")

summary = solweig.calculate(
    surface=surface,
    weather=weather_list,
    location=location,
    physics=physics,
    materials=materials,
    output_dir="output/",
)

GPU acceleration

SOLWEIG uses WebGPU (via wgpu/Rust) for shadow casting and anisotropic sky computations. GPU is enabled by default when available.

import solweig

# Check GPU status
print(solweig.is_gpu_available())     # True/False
print(solweig.get_compute_backend())  # "gpu" or "cpu"
print(solweig.get_gpu_limits())       # {"max_buffer_size": ..., "backend": "Metal"}

# Disable GPU (fall back to CPU)
solweig.disable_gpu()

Large rasters are automatically tiled to fit within GPU buffer limits. Tile size, worker count, and prefetch depth are configurable via ModelConfig or keyword arguments.


Run metadata and reproducibility

Every timeseries run records a run_metadata.json in the output directory capturing the full parameter set:

metadata = solweig.load_run_metadata("output/run_metadata.json")
print(metadata["solweig_version"])
print(metadata["location"])
print(metadata["parameters"]["use_anisotropic_sky"])
print(metadata["timeseries"]["start"], "to", metadata["timeseries"]["end"])

QGIS plugin

SOLWEIG is also available as a QGIS Processing plugin for point-and-click spatial analysis — no Python scripting required.

Installation

  1. PluginsManage and Install Plugins
  2. Settings tab → Check "Show also experimental plugins"
  3. Search for "SOLWEIG"Install Plugin

The plugin requires QGIS 4.0+ (Qt6, Python 3.11+). On first use it will offer to install the solweig Python library automatically.

Processing algorithms

Once installed, SOLWEIG algorithms appear in the Processing Toolbox under the SOLWEIG group:

Algorithm Description
Download / Preview Weather File Download a TMY EPW file from PVGIS, or preview an existing EPW file.
Prepare Surface Data Align rasters, compute wall heights, wall aspects, and SVF. Results are cached and reused.
SOLWEIG Calculation Single-timestep or timeseries Tmrt with optional inline UTCI/PET. Supports EPW and UMEP met files.

QGIS-specific features

  • All inputs and outputs are standard QGIS raster layers (GeoTIFF)
  • Automatic tiling for large rasters with GPU support
  • QGIS progress bar integration with cancellation support
  • Configurable vegetation parameters (transmissivity, seasonal leaf dates, conifer/deciduous)
  • Configurable land cover materials table
  • UTCI heat stress thresholds for day and night
  • Run metadata saved alongside outputs for reproducibility

Typical QGIS workflow

  1. Surface Preparation — Load your DSM (and optionally CDSM, DEM, land cover). The algorithm computes walls, SVF, and caches everything to a working directory.
  2. Tmrt Timeseries — Point to the prepared surface directory and an EPW file. Select your date range, outputs, and run. Results are saved as GeoTIFFs and loaded into the QGIS canvas.
  3. Inspect results — Use standard QGIS tools to style, compare, and export the output layers.

Demos

Complete working scripts:

  • demos/athens-demo.py — Full workflow: rasterise tree vectors, load GeoTIFFs, run a multi-day timeseries, visualise summary grids.
  • demos/bilbao-demo.py — Valley urban canyon with dsm_relative=True, terrain-aware shadows, and max_shadow_distance_m for bounded horizontal reach.
  • demos/madrid-demo.py — Automatic tiling stress test on a 500 M-pixel raster (55 km × 58 km at 2.5 m), exercising resource-aware tile sizing and the full timeseries path end-to-end.
  • demos/solweig_gbg_test.py — Gothenburg: surface preparation with SVF caching, timeseries calculation.

Validation

SOLWEIG is validated against field radiation measurements from three sites in Gothenburg, Sweden (Lindberg et al. 2008, 2011). All geodata, measurements, and test scripts are checked into the repository and run as part of the test suite.

Site Season Days Tmrt RMSE Tmrt R²
Kronenhuset (courtyard, 1 m) Autumn 1 6.7 °C 0.51
Gustav Adolfs torg (open square, 2 m) Autumn + Summer 3 5.7-7.5 °C 0.78-0.87
GVC (university campus, 2 m) Summer 3 1.5-6.1 °C 0.79-0.99

Anisotropic sky mode, matched daytime observation hours. Full details, radiation budget comparisons, and version history: Validation Report.


Citation

Adapted from UMEP by Fredrik Lindberg, Sue Grimmond, and contributors.

If you use SOLWEIG in your research, please cite the original model paper and the UMEP platform:

  1. Lindberg F, Holmer B, Thorsson S (2008) SOLWEIG 1.0 – Modelling spatial variations of 3D radiant fluxes and mean radiant temperature in complex urban settings. International Journal of Biometeorology 52, 697–713 doi:10.1007/s00484-008-0162-7

  2. Lindberg F, Grimmond CSB, Gabey A, Huang B, Kent CW, Sun T, Theeuwes N, Järvi L, Ward H, Capel-Timms I, Chang YY, Jonsson P, Krave N, Liu D, Meyer D, Olofson F, Tan JG, Wästberg D, Xue L, Zhang Z (2018) Urban Multi-scale Environmental Predictor (UMEP) – An integrated tool for city-based climate services. Environmental Modelling and Software 99, 70-87 doi:10.1016/j.envsoft.2017.09.020

Demo data

The Athens demo dataset (demos/data/athens/) uses the following sources:

  • DSM/DEM — Derived from LiDAR data available via the Hellenic Cadastre geoportal
  • Tree vectors (trees.gpkg) — Derived from the Athens Urban Atlas and municipal open data at geodata.gov.gr
  • EPW weather (athens_2023.epw) — Generated using Copernicus Climate Change Service information [2025] via PVGIS. Contains modified Copernicus Climate Change Service information; neither the European Commission nor ECMWF is responsible for any use that may be made of the Copernicus information or data it contains.

License

GNU General Public License v3.0 — see LICENSE.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

solweig-0.1.0b83.tar.gz (309.7 kB view details)

Uploaded Source

Built Distributions

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

solweig-0.1.0b83-cp311-abi3-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.11+Windows x86-64

solweig-0.1.0b83-cp311-abi3-musllinux_1_2_x86_64.whl (2.9 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

solweig-0.1.0b83-cp311-abi3-musllinux_1_2_aarch64.whl (2.6 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

solweig-0.1.0b83-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

solweig-0.1.0b83-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

solweig-0.1.0b83-cp311-abi3-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

solweig-0.1.0b83-cp311-abi3-macosx_10_12_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11+macOS 10.12+ x86-64

File details

Details for the file solweig-0.1.0b83.tar.gz.

File metadata

  • Download URL: solweig-0.1.0b83.tar.gz
  • Upload date:
  • Size: 309.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for solweig-0.1.0b83.tar.gz
Algorithm Hash digest
SHA256 c72b754ae4b189b5cab51fc423f05142910cb526eba7eb16e31c4292eccb5392
MD5 552ec6f6e602fddf7c436ec4ded9d248
BLAKE2b-256 e30d9f07cdd23e4ec2dfb300433d10588e7c34096513bb3c7a9698d118825e9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for solweig-0.1.0b83.tar.gz:

Publisher: python-publish.yml on UMEP-dev/solweig

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

File details

Details for the file solweig-0.1.0b83-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: solweig-0.1.0b83-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for solweig-0.1.0b83-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d14c838014a1b8ce4a842ec4a3dcc786cc462d1bcbdc60c2de505639a39b7826
MD5 fd7625f83bcb356f7a4fc5c99a18390a
BLAKE2b-256 94ceed14f8087e93615943dfa9aa1721dff6b95189ee239608636ce5b7730965

See more details on using hashes here.

Provenance

The following attestation bundles were made for solweig-0.1.0b83-cp311-abi3-win_amd64.whl:

Publisher: python-publish.yml on UMEP-dev/solweig

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

File details

Details for the file solweig-0.1.0b83-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for solweig-0.1.0b83-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c66a2e9fc2b3f886c08fde880635965fd464261295406f20e902a78be907e330
MD5 e9f9c4fa356940d49bb61ca9a6d9f7a4
BLAKE2b-256 46b244898e4d0521ecdc2bfda33e26d1405e3f3f12b8e9573c2134fa03a60d63

See more details on using hashes here.

Provenance

The following attestation bundles were made for solweig-0.1.0b83-cp311-abi3-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on UMEP-dev/solweig

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

File details

Details for the file solweig-0.1.0b83-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for solweig-0.1.0b83-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 0ebcc2a0d5eff0c1abd037bbb41cb77f3b97285ee49f9abb053e97ce1a9cf598
MD5 5c4be1d80f3b6aacb199d24fd023b061
BLAKE2b-256 e2c8a4bc597ac2a50ed6cf909758de7039b6f16a9080420fa28af266ac2e7ec1

See more details on using hashes here.

Provenance

The following attestation bundles were made for solweig-0.1.0b83-cp311-abi3-musllinux_1_2_aarch64.whl:

Publisher: python-publish.yml on UMEP-dev/solweig

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

File details

Details for the file solweig-0.1.0b83-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for solweig-0.1.0b83-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b5f8a16fbfb23188fb61f5c1b87ad4aef329c3e49f8d084707398174554877fb
MD5 c772eb223f35c413e23f71f08b7444cd
BLAKE2b-256 a636b84688ecacd7bfcc3c38167b497a6583862129023f37ce4cc84e505509dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for solweig-0.1.0b83-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-publish.yml on UMEP-dev/solweig

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

File details

Details for the file solweig-0.1.0b83-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for solweig-0.1.0b83-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3f258ebc130e2442e11f5dc5cd6cb728b29a6f4bb2c9609f0b7f2bbed4d21eac
MD5 ea85a510f7424557e5afe62947f4a8fa
BLAKE2b-256 7059cffdf71dfe5d5f895adc2b1f428a8e0e93ca0625ae179ef1790636dd04ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for solweig-0.1.0b83-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: python-publish.yml on UMEP-dev/solweig

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

File details

Details for the file solweig-0.1.0b83-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for solweig-0.1.0b83-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93e27ef1124c4f114134a9414ceaa45f89797a20710ea7f4c0138bb9c221d964
MD5 fcc2e3d675ed0c321a72e0317b0de2ea
BLAKE2b-256 d064d0fdcac9a48cbbb0d94f80ef8a2732c661aac5343368cc1e2eb57074097c

See more details on using hashes here.

Provenance

The following attestation bundles were made for solweig-0.1.0b83-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on UMEP-dev/solweig

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

File details

Details for the file solweig-0.1.0b83-cp311-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for solweig-0.1.0b83-cp311-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 efec6674b07557b199d9bd2bd64806286414af9e869e946140782e2c4def1767
MD5 17b3c11b3436c5cdb9ffff83a04608bd
BLAKE2b-256 5231d17cf4637a8316a0595654dfe800c9fb8eb093029843679f19231faf00a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for solweig-0.1.0b83-cp311-abi3-macosx_10_12_x86_64.whl:

Publisher: python-publish.yml on UMEP-dev/solweig

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