Skip to content
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 30 commits into from
Jul 5, 2024
Merged

Conversation

finozzifa
Copy link
Collaborator

@finozzifa finozzifa commented Jul 2, 2024

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

  • pypsa-earth/scripts/build_shapes.py
  • pypsa-earth-sec/scripts/build_shapes.py
  • pypsa-earth-sec/scripts/helpers.py
  • pypsa-earth-sec/scripts/prepare_gas_network.py

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

  • pypsa-earth/scripts/build_shapes.py
  • pypsa-earth-sec/scripts/build_shapes.py
  • pypsa-earth-sec/scripts/prepare_gas_network.py

Methods using GADM 3.6 version data

  • pypsa-earth-sec/scripts/helpers.py

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:

  1. "shapes/country_shapes.geojson"
  2. "shapes/offshore_shapes.geojson"
  3. "shapes/africa_shape.geojson"
  4. "shapes/gadm_shapes.geojson

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:

  • ipopt[version='<3.13.3']`

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 toipopt. 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

  • I consent to the release of this PR's code under the AGPLv3 license and non-code contributions under CC0-1.0 and CC-BY-4.0.
  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Newly introduced dependencies are added to envs/environment.yaml and doc/requirements.txt.
  • Changes in configuration options are added in all of config.default.yaml and config.tutorial.yaml.
  • Add a test config or line additions to test/ (note tests are changing the config.tutorial.yaml)
  • Changes in configuration options are also documented in doc/configtables/*.csv and line references are adjusted in doc/configuration.rst and doc/tutorial.rst.
  • A note for the release notes doc/release_notes.rst is amended in the format of previous release notes, including reference to the requested PR.

@finozzifa finozzifa requested review from FabianHofmann and pz-max July 2, 2024 14:39
@finozzifa finozzifa removed the request for review from pz-max July 4, 2024 13:45
Copy link
Collaborator

@FabianHofmann FabianHofmann left a 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 👍

config.default.yaml Outdated Show resolved Hide resolved
@finozzifa finozzifa merged commit de1ad66 into oet_main Jul 5, 2024
3 checks passed
ekatef pushed a commit that referenced this pull request Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants