From 8092a3c81ffe10e74af1e42b39eb6325ada981ea Mon Sep 17 00:00:00 2001 From: areza-blocpower Date: Mon, 8 May 2017 10:21:02 -0400 Subject: [PATCH 1/4] remove all mention of ECM in var names --- bpeng/reports/cbra_diag.py | 175 +++++++++++++++++++------------------ bpeng/reports/constants.py | 2 +- 2 files changed, 89 insertions(+), 88 deletions(-) diff --git a/bpeng/reports/cbra_diag.py b/bpeng/reports/cbra_diag.py index bf65401..1b63a98 100644 --- a/bpeng/reports/cbra_diag.py +++ b/bpeng/reports/cbra_diag.py @@ -22,7 +22,7 @@ from pptx.enum.text import ( # pylint: disable=no-name-in-module ) from pptx.util import Inches, Pt -from .constants import ECM_TO_SLIDE, RETROFIT_TO_CBRA_RETROFIT +from .constants import RETRO_TO_SLIDE, RETROFIT_TO_CBRA_RETROFIT class CbraDiagnostic: @@ -36,7 +36,7 @@ class CbraDiagnostic: project_summary_data, util_break_data, heat_loss_data, - ecm_data, + retro_data, ): """ Generate powerpoint file @@ -50,7 +50,7 @@ class CbraDiagnostic: util_break_data (dict): python dictionary of utility breakdown [$] by end usage heat_loss_data (dict): python dictionary of building components and heat loss values - ecm_data (dict): python dictionary of selected retrofits and calculated percent + retro_data (dict): python dictionary of selected retrofits and calculated percent savings on utility bill [$] by fuel @@ -77,40 +77,40 @@ class CbraDiagnostic: heat_loss_cat = heat_loss_data['heat_loss_cat'] heat_loss_val = heat_loss_data['heat_loss_val'] - ecm_list = ecm_data['ecm_list'] - ecm_heat_save = ecm_data['ecm_heat_save'] - ecm_elec_save = ecm_data['ecm_elec_save'] + retrofit_list = retro_data['retrofit_list'] + retrofit_heat_save = retro_data['retrofit_heat_save'] + retrofit_elec_save = retro_data['retrofit_elec_save'] # Convert database strings to presentation strings # Also calculate new heat or elec save in cases where - # database ecm's are combined to a single presentation ecm - new_ecm_list = [] - new_ecm_heat_save = [] - new_ecm_elec_save = [] - for name, heat, elec in zip(ecm_list, ecm_heat_save, ecm_elec_save): - presentation_name = ECM_TO_SLIDE[name]['slide_name'] - if presentation_name in new_ecm_list: - combine_index = new_ecm_list.index(presentation_name) + # database retrofit's are combined to a single presentation retrofit + new_retrofit_list = [] + new_retrofit_heat_save = [] + new_retrofit_elec_save = [] + for name, heat, elec in zip(retrofit_list, retrofit_heat_save, retrofit_elec_save): + presentation_name = RETRO_TO_SLIDE[name]['slide_name'] + if presentation_name in new_retrofit_list: + combine_index = new_retrofit_list.index(presentation_name) # Right now we just add together heat and elec. # In the future we might want to calculate the combined value for - # heat and elec differently based on the ECM - new_ecm_heat_save[combine_index] += heat - new_ecm_elec_save[combine_index] += elec + # heat and elec differently based on the retrofit + new_retrofit_heat_save[combine_index] += heat + new_retrofit_elec_save[combine_index] += elec else: - new_ecm_list.append(presentation_name) - new_ecm_heat_save.append(heat) - new_ecm_elec_save.append(elec) - ecm_list = new_ecm_list - ecm_heat_save = new_ecm_heat_save - ecm_elec_save = new_ecm_elec_save - - # Create a delete list by adding everything not in the ecm_list - ecm_delete_list = [] - for slide in ECM_TO_SLIDE.values(): - if slide['slide_name'] not in ecm_list and slide['slide_index'] not in ecm_delete_list: - ecm_delete_list.append(slide['slide_index']) + new_retrofit_list.append(presentation_name) + new_retrofit_heat_save.append(heat) + new_retrofit_elec_save.append(elec) + retrofit_list = new_retrofit_list + retrofit_heat_save = new_retrofit_heat_save + retrofit_elec_save = new_retrofit_elec_save + + # Create a delete list by adding everything not in the retrofit_list + retrofit_delete_list = [] + for slide in RETRO_TO_SLIDE.values(): + if slide['slide_name'] not in retrofit_list and slide['slide_index'] not in retrofit_delete_list: + retrofit_delete_list.append(slide['slide_index']) # Put delete list in reverse order so we delete from the back - ecm_delete_list.sort(reverse=True) + retrofit_delete_list.sort(reverse=True) # Define presentation to edit as the finished template diag_rep = Presentation(template_file) @@ -147,7 +147,7 @@ class CbraDiagnostic: crnyc_intro_run.text = 'Community Retrofit NYC’s engineering feasibility study provides ' \ 'a cost effective and energy efficient solution for {}. ' \ - 'Implementation of the recommended ECMs would ' \ + 'Implementation of the recommended retrofits would ' \ 'result in the following:'.format(project_address) crnyc_intro_run.font.name = 'Arial' @@ -256,7 +256,7 @@ class CbraDiagnostic: heat_loss_labels.font.bold = True # Slide 4: Potential Savings, includes utility expenses stacked bar charts for - # pre+post-retrofit, ECM table w/ names, savings for elec and gas, and total savings + # pre+post-retrofit, retrofit table w/ names, savings for elec and gas, and total savings # Slide 4: Utility breakdown utility_projection_slide = diag_rep.slides[3] @@ -316,60 +316,60 @@ class CbraDiagnostic: util_break_chart.value_axis.has_major_gridlines = False util_break_chart.value_axis.tick_label_position = XL_TICK_LABEL_POSITION.NONE - # Create ECM summary table + # Create retrofit summary table - ecm_count = len(ecm_list) - ecm_table_head = [ + retrofit_count = len(retrofit_list) + retrofit_table_head = [ 'Energy Conservation Measure', "Heating Savings*", "Electricity Savings*", "Water Savings*" ] - ecm_table = utility_projection_slide.shapes.add_table( - ecm_count + 2, - len(ecm_table_head), + retrofit_table = utility_projection_slide.shapes.add_table( + retrofit_count + 2, + len(retrofit_table_head), Inches(3.62), Inches(0.08), Inches(6.12), Inches(4.9) ) - ecm_table.last_row = True - ecm_table.horz_banding = False - ecm_table.table.columns[0].width = Inches(3.12) - ecm_table.table.columns[1].width = Inches(1) - ecm_table.table.columns[2].width = Inches(1) - ecm_table.table.columns[3].width = Inches(1) - - for j in range(len(ecm_table_head)): # pylint: disable=consider-using-enumerate - ecm_table.table.cell(0, j).text = ecm_table_head[j] - ecm_table.table.cell(0, j).text_frame.paragraphs[0].font.size = Pt(12) - ecm_table.table.cell(0, j).text_frame.paragraphs[0].font.bold = True - - for k, j in zip(ecm_list, range(len(ecm_list))): - ecm_table.table.cell(j+1, 0).text_frame.paragraphs[0].font.size = Pt(10) - ecm_table.table.cell(j+1, 0).text = k - ecm_table.table.cell(j+1, 1).text_frame.paragraphs[0].font.size = Pt(10) - ecm_table.table.cell(j+1, 1).text = str(int(ecm_heat_save[j])) + '\N{PERCENT SIGN}' - ecm_table.table.cell(j+1, 1).text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER - ecm_table.table.cell(j+1, 1).text_frame.vertical_anchor = MSO_ANCHOR.MIDDLE - ecm_table.table.cell(j+1, 2).text_frame.paragraphs[0].font.size = Pt(10) - ecm_table.table.cell(j+1, 2).text = str(int(ecm_elec_save[j])) + '\N{PERCENT SIGN}' - ecm_table.table.cell(j+1, 2).text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER - ecm_table.table.cell(j+1, 2).text_frame.vertical_anchor = MSO_ANCHOR.MIDDLE - - ecm_table.table.cell(ecm_count+1, 0).text_frame.paragraphs[0].font.size = Pt(12) - ecm_table.table.cell(ecm_count+1, 0).text_frame.paragraphs[0].font.bold = True - ecm_table.table.cell(ecm_count+1, 0).text = 'Total' - - ecm_table.table.cell(ecm_count+1, 2).text_frame.paragraphs[0].font.size = Pt(12) - ecm_table.table.cell(ecm_count+1, 2).text_frame.paragraphs[0].font.bold = True - ecm_table.table.cell(ecm_count+1, 2).text = str(annual_utility_percent) + '\N{PERCENT SIGN}' + retrofit_table.last_row = True + retrofit_table.horz_banding = False + retrofit_table.table.columns[0].width = Inches(3.12) + retrofit_table.table.columns[1].width = Inches(1) + retrofit_table.table.columns[2].width = Inches(1) + retrofit_table.table.columns[3].width = Inches(1) + + for j in range(len(retrofit_table_head)): # pylint: disable=consider-using-enumerate + retrofit_table.table.cell(0, j).text = retrofit_table_head[j] + retrofit_table.table.cell(0, j).text_frame.paragraphs[0].font.size = Pt(12) + retrofit_table.table.cell(0, j).text_frame.paragraphs[0].font.bold = True + + for k, j in zip(retrofit_list, range(len(retrofit_list))): + retrofit_table.table.cell(j+1, 0).text_frame.paragraphs[0].font.size = Pt(10) + retrofit_table.table.cell(j+1, 0).text = k + retrofit_table.table.cell(j+1, 1).text_frame.paragraphs[0].font.size = Pt(10) + retrofit_table.table.cell(j+1, 1).text = str(int(retrofit_heat_save[j])) + '\N{PERCENT SIGN}' + retrofit_table.table.cell(j+1, 1).text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER + retrofit_table.table.cell(j+1, 1).text_frame.vertical_anchor = MSO_ANCHOR.MIDDLE + retrofit_table.table.cell(j+1, 2).text_frame.paragraphs[0].font.size = Pt(10) + retrofit_table.table.cell(j+1, 2).text = str(int(retrofit_elec_save[j])) + '\N{PERCENT SIGN}' + retrofit_table.table.cell(j+1, 2).text_frame.paragraphs[0].alignment = PP_ALIGN.CENTER + retrofit_table.table.cell(j+1, 2).text_frame.vertical_anchor = MSO_ANCHOR.MIDDLE + + retrofit_table.table.cell(retrofit_count+1, 0).text_frame.paragraphs[0].font.size = Pt(12) + retrofit_table.table.cell(retrofit_count+1, 0).text_frame.paragraphs[0].font.bold = True + retrofit_table.table.cell(retrofit_count+1, 0).text = 'Total' + + retrofit_table.table.cell(retrofit_count+1, 2).text_frame.paragraphs[0].font.size = Pt(12) + retrofit_table.table.cell(retrofit_count+1, 2).text_frame.paragraphs[0].font.bold = True + retrofit_table.table.cell(retrofit_count+1, 2).text = str(annual_utility_percent) + '\N{PERCENT SIGN}' # Slides 5-end: removing slides based on recommendations - for ecm_index in ecm_delete_list: + for retrofit_index in retrofit_delete_list: diag_rep.slides.delete_slide( diag_rep, - ecm_index, + retrofit_index, ) return project_address, diag_rep @@ -387,16 +387,17 @@ class CbraDiagnostic: project_summary_data, util_break_data, heat_loss_data, - ecm_data + retro_data ) = CbraDiagnostic.parse_arguments(sheet_input) project_address, diag_rep = CbraDiagnostic._generate_report( template_file, project_summary_data, util_break_data, heat_loss_data, - ecm_data, + retro_data, ) diag_rep.save('EEDR {}.pptx'.format(project_address)) + print('Report generated!') @staticmethod def parse_arguments(sheet_input): @@ -410,7 +411,7 @@ class CbraDiagnostic: dict: A dictionary containing all of the project summary data dict: A dictionary containing all of the utility breakdown data dict: A dictionary containing all of the heat loss data - dict: A dictionary containing all of the ECM data + dict: A dictionary containing all of the retrofit data """ project_summary_data = { @@ -439,25 +440,25 @@ class CbraDiagnostic: 'heat_loss_val': input_values[9:15], } - ecm_list = [] - ecm_heat_save = [] - ecm_elec_save = [] + retrofit_list = [] + retrofit_heat_save = [] + retrofit_elec_save = [] for j in range(len(input_values)): # pylint: disable=C0200 if input_values[j] == 'Y': # Convert to database string - ecm_list.append( + retrofit_list.append( RETROFIT_TO_CBRA_RETROFIT[input_list[j]] ) - ecm_heat_save.append(input_values[j+1]) - ecm_elec_save.append(input_values[j+2]) + retrofit_heat_save.append(input_values[j+1]) + retrofit_elec_save.append(input_values[j+2]) - ecm_data = { - 'ecm_list': ecm_list, - 'ecm_heat_save': ecm_heat_save, - 'ecm_elec_save': ecm_elec_save, + retro_data = { + 'retrofit_list': retrofit_list, + 'retrofit_heat_save': retrofit_heat_save, + 'retrofit_elec_save': retrofit_elec_save, } - return project_summary_data, util_break_data, heat_loss_data, ecm_data + return project_summary_data, util_break_data, heat_loss_data, retro_data @staticmethod def cbra_multi_rep(): @@ -484,14 +485,14 @@ class CbraDiagnostic: project_summary_data, util_break_data, heat_loss_data, - ecm_data + retro_data ) = CbraDiagnostic.parse_arguments(sheet_input) proj_loc, diag_rep = CbraDiagnostic._generate_report( template_file, project_summary_data, util_break_data, heat_loss_data, - ecm_data, + retro_data, ) diag_rep.save('EEDR {}.pptx'.format(proj_loc)) print('Reports generated!') diff --git a/bpeng/reports/constants.py b/bpeng/reports/constants.py index 6e1dcdb..674ab16 100644 --- a/bpeng/reports/constants.py +++ b/bpeng/reports/constants.py @@ -1,4 +1,4 @@ -ECM_TO_SLIDE = { +RETRO_TO_SLIDE = { 'Weatherstripping (Exterior Doors)': { 'slide_index': 4, 'slide_name': 'Install Weather-stripping', -- GitLab From 251d622b523163a210feadae8952c542bdd1b343 Mon Sep 17 00:00:00 2001 From: areza-blocpower Date: Tue, 9 May 2017 10:28:53 -0400 Subject: [PATCH 2/4] Change retro to retrofit in var names. Change constant list from RETRO_TO_SLIDE to MASTER_TO_SLIDE --- bpeng/reports/cbra_diag.py | 28 ++++++++++++++-------------- bpeng/reports/constants.py | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bpeng/reports/cbra_diag.py b/bpeng/reports/cbra_diag.py index 1b63a98..0a4e278 100644 --- a/bpeng/reports/cbra_diag.py +++ b/bpeng/reports/cbra_diag.py @@ -22,7 +22,7 @@ from pptx.enum.text import ( # pylint: disable=no-name-in-module ) from pptx.util import Inches, Pt -from .constants import RETRO_TO_SLIDE, RETROFIT_TO_CBRA_RETROFIT +from .constants import MASTER_TO_SLIDE, RETROFIT_TO_CBRA_RETROFIT class CbraDiagnostic: @@ -36,7 +36,7 @@ class CbraDiagnostic: project_summary_data, util_break_data, heat_loss_data, - retro_data, + retrofit_data, ): """ Generate powerpoint file @@ -50,7 +50,7 @@ class CbraDiagnostic: util_break_data (dict): python dictionary of utility breakdown [$] by end usage heat_loss_data (dict): python dictionary of building components and heat loss values - retro_data (dict): python dictionary of selected retrofits and calculated percent + retrofit_data (dict): python dictionary of selected retrofits and calculated percent savings on utility bill [$] by fuel @@ -77,9 +77,9 @@ class CbraDiagnostic: heat_loss_cat = heat_loss_data['heat_loss_cat'] heat_loss_val = heat_loss_data['heat_loss_val'] - retrofit_list = retro_data['retrofit_list'] - retrofit_heat_save = retro_data['retrofit_heat_save'] - retrofit_elec_save = retro_data['retrofit_elec_save'] + retrofit_list = retrofit_data['retrofit_list'] + retrofit_heat_save = retrofit_data['retrofit_heat_save'] + retrofit_elec_save = retrofit_data['retrofit_elec_save'] # Convert database strings to presentation strings # Also calculate new heat or elec save in cases where # database retrofit's are combined to a single presentation retrofit @@ -87,7 +87,7 @@ class CbraDiagnostic: new_retrofit_heat_save = [] new_retrofit_elec_save = [] for name, heat, elec in zip(retrofit_list, retrofit_heat_save, retrofit_elec_save): - presentation_name = RETRO_TO_SLIDE[name]['slide_name'] + presentation_name = MASTER_TO_SLIDE[name]['slide_name'] if presentation_name in new_retrofit_list: combine_index = new_retrofit_list.index(presentation_name) # Right now we just add together heat and elec. @@ -105,7 +105,7 @@ class CbraDiagnostic: # Create a delete list by adding everything not in the retrofit_list retrofit_delete_list = [] - for slide in RETRO_TO_SLIDE.values(): + for slide in MASTER_TO_SLIDE.values(): if slide['slide_name'] not in retrofit_list and slide['slide_index'] not in retrofit_delete_list: retrofit_delete_list.append(slide['slide_index']) @@ -387,14 +387,14 @@ class CbraDiagnostic: project_summary_data, util_break_data, heat_loss_data, - retro_data + retrofit_data ) = CbraDiagnostic.parse_arguments(sheet_input) project_address, diag_rep = CbraDiagnostic._generate_report( template_file, project_summary_data, util_break_data, heat_loss_data, - retro_data, + retrofit_data, ) diag_rep.save('EEDR {}.pptx'.format(project_address)) print('Report generated!') @@ -452,13 +452,13 @@ class CbraDiagnostic: retrofit_heat_save.append(input_values[j+1]) retrofit_elec_save.append(input_values[j+2]) - retro_data = { + retrofit_data = { 'retrofit_list': retrofit_list, 'retrofit_heat_save': retrofit_heat_save, 'retrofit_elec_save': retrofit_elec_save, } - return project_summary_data, util_break_data, heat_loss_data, retro_data + return project_summary_data, util_break_data, heat_loss_data, retrofit_data @staticmethod def cbra_multi_rep(): @@ -485,14 +485,14 @@ class CbraDiagnostic: project_summary_data, util_break_data, heat_loss_data, - retro_data + retrofit_data ) = CbraDiagnostic.parse_arguments(sheet_input) proj_loc, diag_rep = CbraDiagnostic._generate_report( template_file, project_summary_data, util_break_data, heat_loss_data, - retro_data, + retrofit_data, ) diag_rep.save('EEDR {}.pptx'.format(proj_loc)) print('Reports generated!') diff --git a/bpeng/reports/constants.py b/bpeng/reports/constants.py index 674ab16..b8406f6 100644 --- a/bpeng/reports/constants.py +++ b/bpeng/reports/constants.py @@ -1,4 +1,4 @@ -RETRO_TO_SLIDE = { +MASTER_TO_SLIDE = { 'Weatherstripping (Exterior Doors)': { 'slide_index': 4, 'slide_name': 'Install Weather-stripping', -- GitLab From 9f07c8c50dc2dba3ea758734d06ad1e13d5d6983 Mon Sep 17 00:00:00 2001 From: areza-blocpower Date: Tue, 9 May 2017 13:26:40 -0400 Subject: [PATCH 3/4] Fix spacing error in constants file --- bpeng/reports/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bpeng/reports/constants.py b/bpeng/reports/constants.py index b8406f6..7ccdfef 100644 --- a/bpeng/reports/constants.py +++ b/bpeng/reports/constants.py @@ -303,8 +303,8 @@ RETROFIT_TO_CBRA_RETROFIT = { 'Replace Windows': 'Window Replacement', 'Install Roof Insulation': 'Insulation (Roof)', 'Install Cool Roof': 'Cool Roof', - 'Install Boiler Control (Indoor Feedback)': 'Boiler Control(Indoor Feedback)', - 'Install Boiler Control (Outdoor Reset)': 'Boiler Control(Outdoor Reset)', + 'Install Boiler Control (Indoor Feedback)': 'Boiler Control (Indoor Feedback)', + 'Install Boiler Control (Outdoor Reset)': 'Boiler Control (Outdoor Reset)', 'Install Smart Thermostat with Indoor Sensors': 'Smart Thermostat w/ Indoor Sensor', 'Integrate EMS/BMS Systems': 'Building Management System/ Energy Management system', 'Convert from Oil to Gas': 'Oil to Gas Conversion', -- GitLab From a5fa7312c912bddf4b4b22929dc36e1f43fdcab5 Mon Sep 17 00:00:00 2001 From: Conrad Date: Mon, 19 Jun 2017 17:38:58 -0400 Subject: [PATCH 4/4] Bump bpengine version to 0.3.2 --- bpeng/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bpeng/__init__.py b/bpeng/__init__.py index d561008..6c4b6bc 100644 --- a/bpeng/__init__.py +++ b/bpeng/__init__.py @@ -4,4 +4,4 @@ BlocPower Engine library. Engineering and Financial modeling. """ -__version__ = '0.3.1' +__version__ = '0.3.2' -- GitLab