Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
squoilin committed Apr 24, 2017
1 parent 4ca847f commit 7d35539
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions DispaSET/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging.config
import os

__version__ = "2.2dev"

Expand Down Expand Up @@ -53,6 +54,13 @@
from .postprocessing.postprocessing import get_indicators_powerplant
from .postprocessing.postprocessing import plot_energy_country_fuel

# Removeing log file:
if os.path.isfile('warn.log'):
try:
os.remove('warn.log')
except:
print 'Could not erase previous log file "warn.log"'

# Setting logging configuration:
try:
logging.config.dictConfig(_LOGCONFIG)
Expand Down
5 changes: 4 additions & 1 deletion DispaSET/preprocessing/data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ def merge_series(plants, data, mapping, method='WeightedAverage', tablename=''):
: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
"""

Nunits = len(plants)
plants.index = range(Nunits)
merged = pd.DataFrame(index=data.index)
unitnames = [plants['Unit'][x] for x in mapping['NewIndex']]
# First check the data:
for key in data:
if str(data[key].dtype) not in ['bool','int','float','float16', 'float32', 'float64', 'float128','int8', 'int16', 'int32', 'int64']:
logging.critical('The column "' + key + '" of table + "' + tablename + '" is not numeric!')
for key in data:
if key in unitnames:
i = unitnames.index(key)
Expand Down
2 changes: 1 addition & 1 deletion DispaSET/preprocessing/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ def build_simulation(config,plot_load=False):
logging.info('Build finished')

if os.path.isfile('warn.log'):
shutil.move('warn.log', os.path.join(sim, 'warn_preprocessing.log'))
shutil.copy('warn.log', os.path.join(sim, 'warn_preprocessing.log'))
# %%################################################################################################################
##################################### Plotting load and VRE ################################################
###################################################################################################################
Expand Down
5 changes: 3 additions & 2 deletions DispaSET/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def solve_GAMS(sim_folder, gams_folder=None, output_lst=False):
if os.path.isfile(os.path.join(ws.working_directory, 'debug.gdx')):
logging.warn('A debug file was created. There has probably been an optimization error')
if os.path.isfile('warn.log'):
shutil.move('warn.log', os.path.join(ws.sim_folder, 'warn_solve.log'))
shutil.copy('warn.log', os.path.join(sim_folder, 'warn_solve.log'))
else:
return False

Expand All @@ -108,5 +108,6 @@ def solve_pyomo(sim_folder):
time0 = time.time()
results = DispaSolve(SimData['sets'], SimData['parameters'], LPFormulation=LPFormulation, path_cplex=path_cplex)
logging.info('Completed simulation in {0:.2f} seconds'.format(time.time() - time0))

if os.path.isfile('warn.log'):
shutil.copy('warn.log', os.path.join(sim_folder, 'warn_solve.log'))
return results

0 comments on commit 7d35539

Please sign in to comment.