def main(output_file): import cea.examples archive = zipfile.ZipFile( os.path.join(os.path.dirname(cea.examples.__file__), 'reference-case-open.zip')) archive.extractall(tempfile.gettempdir()) reference_case = os.path.join(tempfile.gettempdir(), 'reference-case-open', 'baseline') locator = InputLocator(reference_case) config = cea.config.Configuration(cea.config.DEFAULT_CONFIG) weather_path = locator.get_weather('Zug_inducity_2009') weather_data = epwreader.epw_reader(weather_path)[[ 'year', 'drybulb_C', 'wetbulb_C', 'relhum_percent', 'windspd_ms', 'skytemp_C' ]] # run properties script import cea.datamanagement.archetypes_mapper cea.datamanagement.archetypes_mapper.archetypes_mapper( locator, True, True, True, True, True, True, []) year = weather_data['year'][0] date_range = get_date_range_hours_from_year(year) resolution_outputs = config.demand.resolution_output loads_output = config.demand.loads_output massflows_output = config.demand.massflows_output temperatures_output = config.demand.temperatures_output use_dynamic_infiltration_calculation = config.demand.use_dynamic_infiltration_calculation debug = config.debug building_properties = BuildingProperties(locator) print("data for test_calc_thermal_loads:") print(building_properties.list_building_names()) schedule_maker_main(locator, config, building='B1011') bpr = building_properties['B1011'] result = calc_thermal_loads('B1011', bpr, weather_data, date_range, locator, use_dynamic_infiltration_calculation, resolution_outputs, loads_output, massflows_output, temperatures_output, config, debug) # test the building csv file df = pd.read_csv(locator.get_demand_results_file('B1011')) expected_columns = list(df.columns) print("expected_columns = %s" % repr(expected_columns)) test_config = configparser.ConfigParser() test_config.read(output_file) value_columns = [ u"E_sys_kWh", u"Qcdata_sys_kWh", u"Qcre_sys_kWh", u"Qcs_sys_kWh", u"Qhs_sys_kWh", u"Qww_sys_kWh", u"Tcs_sys_re_C", u"Ths_sys_re_C", u"Tww_sys_re_C", u"Tcs_sys_sup_C", u"Ths_sys_sup_C", u"Tww_sys_sup_C" ] values = [float(df[column].sum()) for column in value_columns] print("values = %s " % repr(values)) if not test_config.has_section("test_calc_thermal_loads"): test_config.add_section("test_calc_thermal_loads") test_config.set("test_calc_thermal_loads", "value_columns", json.dumps(value_columns)) print(values) test_config.set("test_calc_thermal_loads", "values", json.dumps(values)) print("data for test_calc_thermal_loads_other_buildings:") buildings = [ 'B1013', 'B1012', 'B1010', 'B1000', 'B1009', 'B1011', 'B1006', 'B1003', 'B1004', 'B1001', 'B1002', 'B1005', 'B1008', 'B1007', 'B1014' ] results = {} for building in buildings: bpr = building_properties[building] b, qhs_sys_kwh, qcs_sys_kwh, qww_sys_kwh = run_for_single_building( building, bpr, weather_data, date_range, locator, use_dynamic_infiltration_calculation, resolution_outputs, loads_output, massflows_output, temperatures_output, config, debug) print( "'%(b)s': (%(qhs_sys_kwh).5f, %(qcs_sys_kwh).5f, %(qww_sys_kwh).5f)," % locals()) results[building] = (qhs_sys_kwh, qcs_sys_kwh, qww_sys_kwh) if not test_config.has_section("test_calc_thermal_loads_other_buildings"): test_config.add_section("test_calc_thermal_loads_other_buildings") test_config.set("test_calc_thermal_loads_other_buildings", "results", json.dumps(results)) with open(output_file, 'w') as f: test_config.write(f) print("Wrote output to %(output_file)s" % locals())
def main(output_file): import cea.examples archive = zipfile.ZipFile( os.path.join(os.path.dirname(cea.examples.__file__), 'reference-case-open.zip')) archive.extractall(tempfile.gettempdir()) reference_case = os.path.join(tempfile.gettempdir(), 'reference-case-open', 'baseline') locator = InputLocator(reference_case) config = cea.config.Configuration(cea.config.DEFAULT_CONFIG) weather_path = locator.get_weather('Zug') weather_data = epwreader.epw_reader(weather_path)[[ 'year', 'drybulb_C', 'wetbulb_C', 'relhum_percent', 'windspd_ms', 'skytemp_C' ]] # run properties script import cea.datamanagement.data_helper cea.datamanagement.data_helper.data_helper(locator, config, True, True, True, True, True, True) region = config.region year = weather_data['year'][0] use_daysim_radiation = config.demand.use_daysim_radiation resolution_outputs = config.demand.resolution_output loads_output = config.demand.loads_output massflows_output = config.demand.massflows_output temperatures_output = config.demand.temperatures_output format_output = config.demand.format_output use_dynamic_infiltration_calculation = config.demand.use_dynamic_infiltration_calculation use_stochastic_occupancy = config.demand.use_stochastic_occupancy building_properties, schedules_dict, date = properties_and_schedule( locator, region, year, use_daysim_radiation) print("data for test_calc_thermal_loads:") print(building_properties.list_building_names()) bpr = building_properties['B01'] result = calc_thermal_loads('B01', bpr, weather_data, schedules_dict, date, locator, use_stochastic_occupancy, use_dynamic_infiltration_calculation, resolution_outputs, loads_output, massflows_output, temperatures_output, format_output, region) # test the building csv file df = pd.read_csv(locator.get_demand_results_file('B01')) expected_columns = list(df.columns) print("expected_columns = %s" % repr(expected_columns)) test_config = ConfigParser.SafeConfigParser() test_config.read(output_file) value_columns = [ u"E_sys_kWh", u"Qcdata_sys_kWh", u"Qcre_sys_kWh", u"Qcs_sys_kWh", u"Qhs_sys_kWh", u"Qww_sys_kWh", u"Tcs_sys_re_C", u"Ths_sys_re_C", u"Tww_sys_re_C", u"Tcs_sys_sup_C", u"Ths_sys_sup_C", u"Tww_sys_sup_C" ] values = [float(df[column].sum()) for column in value_columns] print("values = %s " % repr(values)) if not test_config.has_section("test_calc_thermal_loads"): test_config.add_section("test_calc_thermal_loads") test_config.set("test_calc_thermal_loads", "value_columns", json.dumps(value_columns)) print values test_config.set("test_calc_thermal_loads", "values", json.dumps(values)) print("data for test_calc_thermal_loads_other_buildings:") buildings = ['B01', 'B03', 'B02', 'B05', 'B04', 'B07', 'B06', 'B09', 'B08'] results = {} for building in buildings: bpr = building_properties[building] b, qhs_sys_kwh, qcs_sys_kwh, qww_sys_kwh = run_for_single_building( building, bpr, weather_data, schedules_dict, date, locator, use_stochastic_occupancy, use_dynamic_infiltration_calculation, resolution_outputs, loads_output, massflows_output, temperatures_output, format_output, region) print( "'%(b)s': (%(qhs_sys_kwh).5f, %(qcs_sys_kwh).5f, %(qww_sys_kwh).5f)," % locals()) results[building] = (qhs_sys_kwh, qcs_sys_kwh, qww_sys_kwh) if not test_config.has_section("test_calc_thermal_loads_other_buildings"): test_config.add_section("test_calc_thermal_loads_other_buildings") test_config.set("test_calc_thermal_loads_other_buildings", "results", json.dumps(results)) with open(output_file, 'w') as f: test_config.write(f) print("Wrote output to %(output_file)s" % locals())