Skip to content

Commit f985e02

Browse files
committed
add print table with cost-benefit results
1 parent 0ff7839 commit f985e02

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

climada/engine/cost_benefit.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import numpy as np
2626
import matplotlib.pyplot as plt
2727
from matplotlib.patches import Rectangle
28+
from tabulate import tabulate
2829

2930
from climada.engine.impact import Impact
3031

@@ -169,6 +170,17 @@ def calc(self, hazard, entity, haz_future=None, ent_future=None, \
169170
risk_func, save_imp)
170171
self._calc_cost_benefit(entity.disc_rates, imp_time_depen)
171172

173+
# print results
174+
print()
175+
norm_fact, norm_name = self._norm_values(np.array(list(self.benefit.values())).max())
176+
headers = ['Measure', 'Cost (' + self.unit + ' ' + norm_name + ')',
177+
'Benefit (' + self.unit + ' ' + norm_name + ')', 'Benefit/Cost']
178+
table = []
179+
for meas_name in self.benefit.keys():
180+
table.append([meas_name, entity.measures.get_measure(meas_name).cost/norm_fact,
181+
self.benefit[meas_name]/norm_fact, 1/self.cost_ben_ratio[meas_name]])
182+
print(tabulate(table, headers, tablefmt="simple"))
183+
172184
def plot_cost_benefit(self):
173185
""" Plot cost-benefit graph. Call after calc()
174186

0 commit comments

Comments
 (0)