forked from pypsa-meets-earth/pypsa-earth
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify gadm download and layer #3
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good @finozzifa, I just have one comment which might lead to one or to more changes in the code if applied. Otherwise 👍
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes proposed in this Pull Request
Changes on GADM
This pull requests follows up on the comments made by @pz-max on pull request #2
I noticed that the methos get_GADM_layer and download_GADM are duplicated in
The codes are slightly different and I could pinpoint the cause. It seems in fact that pypsa-earth uses the GADM 4.1 version data, whereas pypsa-earth-sec uses GADM 4.1 version data in build_shapes.py but the GADM 3.6 version data in the helpers. In detail:
Methods using GADM 4.1 version data
Methods using GADM 3.6 version data
I managed to create a unified version of the download_gadm and get_gadm_layer and to unit test what feasible.
Tests performed
On top of the above-mentioned unit tests, I have also executed the CI/CD locally with the code from the main and this branch. In particular, the build_shapes.py script is used in rule build_shapes, which produces as output:
The files obtained from the main branch are available at resources_main_branch.zip and the files obtained from this branch are available at resources_new_branch.zip.
To compare them, I created the notebook shapes_comparison.ipynb.zip.
Additional changes
Upgrade of the Node 16 actions
We used to get the following warning
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v3, actions/cache@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
I solved it by upgrading @v2 to @V3 in the workflows files ci-linux.yaml, ci-windows.yaml and ci-mac.yaml
Creation of a Mac dedicated environment.yaml
In the environment.yaml file we are setting
ipopt[version='<3.13.3']
. This condition works well for Windows and Linux, however in the ci-mac.yaml yields (see this example)` PackagesNotFoundError: The following packages are not available from current channels:
The easiest solution would be to remove the restriction on the ipopt version. If we do so however, ci-linux.yaml and ci-mac.yaml work fine, but the ci-windows.yaml fails (see this example)
WARNING:__main__:The configured solver
glpkdoes not support quadratic objectives. Falling back to
ipopt. WARNING:pyomo.solvers:Could not locate the 'ipopt' executable, which is required for solver ipopt ERROR:_helpers:An error happened in module 'C:\\Users\\runneradmin\\miniconda3\\envs\\pypsa-earth\\lib\\site-packages\\pyomo\\opt\\solver\\shellcmd.py', function 'available': No executable found for solver 'ipopt'
I have therefore introduced a mac-dedicated environment.mac.yaml file where I remove the ipopt version restriction and modified the ci-mac.yaml workflow file to use it.
Checklist
envs/environment.yaml
anddoc/requirements.txt
.config.default.yaml
andconfig.tutorial.yaml
.test/
(note tests are changing the config.tutorial.yaml)doc/configtables/*.csv
and line references are adjusted indoc/configuration.rst
anddoc/tutorial.rst
.doc/release_notes.rst
is amended in the format of previous release notes, including reference to the requested PR.