Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

Commit

Permalink
Move code around
Browse files Browse the repository at this point in the history
  • Loading branch information
simnh committed Nov 6, 2016
1 parent d404551 commit 6ac05c2
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 33 deletions.
9 changes: 7 additions & 2 deletions hesysopt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def simulate(es=None, **arguments):

om.solve(arguments['--solver'],
solve_kwargs={'tee':arguments['--solver-output']},
cmdline_options= {"mipgap":0.0})
cmdline_options= {"mipgap":arguments.get('--mipgap', 0)})

om.results()

Expand All @@ -132,6 +132,11 @@ def write_results(es, om, **arguments):

return df

def dump_energysystem(es, **arguments):
"""
"""
dump_path = os.path.join(arguments['--output-directory'])
es.dump(dpath=dump_path, filename='heatingsystem.pkl')

def main_path(**arguments):
"""Sets the main path for the simulation results, lpfiles etc.
Expand Down Expand Up @@ -177,7 +182,7 @@ def main(**arguments):
############################## main ###########################################
if __name__ == '__main__':
arguments = docopt(__doc__, version='HESYSOPT v0.0.1')
es, om, df = main(**arguments)
#es, om, df = main(**arguments)



Expand Down
16 changes: 0 additions & 16 deletions hesysopt/plots/sorted_curve.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import matplotlib.pyplot as plt
plt.style.use('ggplot')

scenarios = ['base']
scenarios = ['1HBP', '2HBP', '4HBP']
homepath = os.path.expanduser('~')

main_df = pd.DataFrame()
Expand All @@ -25,24 +25,23 @@
tmp['Scenario'] = s
main_df = pd.concat([main_df, tmp])

main_df.rename(columns={'bus_label':'Balance',
'type':'Direction',
'obj_label':'Unit',
'datetime': 'Date'}, inplace=True)

# restore orginial df multiindex
main_df.set_index(['Scenario', 'Balance', 'Direction', 'Unit', 'Date'],
main_df.set_index(['Scenario', 'bus_label', 'type', 'obj_label', 'datetime'],
inplace=True)

# set colors
components = main_df.index.get_level_values('Unit').unique()
components = main_df.index.get_level_values('obj_label').unique()
colors = dict(zip(components,
sns.color_palette("coolwarm_r", len(components))
)
)
sns.color_palette("coolwarm_r", len(components))))

# select heat flows from main_df
idx = pd.IndexSlice
heat_df = main_df.loc[idx[scenarios, 'heat_balance', 'to_bus', :, :]].unstack([0, 1, 2, 3])
heat_df.columns = heat_df.columns.droplevel([0, 2, 3])
heat_df.columns.name = 'Unit'
heat_df = main_df.loc[idx[scenarios,
'heat_balance',
'to_bus', :, :]].unstack(['Scenario', 'obj_label'])
heat_df.columns = heat_df.columns.droplevel([0])
heat_df.columns.name = 'Unit'

el_df = main_df.loc[idx[scenarios,
'electrical_balance',
'to_bus', :, :]].unstack(['Scenario', 'obj_label'])
34 changes: 34 additions & 0 deletions hesysopt/timesampling-study/postprocessing/sorted_curve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-
from hesysopt.plots.config import heat_df, colors, pd

df = heat_df['4HBP']
# filling for
df.fillna(method='ffill', inplace=True)
dct = {c: df.sort_values(by=c, ascending=False)[c].values for c in df}
df_sorted = pd.DataFrame(dct, columns=df.columns)
axes = df_sorted.plot(lw=2, title='Sorted heat curves',
colors=list(map(colors.get, df.columns)))
axes.set_xlabel('Hours')
axes.set_ylabel('Heat in MW')


#fig1 = plt.figure(1)
#fig1 = df.sum().plot(kind="bar", color=list(map(colors.get, df.columns)))

#
from bokeh.charts import show, output_file, Step
heat_df.columns = heat_df.columns.swaplevel(0,1)

df = heat_df['BP1']
df.index = df.index.droplevel([0,1])
# filling for
df.fillna(method='ffill', inplace=True)


dct = {c: df.sort_values(by=c, ascending=False)[c].values for c in df}
area2 = Step(dct,
title="Heat Production", legend="top_left", xlabel='Date',
ylabel='Heat in MWh')

output_file("area.html", title="HESYSOPT Results")
show(area2)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
version=hesysopt.__version__,
url='http://github.com/znes/HESYSOPT',
author='Simon Hilpert',
author_email='simon.hilpert@hs-flensburg.de',
author_email='simon.hilpert@uni-flensburg.de',
description='HESYSOPT - Open source heating system optimization tool.',
namespace_package = ['hesysopt'],
packages=find_packages(),
Expand Down

0 comments on commit 6ac05c2

Please sign in to comment.