modex-flexmex / oemof-flexmex

oemof-flexmex is an oemof model built for model comparison within the Modex project FlexMex.
https://oemof-flexmex.readthedocs.io
MIT License
0 stars 0 forks source link

Export component and bus sequences #167

Closed jnnr closed 3 years ago

jnnr commented 3 years ago

With this PR, the postprocessing does not only export timeseries for each bus, but also timeseries for each component type.

monika-o commented 3 years ago

I get the following error message when executing the postprocessing rule:

Traceback (most recent call last): File "scripts/postprocessing.py", line 27, in run_postprocessing(scenario_specs, paths) File "/home/.../oemof-flexmex/oemof_flexmex/postprocessing.py", line 1189, in run_postprocessing df_re_generation = aggregate_re_generation_timeseries(sequences_by_tech) File "/home/.../oemof-flexmex/oemof_flexmex/postprocessing.py", line 1033, in aggregate_re_generation_timeseries df_renewable_sum = df_renewable.groupby(['region'], axis=1).sum() File "/home/.../anaconda3/envs/oemof-flexmex/lib/python3.6/site-packages/pandas/core/generic.py", line 7894, in groupby kwargs File "/home/.../anaconda3/envs/oemof-flexmex/lib/python3.6/site-packages/pandas/core/groupby/groupby.py", line 2522, in groupby return klass(obj, by, kwds) File "/home/.../anaconda3/envs/oemof-flexmex/lib/python3.6/site-packages/pandas/core/groupby/groupby.py", line 391, in init mutated=self.mutated, File "/home/.../anaconda3/envs/oemof-flexmex/lib/python3.6/site-packages/pandas/core/groupby/grouper.py", line 621, in _get_grouper raise KeyError(gpr) KeyError: 'region'

Does this error also occur to you or do you know it, @jnnr ?

monika-o commented 3 years ago

It works for me if I change line 1033 in the postprocessing file from df_renewable_sum = df_renewable.groupby(['region'], axis=1).sum() to df_renewable_sum = df_renewable.groupby(level = ['region'], axis=1).sum().

jnnr commented 3 years ago

It works for me if I change line 1033 in the postprocessing file from df_renewable_sum = df_renewable.groupby(['region'], axis=1).sum() to df_renewable_sum = df_renewable.groupby(level = ['region'], axis=1).sum().

Have you checked if this leads to the correct results? If you call groupby in the original way, the keyword would be by, not level.

monika-o commented 3 years ago

It works for me if I change line 1033 in the postprocessing file from df_renewable_sum = df_renewable.groupby(['region'], axis=1).sum() to df_renewable_sum = df_renewable.groupby(level = ['region'], axis=1).sum().

Have you checked if this leads to the correct results? If you call groupby in the original way, the keyword would be by, not level.

I am not sure where the difference would occur. But the resulting scalars for RE production remain the same. An when looking into df_renewable and df_renewable_sum during execution, the code also does what it should (adding up the RE production by country). Replacing "level" by "by" in the code results (unsurprisingly) in the same key error as occurred initially.

monika-o commented 3 years ago

The above-mentioned error disappeared when I used pandas 1.1.0 (prior to that I used either version 0.24 or 0.25).