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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a1efb82
initial changes
finozzifa Jun 15, 2024
ace2f20
initial unified draft of download_gadm
finozzifa Jun 18, 2024
751509e
add unit tests for get_gadm_url
finozzifa Jun 18, 2024
8076454
changes to _helpers.py and test_helpers.py
finozzifa Jun 19, 2024
657da17
new unit test
finozzifa Jun 19, 2024
9599d11
comment out biogeo test
finozzifa Jun 19, 2024
c3956cf
finalize test
finozzifa Jun 19, 2024
ed26c59
enhance download_gadm unit test
finozzifa Jun 20, 2024
9bf40dd
initial changes to get_gadm_layer
finozzifa Jun 20, 2024
e6ed853
work on get_gadm_layer
finozzifa Jun 20, 2024
c432cb8
merge from upstream main
finozzifa Jul 1, 2024
951e6c8
changes to _helpers.py locate_bus
finozzifa Jul 1, 2024
7413e4e
add exception message
finozzifa Jul 2, 2024
3e9b7bb
use in build_shapes, methods from the _helpers.py
finozzifa Jul 2, 2024
1551e8a
add new configs
finozzifa Jul 2, 2024
bfe67bb
update unit tests
finozzifa Jul 2, 2024
e5ff672
merge from oet_main
finozzifa Jul 2, 2024
2bb1ed1
keep only version gadm 4.1
finozzifa Jul 3, 2024
db5f2a2
upgrade actions from v2 to v3
finozzifa Jul 3, 2024
49c06ce
upgrade setup-miniconda@v2 to setup-miniconda@v3
finozzifa Jul 3, 2024
0a7fe5e
changes to workflow files
finozzifa Jul 3, 2024
dc36d01
remove get_gadm_country_code
finozzifa Jul 4, 2024
09b818f
remove ipopt version requirement
finozzifa Jul 4, 2024
b5baee0
change to unit test
finozzifa Jul 4, 2024
4af46c8
remove use_zip_file
finozzifa Jul 4, 2024
a471ee9
str filename in prepare_network
finozzifa Jul 4, 2024
ddc7019
modify download_emission_data
finozzifa Jul 4, 2024
f5cb664
re-add limitation to ipopt version
finozzifa Jul 4, 2024
4946a49
add mac specific environment file
finozzifa Jul 4, 2024
3c2bd3c
generalize configs
finozzifa Jul 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: pypsa-earth
use-mamba: true

- name: Create environment cache
uses: actions/cache@v2
uses: actions/cache@v3
id: cache
with:
path: ${{ matrix.prefix }}
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/ci-mac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,31 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

# - name: Add solver to environment
# run: |
# echo -e "- glpk\n- ipopt<3.13.3" >> envs/environment.yaml

- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: pypsa-earth
use-mamba: true

- name: Create environment cache
uses: actions/cache@v2
uses: actions/cache@v3
id: cache
with:
path: ${{ matrix.prefix }}
key: ${{ matrix.label }}-conda-${{ hashFiles('envs/environment.yaml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}
key: ${{ matrix.label }}-conda-${{ hashFiles('envs/environment.mac.yaml') }}-${{ env.DATE }}-${{ env.CACHE_NUMBER }}

- name: Update environment due to outdated or unavailable cache
if: steps.cache.outputs.cache-hit != 'true'
run: mamba env update -n pypsa-earth -f envs/environment.yaml
run: mamba env update -n pypsa-earth -f envs/environment.mac.yaml

- name: Conda list
run: |
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/ci-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,23 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3

# - name: Add solver to environment
# run: |
# echo -e "- glpk\n- ipopt<3.13.3" >> envs/environment.yaml

- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: pypsa-earth
use-mamba: true

- name: Create environment cache
uses: actions/cache@v2
uses: actions/cache@v3
id: cache
with:
path: ${{ matrix.prefix }}
Expand Down
2 changes: 2 additions & 0 deletions config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ build_shape_options:
worldpop_method: "standard" # "standard" pulls from web 1kmx1km raster, "api" pulls from API 100mx100m raster, false (not "false") no pop addition to shape which is useful when generating only cutout
gdp_method: "standard" # "standard" pulls from web 1x1km raster, false (not "false") no gdp addition to shape which useful when generating only cutout
contended_flag: "set_by_country" # "set_by_country" assigns the contended areas to the countries according to the GADM database, "drop" drops these contended areas from the model
gadm_file_prefix: "gadm41_"
gadm_url_prefix: "https://geodata.ucdavis.edu/gadm/gadm4.1/gpkg/"

clean_osm_data_options: # osm = OpenStreetMap
names_by_shapes: true # Set the country name based on the extended country shapes
Expand Down
4 changes: 3 additions & 1 deletion config.tutorial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ countries: ["NG", "BJ"]
#["NG"] # Nigeria
#["NE"] # Niger
#["SL"] # Sierra Leone
#["MA"] # Morroco
#["MA"] # Morocco
#["ZA"] # South Africa

enable:
Expand Down Expand Up @@ -108,6 +108,8 @@ build_shape_options:
worldpop_method: "standard" # "standard" pulls from web 1kmx1km raster, "api" pulls from API 100mx100m raster, false (not "false") no pop addition to shape which is useful when generating only cutout
gdp_method: "standard" # "standard" pulls from web 1x1km raster, false (not "false") no gdp addition to shape which useful when generating only cutout
contended_flag: "set_by_country" # "set_by_country" assigns the contended areas to the countries according to the GADM database, "drop" drops these contended areas from the model
gadm_file_prefix: "gadm41_"
gadm_url_prefix: "https://geodata.ucdavis.edu/gadm/gadm4.1/gpkg/"

clean_osm_data_options:
names_by_shapes: true # Set the country name based on the extended country shapes
Expand Down
87 changes: 87 additions & 0 deletions envs/environment.mac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# SPDX-FileCopyrightText: PyPSA-Earth and PyPSA-Eur Authors
#
# SPDX-License-Identifier: AGPL-3.0-or-later

name: pypsa-earth
channels:
- conda-forge
- bioconda
- gurobi
dependencies:
- python>=3.8
- pip
- mamba # esp for windows build

- pypsa>=0.24, <0.25
# - atlite>=0.2.4 # until https://github.com/PyPSA/atlite/issues/244 is not merged
- dask
- powerplantmatching>=0.5.7
- earth-osm>=2.1
- atlite

# Dependencies of the workflow itself
- xlrd
- openpyxl
- seaborn
- snakemake-minimal<8
- memory_profiler
- ruamel.yaml<=0.17.26
- pytables
- lxml
- numpy
- pandas
- geopandas>=0.11.0, <=0.14.3
- fiona!=1.8.22
- xarray>=2023.11.0, <2023.12.0
- netcdf4
- networkx
- scipy
- pydoe2
- shapely!=2.0.4
- pre-commit
- pyomo
- matplotlib<=3.5.2
- reverse-geocode
- country_converter
- pyogrio
- numba
- py7zr

# Keep in conda environment when calling ipython
- ipython
# Jupyter notebook requirement
- ipykernel
- jupyterlab

# GIS dependencies:
- cartopy
- descartes
- rasterio!=1.2.10
- rioxarray

# Plotting
- geoviews
- hvplot
- graphviz
- contextily
- graphviz

# PyPSA-Eur-Sec Dependencies
- geopy
- tqdm
- pytz
- country_converter

# Cloud download
# - googledrivedownloader # Commented until https://github.com/ndrplz/google-drive-downloader/pull/28 is merged: PR installed using pip

# Default solver for tests (required for CI)
- glpk
- ipopt
- gurobi

- pip:
- git+https://github.com/davide-f/google-drive-downloader@master # google drive with fix for virus scan
- git+https://github.com/FRESNA/vresutils@master # until new pip release > 0.3.1 (strictly)
- tsam>=1.1.0
- chaospy # lastest version only available on pip
Loading
Loading