def get_syrx_data(config): """ Gets the data for the syrx number in config and returns a kendo-formatted object of the data :param config: EquipmentReport :return: """ report_series_dict = {} benchmark_series_dict = {} if len(config.syrx_nums) > 1: target_unit = "mmbtu" else: target_unit = None for syrx_num in config.syrx_nums: # get the equipment point ep = g.uow.equipment.get_equipment_point_by_syrx_num(syrx_num) if not target_unit: target_unit = ep['units'].lower() conversion_factor = SharedReporting.get_component_point_conversion(ep['units'].lower(), 'mmbtu') syrx_series = get_consumption_data_for_year(syrx_num, config.report_year, config.start_month, config.end_month, conversion_factor) # add to the existing series add_to_new_series_data(report_series_dict, syrx_series[0]['data']) syrx_series_benchmark = get_consumption_data_for_year(syrx_num, config.comparison_year, config.start_month, config.end_month, conversion_factor) # add to the existing series add_to_new_series_data(benchmark_series_dict, syrx_series_benchmark[0]['data']) report_difference_list, benchmark_difference_list = calculate_difference_equipment_report(report_series_dict, benchmark_series_dict) consumption_series_list = convert_dict_to_list(report_series_dict) consumption_series_list[0]['name'] = 'Reported Consumption' benchmark_series_list = convert_dict_to_list(benchmark_series_dict) consumption_series_list += benchmark_series_list consumption_series_list[1]['name'] = 'Benchmark Consumption' difference_series_list = convert_dict_to_list(report_difference_list) difference_series_list[0]['name'] = 'Reported Consumption' difference_series_list += convert_dict_to_list(benchmark_difference_list) difference_series_list[1]['name'] = 'Benchmark Consumption' chart_info = ComponentDifferenceDataContainer() chart_info.component_description = "" chart_info.title = "Intensity" chart_info.consumption_data = consumption_series_list chart_info.difference_data = difference_series_list chart_info.x_axis_label = "Temperature (F)" chart_info.y_axis_label = "Energy Consumption (" + SharedReporting.get_y_unit_label(target_unit.lower()) + ")" return chart_info
def get_difference_chart_data(config, entity): """ Gets a ComponentDifferenceDataContainer that holds information for the chart :param config: ComponentReportingDifferenceConfiguration :param entity: Selected entity to get data for :return: ComponentDifferenceDataContainer that holds all information for the chart """ consumption_series_list = [] difference_series_list = [] # get syrx numbers for entity syrx_nums = get_syrx_nums_from_entity(entity) # get label for entity label = get_label_for_entity(entity) if syrx_nums: # get data for the report year and benchmark year independently report_data = get_difference_data_for_year(syrx_nums, config.report_year, 'Reported Consumption') consumption_series_list += report_data benchmark_data = get_difference_data_for_year(syrx_nums, config.benchmark_year, 'Benchmark Consumption') consumption_series_list += benchmark_data list_by_temp = map_difference_data(report_data, benchmark_data) # sort the list by temperature list_by_temp = sorted(list_by_temp, key=lambda x: x['temp']) # find the differences difference_series_list += calculate_difference(list_by_temp) chart_info = ComponentDifferenceDataContainer() chart_info.component_description = label chart_info.title = "Intensity" chart_info.consumption_data = consumption_series_list chart_info.difference_data = difference_series_list chart_info.x_axis_label = "Temperature (F)" chart_info.y_axis_label = "Energy Consumption (BTU)" return chart_info