Skip to content

Commit

Permalink
Fix crash when erroneous hydro input
Browse files Browse the repository at this point in the history
Passing the wrong parameter in Hydroscheduling was causing an Exception as `temp` was never defined.
  • Loading branch information
kavvkon committed Feb 6, 2020
1 parent dd616a6 commit 5d59091
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions dispaset/preprocessing/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def mid_term_scheduling(config, zones, profiles=None):
# Day/hour corresponding to the first and last days of the simulation:
# Note that the first available data corresponds to 2015.01.31 (23.00) and the
# last day with data is 2015.12.31 (22.00)
import pickle
y_end, m_end, d_end, _, _, _ = config['StopDate']
config['StopDate'] = (y_end, m_end, d_end, 23, 59, 00) # updating stopdate to the end of the day

Expand Down Expand Up @@ -154,8 +155,8 @@ def mid_term_scheduling(config, zones, profiles=None):
temp = temp.set_index(idx)
temp = temp.rename(columns={col: col.split(' - ')[1] for col in temp.columns})
else:
logging.info('Mid term scheduling turned off')
import pickle
logging.error('HydroScheduling parameter should be either "Regional" or "Zonal" (case sensitive). ')
sys.exit()
pickle.dump(temp, open("temp_profiles.p", "wb"))
return temp

Expand All @@ -176,4 +177,4 @@ def get_temp_sim_results(config, gams_dir=None):
verbose=True)
results['OutputStorageLevel'] = results['OutputStorageLevel'].reindex(list(range(results['OutputStorageLevel'].index.min(),
results['OutputStorageLevel'].index.max() + 1)), fill_value=0)
return results
return results

0 comments on commit 5d59091

Please sign in to comment.