pypsa-meets-earth / pypsa-earth-sec

GNU General Public License v3.0
18 stars 16 forks source link

Add params as PyPSA-Earth #330

Open davide-f opened 3 weeks ago

energyLS commented 3 weeks ago

Davide:

energyLS commented 3 weeks ago

@Eddy-JV and @energyLS will work on this, @davide-f supports with hints etc.

davide-f commented 3 weeks ago

Davide:

  • Add function argument which includes ??
  • drop snakemake.config and replace by ??

* Add function argument which includes

To add context here, it is common that within functions we have "snakemake.{anything}", for example here https://github.com/pypsa-meets-earth/pypsa-earth-sec/blob/cad684a0734909b995407365810c2c0e98dd687a/scripts/prepare_sector_network.py#L153 for the function add_oil(n, costs)

The recommendation for that case may be for example to revise the arguments as appropriate, like: add_oil(n, oil_reserve [or oil_options], costs) where oil_options is specified in the main as oil_options = snakemake.params["fossil_reserves"] or oil_reserve = snakemake.params["fossil_reserves"].get("oil", 0.0) for example.

* drop snakemake.config and replace by ??

Inside the scripts, as mentioned above, it is typical that we use values in snakemake.config to change the outputs. However, when passed through config, snakemake does not understand that when that parameter is changed, the rule shall be retriggered. To allow that, the object shall be retrieved using snakemake.params instead. To do so, there is the need to add the params field in snakefile for all rules and change the scripts to load parameters from there, See https://github.com/pypsa-meets-earth/pypsa-earth/blob/b23cb9ba07f2f061a71de23cad5293fc42a89990/Snakefile#L150-L153

I'd recommend to start from very simple rules to begin with, definitely not prepare_sector_network