setting to 0 values when the building cannot be calculated
This commit is contained in:
parent
d3bd6e782c
commit
59aa2b9494
|
@ -9,6 +9,7 @@ import pandas as pd
|
|||
import sys
|
||||
import csv
|
||||
from insel.insel import Insel
|
||||
from hub.hub_logger import logger
|
||||
|
||||
|
||||
class MonthlyDemandCalculation(Insel):
|
||||
|
@ -22,28 +23,29 @@ class MonthlyDemandCalculation(Insel):
|
|||
file_name = building.name + '.out'
|
||||
full_path_out = Path(self._path / file_name).resolve()
|
||||
full_path_out.parent.mkdir(parents=True, exist_ok=True)
|
||||
try:
|
||||
if Path(full_path_out).is_file():
|
||||
building.heating['month'], building.cooling['month'] = self._demand(full_path_out)
|
||||
heating_year = 0
|
||||
for value in building.heating['month']['INSEL']:
|
||||
if value == 'NaN':
|
||||
value = '0'
|
||||
heating_year += float(value)
|
||||
yearly_heating = pd.DataFrame([heating_year], columns=['INSEL'])
|
||||
building.heating['year'] = yearly_heating
|
||||
else:
|
||||
building.heating['month'] = pd.DataFrame([0] * 12, columns=['INSEL'])
|
||||
building.cooling['month'] = pd.DataFrame([0] * 12, columns=['INSEL'])
|
||||
logger.error(f'Building {building.name} could not be processed. Heating and cooling set to 0\n')
|
||||
sys.stderr.write(f'Building {building.name} could not be processed. Heating and cooling set to 0\n')
|
||||
|
||||
cooling_year = 0
|
||||
for value in building.cooling['month']['INSEL']:
|
||||
if value == 'NaN':
|
||||
value = '0'
|
||||
cooling_year += float(value)
|
||||
yearly_cooling = pd.DataFrame([cooling_year], columns=['INSEL'])
|
||||
building.cooling['year'] = yearly_cooling
|
||||
heating_year = 0
|
||||
for value in building.heating['month']['INSEL']:
|
||||
if value == 'NaN':
|
||||
value = '0'
|
||||
heating_year += float(value)
|
||||
yearly_heating = pd.DataFrame([heating_year], columns=['INSEL'])
|
||||
building.heating['year'] = yearly_heating
|
||||
|
||||
except ValueError:
|
||||
print(sys.exc_info()[1])
|
||||
print('Building ' + building.name + ' could not be processed')
|
||||
continue
|
||||
cooling_year = 0
|
||||
for value in building.cooling['month']['INSEL']:
|
||||
if value == 'NaN':
|
||||
value = '0'
|
||||
cooling_year += float(value)
|
||||
yearly_cooling = pd.DataFrame([cooling_year], columns=['INSEL'])
|
||||
building.cooling['year'] = yearly_cooling
|
||||
|
||||
@staticmethod
|
||||
def _demand(insel_outputs_path):
|
||||
|
|
|
@ -26,7 +26,6 @@ _DAYS_A_MONTH = {cte.MONDAY: [5, 4, 4, 5, 4, 4, 5, 4, 4, 5, 4, 5],
|
|||
class MonthlyEnergyBalance:
|
||||
def __init__(self, city, path, attic_heated_case, basement_heated_case, weather_format):
|
||||
self._city = city
|
||||
print(path)
|
||||
self._path = path
|
||||
self._weather_format = weather_format
|
||||
for building in self._city.buildings:
|
||||
|
@ -113,27 +112,31 @@ class MonthlyEnergyBalance:
|
|||
for building in self._city.buildings:
|
||||
lighting_demand = []
|
||||
appliances_demand = []
|
||||
thermal_zone = building.internal_zones[0].thermal_zones[0]
|
||||
area = thermal_zone.total_floor_area
|
||||
if building.internal_zones[0].thermal_zones is None:
|
||||
lighting_demand = [0] * 12
|
||||
appliances_demand = [0] * 12
|
||||
else:
|
||||
thermal_zone = building.internal_zones[0].thermal_zones[0]
|
||||
area = thermal_zone.total_floor_area
|
||||
|
||||
for month in range(0, 12):
|
||||
total_lighting = 0
|
||||
for schedule in thermal_zone.lighting.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
total_lighting += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.lighting.density
|
||||
lighting_demand.append(total_lighting * area)
|
||||
for month in range(0, 12):
|
||||
total_lighting = 0
|
||||
for schedule in thermal_zone.lighting.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
total_lighting += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.lighting.density
|
||||
lighting_demand.append(total_lighting * area)
|
||||
|
||||
total_appliances = 0
|
||||
for schedule in thermal_zone.appliances.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
total_appliances += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.appliances.density
|
||||
appliances_demand.append(total_appliances * area)
|
||||
total_appliances = 0
|
||||
for schedule in thermal_zone.appliances.schedules:
|
||||
total_day = 0
|
||||
for value in schedule.values:
|
||||
total_day += value
|
||||
for day_type in schedule.day_types:
|
||||
total_appliances += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.appliances.density
|
||||
appliances_demand.append(total_appliances * area)
|
||||
|
||||
building.lighting_electrical_demand = pd.DataFrame(lighting_demand,
|
||||
columns=[f'{building.name} lighting electrical demand Wh'])
|
||||
|
|
4
tmp/.gitignore
vendored
4
tmp/.gitignore
vendored
|
@ -1,4 +0,0 @@
|
|||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
Loading…
Reference in New Issue
Block a user