pypsa-eur icon indicating copy to clipboard operation
pypsa-eur copied to clipboard

Write a check_config.py with basic config assertions

Open FabianHofmann opened this issue 5 years ago • 5 comments
trafficstars

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

  • all snapshots of the base.nc being in the cutout time selection
  • the whole spatial area is covered be the cutout.bounds

FabianHofmann avatar May 26 '20 12:05 FabianHofmann

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 avatar May 26 '20 12:05 FabianHofmann

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.

FabianHofmann avatar May 27 '20 12:05 FabianHofmann

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

fneum avatar Sep 26 '20 11:09 fneum

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 avatar Mar 06 '21 18:03 euronion

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

euronion avatar Mar 29 '21 14:03 euronion