Remove non-existing windows/skylights and ratios

This commit is contained in:
Guille Gutierrez 2023-02-22 06:40:44 -05:00
parent 88dba07889
commit f793d86ab8
3 changed files with 67 additions and 14 deletions

View File

@ -1,9 +1,10 @@
import configuration as c
import xmltodict
import json
from urllib.request import urlopen
import xmltodict
from bs4 import BeautifulSoup
import configuration as c
print('start archetypes')
@ -21,6 +22,10 @@ def process_formula(formula, hdd):
with open(c.nrcan_urls, 'r') as f:
urls = xmltodict.parse(f.read(), force_list=['standards_per_period'])
with open(c.transparent_surfaces_path, 'r') as f:
transparent_surfaces = json.load(f)
transparent_surfaces = [list(t.keys())[0] for t in transparent_surfaces['transparent_surfaces']]
base_url_archetypes = urls['nrcan']['@base_url_archetypes']
dictionary = {"archetypes": []}
@ -28,7 +33,6 @@ 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'})
@ -82,16 +86,33 @@ for standard in standards['standard']:
skylight_roof_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
}
construction = f'Window_{period}_{climate_zone}'
if construction in transparent_surfaces:
archetype["constructions"]["OutdoorsWall"] = {
"opaque_surface_name": f'{period}_{climate_zone}',
"transparent_surface_name": f'Window_{period}_{climate_zone}',
"transparent_ratio": window_wall_ratio
}
else:
archetype["constructions"]["OutdoorsWall"] = {
"opaque_surface_name": f'{period}_{climate_zone}',
"transparent_surface_name": None,
"transparent_ratio": c.null_transparent_ratio
}
construction = f'Skylight_{period}_{climate_zone}'
if construction in transparent_surfaces:
archetype["constructions"]["OutdoorsRoofCeiling"] = {
"opaque_surface_name": f'{period}_{climate_zone}',
"transparent_surface_name": f'Skylight_{period}_{climate_zone}',
"transparent_ratio": skylight_roof_ratio
}
else:
archetype["constructions"]["OutdoorsRoofCeiling"] = {
"opaque_surface_name": f'{period}_{climate_zone}',
"transparent_surface_name": None,
"transparent_ratio": c.null_transparent_ratio
}
archetype["constructions"]["OutdoorsFloor"] = {
"opaque_surface_name": f'{period}_{climate_zone}'
}
@ -105,5 +126,5 @@ for standard in standards['standard']:
"opaque_surface_name": f'{period}_{climate_zone}'
}
dictionary["archetypes"].append(archetype)
with open(f'{c.output_path}/archetypes.json', 'w') as f:
with open(f'{c.output_path}/nrcan_archetypes.json', 'w') as f:
json.dump(dictionary, f, indent=2)

View File

@ -3,6 +3,18 @@ from pathlib import Path
data_path = Path('./data/').resolve()
nrcan_urls = Path('./data/nrcan.xml')
output_path = Path('./output/').resolve()
transparent_surfaces_path = (output_path / 'transparent_surfaces.json').resolve()
opaque_surfaces_path = (output_path / 'opaque_surfaces.json').resolve()
nrcan_constructions = (output_path / 'nrcan_constructions.json').resolve()
nrcan_archetypes = (output_path / 'nrcan_archetypes.json').resolve()
null_transparent_ratio = {
"north": None,
"east": None,
"south": None,
"west": None
}
shgc_for_canadian_climate_zones = {'4': 0.39, '5': 0.39, '6': 0.39, '7A': 0.49, '7B': 0.49, '8': 0.41}

20
main.py
View File

@ -1,5 +1,25 @@
import os
import opaque_surfaces
import transparent_surfaces
import archetypes
import configuration as c
import json
print('compacting constructions')
with open(c.opaque_surfaces_path, 'r') as f:
opaque = json.load(f)
with open(c.transparent_surfaces_path, 'r') as f:
transparent = json.load(f)
os.remove(str(c.opaque_surfaces_path))
os.remove(str(c.transparent_surfaces_path))
constructions = dict(opaque_surfaces=opaque['opaque_surfaces'], transparent_surfaces=transparent['transparent_surfaces'])
with open(c.nrcan_constructions, 'w') as f:
json.dump(constructions, f)
print('NRCAN catalog successfully created')