From b80ab70ce35756c47b8090e5e6f1a45b1ea85cbd Mon Sep 17 00:00:00 2001 From: john525 Date: Thu, 15 Aug 2019 14:59:47 -0400 Subject: [PATCH 01/11] first attempt at score calculation, merged with master updates for dynamic crit names --- bpeng/pna/score_calculation.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bpeng/pna/score_calculation.py diff --git a/bpeng/pna/score_calculation.py b/bpeng/pna/score_calculation.py new file mode 100644 index 0000000..2f44927 --- /dev/null +++ b/bpeng/pna/score_calculation.py @@ -0,0 +1,16 @@ +# We have building_id +# From building_id, get question_id and answer_id from submitted_answers table +# list_QA = [(que_id, ans_id)] +​ +# if tuple is in que_ans_sw table => list_CS = [(criteria_id, score_weight)] +​ +def calculate_score_weight(list_CS): + score_weight_1 = 0 + score_weight_2 = 0 + score_weight_3 = 0 + score_weight_4 = 0 + score_weight_5 = 0 +​ + for i in list_CS: + if i[0] == 1: + score_weight_1 += i[1] \ No newline at end of file -- GitLab From 380ff1aa1c98fb11fb7ba145fc598ca8c13b42e2 Mon Sep 17 00:00:00 2001 From: Jinal Soni Date: Thu, 15 Aug 2019 16:33:57 -0400 Subject: [PATCH 02/11] criteria score calculation --- bpeng/pna/score_calculation.py | 80 +++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 5 deletions(-) diff --git a/bpeng/pna/score_calculation.py b/bpeng/pna/score_calculation.py index 2f44927..f1e35d3 100644 --- a/bpeng/pna/score_calculation.py +++ b/bpeng/pna/score_calculation.py @@ -1,16 +1,86 @@ # We have building_id # From building_id, get question_id and answer_id from submitted_answers table # list_QA = [(que_id, ans_id)] -​ # if tuple is in que_ans_sw table => list_CS = [(criteria_id, score_weight)] -​ + +from .discrete_bar_graph import create_graph_factory + def calculate_score_weight(list_CS): + score_weight_1 = 0 score_weight_2 = 0 score_weight_3 = 0 score_weight_4 = 0 - score_weight_5 = 0 -​ + + final_criteria_score = [] + for i in list_CS: if i[0] == 1: - score_weight_1 += i[1] \ No newline at end of file + score_weight_1 += i[1] + elif i[0] == 2: + score_weight_2 += i[1] + elif i[0] == 3: + score_weight_3 += i[1] + elif i[0] == 4: + score_weight_4 += i[1] + elif i[0] == 5: + continue + + final_criteria_score.append((1, score_weight_1)) + final_criteria_score.append((2, score_weight_2)) + final_criteria_score.append((3, score_weight_3)) + final_criteria_score.append((4, score_weight_4)) + + #return final_criteria_score + + if score_weight_1 in range(0, 4): + create_graph_factory(final_criteria_score[0][0], 0) + elif score_weight_1 in range(4, 7): + create_graph_factory(final_criteria_score[0][0], 1) + elif score_weight_1 in range(7, 9): + create_graph_factory(final_criteria_score[0][0], 2) + elif score_weight_1 in range(9, 11): + create_graph_factory(final_criteria_score[0][0], 3) + elif score_weight_1 in range(11, 13): + create_graph_factory(final_criteria_score[0][0], 4) + elif score_weight_1 in range(13, 17): + create_graph_factory(final_criteria_score[0][0], 5) + + if score_weight_2 in range(0, 15): + create_graph_factory(final_criteria_score[1][0], 0) + elif score_weight_2 in range(15, 20): + create_graph_factory(final_criteria_score[1][0], 1) + elif score_weight_2 in range(20, 23): + create_graph_factory(final_criteria_score[1][0], 2) + elif score_weight_2 in range(23, 27): + create_graph_factory(final_criteria_score[1][0], 3) + elif score_weight_2 in range(27, 31): + create_graph_factory(final_criteria_score[1][0], 4) + elif score_weight_2 in range(31, 35): + create_graph_factory(final_criteria_score[1][0], 5) + + if score_weight_3 == 0: + create_graph_factory(final_criteria_score[2][0], 0) + elif score_weight_3 in range(1, 3): + create_graph_factory(final_criteria_score[2][0], 1) + elif score_weight_3 in range(3, 6): + create_graph_factory(final_criteria_score[2][0], 2) + elif score_weight_3 in range(6, 10): + create_graph_factory(final_criteria_score[2][0], 3) + elif score_weight_3 in range(10, 13): + create_graph_factory(final_criteria_score[2][0], 4) + elif score_weight_3 in range(13, 16): + create_graph_factory(final_criteria_score[2][0], 5) + + if score_weight_4 in range(0, 12): + create_graph_factory(final_criteria_score[3][0], 0) + elif score_weight_4 in range(12, 18): + create_graph_factory(final_criteria_score[3][0], 1) + elif score_weight_4 in range(18, 22): + create_graph_factory(final_criteria_score[3][0], 2) + elif score_weight_4 in range(22, 26): + create_graph_factory(final_criteria_score[3][0], 3) + elif score_weight_4 in range(26, 31): + create_graph_factory(final_criteria_score[3][0], 4) + elif score_weight_4 in range(31, 36): + create_graph_factory(final_criteria_score[3][0], 5) -- GitLab From 7788a5b181105d117e0a8e5429d7b0d268a829a6 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Sun, 18 Aug 2019 12:50:11 -0400 Subject: [PATCH 03/11] Retrofit Cost Calculation --- bpeng/pna/RetrofitCosts.py | 257 +++++++++++++++++++++++++++++++++++++ 1 file changed, 257 insertions(+) create mode 100644 bpeng/pna/RetrofitCosts.py diff --git a/bpeng/pna/RetrofitCosts.py b/bpeng/pna/RetrofitCosts.py new file mode 100644 index 0000000..9ed9481 --- /dev/null +++ b/bpeng/pna/RetrofitCosts.py @@ -0,0 +1,257 @@ +# from django.http import JsonResponse, HttpResponse, FileResponse +# from django.views import View +import json + +class RetrofitCost: + def __init__( + 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, + ): + self.building_sq_feet = building_sq_feet + self.number_of_apts = number_of_apts + self.number_of_bedrooms = number_of_bedrooms + self.heated_basement = heated_basement + self.number_of_heated_stairwell = number_of_heated_stairwell + self.number_of_building_floors = number_of_building_floors + self.heated_hallways = heated_hallways + + def retrofit_calculator(self): + # 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, + } + + data = { + 'weather_stripping': { + 'difficulty_of_installation': 2, + 'estimated_cost_low': '', + 'estimated_cost_high': '', + 'payback_years': '2 - 3', + }, + 'ashp_replacement': { + 'difficulty_of_installation': 4, + 'estimated_cost_low': '', + 'estimated_cost_high': '', + 'payback_years': '10 +', + }, + 'solar_pv': { + 'difficulty_of_installation': 2, + 'estimated_cost_low': 21000, + 'estimated_cost_high': 39000, + 'payback_years': '4 - 5', + }, + } + + 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())/self.number_of_apts + } + + #Apartments + outdoor_units = self.number_of_apts + indoor_units = self.number_of_apts + self.number_of_bedrooms + apartment = ashp_cost(outdoor_units, indoor_units) + + #Basement + outdoor_units = 2 + indoor_units = 6 + if self.heated_basement == 1: + basement = ashp_cost(outdoor_units, indoor_units) + + #Stairewell + outdoor_units = self.number_of_heated_stairwell + indoor_units = self.number_of_heated_stairwell * self.number_of_building_floors + stairwells = ashp_cost(outdoor_units, indoor_units) + + #Hallways + outdoor_units = 1 + indoor_units = self.number_of_building_floors + if self.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 + data['ashp_replacement']['estimated_cost_low'] = 1000*round(project['total_cost']*(1-assumptions['spread_cost_range_percentage'])/1000) + data['ashp_replacement']['estimated_cost_high'] = 1000*round(project['total_cost']*(1+assumptions['spread_cost_range_percentage'])/1000) + + #Weatherstripping Cost Range + data['weather_stripping']['estimated_cost_low'] = self.building_sq_feet * 0.33 + data['weather_stripping']['estimated_cost_low'] = self.building_sq_feet * 0.4 + + print(data) + return data + # 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 From cc3ea76594c629f0dbc6884fe970aa9948eb3523 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Sun, 18 Aug 2019 16:02:12 -0400 Subject: [PATCH 04/11] Temp function in pna.py --- bpeng/pna/pna.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bpeng/pna/pna.py b/bpeng/pna/pna.py index 8585034..a70a131 100644 --- a/bpeng/pna/pna.py +++ b/bpeng/pna/pna.py @@ -186,3 +186,7 @@ def generate_ashp_pna(template_path, building_info, hvac, cost_estimates, scores pna_generator.export().save(save_to) return save_to + +def calculate_func(): + print('called') + return 'Hello from Calculator' \ No newline at end of file -- GitLab From 0b11c34c61d698de51fa1c9859b719f2c55b09b8 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Sun, 18 Aug 2019 19:13:14 -0400 Subject: [PATCH 05/11] Retrofit cost function added in pna library --- bpeng/pna/pna.py | 211 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 207 insertions(+), 4 deletions(-) diff --git a/bpeng/pna/pna.py b/bpeng/pna/pna.py index a70a131..0258b55 100644 --- a/bpeng/pna/pna.py +++ b/bpeng/pna/pna.py @@ -6,7 +6,6 @@ from pptx.enum.text import ( # pylint: disable=no-name-in-module MSO_ANCHOR, PP_ALIGN ) - from .template import * from .field_format import * from .discrete_bar_graph import create_graph_factory @@ -187,6 +186,210 @@ def generate_ashp_pna(template_path, building_info, hvac, cost_estimates, scores pna_generator.export().save(save_to) return save_to -def calculate_func(): - print('called') - return 'Hello from Calculator' \ No newline at end of file +def calculate_func(building_sq_feet, + number_of_apts, + number_of_bedrooms, + heated_basement, + number_of_heated_stairwell, + number_of_building_floors, + heated_hallways + ): + 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, + } + + data = { + 'weather_stripping': { + 'difficulty_of_installation': 2, + 'estimated_cost_low': '', + 'estimated_cost_high': '', + 'payback_years': '2 - 3', + }, + 'ashp_replacement': { + 'difficulty_of_installation': 4, + 'estimated_cost_low': '', + 'estimated_cost_high': '', + 'payback_years': '10 +', + }, + 'solar_pv': { + 'difficulty_of_installation': 2, + 'estimated_cost_low': 21000, + 'estimated_cost_high': 39000, + 'payback_years': '4 - 5', + }, + } + + 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 + data['ashp_replacement']['estimated_cost_low'] = 1000*round(project['total_cost']*(1-assumptions['spread_cost_range_percentage'])/1000) + data['ashp_replacement']['estimated_cost_high'] = 1000*round(project['total_cost']*(1+assumptions['spread_cost_range_percentage'])/1000) + + #Weatherstripping Cost Range + data['weather_stripping']['estimated_cost_low'] = building_sq_feet * 0.33 + data['weather_stripping']['estimated_cost_high'] = building_sq_feet * 0.4 + + return data -- GitLab From c9920297c5e3311c3963baa48cb5e24dac4490cd Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Tue, 20 Aug 2019 14:53:56 -0400 Subject: [PATCH 06/11] Changed few values from str to int --- bpeng/pna/pna.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bpeng/pna/pna.py b/bpeng/pna/pna.py index 0258b55..996c94a 100644 --- a/bpeng/pna/pna.py +++ b/bpeng/pna/pna.py @@ -306,14 +306,14 @@ def calculate_func(building_sq_feet, data = { 'weather_stripping': { 'difficulty_of_installation': 2, - 'estimated_cost_low': '', - 'estimated_cost_high': '', + 'estimated_cost_low': 0, + 'estimated_cost_high': 0, 'payback_years': '2 - 3', }, 'ashp_replacement': { 'difficulty_of_installation': 4, - 'estimated_cost_low': '', - 'estimated_cost_high': '', + 'estimated_cost_low': 0, + 'estimated_cost_high': 0, 'payback_years': '10 +', }, 'solar_pv': { -- GitLab From 43c6234d210f843c21963d0feb10af3bb4642b82 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Wed, 21 Aug 2019 17:02:05 -0400 Subject: [PATCH 07/11] Library function for score calculation --- bpeng/pna/pna.py | 2 +- bpeng/pna/score_calculation.py | 137 ++++++++++++++++++++------------- 2 files changed, 84 insertions(+), 55 deletions(-) diff --git a/bpeng/pna/pna.py b/bpeng/pna/pna.py index 996c94a..af4639b 100644 --- a/bpeng/pna/pna.py +++ b/bpeng/pna/pna.py @@ -10,7 +10,7 @@ from .template import * from .field_format import * from .discrete_bar_graph import create_graph_factory -def generate_ashp_pna(template_path, building_info, hvac, cost_estimates, scores, contact_info, +def generate_ashp_pna(template_path, building_info, hvac, cost_estimates, scores, contact_info=None, external=False): """ Generate an ASHP PNA from dicts diff --git a/bpeng/pna/score_calculation.py b/bpeng/pna/score_calculation.py index f1e35d3..a33e114 100644 --- a/bpeng/pna/score_calculation.py +++ b/bpeng/pna/score_calculation.py @@ -1,8 +1,3 @@ -# We have building_id -# From building_id, get question_id and answer_id from submitted_answers table -# list_QA = [(que_id, ans_id)] -# if tuple is in que_ans_sw table => list_CS = [(criteria_id, score_weight)] - from .discrete_bar_graph import create_graph_factory def calculate_score_weight(list_CS): @@ -26,61 +21,95 @@ def calculate_score_weight(list_CS): elif i[0] == 5: continue + # if buildingDetailsList['num_of_heating_violations'] == 'None': + # score_weight_1 += 0 + # elif buildingDetailsList['num_of_heating_violations'] in range(1, 3): + # score_weight_1 += 1 + # elif buildingDetailsList['num_of_heating_violations'] in range(3, 11): + # score_weight_1 += 3 + # elif buildingDetailsList['num_of_heating_violations'] >= 11: + # score_weight_1 += 5 + + # if buildingDetailsList['num_of_dob_violations'] == 'None': + # score_weight_4 += 5 + # elif buildingDetailsList['num_of_dob_violations'] in range(1, 4): + # score_weight_4 += 4 + # elif buildingDetailsList['num_of_dob_violations'] in range(4, 20): + # score_weight_4 += 3 + # elif buildingDetailsList['num_of_dob_violations'] in range(20, 100): + # score_weight_4 += 4 + # elif buildingDetailsList['num_of_dob_violations'] >= 100: + # score_weight_4 += 5 + + # if buildingDetailsList['legal_ownership'] == 'Single': + # score_weight_4 += 3 + # elif buildingDetailsList['legal_ownership'] == 'LLC': + # score_weight_4 += 5 + # elif buildingDetailsList['legal_ownership'] == 'Corporate': + # score_weight_4 += 5 + # elif buildingDetailsList['legal_ownership'] == 'None-Profit': + # score_weight_4 += 3 + final_criteria_score.append((1, score_weight_1)) final_criteria_score.append((2, score_weight_2)) final_criteria_score.append((3, score_weight_3)) final_criteria_score.append((4, score_weight_4)) - #return final_criteria_score + print('final score', final_criteria_score) + + return final_criteria_score - if score_weight_1 in range(0, 4): - create_graph_factory(final_criteria_score[0][0], 0) - elif score_weight_1 in range(4, 7): - create_graph_factory(final_criteria_score[0][0], 1) - elif score_weight_1 in range(7, 9): - create_graph_factory(final_criteria_score[0][0], 2) - elif score_weight_1 in range(9, 11): - create_graph_factory(final_criteria_score[0][0], 3) - elif score_weight_1 in range(11, 13): - create_graph_factory(final_criteria_score[0][0], 4) - elif score_weight_1 in range(13, 17): - create_graph_factory(final_criteria_score[0][0], 5) + ''' + # TODO: change 2 parameters to 1 tuple parameter + if score_weight_1 in range(0, 4): + normalized_scores.append( (1, 0) ) + elif score_weight_1 in range(4, 7): + normalized_scores.append( (1, 1) ) + elif score_weight_1 in range(7, 9): + normalized_scores.append( (1, 2) ) + elif score_weight_1 in range(9, 11): + normalized_scores.append( (1, 3) ) + elif score_weight_1 in range(11, 13): + normalized_scores.append( (1, 4) ) + elif score_weight_1 in range(13, 17): + normalized_scores.append( (1, 5) ) - if score_weight_2 in range(0, 15): - create_graph_factory(final_criteria_score[1][0], 0) - elif score_weight_2 in range(15, 20): - create_graph_factory(final_criteria_score[1][0], 1) - elif score_weight_2 in range(20, 23): - create_graph_factory(final_criteria_score[1][0], 2) - elif score_weight_2 in range(23, 27): - create_graph_factory(final_criteria_score[1][0], 3) - elif score_weight_2 in range(27, 31): - create_graph_factory(final_criteria_score[1][0], 4) - elif score_weight_2 in range(31, 35): - create_graph_factory(final_criteria_score[1][0], 5) + if score_weight_2 in range(0, 15): + normalized_scores.append( (2, 0) ) + elif score_weight_2 in range(15, 20): + normalized_scores.append( (2, 1) ) + elif score_weight_2 in range(20, 23): + normalized_scores.append( (2, 2) ) + elif score_weight_2 in range(23, 27): + normalized_scores.append( (2, 3) ) + elif score_weight_2 in range(27, 31): + normalized_scores.append( (2, 4) ) + elif score_weight_2 in range(31, 35): + normalized_scores.append( (2, 5) ) - if score_weight_3 == 0: - create_graph_factory(final_criteria_score[2][0], 0) - elif score_weight_3 in range(1, 3): - create_graph_factory(final_criteria_score[2][0], 1) - elif score_weight_3 in range(3, 6): - create_graph_factory(final_criteria_score[2][0], 2) - elif score_weight_3 in range(6, 10): - create_graph_factory(final_criteria_score[2][0], 3) - elif score_weight_3 in range(10, 13): - create_graph_factory(final_criteria_score[2][0], 4) - elif score_weight_3 in range(13, 16): - create_graph_factory(final_criteria_score[2][0], 5) + if score_weight_3 == 0: + normalized_scores.append( (3, 0) ) + elif score_weight_3 in range(1, 3): + normalized_scores.append( (3, 1) ) + elif score_weight_3 in range(3, 6): + normalized_scores.append( (3, 2) ) + elif score_weight_3 in range(6, 10): + normalized_scores.append( (3, 3) ) + elif score_weight_3 in range(10, 13): + normalized_scores.append( (3, 4) ) + elif score_weight_3 in range(13, 16): + normalized_scores.append( (3, 5) ) - if score_weight_4 in range(0, 12): - create_graph_factory(final_criteria_score[3][0], 0) - elif score_weight_4 in range(12, 18): - create_graph_factory(final_criteria_score[3][0], 1) - elif score_weight_4 in range(18, 22): - create_graph_factory(final_criteria_score[3][0], 2) - elif score_weight_4 in range(22, 26): - create_graph_factory(final_criteria_score[3][0], 3) - elif score_weight_4 in range(26, 31): - create_graph_factory(final_criteria_score[3][0], 4) - elif score_weight_4 in range(31, 36): - create_graph_factory(final_criteria_score[3][0], 5) + if score_weight_4 in range(0, 12): + normalized_scores.append( (4, 0) ) + elif score_weight_4 in range(12, 18): + normalized_scores.append( (4, 1) ) + elif score_weight_4 in range(18, 22): + normalized_scores.append( (4, 2) ) + elif score_weight_4 in range(22, 26): + normalized_scores.append( (4, 3) ) + elif score_weight_4 in range(26, 31): + normalized_scores.append( (4, 4) ) + elif score_weight_4 in range(31, 36): + normalized_scores.append( (4, 5) ) + ''' \ No newline at end of file -- GitLab From d10da9d89f92d7e09fbff0b6536ee4c57c5ec5d6 Mon Sep 17 00:00:00 2001 From: Jinal Soni Date: Wed, 21 Aug 2019 18:03:24 -0400 Subject: [PATCH 08/11] Bar graph code (not tested) --- bpeng/pna/pna.py | 86 +++++++++++++++++++++--- bpeng/pna/score_calculation.py | 117 ++++++++++----------------------- 2 files changed, 112 insertions(+), 91 deletions(-) diff --git a/bpeng/pna/pna.py b/bpeng/pna/pna.py index af4639b..053474e 100644 --- a/bpeng/pna/pna.py +++ b/bpeng/pna/pna.py @@ -10,6 +10,7 @@ from .template import * from .field_format import * from .discrete_bar_graph import create_graph_factory + def generate_ashp_pna(template_path, building_info, hvac, cost_estimates, scores, contact_info=None, external=False): """ @@ -98,17 +99,19 @@ def generate_ashp_pna(template_path, building_info, hvac, cost_estimates, scores if scores[i][0].lower().find('utility') != -1: new_crit_name = scores[i][0] + '*' # Put an asterisk/footnote on utility scores, for legal reasons scores[i] = (new_crit_name, scores[i][1]) - + addr_sub_2a = Substitution('ADDRESS', addr) criteria_name_sub1 = Substitution('CRITERIA_NAME_0', scores[0][0], font_size=18) criteria_name_sub2 = Substitution('CRITERIA_NAME_1', scores[1][0], font_size=18) criteria_name_sub3 = Substitution('CRITERIA_NAME_2', scores[2][0], font_size=18) criteria_name_sub4 = Substitution('CRITERIA_NAME_3', scores[3][0], font_size=18) - graph_factory1 = create_graph_factory('CSCORE0', scores[0][1], total=5) - graph_factory2 = create_graph_factory('CSCORE1', scores[1][1], total=5) - graph_factory3 = create_graph_factory('CSCORE2', scores[2][1], total=5) - graph_factory4 = create_graph_factory('CSCORE3', scores[3][1], total=5) + num_list = calculate_bar_color_number(scores) + + graph_factory1 = create_graph_factory('CSCORE0', num_list[0], total=5) + graph_factory2 = create_graph_factory('CSCORE1', num_list[1], total=5) + graph_factory3 = create_graph_factory('CSCORE2', num_list[2], total=5) + graph_factory4 = create_graph_factory('CSCORE3', num_list[3], total=5) graph_slide = pna_generator.templateSlideNumber(4) @@ -150,7 +153,7 @@ def generate_ashp_pna(template_path, building_info, hvac, cost_estimates, scores name = ' ' email = 'BusinessDevelopment@blocpower.io' phone = '(718) 924-2873' # TODO: don't hardcode these values - + pronoun_sub = Substitution( 'PRONOUN', pronoun, @@ -186,8 +189,8 @@ def generate_ashp_pna(template_path, building_info, hvac, cost_estimates, scores pna_generator.export().save(save_to) return save_to -def calculate_func(building_sq_feet, - number_of_apts, +def calculate_func(building_sq_feet, + number_of_apts, number_of_bedrooms, heated_basement, number_of_heated_stairwell, @@ -393,3 +396,70 @@ def calculate_func(building_sq_feet, data['weather_stripping']['estimated_cost_high'] = building_sq_feet * 0.4 return data + +def calculate_bar_color_number(scores): + + num0 = 0 + num1 = 0 + num2 = 0 + num3 = 0 + num_list = [] + + if scores[0][1] in range(0, 4): + num0 = 0 + elif scores[0][1] in range(4, 7): + num0 = 1 + elif scores[0][1] in range(7, 9): + num0 = 2 + elif scores[0][1] in range(9, 11): + num0 = 3 + elif scores[0][1] in range(11, 13): + num0 = 4 + elif scores[0][1] in range(13, 17): + num0 = 5 + + if scores[1][1] in range(0, 15): + num1 = 0 + elif scores[1][1] in range(15, 20): + num1 = 1 + elif scores[1][1] in range(20, 23): + num1 = 2 + elif scores[1][1] in range(23, 27): + num1 = 3 + elif scores[1][1] in range(27, 31): + num1 = 4 + elif scores[1][1] in range(31, 35): + num1 = 5 + + if scores[2][1] == 0: + num2 = 0 + elif scores[2][1] in range(1, 3): + num2 = 1 + elif scores[2][1] in range(3, 6): + num2 = 2 + elif scores[2][1] in range(6, 10): + num2 = 3 + elif scores[2][1] in range(10, 13): + num2 = 4 + elif scores[2][1] in range(13, 16): + num2 = 5 + + if scores[3][1] in range(0, 12): + num3 = 0 + elif scores[3][1] in range(12, 18): + num3 = 0 + elif scores[3][1] in range(18, 22): + num3 = 0 + elif scores[3][1] in range(22, 26): + num3 = 0 + elif scores[3][1] in range(26, 31): + num3 = 0 + elif scores[3][1] in range(31, 36): + num3 = 0 + + num_list.append(num0) + num_list.append(num1) + num_list.append(num2) + num_list.append(num3) + + return num_list diff --git a/bpeng/pna/score_calculation.py b/bpeng/pna/score_calculation.py index a33e114..c82d0f2 100644 --- a/bpeng/pna/score_calculation.py +++ b/bpeng/pna/score_calculation.py @@ -1,6 +1,6 @@ from .discrete_bar_graph import create_graph_factory -def calculate_score_weight(list_CS): +def calculate_score_weight(weights_list, details_list): score_weight_1 = 0 score_weight_2 = 0 @@ -9,7 +9,7 @@ def calculate_score_weight(list_CS): final_criteria_score = [] - for i in list_CS: + for i in weights_list: if i[0] == 1: score_weight_1 += i[1] elif i[0] == 2: @@ -21,34 +21,40 @@ def calculate_score_weight(list_CS): elif i[0] == 5: continue - # if buildingDetailsList['num_of_heating_violations'] == 'None': - # score_weight_1 += 0 - # elif buildingDetailsList['num_of_heating_violations'] in range(1, 3): - # score_weight_1 += 1 - # elif buildingDetailsList['num_of_heating_violations'] in range(3, 11): - # score_weight_1 += 3 - # elif buildingDetailsList['num_of_heating_violations'] >= 11: - # score_weight_1 += 5 + if details_list.num_of_heating_violations == 'None': + score_weight_1 += 0 + elif details_list.num_of_heating_violations in range(1, 3): + score_weight_1 += 1 + elif details_list.num_of_heating_violations in range(3, 11): + score_weight_1 += 3 + elif details_list.num_of_heating_violations >= 11: + score_weight_1 += 5 + else: + score_weight_1 += 0 - # if buildingDetailsList['num_of_dob_violations'] == 'None': - # score_weight_4 += 5 - # elif buildingDetailsList['num_of_dob_violations'] in range(1, 4): - # score_weight_4 += 4 - # elif buildingDetailsList['num_of_dob_violations'] in range(4, 20): - # score_weight_4 += 3 - # elif buildingDetailsList['num_of_dob_violations'] in range(20, 100): - # score_weight_4 += 4 - # elif buildingDetailsList['num_of_dob_violations'] >= 100: - # score_weight_4 += 5 + if details_list.num_of_dob_violations == 'None': + score_weight_4 += 5 + elif details_list.num_of_dob_violations in range(1, 4): + score_weight_4 += 4 + elif details_list.num_of_dob_violations in range(4, 20): + score_weight_4 += 3 + elif details_list.num_of_dob_violations in range(20, 100): + score_weight_4 += 4 + elif details_list.num_of_dob_violations >= 100: + score_weight_4 += 5 + else: + score_weight_4 += 0 - # if buildingDetailsList['legal_ownership'] == 'Single': - # score_weight_4 += 3 - # elif buildingDetailsList['legal_ownership'] == 'LLC': - # score_weight_4 += 5 - # elif buildingDetailsList['legal_ownership'] == 'Corporate': - # score_weight_4 += 5 - # elif buildingDetailsList['legal_ownership'] == 'None-Profit': - # score_weight_4 += 3 + if details_list.legal_ownership == 'Single': + score_weight_4 += 3 + elif details_list.legal_ownership == 'LLC': + score_weight_4 += 5 + elif details_list.legal_ownership == 'Corporate': + score_weight_4 += 5 + elif details_list.legal_ownership == 'None-Profit': + score_weight_4 += 3 + else: + score_weight_4 += 0 final_criteria_score.append((1, score_weight_1)) final_criteria_score.append((2, score_weight_2)) @@ -58,58 +64,3 @@ def calculate_score_weight(list_CS): print('final score', final_criteria_score) return final_criteria_score - - ''' - # TODO: change 2 parameters to 1 tuple parameter - if score_weight_1 in range(0, 4): - normalized_scores.append( (1, 0) ) - elif score_weight_1 in range(4, 7): - normalized_scores.append( (1, 1) ) - elif score_weight_1 in range(7, 9): - normalized_scores.append( (1, 2) ) - elif score_weight_1 in range(9, 11): - normalized_scores.append( (1, 3) ) - elif score_weight_1 in range(11, 13): - normalized_scores.append( (1, 4) ) - elif score_weight_1 in range(13, 17): - normalized_scores.append( (1, 5) ) - - if score_weight_2 in range(0, 15): - normalized_scores.append( (2, 0) ) - elif score_weight_2 in range(15, 20): - normalized_scores.append( (2, 1) ) - elif score_weight_2 in range(20, 23): - normalized_scores.append( (2, 2) ) - elif score_weight_2 in range(23, 27): - normalized_scores.append( (2, 3) ) - elif score_weight_2 in range(27, 31): - normalized_scores.append( (2, 4) ) - elif score_weight_2 in range(31, 35): - normalized_scores.append( (2, 5) ) - - if score_weight_3 == 0: - normalized_scores.append( (3, 0) ) - elif score_weight_3 in range(1, 3): - normalized_scores.append( (3, 1) ) - elif score_weight_3 in range(3, 6): - normalized_scores.append( (3, 2) ) - elif score_weight_3 in range(6, 10): - normalized_scores.append( (3, 3) ) - elif score_weight_3 in range(10, 13): - normalized_scores.append( (3, 4) ) - elif score_weight_3 in range(13, 16): - normalized_scores.append( (3, 5) ) - - if score_weight_4 in range(0, 12): - normalized_scores.append( (4, 0) ) - elif score_weight_4 in range(12, 18): - normalized_scores.append( (4, 1) ) - elif score_weight_4 in range(18, 22): - normalized_scores.append( (4, 2) ) - elif score_weight_4 in range(22, 26): - normalized_scores.append( (4, 3) ) - elif score_weight_4 in range(26, 31): - normalized_scores.append( (4, 4) ) - elif score_weight_4 in range(31, 36): - normalized_scores.append( (4, 5) ) - ''' \ No newline at end of file -- GitLab From 229781ce123edd9bce0644e2e0c1ffbba0fc6e1e Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Wed, 21 Aug 2019 18:34:49 -0400 Subject: [PATCH 09/11] Bar graph (Tested) --- bpeng/pna/score_calculation.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bpeng/pna/score_calculation.py b/bpeng/pna/score_calculation.py index c82d0f2..9f2c7a9 100644 --- a/bpeng/pna/score_calculation.py +++ b/bpeng/pna/score_calculation.py @@ -21,37 +21,37 @@ def calculate_score_weight(weights_list, details_list): elif i[0] == 5: continue - if details_list.num_of_heating_violations == 'None': + if details_list['num_of_heating_violations'] == 'None': score_weight_1 += 0 - elif details_list.num_of_heating_violations in range(1, 3): + elif details_list['num_of_heating_violations'] in range(1, 3): score_weight_1 += 1 - elif details_list.num_of_heating_violations in range(3, 11): + elif details_list['num_of_heating_violations'] in range(3, 11): score_weight_1 += 3 - elif details_list.num_of_heating_violations >= 11: + elif details_list['num_of_heating_violations'] >= 11: score_weight_1 += 5 else: score_weight_1 += 0 - if details_list.num_of_dob_violations == 'None': + if details_list['num_of_dob_violations'] == 'None': score_weight_4 += 5 - elif details_list.num_of_dob_violations in range(1, 4): + elif details_list['num_of_dob_violations'] in range(1, 4): score_weight_4 += 4 - elif details_list.num_of_dob_violations in range(4, 20): + elif details_list['num_of_dob_violations'] in range(4, 20): score_weight_4 += 3 - elif details_list.num_of_dob_violations in range(20, 100): + elif details_list['num_of_dob_violations'] in range(20, 100): score_weight_4 += 4 - elif details_list.num_of_dob_violations >= 100: + elif details_list['num_of_dob_violations'] >= 100: score_weight_4 += 5 else: score_weight_4 += 0 - if details_list.legal_ownership == 'Single': + if details_list['legal_ownership'] == 'Single': score_weight_4 += 3 - elif details_list.legal_ownership == 'LLC': + elif details_list['legal_ownership'] == 'LLC': score_weight_4 += 5 - elif details_list.legal_ownership == 'Corporate': + elif details_list['legal_ownership'] == 'Corporate': score_weight_4 += 5 - elif details_list.legal_ownership == 'None-Profit': + elif details_list['legal_ownership'] == 'Non-Profit': score_weight_4 += 3 else: score_weight_4 += 0 -- GitLab From 417c007fae82765b2b3515ed36d2aa331b2f9277 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Thu, 22 Aug 2019 09:32:06 -0400 Subject: [PATCH 10/11] removed logs --- bpeng/pna/RetrofitCosts.py | 257 -------------------------------- bpeng/pna/discrete_bar_graph.py | 3 - bpeng/pna/pna.py | 2 +- bpeng/pna/template.py | 11 -- 4 files changed, 1 insertion(+), 272 deletions(-) delete mode 100644 bpeng/pna/RetrofitCosts.py diff --git a/bpeng/pna/RetrofitCosts.py b/bpeng/pna/RetrofitCosts.py deleted file mode 100644 index 9ed9481..0000000 --- a/bpeng/pna/RetrofitCosts.py +++ /dev/null @@ -1,257 +0,0 @@ -# from django.http import JsonResponse, HttpResponse, FileResponse -# from django.views import View -import json - -class RetrofitCost: - def __init__( - 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, - ): - self.building_sq_feet = building_sq_feet - self.number_of_apts = number_of_apts - self.number_of_bedrooms = number_of_bedrooms - self.heated_basement = heated_basement - self.number_of_heated_stairwell = number_of_heated_stairwell - self.number_of_building_floors = number_of_building_floors - self.heated_hallways = heated_hallways - - def retrofit_calculator(self): - # 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, - } - - data = { - 'weather_stripping': { - 'difficulty_of_installation': 2, - 'estimated_cost_low': '', - 'estimated_cost_high': '', - 'payback_years': '2 - 3', - }, - 'ashp_replacement': { - 'difficulty_of_installation': 4, - 'estimated_cost_low': '', - 'estimated_cost_high': '', - 'payback_years': '10 +', - }, - 'solar_pv': { - 'difficulty_of_installation': 2, - 'estimated_cost_low': 21000, - 'estimated_cost_high': 39000, - 'payback_years': '4 - 5', - }, - } - - 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())/self.number_of_apts - } - - #Apartments - outdoor_units = self.number_of_apts - indoor_units = self.number_of_apts + self.number_of_bedrooms - apartment = ashp_cost(outdoor_units, indoor_units) - - #Basement - outdoor_units = 2 - indoor_units = 6 - if self.heated_basement == 1: - basement = ashp_cost(outdoor_units, indoor_units) - - #Stairewell - outdoor_units = self.number_of_heated_stairwell - indoor_units = self.number_of_heated_stairwell * self.number_of_building_floors - stairwells = ashp_cost(outdoor_units, indoor_units) - - #Hallways - outdoor_units = 1 - indoor_units = self.number_of_building_floors - if self.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 - data['ashp_replacement']['estimated_cost_low'] = 1000*round(project['total_cost']*(1-assumptions['spread_cost_range_percentage'])/1000) - data['ashp_replacement']['estimated_cost_high'] = 1000*round(project['total_cost']*(1+assumptions['spread_cost_range_percentage'])/1000) - - #Weatherstripping Cost Range - data['weather_stripping']['estimated_cost_low'] = self.building_sq_feet * 0.33 - data['weather_stripping']['estimated_cost_low'] = self.building_sq_feet * 0.4 - - print(data) - return data - # 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/bpeng/pna/discrete_bar_graph.py b/bpeng/pna/discrete_bar_graph.py index 678c894..bb5cace 100644 --- a/bpeng/pna/discrete_bar_graph.py +++ b/bpeng/pna/discrete_bar_graph.py @@ -29,7 +29,4 @@ def create_graph_factory(name_in_ppt, num_colored, total=5, horizontal=True, bla i += 1 if i > num_colored: cell.fill.fore_color.rgb = RGBColor(blank_color[0], blank_color[1], blank_color[2]) - print("ayy") - else: - print("vertical not programmed yet sorry") return graph_factory diff --git a/bpeng/pna/pna.py b/bpeng/pna/pna.py index 053474e..f59e5ec 100644 --- a/bpeng/pna/pna.py +++ b/bpeng/pna/pna.py @@ -35,7 +35,7 @@ def generate_ashp_pna(template_path, building_info, hvac, cost_estimates, scores Returns a python-pptx presentation object """ - pna_generator = TemplateInstantiator(template_path) + pna_generator = TemplateInstantiator('template_path') addr = building_info['address'] # Provide template with address, client name, and date for title page diff --git a/bpeng/pna/template.py b/bpeng/pna/template.py index e911e4f..500b734 100644 --- a/bpeng/pna/template.py +++ b/bpeng/pna/template.py @@ -93,11 +93,6 @@ class Substitution(): self.formatter = lambda x: x else: self.formatter = formatter - - # if external_value is None: - # self.exteternal_value = value - # else: - # self.exteternal_value = external_value def ___repr___(self): return "[" + self.name_in_ppt + ", " + self.formatter(self.value) + "]" @@ -116,17 +111,12 @@ class Substitution(): for shape in slide.shapes: if shape is None: continue - if shape.has_text_frame: - print("text frame found: " + shape.text) - print("searching for: " + self.name_in_ppt) - print(shape.text.find(self.name_in_ppt)) if shape.has_text_frame and shape.text.find(self.name_in_ppt) != -1: new_text = shape.text new_text = new_text.replace( self.name_in_ppt, # underscores from constructor self.formatter(self.value) ) - print("did update") shape.text = new_text for p in shape.text_frame.paragraphs: @@ -139,7 +129,6 @@ class Substitution(): if shape.has_table: for row in shape.table.rows: for cell in row.cells: - #cell = shape.table.cell(r,c) if cell.text is not None and cell.text.find(self.name_in_ppt) != -1: cell.text = cell.text.replace( self.name_in_ppt, # underscores from constructor -- GitLab From d421354480505a571748254f64370eb1577d22a4 Mon Sep 17 00:00:00 2001 From: RujitRaval Date: Thu, 22 Aug 2019 09:33:55 -0400 Subject: [PATCH 11/11] Removed print statement --- bpeng/pna/score_calculation.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bpeng/pna/score_calculation.py b/bpeng/pna/score_calculation.py index 9f2c7a9..c097eae 100644 --- a/bpeng/pna/score_calculation.py +++ b/bpeng/pna/score_calculation.py @@ -61,6 +61,4 @@ def calculate_score_weight(weights_list, details_list): final_criteria_score.append((3, score_weight_3)) final_criteria_score.append((4, score_weight_4)) - print('final score', final_criteria_score) - return final_criteria_score -- GitLab