From dd781a56bf64ef432eef276d2153d7fdd6b79b98 Mon Sep 17 00:00:00 2001 From: guille Date: Mon, 20 Feb 2023 07:20:36 -0500 Subject: [PATCH] Completed v0.1 --- archetypes.py | 105 ++++++++++++++++++++++++++++++++++++++++ data/nrcan.xml | 2 +- transparent_surfaces.py | 2 +- 3 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 archetypes.py diff --git a/archetypes.py b/archetypes.py new file mode 100644 index 0000000..a4b72f0 --- /dev/null +++ b/archetypes.py @@ -0,0 +1,105 @@ +import configuration as c +import xmltodict +import json +from urllib.request import urlopen +from bs4 import BeautifulSoup + +def process_formula(formula, hdd): + formula = formula.replace('( hdd < ', '').replace(') ', '').split(':') + for equation in formula: + values = equation.split('? ') + if len(values) == 2: + if float(values[0]) > hdd: + return float(values[1]) + else: + return float(equation) + +with open(c.nrcan_urls, 'r') as f: + urls = xmltodict.parse(f.read(), force_list=['standards_per_period']) + +base_url_archetypes = urls['nrcan']['@base_url_archetypes'] +dictionary = {"archetypes": []} + +standards = urls['nrcan']['standards_per_function'] + +for standard in standards['standard']: + archetype_url = f'{base_url_archetypes}{standard["file_location"]}' + print(archetype_url) + html = urlopen(archetype_url).read() + parsed_html = BeautifulSoup(html, features="html.parser") + div = parsed_html.body.findAll('div', attrs={'class': 'in'}) + cells = str(div).replace('', '').replace('\n', '').replace('', '').split('') + for period in c.heavy_light.keys(): + for climate_zone in c.hdd_canadian_climate_zones.keys(): + + archetype = {} + function = standard['@function'] + archetype["function"] = function + archetype["period_of_construction"] = period + archetype["climate_zone"] = climate_zone + archetype["average_storey_height"] = 3.5 + if "Apartment" in function: + archetype["average_storey_height"] = 3.0 + archetype["thermal_capacity"] = 200 + archetype["extra_loses_due_thermal_bridges"] = 0.05 + if period == '1000_1979': + archetype["thermal_capacity"] = 300 + archetype["extra_loses_due_thermal_bridges"] = 0.1 + archetype["infiltration_rate_for_ventilation_system_on"] = 0 + archetype["infiltration_rate_for_ventilation_system_off"] = 0.3 + if period == '1000_1979': + archetype["infiltration_rate_for_ventilation_system_off"] = 1.8 + elif period == '1980_2010': + archetype["infiltration_rate_for_ventilation_system_off"] = 1.0 + count = 10 + window_wall_ratio = {"transparent_ratio": {}} + for cell in cells: + if cell == 'Gross Window-Wall Ratio': + count = 0 + if count == 2: + window_wall_ratio["transparent_ratio"]['north'] = cell + if count == 3: + window_wall_ratio["transparent_ratio"]['east'] = cell + if count == 4: + window_wall_ratio["transparent_ratio"]['south'] = cell + if count == 5: + window_wall_ratio["transparent_ratio"]['west'] = cell + if count < 6: + count += 1 + found = False + skylight_roof_ratio = {"transparent_ratio": {}} + for cell in cells: + if cell == 'Skylight-Roof Ratio': + found = True + elif found: + skylight_roof_ratio['transparent_ratio']['north'] = cell + skylight_roof_ratio['transparent_ratio']['east'] = cell + skylight_roof_ratio['transparent_ratio']['south'] = cell + skylight_roof_ratio['transparent_ratio']['west'] = cell + found = False + archetype["constructions"] = {} + archetype["constructions"]["OutdoorsWall"] = { + "opaque_surface_name": f'{period}_{climate_zone}', + "transparent_surface_name": f'Window_{period}_{climate_zone}', + "transparent_ratio": window_wall_ratio + } + archetype["constructions"]["OutdoorsRoofCeiling"] = { + "opaque_surface_name": f'{period}_{climate_zone}', + "transparent_surface_name": f'Skylight_{period}_{climate_zone}', + "transparent_ratio": skylight_roof_ratio + } + archetype["constructions"]["OutdoorsFloor"] = { + "opaque_surface_name": f'{period}_{climate_zone}' + } + archetype["constructions"]["GroundWall"] = { + "opaque_surface_name": f'{period}_{climate_zone}' + } + archetype["constructions"]["GroundRoofCeiling"] = { + "opaque_surface_name": f'{period}_{climate_zone}' + } + archetype["constructions"]["GroundFloor"] = { + "opaque_surface_name": f'{period}_{climate_zone}' + } + dictionary["archetypes"].append({"archetype": archetype}) +with open(f'{c.output_path}/archetypes.json', 'w') as f: + json.dump(dictionary, f, indent=2) diff --git a/data/nrcan.xml b/data/nrcan.xml index 757c07f..a23eb99 100644 --- a/data/nrcan.xml +++ b/data/nrcan.xml @@ -52,7 +52,7 @@ PrimarySchool/CAN_PQ_Montreal.Intl.AP.716270_CWEC/os_report/87f45397-5ef4-4df9-be41-d33c4b6d2fb7-os-report.html - QuickServiceRestaurant/CAN_PQ_Montreal.Intl.AP.716270_CWEC/ 0bc55858-a81b-4d07-9923-1d84e8a23194-os-report.html + QuickServiceRestaurant/CAN_PQ_Montreal.Intl.AP.716270_CWEC/os_report/0bc55858-a81b-4d07-9923-1d84e8a23194-os-report.html RetailStandalone/CAN_PQ_Montreal.Intl.AP.716270_CWEC/os_report/a3643bcb-0eea-47d4-b6b9-253ed188ec0c-os-report.html diff --git a/transparent_surfaces.py b/transparent_surfaces.py index 6c243fb..a865fb0 100644 --- a/transparent_surfaces.py +++ b/transparent_surfaces.py @@ -30,7 +30,7 @@ for standard in urls['nrcan']['standards_per_period']['standard']: windows_dictionary['transparent_surfaces'].append( { "transparent_surface": { - "name": f'{standard["@period_of_construction"]}_{climate_zone}', + "name": f'{ table["surface"]}_{standard["@period_of_construction"]}_{climate_zone}', "period_of_construction": f'{standard["@period_of_construction"]}', "climate_zone": f'{climate_zone}', "shgc": c.shgc_for_canadian_climate_zones[climate_zone],