PyPSA-KZ
Aims to model the Kazakh power system, incorporating a substantial increase in variable generation, such as solar and wind, surpassing the current official mid-term policy goal of 15% of all renewable energy sources in generation by 2030.
https://github.com/pypsa-meets-earth/pypsa-kz-data
Category: Energy Systems
Sub Category: Global and Regional Energy System Models
Keywords from Contributors
energy-system energy-system-model linopy energy-model scenario-analysis pypsa-earth pypsa-africa power-system-planning power-system-model operational-optimization
Last synced: about 6 hours ago
JSON representation
Repository metadata
Extra data for Kazakhstan model that will be used as input for PyPSA-Earth
- Host: GitHub
- URL: https://github.com/pypsa-meets-earth/pypsa-kz-data
- Owner: pypsa-meets-earth
- Created: 2023-04-12T08:20:12.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-11T17:21:48.000Z (9 months ago)
- Last Synced: 2025-04-13T12:11:28.621Z (15 days ago)
- Language: Python
- Size: 754 KB
- Stars: 7
- Watchers: 0
- Forks: 17
- Open Issues: 1
- Releases: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSES/AGPL-3.0-or-later.txt
README.md
About the Project
Agora Energiewende aims to model the Kazakh power system, incorporating a substantial increase in variable generation, such as solar and wind, surpassing the current official mid-term policy goal of 15% of all renewable energy sources (RES) in generation by 2030. This endeavor has received support from Open Energy Transition on the modeling side.
Used for 2024 study, "Modernising Kazakhstan’s coal-dependent power sector through renewables - Challenges, solutions and scenarios up to 2030 and beyond"
Development status: Active and Stable
PyPSA-KZ-Data
Extra data for the Kazakhstan model that will be used as input for PyPSA-Earth.
Repo design oriented on: https://github.com/pypsa-meets-earth/pypsa-zm-data
Data
Contains openly available data for Kazakhstan
Demand data
Monthly electricity demand data with monthly aggregation provided by Kazakhstan operator of the electric energy and power market
kz_demand_validation.csv
(demand_valid_clean.R
contains for details on how data were extracted and a simple vizualization; needs to work any R terminal + installation of two libraries)
Model Execution
Setting up the general repositories
The provided workflow builds on PyPSA-Earth. Therefore, first, the PyPSA-Earth repository must be forked and the fork should then be cloned. A fork can be created by navigating to the PyPSA-Earth website. By clicking on the fork-symbol in the upper right corner, a fork is created and linked to the specific user. While making a fork, unclick Copy the main branch only
option to fork all branches and tags of pypsa-earth
repository.
Next, we also need to fork the pypsa-kz-data repository. A fork can be created by navigating to the pypsa-kz-data website and clicking the fork symbol in the upper right corner.
In order to clone both forks to the correct locations on a local machine, the following commands can be used using the local machines shell:
git clone https://github.com/<user-name>/pypsa-earth
<user-name>
must be replaced with the personal github-username.
After that, one must change to the freshly created pypsa-earth repository.
cd pypsa-earth/
Switch to the stable v0.4.0
version of pypsa-earth
that is compatible with pypsa-kz-data
repository:
git checkout tags/v0.4.0
Repeat the cloning, this time for the pypsa-kz-data repository.
git clone https://github.com/<user-name>/pypsa-kz-data
Again, <user-name>
must be replaced with the personal github-username.
In order to install the pypsa-earth environment, instructions are provided in the pypsa-earth documentation, see Install dependencies
and Python dependencies
.
After installing the environment, activate it using
conda activate pypsa-earth
Modeling adaptations for KZ study
To adapt the overall workflow for kz, only two further changes are necessary.
Firstly, open the Snakefile (in pypsa-earth/
) and navigate to line 1071-1072, which should read
os.system("snakemake -j all solve_all_networks --rerun-incomplete")
os.system("snakemake -j1 make_statistics --force")
and replace these two lines with
os.system(f"snakemake -j1 networks/{wildcards.scenario_name}/base.nc")
os.system("cp pypsa-kz-data/data/custom_powerplants.csv data/custom_powerplants.csv")
os.system("snakemake -j1 solve_everything --rerun-incomplete")
Secondly, copy the default configuration file to the pypsa-earth folder using:
cp pypsa-kz-data/config.kz_default.yaml config.default.yaml
In case you already have a custom config file, make sure to replace it as well, using
cp pypsa-kz-data/config.kz_default.yaml config.yaml
Note! Run two aforementioned commands in pypsa-earth
directory.
You are now all set to run all scenarios!
Running KZ scenarios
To prepare running all scenarios, execute
snakemake -j1 prepare_kz_scenarios
Optionally, to save time for future runs, you can now set enable: retrieve_databundle: True
in the config.yaml
to False
. If you already have build all cutouts for 2011, 2013 and 2018, you can also set enable: build_cutout: True
to False
.
Finally, to run all scenarios, execute
snakemake -j1 run_all_scenarios
After all scenarios have executed successfully, all results are generated and locally saved in pypsa-earth/results/<scenario_folder>/networks/
.
Potential errors
-
A rule is killed. In this case, open the
Snakefile
inpypsa-earth
or openkz.smk
inpypsa-kz-data
(depending on the rule which is killed), navigate to the rule that is being killed in the workflow and increase the memory assignment (for example, add a 0 at the end). -
The workflow runs into an error during the
build_powerplants
rule. In this case, try to repeat step 1. of the workflow using the command
cp pypsa-kz-data/data/custom_powerplants.csv data/custom_powerplants.csv
- Unusual error arising from either Snakemake or the
Snakefile
and proving to be challenging to comprehend: Inspect all indentation. Ensure there is no tab spacing; employ only spaces, i.e.,
os.system(f"snakemake -j1 networks/{wildcards.scenario_name}/base.nc")
os.system("cp pypsa-kz-data/data/custom_powerplants.csv data/custom_powerplants.csv")
os.system("snakemake -j1 solve_everything --rerun-incomplete")
are tabs instead of four spaces.
- Missing
data/
folder or some relevant subfolders. This should normally be executed automatically when executing the ruleprepare_kz_scenarios
, however might be missing due to incorrect execution. The databundle can be also retrieved manually via:
snakemake -j 1 retrieve_databundle_light
-
The rule
retrieve_databundle_light
always executes with an error. To avoid this, try settingenable: build_cutout: False
toTrue
. -
Hydrobasins data might not be accessible in some regions (e.g. in Kazakhstan). It is recommended to retrieve the databundle using VPN.
Comes in handy
After all cutouts were generated (i.e. the three files asia-<year>-era5.nc
exist in the folder pypsa-earth/cutouts/
, where <year>
is 2011, 2013, and 2018, navigate to pypsa-earth/pypsa-kz-data
, open the default config file, navigate to line 36, which should read build_cutout: True
, and set it to build_cutout: false
. This will save you a lot of time when (re-)runnig scenarios. But remember to set it back to true
in case one of the cutouts was deleted!
Acknowledgement
Code development and testing:
Open Energy Transition
Model assumptions:
Agora Energiewende
Owner metadata
- Name: PyPSA meets Earth
- Login: pypsa-meets-earth
- Email:
- Kind: organization
- Description: An open source energy system model initiative for our Earth
- Website: https://pypsa-meets-earth.github.io/
- Location:
- Twitter: pypsameetsearth
- Company:
- Icon url: https://avatars.githubusercontent.com/u/84225086?v=4
- Repositories: 11
- Last ynced at: 2023-03-04T04:30:40.464Z
- Profile URL: https://github.com/pypsa-meets-earth
GitHub Events
Total
- Watch event: 1
- Fork event: 1
Last Year
- Watch event: 1
- Fork event: 1
Committers metadata
Last synced: 8 days ago
Total Commits: 197
Total Committers: 5
Avg Commits per committer: 39.4
Development Distribution Score (DDS): 0.279
Commits in past year: 7
Committers in past year: 1
Avg Commits per committer in past year: 7.0
Development Distribution Score (DDS) in past year: 0.0
Name | Commits | |
---|---|---|
yerbol-akhmetov | y****3@g****m | 142 |
martacki | m****i@g****m | 47 |
Max Parzen | m****n@e****k | 5 |
ekatef | e****a@g****m | 2 |
Alfiya | 3****s | 1 |
Committer domains:
- ed.ac.uk: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 1
Total pull requests: 43
Average time to close issues: 7 days
Average time to close pull requests: 3 days
Total issue authors: 1
Total pull request authors: 4
Average comments per issue: 1.0
Average comments per pull request: 0.3
Merged pull request: 32
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 1
Past year average time to close issues: N/A
Past year average time to close pull requests: 7 days
Past year issue authors: 0
Past year pull request authors: 1
Past year average comments per issue: 0
Past year average comments per pull request: 3.0
Past year merged pull request: 1
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- martacki (1)
Top Pull Request Authors
- yerbol-akhmetov (30)
- martacki (10)
- alfiyaks (2)
- ekatef (1)
Top Issue Labels
Top Pull Request Labels
Dependencies
- actions/cache v2 composite
- actions/checkout v2 composite
- conda-incubator/setup-miniconda v2 composite
Score: 3.688879454113936