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

Preprocessing: Create profile functions have its own profile name definitions #71

Closed unndreay closed 4 years ago

unndreay commented 4 years ago

This is redundant. The functions should read the component names from components.csv instead and add "_profile" (analogously to building.infer_metadata()) to prevent errors.

Seen at create_hydro_reservoir_profiles(). Respective functions for solar, wind offshore, wind onshore contain even more redundant info.

unndreay commented 4 years ago

More over, there is no error message, if the profile name cannot be found.

The only known error msg is for the file name ('resource'):

17:27:18-INFO-Creating EnergySystem from datapackage
Traceback (most recent call last):
  File "/home/unndreay/Workspaces/oemof-tabular/src/oemof/tabular/datapackage/reading.py", line 378, in deserialize_energy_system
    facade_data = r.read(keyed=True, relations=True)
  File "/home/unndreay/.virtualenvs/oemo-flex/lib/python3.7/site-packages/datapackage/resource.py", line 186, in read
    relations = self.__get_relations()
  File "/home/unndreay/.virtualenvs/oemo-flex/lib/python3.7/site-packages/datapackage/resource.py", line 397, in __get_relations
    if data.tabular:
AttributeError: 'NoneType' object has no attribute 'tabular'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/unndreay/Workspaces/oemo-flex/experiment_1/scripts/FlexMex1_3/runall.py", line 16, in <module>
    optimization.main()
  File "/home/unndreay/Workspaces/oemo-flex/experiment_1/scripts/FlexMex1_3/optimization.py", line 23, in main
    optimize(exp_paths.data_preprocessed, exp_paths.results_optimization)
  File "/home/unndreay/Workspaces/oemo-flex/oemoflex/optimization.py", line 21, in optimize
    attributemap={}, typemap=TYPEMAP,
  File "/home/unndreay/Workspaces/oemof-tabular/src/oemof/tabular/datapackage/reading.py", line 387, in deserialize_energy_system
    ).format(r.name, e)
tableschema.exceptions.LoadError: Could not read data for resource with name `hydro-reservoir`.  Maybe wrong foreign keys?
Exception was: 'NoneType' object has no attribute 'tabular'
jnnr commented 4 years ago

Indeed, the createprofile functions are in part redundant. Most them do the same thing - mapping the path of the profiles in the raw data to the naming convention to oemoflex. For all of those, a single update function together with a mapping would be the more efficient way. But components.csv does not help here I think, because it knows nothing about that mapping.

However, in some cases, some extra calculations are performed, e.g. in create_electricity_bev_profiles.

jnnr commented 4 years ago

More over, there is no error message, if the profile name cannot be found.

This is an issue of oemof.tabular, am I right?

unndreay commented 4 years ago

The initial explanation only addresses a tiny bit of what a solution with mapping can bring. Both the redundant profile identifier definition and the error msg can be solved by is solved with #92.