{"id":146955,"name":"LDCast","description":"A precipitation nowcasting model based on a latent diffusion model.","url":"https://github.com/meteoswiss/ldcast","last_synced_at":"2026-05-30T19:30:18.661Z","repository":{"id":156754200,"uuid":"620812225","full_name":"MeteoSwiss/ldcast","owner":"MeteoSwiss","description":"Latent diffusion for generative precipitation nowcasting","archived":false,"fork":false,"pushed_at":"2023-07-10T14:33:38.000Z","size":173,"stargazers_count":143,"open_issues_count":8,"forks_count":18,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-05-14T12:04:15.930Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MeteoSwiss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-03-29T12:24:36.000Z","updated_at":"2026-04-01T18:19:58.000Z","dependencies_parsed_at":"2024-01-02T22:23:36.824Z","dependency_job_id":"f92bba75-3c9a-489b-b094-d50ff2341292","html_url":"https://github.com/MeteoSwiss/ldcast","commit_stats":{"total_commits":24,"total_committers":2,"mean_commits":12.0,"dds":"0.45833333333333337","last_synced_commit":"267ef65619a7b19c9bfaa60cff7739f7a0415674"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MeteoSwiss/ldcast","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeteoSwiss%2Fldcast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeteoSwiss%2Fldcast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeteoSwiss%2Fldcast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeteoSwiss%2Fldcast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MeteoSwiss","download_url":"https://codeload.github.com/MeteoSwiss/ldcast/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MeteoSwiss%2Fldcast/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33352352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"online","status_checked_at":"2026-05-22T02:00:06.671Z","response_time":265,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"owner":{"login":"MeteoSwiss","name":"MeteoSwiss","uuid":"10277948","kind":"organization","description":"Federal Office of Meteorology and Climatology MeteoSwiss","email":null,"website":"https://www.meteoswiss.ch","location":"Zurich, Geneva, Locarno, Payerne","twitter":"meteosuisse","company":null,"icon_url":"https://avatars.githubusercontent.com/u/10277948?v=4","repositories_count":22,"last_synced_at":"2023-03-07T00:58:37.643Z","metadata":{"has_sponsors_listing":false},"html_url":"https://github.com/MeteoSwiss","funding_links":[],"total_stars":null,"followers":null,"following":null,"created_at":"2022-11-17T00:42:02.515Z","updated_at":"2023-03-07T00:58:37.651Z","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MeteoSwiss","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MeteoSwiss/repositories"},"packages":[],"commits":{"id":1452592,"full_name":"meteoswiss/ldcast","default_branch":"master","total_commits":24,"total_committers":2,"total_bot_commits":0,"total_bot_committers":0,"mean_commits":12.0,"dds":0.45833333333333337,"past_year_total_commits":0,"past_year_total_committers":0,"past_year_total_bot_commits":0,"past_year_total_bot_committers":0,"past_year_mean_commits":0.0,"past_year_dds":0.0,"last_synced_at":"2026-05-26T18:02:20.669Z","last_synced_commit":"267ef65619a7b19c9bfaa60cff7739f7a0415674","created_at":"2023-12-05T11:23:45.321Z","updated_at":"2026-05-26T18:02:09.388Z","committers":[{"name":"Jussi Leinonen","email":"jussi.leinonen@meteoswiss.ch","login":null,"count":13},{"name":"Jussi Leinonen","email":"jsleinonen@gmail.com","login":"jleinonen","count":11}],"past_year_committers":[],"commits_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteoswiss%2Fldcast/commits","host":{"name":"GitHub","url":"https://github.com","kind":"github","last_synced_at":"2026-05-29T00:00:10.182Z","repositories_count":6247227,"commits_count":883273702,"contributors_count":34977228,"owners_count":1160033,"icon_url":"https://github.com/github.png","host_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://commits.ecosyste.ms/api/v1/hosts/GitHub/repositories"}},"issues_stats":{"full_name":"meteoswiss/ldcast","html_url":"https://github.com/meteoswiss/ldcast","last_synced_at":"2026-03-24T12:03:09.584Z","status":"error","issues_count":20,"pull_requests_count":0,"avg_time_to_close_issue":1448988.6666666667,"avg_time_to_close_pull_request":null,"issues_closed_count":12,"pull_requests_closed_count":0,"pull_request_authors_count":0,"issue_authors_count":12,"avg_comments_per_issue":2.15,"avg_comments_per_pull_request":null,"merged_pull_requests_count":0,"bot_issues_count":0,"bot_pull_requests_count":0,"past_year_issues_count":0,"past_year_pull_requests_count":0,"past_year_avg_time_to_close_issue":null,"past_year_avg_time_to_close_pull_request":null,"past_year_issues_closed_count":0,"past_year_pull_requests_closed_count":0,"past_year_pull_request_authors_count":0,"past_year_issue_authors_count":0,"past_year_avg_comments_per_issue":null,"past_year_avg_comments_per_pull_request":null,"past_year_bot_issues_count":0,"past_year_bot_pull_requests_count":0,"past_year_merged_pull_requests_count":0,"created_at":"2023-12-05T11:23:47.907Z","updated_at":"2026-03-24T12:03:09.585Z","repository_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteoswiss%2Fldcast","issues_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories/meteoswiss%2Fldcast/issues","issue_labels_count":{},"pull_request_labels_count":{},"issue_author_associations_count":{"NONE":17},"pull_request_author_associations_count":{},"issue_authors":{"nathzi1505":4,"bugsuse":3,"tomasvanoyen":3,"caglarkucuk":1,"jacksd233":1,"jichongxing2023":1,"wang6501sfx":1,"ajikmr":1,"M4verrick":1,"DaDaDa-FH":1},"pull_request_authors":{},"host":{"name":"GitHub","url":"https://github.com","kind":"github","last_synced_at":"2026-05-29T00:00:19.590Z","repositories_count":14722103,"issues_count":33633958,"pull_requests_count":110637464,"authors_count":11281253,"icon_url":"https://github.com/github.png","host_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/repositories","owners_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/owners","authors_url":"https://issues.ecosyste.ms/api/v1/hosts/GitHub/authors"},"past_year_issue_labels_count":{},"past_year_pull_request_labels_count":{},"past_year_issue_author_associations_count":{},"past_year_pull_request_author_associations_count":{},"past_year_issue_authors":{},"past_year_pull_request_authors":{},"maintainers":[],"active_maintainers":[]},"events":{"total":{"ForkEvent":2,"WatchEvent":26},"last_year":{"WatchEvent":6}},"keywords":[],"dependencies":[{"ecosystem":"pypi","filepath":"setup.py","sha":null,"kind":"manifest","created_at":"2024-01-02T22:23:36.809Z","updated_at":"2024-01-02T22:23:36.809Z","repository_link":"https://github.com/MeteoSwiss/ldcast/blob/master/setup.py","dependencies":[{"id":15399945513,"package_name":"dask","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945514,"package_name":"fire","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945515,"package_name":"einops","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945516,"package_name":"h5py","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945517,"package_name":"matplotlib","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945518,"package_name":"netCDF4","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945519,"package_name":"numba","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945520,"package_name":"numpy","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945521,"package_name":"omegaconf","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945522,"package_name":"pyshp","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945523,"package_name":"pytorch-lightning","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945524,"package_name":"scipy","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945525,"package_name":"torch","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false},{"id":15399945526,"package_name":"tqdm","ecosystem":"pypi","requirements":"*","direct":true,"kind":"runtime","optional":false}]}],"score":5.71042701737487,"created_at":"2023-12-05T11:23:44.878Z","updated_at":"2026-05-30T19:30:18.666Z","avatar_url":"https://github.com/MeteoSwiss.png","language":"Python","category":"Natural Resources","sub_category":"Water Supply and Quality","monthly_downloads":0,"total_dependent_repos":0,"total_dependent_packages":0,"readme":"LDCast is a precipitation nowcasting model based on a latent diffusion model (LDM, used by e.g. [Stable Diffusion](https://github.com/CompVis/stable-diffusion)).\n\nThis repository contains the code for using LDCast to make predictions and the code used to generate the analysis in the LDCast paper (a preprint is available at https://arxiv.org/abs/2304.12891).\n\nA GPU is recommended for both using and training LDCast, although you may be able to generate some samples with a CPU and enough patience.\n\n# Installation\n\nIt is recommended you install the code in its own virtual environment (created with e.g. pyenv or conda).\n\nClone the repository, then, in the main directory, run\n```bash\n$ pip install -e .\n```\nThis should automatically install the required packages (which might take some minutes). In the paper, we used PyTorch 11.2 but are not aware of any problems with newer versions.\n\nIf you don't want the requirements to be installed (e.g. if you installed them manually with conda), use:\n```bash\n$ pip install --no-dependencies -e .\n```\n\n# Using LDCast\n\n## Pretrained models\n\nThe pretrained models are available at the Zenodo repository https://doi.org/10.5281/zenodo.7780914. Unzip the file `ldcast-models.zip`. The default is to unzip it to the `models` directory, but you can also use another location.\n\n## Producing predictions\n\nThe easiest way to produce predictions is to use the `ldcast.forecast.Forecast` class, which will set up all models and data transformations and is callable with a past precipitation array.\n```python\nfrom ldcast import forecast\n\nfc = forecast.Forecast(\n    ldm_weights_fn=ldm_weights_fn, autoenc_weights_fn=autoenc_weights_fn\n)\nR_pred = fc(R_past)\n```\nHere, `ldm_weights_fn` is the path to the LDM weights and `autoenc_weights_fn` is the path to the autoencoder weights. `R_past` is a NumPy array of precipitation rates with shape `(timesteps, height, width)` where `timesteps` must be 4 and `height` and `width` must be divisible by 32.\n\n### Ensemble predictions\n\nIf want to process multiple cases at once and/or generate several ensemble members, there is the `ldcast.forecast.ForecastDistributed` class. The usage is similar to the `Forecast` class, for example:\n```python\nfrom ldcast import forecast\n\nfc = forecast.ForecastDistributed(\n    ldm_weights_fn=ldm_weights_fn, autoenc_weights_fn=autoenc_weights_fn\n)\nR_pred = fc(R_past, ensemble_members=32)\n```\nHere, `R_past` should be of shape `(cases, timesteps, height, width)` where `cases` is the number of cases you want to process. For each case, `ensemble_members` predictions are produced (this is the last axis of `R_pred`). `ForecastDistributed` automatically distributes the workload to multiple GPUs if you have them.\n\n## Demo\n\nFor a practical example, you can run the demo in the `scripts` directory. First download the `ldcast-demo-20210622.zip` file from the [Zenodo repository](https://doi.org/10.5281/zenodo.7780914), then unzip it in the `data` directory. Then run\n```bash\n$ python forecast_demo.py\n```\nA sample output can be found in the file `ldcast-demo-video-20210622.zip` in the data repository. See the function `forecast_demo` in `forecast_demo.py` see how the `Forecast` class works. To run an ensemble mean of 8 members using the `ForecastDistributed` class, you can use:\n```bash\n$ python forecast_demo.py --ensemble-members=8\n```\n\nThe demo for a single ensemble member runs in a couple of minutes on our system using one V100 GPU; with a CPU around 10 minutes or more would be expected. A progress bar will show the status of the generation.\n\n# Training \n\n## Training data\n\nThe preprocessed training data, needed to rerun the LDCast training, can be found at the [Zenodo repository](https://doi.org/10.5281/zenodo.7780914). Unzip the `ldcast-datasets.zip` file to the `data` directory.\n\n## Training the autoencoder\n\nIn the `scripts` directory, run\n```bash\n$ python train_autoenc.py --model_dir=\"../models/autoenc_train\"\n```\nto run the training of the autoencoder with the default parameters. The training checkpoints will be saved in the `../models/autoenc_train` directory (feel free to change this).\n\nIt has been reported that this training may encounter a condition where the loss goes to `nan`. If this happens, try restarting from the latest checkpoint:\n```bash\n$ python train_autoenc.py --model_dir=\"../models/autoenc_train\" --ckpt_path=\"../models/autoenc_train/\u003ccheckpoint_file\u003e\"\n```\nwhere `\u003ccheckpoint_file\u003e` should be the latest checkpoint in the `../models/autoenc_train/` directory.\n\n## Training the diffusion model\n\nIn the `scripts` directory, run\n```bash\n$ python train_genforecast.py --model_dir=\"../models/genforecast_train\"\n```\nto run the training of the diffusion model with the default parameters, or\n```bash\n$ python train_genforecast.py --model_dir=\"../models/genforecast_train\" --config=\u003cpath_to_config_file\u003e\n```\nto run the training with different parameters. Some config files can be found in the `config` directory. The training checkpoints will be saved in the `../models/genforecast_train` directory (again, this can be changed freely).\n\n# Evaluation\n\nYou can find scripts for evaluating models in the `scripts` directory:\n* `eval_genforecast.py` to evaluate LDCast\n* `eval_dgmr.py` to evaluate DGMR (requires tensorflow installation and the DGMR model from https://github.com/deepmind/deepmind-research/tree/master/nowcasting placed in the `models/dgmr` directory)\n* `eval_pysteps.py` to evaluate PySTEPS (requires pysteps installation)\n* `metrics.py` to produce metrics from the evaluation results produced with the functions in scripts above\n* `plot_genforecast.py` to make plots from the results generated\n","funding_links":[],"readme_doi_urls":["https://doi.org/10.5281/zenodo.7780914"],"works":{},"citation_counts":{},"total_citations":0,"keywords_from_contributors":[],"project_url":"https://ost.ecosyste.ms/api/v1/projects/146955","html_url":"https://ost.ecosyste.ms/projects/146955"}