completed parser for the data sources

This commit is contained in:
Guille Gutierrez 2022-05-19 12:02:13 -04:00
parent 15c1c1235f
commit c38d163d23
3 changed files with 78 additions and 21 deletions

View File

@ -4,10 +4,9 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group Copyright © 2022 Concordia CERC group
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
""" """
from typing import Union, List from typing import Union
from catalog_factories.data_models.usages.appliances import Appliances from catalog_factories.data_models.usages.appliances import Appliances
from catalog_factories.data_models.usages.internal_gain import InternalGain
from catalog_factories.data_models.usages.lighting import Lighting from catalog_factories.data_models.usages.lighting import Lighting
from catalog_factories.data_models.usages.ocupancy import Occupancy from catalog_factories.data_models.usages.ocupancy import Occupancy
from catalog_factories.data_models.usages.thermal_control import ThermalControl from catalog_factories.data_models.usages.thermal_control import ThermalControl
@ -18,6 +17,7 @@ class Usage:
hours_day, hours_day,
days_year, days_year,
mechanical_air_change, mechanical_air_change,
ventilation_rate,
occupancy, occupancy,
lighting, lighting,
appliances, appliances,
@ -26,6 +26,7 @@ class Usage:
self._hours_day = hours_day self._hours_day = hours_day
self._days_year = days_year self._days_year = days_year
self._mechanical_air_change = mechanical_air_change self._mechanical_air_change = mechanical_air_change
self._ventilation_rate = ventilation_rate
# classes # classes
self._occupancy = occupancy self._occupancy = occupancy
self._lighting = lighting self._lighting = lighting
@ -64,6 +65,14 @@ class Usage:
""" """
return self._mechanical_air_change return self._mechanical_air_change
@property
def ventilation_rate(self) -> Union[None, float]:
"""
Get usage zone ventilation rate in m3/m2s
:return: None or float
"""
return self._ventilation_rate
@property @property
def occupancy(self) -> Union[None, Occupancy]: def occupancy(self) -> Union[None, Occupancy]:
""" """
@ -103,4 +112,3 @@ class Usage:
:return: None or ThermalControl :return: None or ThermalControl
""" """
return self._thermal_control return self._thermal_control

View File

@ -11,6 +11,7 @@ import pandas as pd
import helpers.constants as cte import helpers.constants as cte
from catalog_factories.catalog import Catalog from catalog_factories.catalog import Catalog
from catalog_factories.data_models.usages.appliances import Appliances from catalog_factories.data_models.usages.appliances import Appliances
from catalog_factories.data_models.usages.content import Content
from catalog_factories.data_models.usages.lighting import Lighting from catalog_factories.data_models.usages.lighting import Lighting
from catalog_factories.data_models.usages.ocupancy import Occupancy from catalog_factories.data_models.usages.ocupancy import Occupancy
from catalog_factories.data_models.usages.schedule import Schedule from catalog_factories.data_models.usages.schedule import Schedule
@ -26,6 +27,7 @@ class ComnetCatalog(Catalog):
self._comnet_schedules_path = str(path / 'comnet_schedules_archetypes.xlsx') self._comnet_schedules_path = str(path / 'comnet_schedules_archetypes.xlsx')
self._archetypes = self._read_archetype_file() self._archetypes = self._read_archetype_file()
self._schedules = self._read_schedules_file() self._schedules = self._read_schedules_file()
sensible_convective = ch().comnet_occupancy_sensible_convective sensible_convective = ch().comnet_occupancy_sensible_convective
sensible_radiative = ch().comnet_occupancy_sensible_radiant sensible_radiative = ch().comnet_occupancy_sensible_radiant
lighting_convective = ch().comnet_lighting_convective lighting_convective = ch().comnet_lighting_convective
@ -34,6 +36,8 @@ class ComnetCatalog(Catalog):
appliances_convective = ch().comnet_plugs_convective appliances_convective = ch().comnet_plugs_convective
appliances_radiative = ch().comnet_plugs_radiant appliances_radiative = ch().comnet_plugs_radiant
appliances_latent = ch().comnet_plugs_latent appliances_latent = ch().comnet_plugs_latent
usages = []
for schedule_key in self._archetypes['schedules_key']: for schedule_key in self._archetypes['schedules_key']:
comnet_usage = schedule_key comnet_usage = schedule_key
schedule_name = self._archetypes['schedules_key'][schedule_key] schedule_name = self._archetypes['schedules_key'][schedule_key]
@ -41,11 +45,15 @@ class ComnetCatalog(Catalog):
occupancy_archetype = self._archetypes['occupancy'][comnet_usage] occupancy_archetype = self._archetypes['occupancy'][comnet_usage]
lighting_archetype = self._archetypes['lighting'][comnet_usage] lighting_archetype = self._archetypes['lighting'][comnet_usage]
appliances_archetype = self._archetypes['plug loads'][comnet_usage] appliances_archetype = self._archetypes['plug loads'][comnet_usage]
mechanical_air_change = None # comnet provides ventilation rate only
ventilation_rate = self._archetypes['ventilation rate'][comnet_usage]
# convert cfm/ft2 to m3/m2.s
ventilation_rate = ventilation_rate / (cte.METERS_TO_FEET * cte.MINUTES_TO_SECONDS)
# get occupancy # get occupancy
occupancy_density = occupancy_archetype[0] occupancy_density = occupancy_archetype[0] / pow(cte.METERS_TO_FEET,2)
sensible_heat_gain = occupancy_archetype[1] sensible_heat_gain = occupancy_archetype[1] * cte.BTU_H_TO_WATTS
latent_heat_gain = occupancy_archetype[1] latent_heat_gain = occupancy_archetype[1] * cte.BTU_H_TO_WATTS
if occupancy_density != 0: if occupancy_density != 0:
occupancy_density = 1 / occupancy_density occupancy_density = 1 / occupancy_density
sensible_convective_internal_gain = occupancy_density * sensible_heat_gain * sensible_convective sensible_convective_internal_gain = occupancy_density * sensible_heat_gain * sensible_convective
@ -58,7 +66,7 @@ class ComnetCatalog(Catalog):
self._schedules[schedule_name]['Occupancy']) self._schedules[schedule_name]['Occupancy'])
# get lighting # get lighting
density = lighting_archetype[4] density = lighting_archetype[4] / pow(cte.METERS_TO_FEET,2)
lighting = Lighting(density, lighting = Lighting(density,
lighting_convective, lighting_convective,
lighting_radiative, lighting_radiative,
@ -67,6 +75,10 @@ class ComnetCatalog(Catalog):
# get appliances # get appliances
density = appliances_archetype[0] density = appliances_archetype[0]
if density == 'n.a.':
density = 0
# convert W/ft2 to W/m2
density = float(density) / pow(cte.METERS_TO_FEET,2)
appliances = Appliances(density, appliances = Appliances(density,
appliances_convective, appliances_convective,
appliances_radiative, appliances_radiative,
@ -74,21 +86,45 @@ class ComnetCatalog(Catalog):
self._schedules[schedule_name]['Receptacle']) self._schedules[schedule_name]['Receptacle'])
# get thermal control # get thermal control
max_heating_setpoint = -1 max_heating_setpoint = cte.MIN_FLOAT
min_heating_setpoint = 50 min_heating_setpoint = cte.MAX_FLOAT
for schedule in self._schedules[schedule_name]['HtgSetPt']:
if max(schedule) > max_heating_setpoint:
max_heating_setpoint = max(schedule)
if min(schedule) < min_heating_setpoint:
min_heating_setpoint = min(schedule)
min_cooling_setpoint = 50
for schedule in self._schedules[schedule_name]['ClgSetPt']:
if max(schedule) > min_cooling_setpoint:
min_cooling_setpoint = max(schedule)
thermal_control = ThermalControl(max_heating_setpoint, min_heating_setpoint, )
usage = Usage(comnet_usage, hours_day, 365, None, occupancy, lighting, appliances, thermal_control)
# usage = Usage(usage_type) for schedule in self._schedules[schedule_name]['HtgSetPt']:
if schedule.values is None:
max_heating_setpoint = None
min_heating_setpoint = None
break
if max(schedule.values) > max_heating_setpoint:
max_heating_setpoint = max(schedule.values)
if min(schedule.values) < min_heating_setpoint:
min_heating_setpoint = min(schedule.values)
min_cooling_setpoint = cte.MAX_FLOAT
for schedule in self._schedules[schedule_name]['ClgSetPt']:
if schedule.values is None:
min_cooling_setpoint = None
break
if min(schedule.values) < min_cooling_setpoint:
min_cooling_setpoint = min(schedule.values)
thermal_control = ThermalControl(max_heating_setpoint,
min_heating_setpoint,
min_cooling_setpoint,
self._schedules[schedule_name]['HVAC Avail'],
self._schedules[schedule_name]['HtgSetPt'],
self._schedules[schedule_name]['ClgSetPt']
)
usages.append(Usage(comnet_usage,
hours_day,
365,
mechanical_air_change,
ventilation_rate,
occupancy,
lighting,
appliances,
thermal_control))
self._content = Content(usages)
def _read_schedules_file(self) -> Dict: def _read_schedules_file(self) -> Dict:
dictionary = {} dictionary = {}
@ -118,6 +154,12 @@ class ComnetCatalog(Catalog):
_schedule_values[day] = _extracted_data.iloc[start:end, 3:26].to_numpy().tolist()[0] _schedule_values[day] = _extracted_data.iloc[start:end, 3:26].to_numpy().tolist()[0]
_schedule = [] _schedule = []
for day in _schedule_values: for day in _schedule_values:
if schedule_data_type == 'temperature':
# to celsius
if 'n.a.' in _schedule_values[day]:
_schedule_values[day] = None
else:
_schedule_values[day] = [(float(value)-32)*5/9 for value in _schedule_values[day]]
_schedule.append(Schedule(schedule_name, _schedule_values[day], schedule_data_type, cte.HOUR, cte.DAY, [day])) _schedule.append(Schedule(schedule_name, _schedule_values[day], schedule_data_type, cte.HOUR, cte.DAY, [day]))
_schedules[schedule_name] = _schedule _schedules[schedule_name] = _schedule
dictionary[usage_name] = _schedules dictionary[usage_name] = _schedules

View File

@ -6,10 +6,13 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
""" """
# universal constants # universal constants
import sys
KELVIN = 273.15 KELVIN = 273.15
# converters # converters
HOUR_TO_MINUTES = 60 HOUR_TO_MINUTES = 60
MINUTES_TO_SECONDS = 60
METERS_TO_FEET = 3.28084 METERS_TO_FEET = 3.28084
BTU_H_TO_WATTS = 0.29307107 BTU_H_TO_WATTS = 0.29307107
KILO_WATTS_HOUR_TO_JULES = 3600000 KILO_WATTS_HOUR_TO_JULES = 3600000
@ -125,3 +128,7 @@ HEATING_AND_VENTILATION = 'Heating and ventilation'
COOLING_AND_VENTILATION = 'Cooling and ventilation' COOLING_AND_VENTILATION = 'Cooling and ventilation'
HEATING_AND_COLLING = 'Heating and cooling' HEATING_AND_COLLING = 'Heating and cooling'
FULL_HVAC = 'Heating and cooling and ventilation' FULL_HVAC = 'Heating and cooling and ventilation'
# Floats
MAX_FLOAT = float('inf')
MIN_FLOAT = float('-inf')