Completed v0.1
This commit is contained in:
parent
05c8273ecc
commit
dd781a56bf
105
archetypes.py
Normal file
105
archetypes.py
Normal file
|
@ -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('</td>', '').replace('\n', '').replace('</tr><tr>', '').split('<td>')
|
||||
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)
|
|
@ -52,7 +52,7 @@
|
|||
<file_location>PrimarySchool/CAN_PQ_Montreal.Intl.AP.716270_CWEC/os_report/87f45397-5ef4-4df9-be41-d33c4b6d2fb7-os-report.html</file_location>
|
||||
</standard>
|
||||
<standard function="QuickServiceRestaurant">
|
||||
<file_location>QuickServiceRestaurant/CAN_PQ_Montreal.Intl.AP.716270_CWEC/ 0bc55858-a81b-4d07-9923-1d84e8a23194-os-report.html</file_location>
|
||||
<file_location>QuickServiceRestaurant/CAN_PQ_Montreal.Intl.AP.716270_CWEC/os_report/0bc55858-a81b-4d07-9923-1d84e8a23194-os-report.html</file_location>
|
||||
</standard>
|
||||
<standard function="RetailStandalone">
|
||||
<file_location>RetailStandalone/CAN_PQ_Montreal.Intl.AP.716270_CWEC/os_report/a3643bcb-0eea-47d4-b6b9-253ed188ec0c-os-report.html</file_location>
|
||||
|
|
|
@ -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],
|
||||
|
|
Loading…
Reference in New Issue
Block a user