PyPSA / pypsa-eur

PyPSA-Eur: A Sector-Coupled Open Optimisation Model of the European Energy System
https://pypsa-eur.readthedocs.io/
338 stars 238 forks source link

Write a check_config.py with basic config assertions #158

Open FabianHofmann opened 4 years ago

FabianHofmann commented 4 years ago

After tackling some issues with the spatial and temporal cutout bounds, it seemed sensible to add a dedicated script which reviews the config and basic ressources created during the work flow.

To start with: we should add an assertion for the following for

FabianHofmann commented 4 years ago

This is the current bounding box for all grid cells (default config) and the offshore area, it seems not right that some of the offshore area remains uncovered. However I still have to figure out how the maximal distance of wind turbines plays out here. geomap

FabianHofmann commented 4 years ago

After a small discussion with @euronion we agreed that it would be better to double check such configuration manners in a dedicated file.

Such would be named check_config.py and would contain basic assertions for consistency and validation. Atm for such a case as above where you to double check a ressource, it would probably contain function which you called here.

fneum commented 4 years ago

Could be called in Snakefile after

https://github.com/PyPSA/pypsa-eur/blob/4d0a86024646f3a468c4fcb6c40dc435b8ab11f5/Snakefile#L11-L12

configfile: "config.yaml"

assert check_config(config), "Configfile not correct."

With function definition either directly in Snakefile or imported from separate file (like scripts/_helpers.py).

euronion commented 3 years ago

In the PR we came across options in config.yaml which became deprecated. It would be a nice addition to have the check_config(...) also warn about options in the config file which are deprecated (or soon will) and are thus without effect.

euronion commented 3 years ago

snakemake offers some basic config validation using a JSON file (details). This could partially take care of validation (correct structure and types), deprecation and consistency validation between options cannot be outsoured to this functionality (I think).