{"id":40676177,"url":"https://github.com/paulaharder/constrained-downscaling","last_synced_at":"2026-01-21T09:40:30.100Z","repository":{"id":106714103,"uuid":"599197426","full_name":"paulaharder/constrained-downscaling","owner":"paulaharder","description":"A project on how to incorporate physics constraints into deep learning architectures for downscaling or other super--resolution tasks. ","archived":false,"fork":false,"pushed_at":"2023-06-08T10:08:11.000Z","size":74,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-01-29T07:52:51.421Z","etag":null,"topics":["climate","deep-learning","downscaling","physics-constrained","super-resolution"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulaharder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-02-08T16:49:16.000Z","updated_at":"2023-12-30T03:30:59.000Z","dependencies_parsed_at":"2023-07-08T08:46:39.895Z","dependency_job_id":null,"html_url":"https://github.com/paulaharder/constrained-downscaling","commit_stats":{"total_commits":39,"total_committers":3,"mean_commits":13.0,"dds":0.05128205128205132,"last_synced_commit":"0aa45651d156e210788d65d748876dc3a7890e16"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/paulaharder/constrained-downscaling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulaharder%2Fconstrained-downscaling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulaharder%2Fconstrained-downscaling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulaharder%2Fconstrained-downscaling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulaharder%2Fconstrained-downscaling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulaharder","download_url":"https://codeload.github.com/paulaharder/constrained-downscaling/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulaharder%2Fconstrained-downscaling/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28631537,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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"}},"keywords":["climate","deep-learning","downscaling","physics-constrained","super-resolution"],"created_at":"2026-01-21T09:40:30.028Z","updated_at":"2026-01-21T09:40:30.090Z","avatar_url":"https://github.com/paulaharder.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Physics-constrained deep learning for climate downscaling\n\nThis code belongs to a paper currently under review, a preprint can be found at: https://arxiv.org/pdf/2208.05424.pdf\n\nAbstract: *The availability of reliable, high-resolution climate and weather data is important to inform long-term decisions on climate adaptation and mitigation and to guide rapid responses to extreme events. Forecasting models are limited by computational costs and, therefore, often generate coarse-resolution predictions. Statistical downscaling can provide an efficient method of upsampling low-resolution data. In this field, deep learning has been applied successfully, often using image super-resolution methods from computer vision. However, despite achieving visually compelling results in some cases, such models frequently violate conservation laws when predicting physical variables. In order to conserve physical quantities, we develop methods that guarantee physical constraints are satisfied by a deep learning downscaling model while also improving their performance according to traditional metrics. We compare different constraining approaches and demonstrate their applicability across different neural architectures as well as a variety of climate and weather data sets. While our novel methodologies enable faster and more accurate climate predictions, we also show how they can improve super-resolution for satellite data and standard data sets.*\n\n## Setup\n\nClone the repository and install the requirements\n```sh\n$ git clone https://github.com/RolnickLab/constrained-downscaling.git\n$ cd constrained-downscaling\n$ conda env create -f requirements.yml\n$ conda activate constrained-ds\n```\n\n## Get the data\n\nOne of our main data sets, ERA5 total columnt water, 4x upsampling, can be downloaded in a ML-ready form at: https://drive.google.com/file/d/1IENhP1-aTYyqOkRcnmCIvxXkvUW2Qbdx/view?usp=sharing\n\nYou can use wget:\n```sh\n$ wget --load-cookies /tmp/cookies.txt \"https://docs.google.com/uc?export=download\u0026confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download\u0026id=1IENhP1-aTYyqOkRcnmCIvxXkvUW2Qbdx' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\\1\\n/p')\u0026id=1IENhP1-aTYyqOkRcnmCIvxXkvUW2Qbdx\" -O era5_sr_data.zip \u0026\u0026 rm -rf /tmp/cookies.txt\n```\n\nthen unzip\n```sh\n$ mkdir data/\n$ unzip -o era5_sr_data.zip -d data/\n$ rm era5_sr_data.zip \n```\n\nOther data sets are available upon request from the author or can be generated by using public sources for ERA5 (https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-single-levels?tab=form.) and NorESM (https://esgf-index1.ceda.ac.uk/search/cmip6-ceda/) data.\n\n\n## Run training \n\nTo run our standard CNN withour constrained run\n\n```sh\n$ python main.py --dataset era5_sr_data --model cnn --model_id twc_cnn_noconstraints --constraints none\n```\n\nto run with softmax constraining (hard constraining) run\n\n```sh\n$ python main.py --dataset era5_sr_data --model cnn --model_id twc_cnn_softmaxconstraints --constraints softmax\n```\n\nto run with soft constraining run, with a factor of alpha run\n\n```sh\n$ python main.py --dataset era5_sr_data --model cnn --model_id twc_cnn_softconstraints --constraints soft --loss mass_constraints --alpha 0.99\n```\n\nFor other setups: \n--model can be either cnn, gan, convgru, flowconvgru (last two require different data sets)\n--constraints can be none, softmax, scadd, mult, add, soft\nother arguents are --epochs, --lr (learning rate), --number_residual_blocks, --weight_decay\n\n## Run inference\n\nAn example evaluation for the unconstrained model:\n\n```sh\n$ python main.py --training_evalonly evalonly --dataset era5_sr_data --model cnn --model_id twc_cnn_noconstraints --constraints none\n```\n\nIt produces a csv file with all metrics on either validation or test set.\n\n## Citation\n\nIf you find this repository helpful please consider to cite our work\n\n    @misc{harder2022,\n    author = {Harder, Paula and Yang, Qidong and Ramesh, Venkatesh and Sattigeri, Prasanna and Hernandez-Garcia, Alex and Watson, Campbell and Szwarcman, Daniela and Rolnick, David},\n      title = {Generating physically-consistent high-resolution climate data with hard-constrained neural networks},\n      publisher = {arXiv}, \n      year = {2022}\n    }\n    \n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulaharder%2Fconstrained-downscaling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulaharder%2Fconstrained-downscaling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulaharder%2Fconstrained-downscaling/lists"}