Skip to content

Commit

Permalink
Improved warning messages in case of unmatched unit names
Browse files Browse the repository at this point in the history
  • Loading branch information
squoilin committed Apr 4, 2017
1 parent 1901ef2 commit d63fd92
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions DispaSET/preprocessing/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
import pandas as pd


def merge_series(plants, data, mapping, method='WeightedAverage'):
def merge_series(plants, data, mapping, method='WeightedAverage', tablename=''):
"""
Function that merges the times series corresponding to the merged units (e.g. outages, inflows, etc.)
:param plants: Pandas dataframe with the information relative to the original units
:param data: Pandas dataframe with the time series and the original unit names as column header
:param mapping: Mapping between the merged units and the original units. Output of the clustering function
:param method: Select the merging method ('WeightedAverage'/'Sum')
:param tablename: Name of the table being processed (e.g. 'Outages'), used in the warnings
:return merged: Pandas dataframe with the merged time series when necessary
"""

Expand Down Expand Up @@ -50,10 +51,14 @@ def merge_series(plants, data, mapping, method='WeightedAverage'):
else:
logging.critical('Method "' + str(method) + '" unknown in function MergeSeries')
sys.exit(1)
elif key in plants['Unit']:
if not type(
key) == tuple: # if the columns header is a tuple, it does not come from the data and has been added by Dispa-SET
logging.warn('Column ' + str(key) + ' present in the table "' + tablename + '" not found in the mapping between original and clustered units. Skipping')
else:
if not type(
key) == tuple: # if the columns header is a tuple, it does not come from the data and has been added by Dispa-SET
logging.warn('Column ' + str(key) + ' not found in the mapping between original and clustered units. Skipping')
logging.warn('Column ' + str(key) + ' present in the table "' + tablename + '" not found in the table of power plants. Skipping')
return merged


Expand Down
6 changes: 3 additions & 3 deletions DispaSET/preprocessing/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ def build_simulation(config):
Outages[oldname] = Outages[('all', Plants_merged['Technology'][newname])]

# Merging the time series relative to the clustered power plants:
ReservoirScaledInflows_merged = merge_series(plants, ReservoirScaledInflows, mapping, method='WeightedAverage')
ReservoirLevels_merged = merge_series(plants, ReservoirLevels, mapping)
Outages_merged = merge_series(plants, Outages, mapping)
ReservoirScaledInflows_merged = merge_series(plants, ReservoirScaledInflows, mapping, method='WeightedAverage', tablename='ScaledInflows')
ReservoirLevels_merged = merge_series(plants, ReservoirLevels, mapping, tablename='ReservoirLevels')
Outages_merged = merge_series(plants, Outages, mapping, tablename='Outages')

# %%
# checking data
Expand Down
2 changes: 1 addition & 1 deletion Docs/workflow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ To run the pre-processing tool with this configuration file, 2 options are avail

python dispacli.py -c ./ConfigFiles/ConfigTest.xlsx build

* From a python IDE (e.g. Spyder), specifying the configuration file. Configure the "DispaSet.py" file to be run with the command line option "-b ConfigFiles/ConfigTest.xlsx". The figure below shows the "Run Settings" dialog properly configure for Spyder.
* It also possible to run the command line interface from a python IDE (e.g. Spyder), specifying the configuration file. Configure the "DispaSet.py" file to be run with the command line option "-b ConfigFiles/ConfigTest.xlsx". The figure below shows the "Run Settings" dialog properly configure for Spyder. Note that this is not recommended. Some running scripts are available in the corresponding directory to be run from and IDE.

.. image:: figures/spyder_config.png

Expand Down

0 comments on commit d63fd92

Please sign in to comment.