From 36ec01e1db6afc4d1bc17ba1df206b8b1d6292ea Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 3 Sep 2019 15:43:30 -0400 Subject: [PATCH 1/2] Add seaborn package to requirements.txt --- bpeng/pna/RetrofitCostCalculator.py | 231 ++++++++++++++++++++++++++++ requirements.txt | 1 + 2 files changed, 232 insertions(+) create mode 100644 bpeng/pna/RetrofitCostCalculator.py diff --git a/bpeng/pna/RetrofitCostCalculator.py b/bpeng/pna/RetrofitCostCalculator.py new file mode 100644 index 0000000..720d88c --- /dev/null +++ b/bpeng/pna/RetrofitCostCalculator.py @@ -0,0 +1,231 @@ +from django.http import JsonResponse, HttpResponse, FileResponse +from django.views import View +import logging +from io import BytesIO +import base64 +from wsgiref.util import FileWrapper +from bpeng.pna import pna + + +class RetrofitCostCalculator(View): + def get(self, request, building_id): + #Inputs from questions + building_sq_feet = 12000 + number_of_apts = 3 + number_of_bedrooms = 3 + heated_basement = 1 + number_of_heated_stairwell = 3 + number_of_building_floors = 2 + heated_hallways = 1 + + # Static material cost + material_unit_cost = { + 'outdoor': 2100, + 'indoor': 475, + 'ancillary_equipment':500, + 'refrigerant_line_run': 5, + 'outdoor_electric_connection': 400 + } + + # Static labor cost + labor_unit_cost = { + 'outdoor': 750, + 'indoor': 350, + 'refrigerant_line_run': 25, + 'outdoor_electric_connection': 25 + } + + # Assumptions + assumptions = { + 'feet_refrigerant_line_indoor_unit' : 30, + 'feet_electric_wire_outdoor_unit' : 30, + 'spread_cost_range_percentage' : 0.15 + } + + #Difficulty of installation + installation_difficulty = { + 'weather_stripping': 2, + 'ashp': 4, + 'solar': 2 + } + + #Paybacks + payback = { + 'weather_stripping': '2 - 3', + 'ashp': '10 +', + 'solar': '4 - 5' + } + + #Solar PV estimated cost + solar_cost = { + 'low': 21000, + 'high': 39000 + } + + #Material costs + material_costs = { + 'indoor': 0, + 'outdoor': 0, + 'ancillary_equipment': 0, + 'refrigerant_line_run': 0, + 'outdoor_electric_connection': 0, + } + + #Labor costs + labor_costs = { + 'outdoor': 0, + 'indoor': 0, + 'refrigerant_line_run': 0, + 'outdoor_electric_connection': 0 + } + + #Total costs + total_costs = { + 'outdoor': 0, + 'indoor': 0, + 'ancillary_equipment': 0, + 'refrigerant_line_run': 0, + 'outdoor_electric_connection': 0 + } + + #Apartment + apartment = { + 'material_cost': 0, + 'labor_cost': 0, + 'total_cost': 0, + 'avg_cost': 0, + } + + #Basement + basement = { + 'material_cost': 0, + 'labor_cost': 0, + 'total_cost': 0, + 'avg_cost': 0, + } + + #Stairewells + stairwells = { + 'material_cost': 0, + 'labor_cost': 0, + 'total_cost': 0, + 'avg_cost': 0, + } + + #Hallways + hallways = { + 'material_cost': 0, + 'labor_cost': 0, + 'total_cost': 0, + 'avg_cost': 0, + } + + #Project costs + project = { + 'material_cost': 0, + 'labor_cost': 0, + 'total_cost': 0, + 'avg_cost': 0, + } + + def ashp_cost(outdoor_units, indoor_units): + key = 'outdoor' + material_costs[key] = outdoor_units * material_unit_cost[key] + labor_costs[key] = outdoor_units * labor_unit_cost[key] + total_costs[key] = material_costs[key] + labor_costs[key] + + key = 'indoor' + material_costs[key] = indoor_units * material_unit_cost[key] + labor_costs[key] = indoor_units * labor_unit_cost[key] + total_costs[key] = material_costs[key] + labor_costs[key] + + key = 'ancillary_equipment' + material_costs[key] = outdoor_units * material_unit_cost[key] + total_costs[key] = material_costs[key] + + key = 'refrigerant_line_run' + refrigerant_line_run = indoor_units * assumptions['feet_refrigerant_line_indoor_unit'] + material_costs[key] = refrigerant_line_run * material_unit_cost[key] + labor_costs[key] = refrigerant_line_run * labor_unit_cost[key] + total_costs[key] = material_costs[key] + labor_costs[key] + + key = 'outdoor_electric_connection' + outdoor_electric_connection = outdoor_units * assumptions['feet_electric_wire_outdoor_unit'] + material_costs[key] = outdoor_units * material_unit_cost[key] + labor_costs[key] = outdoor_electric_connection * labor_unit_cost[key] + total_costs[key] = material_costs[key] + labor_costs[key] + + return { + 'material_cost': sum(material_costs.values()), \ + 'labor_cost': sum(labor_costs.values()), \ + 'total_cost': sum(total_costs.values()), \ + 'avg_cost': sum(total_costs.values())/number_of_apts + } + + #Apartments + outdoor_units = number_of_apts + indoor_units = number_of_apts + number_of_bedrooms + apartment = ashp_cost(outdoor_units, indoor_units) + + #Basement + outdoor_units = 2 + indoor_units = 6 + if heated_basement == 1: + basement = ashp_cost(outdoor_units, indoor_units) + + #Stairewell + outdoor_units = number_of_heated_stairwell + indoor_units = number_of_heated_stairwell * number_of_building_floors + stairwells = ashp_cost(outdoor_units, indoor_units) + + #Hallways + outdoor_units = 1 + indoor_units = number_of_building_floors + if heated_hallways == 1: + hallways = ashp_cost(outdoor_units, indoor_units) + + #Total Project Costs + for cost in ['material_cost', 'labor_cost', 'avg_cost', 'total_cost']: + project[cost] = apartment[cost] + basement[cost] + stairwells[cost] + hallways[cost] + + #ASHP Cost Range + low_range_output = 1000*round(project['total_cost']*(1-assumptions['spread_cost_range_percentage'])/1000) + high_range_output = 1000*round(project['total_cost']*(1+assumptions['spread_cost_range_percentage'])/1000) + + #Weatherstripping Cost Range + weather_striping_low = building_sq_feet * 0.33 + weather_striping_high = building_sq_feet * 0.4 + + return JsonResponse({'material_cost_apartment': apartment['material_cost'], \ + 'labor_cost_apartment': apartment['labor_cost'], \ + 'total_cost_apartment': apartment['total_cost'],\ + 'avg_per_apartment_apt': apartment['avg_cost'], \ + 'material_cost_basement': basement['material_cost'],\ + 'labor_cost_basement': basement['labor_cost'], \ + 'total_cost_basement': basement['total_cost'], \ + 'avg_per_apartment_basement': basement['avg_cost'], \ + 'material_cost_stairwell': stairwells['material_cost'], \ + 'labor_cost_stairwell': stairwells['labor_cost'],\ + 'total_cost_stairwell': stairwells['total_cost'], \ + 'avg_per_apartment_stairwell': stairwells['avg_cost'],\ + 'material_cost_hallways': hallways['material_cost'], \ + 'labor_cost_hallways': hallways['labor_cost'], \ + 'total_cost_hallways': hallways['total_cost'], \ + 'avg_per_apartment_hallways': hallways['avg_cost'], \ + 'total_project_material_cost': project['material_cost'], \ + 'total_project_labor_cost':project['labor_cost'],\ + 'total_project_avg_cost':project['avg_cost'],\ + 'total_project_cost': project['total_cost'], \ + 'low_range_output': low_range_output, \ + 'high_range_output': high_range_output, \ + 'weather_striping_low':weather_striping_low, \ + 'weather_striping_high': weather_striping_high, \ + 'solar_cost_low':solar_cost['low'], \ + 'solar_cost_high':solar_cost['high'], \ + 'weather_stripping_difficulty_of_installation': \ + installation_difficulty['weather_stripping'], \ + 'ashp_difficulty_of_installation': installation_difficulty['ashp'], \ + 'solar_difficulty_of_installation': installation_difficulty['solar'], \ + 'weather_stripping_payback': payback['weather_stripping'],\ + 'ashp_payback': payback['ashp'], \ + 'solar_payback': payback['solar'], }) diff --git a/requirements.txt b/requirements.txt index 72dcdc9..395fa83 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,3 +9,4 @@ psycopg2==2.8.2 influxdb==5.2.2 scipy==0.19.0 python-pptx==0.6.18 +seaborn==0.9.0 -- GitLab From f97914e1cfaaa93bc5745ad6159f4c6efaf81e3b Mon Sep 17 00:00:00 2001 From: Aizizi Yigaimu Date: Tue, 3 Sep 2019 15:45:13 -0400 Subject: [PATCH 2/2] Add seaborn package to requirements.txt --- bpeng/pna/RetrofitCostCalculator.py | 231 ---------------------------- 1 file changed, 231 deletions(-) delete mode 100644 bpeng/pna/RetrofitCostCalculator.py diff --git a/bpeng/pna/RetrofitCostCalculator.py b/bpeng/pna/RetrofitCostCalculator.py deleted file mode 100644 index 720d88c..0000000 --- a/bpeng/pna/RetrofitCostCalculator.py +++ /dev/null @@ -1,231 +0,0 @@ -from django.http import JsonResponse, HttpResponse, FileResponse -from django.views import View -import logging -from io import BytesIO -import base64 -from wsgiref.util import FileWrapper -from bpeng.pna import pna - - -class RetrofitCostCalculator(View): - def get(self, request, building_id): - #Inputs from questions - building_sq_feet = 12000 - number_of_apts = 3 - number_of_bedrooms = 3 - heated_basement = 1 - number_of_heated_stairwell = 3 - number_of_building_floors = 2 - heated_hallways = 1 - - # Static material cost - material_unit_cost = { - 'outdoor': 2100, - 'indoor': 475, - 'ancillary_equipment':500, - 'refrigerant_line_run': 5, - 'outdoor_electric_connection': 400 - } - - # Static labor cost - labor_unit_cost = { - 'outdoor': 750, - 'indoor': 350, - 'refrigerant_line_run': 25, - 'outdoor_electric_connection': 25 - } - - # Assumptions - assumptions = { - 'feet_refrigerant_line_indoor_unit' : 30, - 'feet_electric_wire_outdoor_unit' : 30, - 'spread_cost_range_percentage' : 0.15 - } - - #Difficulty of installation - installation_difficulty = { - 'weather_stripping': 2, - 'ashp': 4, - 'solar': 2 - } - - #Paybacks - payback = { - 'weather_stripping': '2 - 3', - 'ashp': '10 +', - 'solar': '4 - 5' - } - - #Solar PV estimated cost - solar_cost = { - 'low': 21000, - 'high': 39000 - } - - #Material costs - material_costs = { - 'indoor': 0, - 'outdoor': 0, - 'ancillary_equipment': 0, - 'refrigerant_line_run': 0, - 'outdoor_electric_connection': 0, - } - - #Labor costs - labor_costs = { - 'outdoor': 0, - 'indoor': 0, - 'refrigerant_line_run': 0, - 'outdoor_electric_connection': 0 - } - - #Total costs - total_costs = { - 'outdoor': 0, - 'indoor': 0, - 'ancillary_equipment': 0, - 'refrigerant_line_run': 0, - 'outdoor_electric_connection': 0 - } - - #Apartment - apartment = { - 'material_cost': 0, - 'labor_cost': 0, - 'total_cost': 0, - 'avg_cost': 0, - } - - #Basement - basement = { - 'material_cost': 0, - 'labor_cost': 0, - 'total_cost': 0, - 'avg_cost': 0, - } - - #Stairewells - stairwells = { - 'material_cost': 0, - 'labor_cost': 0, - 'total_cost': 0, - 'avg_cost': 0, - } - - #Hallways - hallways = { - 'material_cost': 0, - 'labor_cost': 0, - 'total_cost': 0, - 'avg_cost': 0, - } - - #Project costs - project = { - 'material_cost': 0, - 'labor_cost': 0, - 'total_cost': 0, - 'avg_cost': 0, - } - - def ashp_cost(outdoor_units, indoor_units): - key = 'outdoor' - material_costs[key] = outdoor_units * material_unit_cost[key] - labor_costs[key] = outdoor_units * labor_unit_cost[key] - total_costs[key] = material_costs[key] + labor_costs[key] - - key = 'indoor' - material_costs[key] = indoor_units * material_unit_cost[key] - labor_costs[key] = indoor_units * labor_unit_cost[key] - total_costs[key] = material_costs[key] + labor_costs[key] - - key = 'ancillary_equipment' - material_costs[key] = outdoor_units * material_unit_cost[key] - total_costs[key] = material_costs[key] - - key = 'refrigerant_line_run' - refrigerant_line_run = indoor_units * assumptions['feet_refrigerant_line_indoor_unit'] - material_costs[key] = refrigerant_line_run * material_unit_cost[key] - labor_costs[key] = refrigerant_line_run * labor_unit_cost[key] - total_costs[key] = material_costs[key] + labor_costs[key] - - key = 'outdoor_electric_connection' - outdoor_electric_connection = outdoor_units * assumptions['feet_electric_wire_outdoor_unit'] - material_costs[key] = outdoor_units * material_unit_cost[key] - labor_costs[key] = outdoor_electric_connection * labor_unit_cost[key] - total_costs[key] = material_costs[key] + labor_costs[key] - - return { - 'material_cost': sum(material_costs.values()), \ - 'labor_cost': sum(labor_costs.values()), \ - 'total_cost': sum(total_costs.values()), \ - 'avg_cost': sum(total_costs.values())/number_of_apts - } - - #Apartments - outdoor_units = number_of_apts - indoor_units = number_of_apts + number_of_bedrooms - apartment = ashp_cost(outdoor_units, indoor_units) - - #Basement - outdoor_units = 2 - indoor_units = 6 - if heated_basement == 1: - basement = ashp_cost(outdoor_units, indoor_units) - - #Stairewell - outdoor_units = number_of_heated_stairwell - indoor_units = number_of_heated_stairwell * number_of_building_floors - stairwells = ashp_cost(outdoor_units, indoor_units) - - #Hallways - outdoor_units = 1 - indoor_units = number_of_building_floors - if heated_hallways == 1: - hallways = ashp_cost(outdoor_units, indoor_units) - - #Total Project Costs - for cost in ['material_cost', 'labor_cost', 'avg_cost', 'total_cost']: - project[cost] = apartment[cost] + basement[cost] + stairwells[cost] + hallways[cost] - - #ASHP Cost Range - low_range_output = 1000*round(project['total_cost']*(1-assumptions['spread_cost_range_percentage'])/1000) - high_range_output = 1000*round(project['total_cost']*(1+assumptions['spread_cost_range_percentage'])/1000) - - #Weatherstripping Cost Range - weather_striping_low = building_sq_feet * 0.33 - weather_striping_high = building_sq_feet * 0.4 - - return JsonResponse({'material_cost_apartment': apartment['material_cost'], \ - 'labor_cost_apartment': apartment['labor_cost'], \ - 'total_cost_apartment': apartment['total_cost'],\ - 'avg_per_apartment_apt': apartment['avg_cost'], \ - 'material_cost_basement': basement['material_cost'],\ - 'labor_cost_basement': basement['labor_cost'], \ - 'total_cost_basement': basement['total_cost'], \ - 'avg_per_apartment_basement': basement['avg_cost'], \ - 'material_cost_stairwell': stairwells['material_cost'], \ - 'labor_cost_stairwell': stairwells['labor_cost'],\ - 'total_cost_stairwell': stairwells['total_cost'], \ - 'avg_per_apartment_stairwell': stairwells['avg_cost'],\ - 'material_cost_hallways': hallways['material_cost'], \ - 'labor_cost_hallways': hallways['labor_cost'], \ - 'total_cost_hallways': hallways['total_cost'], \ - 'avg_per_apartment_hallways': hallways['avg_cost'], \ - 'total_project_material_cost': project['material_cost'], \ - 'total_project_labor_cost':project['labor_cost'],\ - 'total_project_avg_cost':project['avg_cost'],\ - 'total_project_cost': project['total_cost'], \ - 'low_range_output': low_range_output, \ - 'high_range_output': high_range_output, \ - 'weather_striping_low':weather_striping_low, \ - 'weather_striping_high': weather_striping_high, \ - 'solar_cost_low':solar_cost['low'], \ - 'solar_cost_high':solar_cost['high'], \ - 'weather_stripping_difficulty_of_installation': \ - installation_difficulty['weather_stripping'], \ - 'ashp_difficulty_of_installation': installation_difficulty['ashp'], \ - 'solar_difficulty_of_installation': installation_difficulty['solar'], \ - 'weather_stripping_payback': payback['weather_stripping'],\ - 'ashp_payback': payback['ashp'], \ - 'solar_payback': payback['solar'], }) -- GitLab