rl-institut / oemof-B3

An open-source energy system model for Brandenburg/Berlin.
https://oemof-b3.readthedocs.io/
GNU Affero General Public License v3.0
9 stars 5 forks source link

Features/add empty ts #325

Closed MaGering closed 1 year ago

MaGering commented 1 year ago

With this PR it is possible to create empty time series in the directory raw/time_series.

Empty means in this case, that the time series contain either "0" or "nan" as values. This can be set via create_empty_ts.ts_values in settings.yaml.

The docs have been updated.

To test the new functionality run:

snakemake -j1 create_empty_ts

Before you need to install oemof-B3 according to docs and download raw directory with:

snakemake -j1 download_raw_data
MaGering commented 1 year ago

Thanks for your review @chrwm!

  • When running the the script with snakemake -j1 create_empty_ts and zeros in settings.yaml the files are created as expected with zeros in the series column. When running the script again with empty the files are not created. Only deletion of existing files leads to new creation with NaNs in series column. The same applies the other way around. Not sure if this is intended.

I introduced a variable overwrite in settings.yaml with commit https://github.com/rl-institut/oemof-B3/pull/325/commits/73160f56083d73e34e9627999a7c9be2e2722564. It let's you the option to overwrite the empty time series if set to true

  • The var_name column is filled with placeholders from the scenario data. I assume you indended this to provide example parameter names ?

Yes, thanks for checking. This is intended. However the loop over scenarios has been broken, thank you @Stefanie08 for finding this! :) I fixed it with commit https://github.com/rl-institut/oemof-B3/pull/325/commits/dcdd9fc88953193d301a67aab83b6ffc0fec8d49. Now the respective time series is updated with each scenario and in the end all duplicates are dropped, so that only unique time series are saved. Also I switched to retrieve the start of the date time from the filter instead from the scenario specification with commit https://github.com/rl-institut/oemof-B3/pull/325/commits/74738b51ecc9107453ef0acce1276b9cc626c378.

  • I'd recommend to write a small unit test.

Yes, that would certainly be good. Unfortunately, we did not do that consistently in oemof-B3. Due to time constraints, I would not do that at this point.

MaGering commented 1 year ago

@Stefanie08 could you test my changes? Try to see if anything else can be broken. :-D

With

snakemake -j1 create_empty_ts -f

you can make a force run with snakemake. This means that output will be produced even if it is already there. Please check if it conforms to the logic behind overwrite in settings.yaml.

chrwm commented 1 year ago

After pulling your latest changes, when running snakemake -j1 create_empty_ts, I get

The flag 'directory' used in rule create_empty_scalars is only valid for outputs, not inputs.
CRITICAL - The flag 'directory' used in rule create_empty_scalars is only valid for outputs, not inputs.
The flag 'directory' used in rule create_empty_ts is only valid for outputs, not inputs.
CRITICAL - The flag 'directory' used in rule create_empty_ts is only valid for outputs, not inputs.
Building DAG of jobs...
WARNING - Building DAG of jobs...
Nothing to be done (all requested files are present and up to date).
WARNING - Nothing to be done (all requested files are present and up to date).
Complete log: .snakemake\log\2023-04-24T181312.420508.snakemake.log
WARNING - Complete log: .snakemake\log\2023-04-24T181312.420508.snakemake.log

with snakemake -j1 create_empty_ts -f it works though

MaGering commented 1 year ago

Thanks for the rereview @chrwm! :)

After pulling your latest changes, when running snakemake -j1 create_empty_ts, I get

The flag 'directory' used in rule create_empty_scalars is only valid for outputs, not inputs.
CRITICAL - The flag 'directory' used in rule create_empty_scalars is only valid for outputs, not inputs.
The flag 'directory' used in rule create_empty_ts is only valid for outputs, not inputs.
CRITICAL - The flag 'directory' used in rule create_empty_ts is only valid for outputs, not inputs.
Building DAG of jobs...
WARNING - Building DAG of jobs...
Nothing to be done (all requested files are present and up to date).
WARNING - Nothing to be done (all requested files are present and up to date).
Complete log: .snakemake\log\2023-04-24T181312.420508.snakemake.log
WARNING - Complete log: .snakemake\log\2023-04-24T181312.420508.snakemake.log

This is because you already created the empty ts. The respective files already exist in oemof-B3/raw/time_series dir. If you want to run this and other snakemake prompts without getting Nothing to be done (all requested files are present and up to date). you'll have to delete the files first.

with snakemake -j1 create_empty_ts -f it works though

This is because the force flag -f neglects the fact that the files already exist.