2 changed files with 122 additions and 0 deletions
@ -0,0 +1,30 @@ |
|||
{ |
|||
"currency": "SEK", |
|||
"legend": ["Installation price", "Heating expenditure"], |
|||
"technologies": [ |
|||
{ |
|||
"label": "Air water heat pump", |
|||
"installation_price": 120000, |
|||
"kwh_expenditure": 11000, |
|||
"kwh_price": 2, |
|||
"percent_inflation": 2, |
|||
"years_lifespan": 15 |
|||
}, |
|||
{ |
|||
"label": "Geothermal heat pump", |
|||
"installation_price": 222788, |
|||
"kwh_expenditure": 5000, |
|||
"kwh_price": 2, |
|||
"percent_inflation": 2, |
|||
"years_lifespan": 25 |
|||
}, |
|||
{ |
|||
"label": "District heating", |
|||
"installation_price": 95133, |
|||
"kwh_expenditure": 25000, |
|||
"kwh_price": 0.95, |
|||
"percent_inflation": 10, |
|||
"years_lifespan": 50 |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,92 @@ |
|||
import matplotlib |
|||
matplotlib.use('Qt5Agg') # or 'Qt5Agg', depending on your setup |
|||
import matplotlib.pyplot as plt |
|||
import numpy as np |
|||
import json |
|||
import sys |
|||
import argparse |
|||
__author__ = 'm3x1m0m' |
|||
|
|||
class JsonSettingsExtractor: |
|||
|
|||
def __init__(self, fname): |
|||
with open(fname, "r") as rf: |
|||
settings = json.load(rf) |
|||
self._currency = settings["currency"] |
|||
self._legend = settings["legend"] |
|||
# Kind of inefficient code. Does not matter only runs once at startup |
|||
_technologies = settings["technologies"] |
|||
self._label = [technology["label"] for technology in _technologies] |
|||
self._installation_price = [technology["installation_price"] for technology in _technologies] |
|||
self._kwh_expenditure = [technology["kwh_expenditure"] for technology in _technologies] |
|||
self._kwh_price = [technology["kwh_price"] for technology in _technologies] |
|||
self._percent_inflation = [technology["percent_inflation"] for technology in _technologies] |
|||
self._years_lifespan = [technology["years_lifespan"] for technology in _technologies] |
|||
|
|||
@property |
|||
def currency(self): |
|||
return self._currency |
|||
|
|||
@property |
|||
def legend(self): |
|||
return self._legend |
|||
|
|||
@property |
|||
def label(self): |
|||
return self._label |
|||
|
|||
@property |
|||
def installation_price(self): |
|||
return self._installation_price |
|||
|
|||
@property |
|||
def kwh_expenditure(self): |
|||
return self._kwh_expenditure |
|||
|
|||
@property |
|||
def percent_inflation(self): |
|||
self._percent_inflation |
|||
|
|||
@property |
|||
def years_lifespan(self): |
|||
self._years_lifespan |
|||
|
|||
def main(): |
|||
|
|||
parser = argparse.ArgumentParser(description='This script allows to calculate which heating technology makes sense financially for you.') |
|||
parser.add_argument('-a','--settings', help='Settings file.', required=True, metavar=('FILENAME')) |
|||
parser.add_argument('-g','--plot', help='Visualize costs over one or multiple years.', type=int, metavar=('YEARS')) |
|||
args = parser.parse_args() |
|||
|
|||
input_data = JsonSettingsExtractor(args.settings) |
|||
|
|||
print("Inflations: {}".format(input_data.percent_inflation)) |
|||
print("Expend: {}".format(input_data.kwh_expenditure)) |
|||
|
|||
|
|||
# if args.plot != None: |
|||
# # Basic settings |
|||
# width = 0.3 |
|||
# plt_colors = ["#8ecae6", "#219ebc", "#023047", "#ffb703", "#fb8500"]; |
|||
# fig, ax = plt.subplots() |
|||
# ax.bar(input_data.label, input_data.installation_price, width, label = "Installation price", color = plt_colors[0]) |
|||
|
|||
# current_y = input_data.installation_price |
|||
# years = 0 #first year |
|||
|
|||
# # Iteration for years in service |
|||
# for i in range(args.plot): |
|||
# inflation_factor = 1.0 + (input_data.percent_inflation * years) / 100.0 |
|||
# increase = input_data.kwh_expenditure * inflation_factor |
|||
# ax.bar(input_data.label, increase, width, bottom = current_y, label = "Expenditure".format(y), color = plt_colors[1]) |
|||
# years += 1 |
|||
# current_y += increase |
|||
|
|||
# ax.set_ylabel(input_data.currency) |
|||
# ax.set_title("Comparision of economics w/ different heating technologies") |
|||
# ax.legend(input_data.legend) |
|||
|
|||
# plt.show() |
|||
|
|||
if __name__ == "__main__": |
|||
main() |
Loading…
Reference in new issue