erased populate and created enrich in libs.helpers.
add new constants to helpers.constants
This commit is contained in:
parent
e5cc627ce4
commit
b319ae50dc
|
@ -1,8 +1,51 @@
|
||||||
|
# universal constants
|
||||||
KELVIN = 273.15
|
KELVIN = 273.15
|
||||||
|
|
||||||
|
# time
|
||||||
MINUTE = 'minute'
|
MINUTE = 'minute'
|
||||||
HOUR = 'hour'
|
HOUR = 'hour'
|
||||||
DAY = 'day'
|
DAY = 'day'
|
||||||
WEEK = 'week'
|
WEEK = 'week'
|
||||||
MONTH = 'month'
|
MONTH = 'month'
|
||||||
YEAR = 'year'
|
YEAR = 'year'
|
||||||
|
|
||||||
|
# todo: modify code to use global constants instead of hard-coded values
|
||||||
|
# surface types
|
||||||
|
WALL = 'Wall'
|
||||||
|
GROUND_WALL = 'Ground wall'
|
||||||
|
GROUND = 'Ground'
|
||||||
|
ATTIC_FLOOR = 'Attic floor'
|
||||||
|
ROOF = 'Roof'
|
||||||
|
INTERIOR_SLAB = 'Interior slab'
|
||||||
|
INTERIOR_WALL = 'Interior wall'
|
||||||
|
WINDOW = 'Window'
|
||||||
|
DOOR = 'Door'
|
||||||
|
SKYLIGHT = 'Skylight'
|
||||||
|
|
||||||
|
# todo: homogenize function and usage!!
|
||||||
|
# function
|
||||||
|
RESIDENTIAL = 'residential'
|
||||||
|
SFH = 'single family house'
|
||||||
|
MFH = 'multifamily house'
|
||||||
|
HOTEL = 'hotel'
|
||||||
|
HOSPITAL = 'hospital'
|
||||||
|
OUTPATIENT = 'outpatient'
|
||||||
|
COMMERCIAL = 'commercial'
|
||||||
|
STRIP_MALL = 'strip mall'
|
||||||
|
WAREHOUSE = 'warehouse'
|
||||||
|
PRIMARY_SCHOOL = 'primary school'
|
||||||
|
SECONDARY_SCHOOL = 'secondary school'
|
||||||
|
OFFICE = 'office'
|
||||||
|
LARGE_OFFICE = 'large office'
|
||||||
|
|
||||||
|
# usage
|
||||||
|
INDUSTRY = 'industry'
|
||||||
|
OFFICE_ADMINISTRATION = 'office and administration'
|
||||||
|
HEALTH_CARE = 'health care'
|
||||||
|
RETAIL = 'retail'
|
||||||
|
HALL = 'hall'
|
||||||
|
RESTAURANT = 'restaurant'
|
||||||
|
EDUCATION = 'education'
|
||||||
|
|
||||||
|
# general project-related
|
||||||
ROUGHNESS = "MediumRough"
|
ROUGHNESS = "MediumRough"
|
||||||
|
|
71
helpers/enrich_city.py
Normal file
71
helpers/enrich_city.py
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
"""
|
||||||
|
Enrich city
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
"""
|
||||||
|
|
||||||
|
from imports.construction_factory import ConstructionFactory
|
||||||
|
from imports.usage_factory import UsageFactory
|
||||||
|
from imports.schedules_factory import SchedulesFactory
|
||||||
|
|
||||||
|
|
||||||
|
class EnrichCity:
|
||||||
|
def __init__(self, city):
|
||||||
|
self._city = city
|
||||||
|
self._enriched_city = None
|
||||||
|
self._errors = []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def errors(self):
|
||||||
|
return self._errors
|
||||||
|
|
||||||
|
def enriched_city(self, construction_format=None, usage_format=None, schedules_format=None):
|
||||||
|
if self._enriched_city is None:
|
||||||
|
self._errors = []
|
||||||
|
|
||||||
|
print('original:', len(self._city.buildings))
|
||||||
|
if construction_format is not None:
|
||||||
|
ConstructionFactory(construction_format, self._city).enrich()
|
||||||
|
for building in self._city.buildings:
|
||||||
|
# infiltration_rate_system_off is a mandatory parameter.
|
||||||
|
# If it is not returned, extract the building from the calculation list
|
||||||
|
if building.thermal_zones[0].infiltration_rate_system_off is None:
|
||||||
|
self._city.remove_city_object(building)
|
||||||
|
if self._city.buildings is None:
|
||||||
|
self._errors.append('no archetype found per construction')
|
||||||
|
self._enriched_city = self._city
|
||||||
|
return self._enriched_city
|
||||||
|
print('enriched with construction:', len(self._city.buildings))
|
||||||
|
|
||||||
|
if usage_format is not None:
|
||||||
|
UsageFactory(usage_format, self._city).enrich()
|
||||||
|
for building in self._city.buildings:
|
||||||
|
# At least one thermal zone must be created.
|
||||||
|
# If it is not created, extract the building from the calculation list
|
||||||
|
if len(building.usage_zones) <= 0:
|
||||||
|
self._city.remove_city_object(building)
|
||||||
|
if self._city.buildings is None:
|
||||||
|
self._errors.append('no archetype found per usage')
|
||||||
|
self._enriched_city = self._city
|
||||||
|
return self._enriched_city
|
||||||
|
print('enriched with usage:', len(self._city.buildings))
|
||||||
|
|
||||||
|
if schedules_format is not None:
|
||||||
|
SchedulesFactory(schedules_format, self._city).enrich()
|
||||||
|
for building in self._city.buildings:
|
||||||
|
counter_schedules = 0
|
||||||
|
for usage_zone in building.usage_zones:
|
||||||
|
# At least one schedule must be created at each thermal zone.
|
||||||
|
# If it is not created, extract the building from the calculation list
|
||||||
|
if len(usage_zone.schedules) > 0:
|
||||||
|
counter_schedules += 1
|
||||||
|
if counter_schedules < len(building.usage_zones):
|
||||||
|
self._city.remove_city_object(building)
|
||||||
|
if self._city.buildings is None:
|
||||||
|
self._errors.append('no archetype found per usage')
|
||||||
|
self._enriched_city = self._city
|
||||||
|
return self._enriched_city
|
||||||
|
print('enriched with occupancy:', len(self._city.buildings))
|
||||||
|
|
||||||
|
self._enriched_city = self._city
|
||||||
|
return self._enriched_city
|
|
@ -4,24 +4,25 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
from helpers import constants as cte
|
||||||
|
|
||||||
|
|
||||||
class ConstructionHelper:
|
class ConstructionHelper:
|
||||||
# NREL
|
# NREL
|
||||||
function_to_nrel = {
|
function_to_nrel = {
|
||||||
'residential': 'residential',
|
cte.RESIDENTIAL: 'residential',
|
||||||
'single family house': 'single family house',
|
cte.SFH: 'single family house',
|
||||||
'multifamily house': 'multifamily house',
|
cte.MFH: 'multifamily house',
|
||||||
'hotel': 'hotel',
|
cte.HOTEL: 'hotel',
|
||||||
'hospital': 'hospital',
|
cte.HOSPITAL: 'hospital',
|
||||||
'outpatient': 'outpatient',
|
cte.OUTPATIENT: 'outpatient',
|
||||||
'commercial': 'commercial',
|
cte.COMMERCIAL: 'commercial',
|
||||||
'strip mall': 'strip mall',
|
cte.STRIP_MALL: 'strip mall',
|
||||||
'warehouse': 'warehouse',
|
cte.WAREHOUSE: 'warehouse',
|
||||||
'primary school': 'primary school',
|
cte.PRIMARY_SCHOOL: 'primary school',
|
||||||
'secondary school': 'secondary school',
|
cte.SECONDARY_SCHOOL: 'secondary school',
|
||||||
'office': 'office',
|
cte.OFFICE: 'office',
|
||||||
'large office': 'large office'
|
cte.LARGE_OFFICE: 'large office'
|
||||||
}
|
}
|
||||||
nrel_function_default_value = 'residential'
|
nrel_function_default_value = 'residential'
|
||||||
nrel_standards = {
|
nrel_standards = {
|
||||||
|
@ -46,42 +47,42 @@ class ConstructionHelper:
|
||||||
'Duluth': 'ASHRAE_2004:7A',
|
'Duluth': 'ASHRAE_2004:7A',
|
||||||
'Fairbanks': 'ASHRAE_2004:8A'
|
'Fairbanks': 'ASHRAE_2004:8A'
|
||||||
}
|
}
|
||||||
nrel_window_types = ['window', 'door', 'skylight']
|
nrel_window_types = [cte.WINDOW, cte.DOOR, cte.SKYLIGHT]
|
||||||
nrel_construction_types = {
|
nrel_construction_types = {
|
||||||
'Wall': 'exterior wall',
|
cte.WALL: 'exterior wall',
|
||||||
'Interior wall': 'interior wall',
|
cte.INTERIOR_WALL: 'interior wall',
|
||||||
'Ground wall': 'ground wall',
|
cte.GROUND_WALL: 'ground wall',
|
||||||
'Ground': 'exterior slab',
|
cte.GROUND: 'exterior slab',
|
||||||
'Attic floor': 'attic floor',
|
cte.ATTIC_FLOOR: 'attic floor',
|
||||||
'Interior slab': 'interior slab',
|
cte.INTERIOR_SLAB: 'interior slab',
|
||||||
'Roof': 'roof'
|
cte.ROOF: 'roof'
|
||||||
}
|
}
|
||||||
|
|
||||||
# NRCAN
|
# NRCAN
|
||||||
function_to_nrcan = {
|
function_to_nrcan = {
|
||||||
'residential': 'residential',
|
cte.RESIDENTIAL: 'residential',
|
||||||
'single family house': 'single family house',
|
cte.SFH: 'single family house',
|
||||||
'multifamily house': 'multifamily house',
|
cte.MFH: 'multifamily house',
|
||||||
'hotel': 'hotel',
|
cte.HOTEL: 'hotel',
|
||||||
'hospital': 'hospital',
|
cte.HOSPITAL: 'hospital',
|
||||||
'outpatient': 'outpatient',
|
cte.OUTPATIENT: 'outpatient',
|
||||||
'commercial': 'commercial',
|
cte.COMMERCIAL: 'commercial',
|
||||||
'strip mall': 'strip mall',
|
cte.STRIP_MALL: 'strip mall',
|
||||||
'warehouse': 'warehouse',
|
cte.WAREHOUSE: 'warehouse',
|
||||||
'primary school': 'primary school',
|
cte.PRIMARY_SCHOOL: 'primary school',
|
||||||
'secondary school': 'secondary school',
|
cte.SECONDARY_SCHOOL: 'secondary school',
|
||||||
'office': 'office',
|
cte.OFFICE: 'office',
|
||||||
'large office': 'large office'
|
cte.LARGE_OFFICE: 'large office'
|
||||||
}
|
}
|
||||||
nrcan_function_default_value = 'residential'
|
nrcan_function_default_value = 'residential'
|
||||||
nrcan_window_types = ['window']
|
nrcan_window_types = [cte.WINDOW]
|
||||||
nrcan_construction_types = {
|
nrcan_construction_types = {
|
||||||
'Wall': 'wall',
|
cte.WALL: 'exterior wall',
|
||||||
'Ground wall': 'basement_wall',
|
cte.GROUND_WALL: 'ground wall',
|
||||||
'Ground': 'floor',
|
cte.GROUND: 'exterior slab',
|
||||||
'Attic floor': 'attic floor',
|
cte.ATTIC_FLOOR: 'attic floor',
|
||||||
'Interior slab': 'interior slab',
|
cte.INTERIOR_SLAB: 'interior slab',
|
||||||
'Roof': 'roof'
|
cte.ROOF: 'roof'
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -4,6 +4,8 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
class GeometryHelper:
|
class GeometryHelper:
|
||||||
# function
|
# function
|
||||||
|
@ -230,30 +232,30 @@ class GeometryHelper:
|
||||||
'Z9': 'na'
|
'Z9': 'na'
|
||||||
}
|
}
|
||||||
hft_to_function = {
|
hft_to_function = {
|
||||||
'residential': 'residential',
|
'residential': cte.RESIDENTIAL,
|
||||||
'single family house': 'single family house',
|
'single family house': cte.SFH,
|
||||||
'multifamily house': 'multifamily house',
|
'multifamily house': cte.MFH,
|
||||||
'hotel': 'hotel',
|
'hotel': cte.HOTEL,
|
||||||
'hospital': 'hospital',
|
'hospital': cte.HOSPITAL,
|
||||||
'outpatient': 'outpatient',
|
'outpatient': cte.OUTPATIENT,
|
||||||
'commercial': 'commercial',
|
'commercial': cte.COMMERCIAL,
|
||||||
'strip mall': 'strip mall',
|
'strip mall': cte.STRIP_MALL,
|
||||||
'warehouse': 'warehouse',
|
'warehouse': cte.WAREHOUSE,
|
||||||
'primary school': 'primary school',
|
'primary school': cte.PRIMARY_SCHOOL,
|
||||||
'secondary school': 'secondary school',
|
'secondary school': cte.SECONDARY_SCHOOL,
|
||||||
'office': 'office',
|
'office': cte.OFFICE,
|
||||||
'large office': 'large office'
|
'large office': cte.LARGE_OFFICE
|
||||||
}
|
}
|
||||||
|
|
||||||
# usage
|
# usage
|
||||||
function_to_usage = {
|
function_to_usage = {
|
||||||
'full service restaurant': 'restaurant',
|
'full service restaurant': 'restaurant',
|
||||||
'highrise apartment': 'residential',
|
'highrise apartment': cte.RESIDENTIAL,
|
||||||
'hospital': 'health care',
|
'hospital': 'health care',
|
||||||
'large hotel': 'hotel',
|
'large hotel': 'hotel',
|
||||||
'large office': 'office and administration',
|
'large office': 'office and administration',
|
||||||
'medium office': 'office and administration',
|
'medium office': 'office and administration',
|
||||||
'midrise apartment': 'residential',
|
'midrise apartment': cte.RESIDENTIAL,
|
||||||
'outpatient healthcare': 'health care',
|
'outpatient healthcare': 'health care',
|
||||||
'primary school': 'education',
|
'primary school': 'education',
|
||||||
'quick service restaurant': 'restaurant',
|
'quick service restaurant': 'restaurant',
|
||||||
|
@ -264,7 +266,7 @@ class GeometryHelper:
|
||||||
'strip mall': 'hall',
|
'strip mall': 'hall',
|
||||||
'supermarket': 'retail',
|
'supermarket': 'retail',
|
||||||
'warehouse': 'industry',
|
'warehouse': 'industry',
|
||||||
'residential': 'residential'
|
'residential': cte.RESIDENTIAL
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -5,19 +5,20 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
|
||||||
contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
import helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
class SchedulesHelper:
|
class SchedulesHelper:
|
||||||
usage_to_comnet = {
|
usage_to_comnet = {
|
||||||
'residential': 'C-12 Residential',
|
cte.RESIDENTIAL: 'C-12 Residential',
|
||||||
'industry': 'C-10 Warehouse',
|
cte.INDUSTRY: 'C-10 Warehouse',
|
||||||
'office and administration': 'C-5 Office',
|
cte.OFFICE_ADMINISTRATION: 'C-5 Office',
|
||||||
'hotel': 'C-3 Hotel',
|
cte.HOTEL: 'C-3 Hotel',
|
||||||
'health care': 'C-2 Health',
|
cte.HEALTH_CARE: 'C-2 Health',
|
||||||
'retail': 'C-8 Retail',
|
cte.RETAIL: 'C-8 Retail',
|
||||||
'hall': 'C-8 Retail',
|
cte.HALL: 'C-8 Retail',
|
||||||
'restaurant': 'C-7 Restaurant',
|
cte.RESTAURANT: 'C-7 Restaurant',
|
||||||
'education': 'C-9 School'
|
cte.EDUCATION: 'C-9 School'
|
||||||
}
|
}
|
||||||
comnet_default_value = 'C-12 Residential'
|
comnet_default_value = 'C-12 Residential'
|
||||||
|
|
||||||
|
|
|
@ -4,19 +4,20 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
import helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
class UsageHelper:
|
class UsageHelper:
|
||||||
usage_to_hft = {
|
usage_to_hft = {
|
||||||
'residential': 'residential',
|
cte.RESIDENTIAL: 'residential',
|
||||||
'industry': 'industry',
|
cte.INDUSTRY: 'industry',
|
||||||
'office and administration': 'office and administration',
|
cte.OFFICE_ADMINISTRATION: 'office and administration',
|
||||||
'hotel': 'hotel',
|
cte.HOTEL: 'hotel',
|
||||||
'health care': 'health care',
|
cte.HEALTH_CARE: 'health care',
|
||||||
'retail': 'retail',
|
cte.RETAIL: 'retail',
|
||||||
'hall': 'hall',
|
cte.HALL: 'hall',
|
||||||
'restaurant': 'restaurant',
|
cte.RESTAURANT: 'restaurant',
|
||||||
'education': 'education'
|
cte.EDUCATION: 'education'
|
||||||
}
|
}
|
||||||
hft_default_value = 'residential'
|
hft_default_value = 'residential'
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ from pathlib import Path
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
from imports.geometry_factory import GeometryFactory
|
from imports.geometry_factory import GeometryFactory
|
||||||
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
||||||
from city_model_structure.city import City
|
|
||||||
from exports.exports_factory import ExportsFactory
|
|
||||||
|
|
||||||
|
|
||||||
class TestGeometryFactory(TestCase):
|
class TestGeometryFactory(TestCase):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user