LDM_res is a downscaling model based on a Latent Diffusion Model (LDM, used by e.g. Stable Diffusion), developed to downscale meteorological variables from ERA5 reanalyses.
We trained and tested LDM_res to produce 2-km fields of 2-m temperature and 10-m wind speed horizontal components starting from a list of predictors from ERA5 (interpolated @16km). The high-resolution reference truth data are provided by a dynamical downscaling performed with COSMO_CLM (VHR-REA IT). The model and its performance are presented and discussed in this GMD paper.
@Article{gmd-18-2051-2025,
AUTHOR = {Tomasi, E. and Franch, G. and Cristoforetti, M.},
TITLE = {Can AI be enabled to perform dynamical downscaling? A latent diffusion model to mimic kilometer-scale COSMO5.0\_CLM9 simulations},
JOURNAL = {Geoscientific Model Development},
VOLUME = {18},
YEAR = {2025},
NUMBER = {6},
PAGES = {2051--2078},
URL = {https://gmd.copernicus.org/articles/18/2051/2025/},
DOI = {10.5194/gmd-18-2051-2025}
}
This repository contains the code for testing and training LDM_res, all the baselines presented in the paper, and the code used to generate all the paper Figures.
A GPU is recommended for both testing and training LDM_res.
# clone project
git clone https://github.com/YourGithubName/your-repo-name
cd your-repo-name
# install pytorch according to instructions
# https://pytorch.org/get-started/
# create virtual env
python3 -m venv .venv
source .venv/bin/activate
# install requirements
pip install -r requirements.txtZenodo hosts:
- a sample dataset [45GB], that you can use to perform a sample training of the models
- the full dataset [330GB], divided into 7 Zenodo repository, that you can use to reproduce our experiments
- the pretrained models (UNET, GAN, VAE_res and LDM_res) and their main outputs [12GB], that you can use to test the models and to reproduce the paper figures.
You can download the sample dataset by running the download_sample_dataset.sh script in data/:
cd data
# download and unzip the sample dataset
bash download_sample_dataset.shYou can download the full dataset by running the download_full_dataset.sh script in data/:
cd data
# download and unzip the full dataset
bash download_full_dataset.shYou can download the pretrained models by running the download_pretrained_models.sh script in pretrained_models/:
cd data
# download the pretrained models
bash download_pretrained_models.shThe notebook notebooks/models_inference.ipynb guides you through the setup and test of the LDM_res model and its baselines. To use this notebook you only need to download the pretrained models Zenodo repo. The notebook also saves model results for later plotting.
You can plot snapshots of the model results with the notebook notebooks/Fig_snapshots.ipynb (as they are presented in the paper), adjusting the paths.
You can recreate all the figures presented in the paper using all the notebooks/Fig_*.ipynb notebooks, reading results files included in pretrained_models/outputs, after downloading from the Zenodo repository.
If you like to train the models you can run the following command, which rely on the configurations set in the files within configs/. To do this you need to download either the sample dataset or the whole dataset from Zenodo.
Train any model with a chosen experiment configuration from configs/experiment/.
- Available ModelNames are UNET, GAN, VAE_res, LDM_res.
- Available VarName are 2mT and UV. To train VAE_res you need to provide a UNET checkpoint and to train LDM_res you need to provide a UNET checkpoint and a VAE_res checkpoint: by default configuration files point to pretrained_models/, reading and using pretrained models checkpoints. If you didn't download the pretrained models from Zenodo, adjust the checkpoint configurations in configs/experiment/downscaling_VAE_res_**.yaml and in configs/experiment/downscaling_LDM_res_**.yaml to point to your UNET and VAE_res checkpoints.
python src/train.py experiment=downscaling_ModelName_VarName