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 sys
|
||||||
import csv
|
import csv
|
||||||
from insel.insel import Insel
|
from insel.insel import Insel
|
||||||
|
from hub.hub_logger import logger
|
||||||
|
|
||||||
|
|
||||||
class MonthlyDemandCalculation(Insel):
|
class MonthlyDemandCalculation(Insel):
|
||||||
|
@ -22,28 +23,29 @@ class MonthlyDemandCalculation(Insel):
|
||||||
file_name = building.name + '.out'
|
file_name = building.name + '.out'
|
||||||
full_path_out = Path(self._path / file_name).resolve()
|
full_path_out = Path(self._path / file_name).resolve()
|
||||||
full_path_out.parent.mkdir(parents=True, exist_ok=True)
|
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)
|
building.heating['month'], building.cooling['month'] = self._demand(full_path_out)
|
||||||
heating_year = 0
|
else:
|
||||||
for value in building.heating['month']['INSEL']:
|
building.heating['month'] = pd.DataFrame([0] * 12, columns=['INSEL'])
|
||||||
if value == 'NaN':
|
building.cooling['month'] = pd.DataFrame([0] * 12, columns=['INSEL'])
|
||||||
value = '0'
|
logger.error(f'Building {building.name} could not be processed. Heating and cooling set to 0\n')
|
||||||
heating_year += float(value)
|
sys.stderr.write(f'Building {building.name} could not be processed. Heating and cooling set to 0\n')
|
||||||
yearly_heating = pd.DataFrame([heating_year], columns=['INSEL'])
|
|
||||||
building.heating['year'] = yearly_heating
|
|
||||||
|
|
||||||
cooling_year = 0
|
heating_year = 0
|
||||||
for value in building.cooling['month']['INSEL']:
|
for value in building.heating['month']['INSEL']:
|
||||||
if value == 'NaN':
|
if value == 'NaN':
|
||||||
value = '0'
|
value = '0'
|
||||||
cooling_year += float(value)
|
heating_year += float(value)
|
||||||
yearly_cooling = pd.DataFrame([cooling_year], columns=['INSEL'])
|
yearly_heating = pd.DataFrame([heating_year], columns=['INSEL'])
|
||||||
building.cooling['year'] = yearly_cooling
|
building.heating['year'] = yearly_heating
|
||||||
|
|
||||||
except ValueError:
|
cooling_year = 0
|
||||||
print(sys.exc_info()[1])
|
for value in building.cooling['month']['INSEL']:
|
||||||
print('Building ' + building.name + ' could not be processed')
|
if value == 'NaN':
|
||||||
continue
|
value = '0'
|
||||||
|
cooling_year += float(value)
|
||||||
|
yearly_cooling = pd.DataFrame([cooling_year], columns=['INSEL'])
|
||||||
|
building.cooling['year'] = yearly_cooling
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _demand(insel_outputs_path):
|
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:
|
class MonthlyEnergyBalance:
|
||||||
def __init__(self, city, path, attic_heated_case, basement_heated_case, weather_format):
|
def __init__(self, city, path, attic_heated_case, basement_heated_case, weather_format):
|
||||||
self._city = city
|
self._city = city
|
||||||
print(path)
|
|
||||||
self._path = path
|
self._path = path
|
||||||
self._weather_format = weather_format
|
self._weather_format = weather_format
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
|
@ -113,27 +112,31 @@ class MonthlyEnergyBalance:
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
lighting_demand = []
|
lighting_demand = []
|
||||||
appliances_demand = []
|
appliances_demand = []
|
||||||
thermal_zone = building.internal_zones[0].thermal_zones[0]
|
if building.internal_zones[0].thermal_zones is None:
|
||||||
area = thermal_zone.total_floor_area
|
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):
|
for month in range(0, 12):
|
||||||
total_lighting = 0
|
total_lighting = 0
|
||||||
for schedule in thermal_zone.lighting.schedules:
|
for schedule in thermal_zone.lighting.schedules:
|
||||||
total_day = 0
|
total_day = 0
|
||||||
for value in schedule.values:
|
for value in schedule.values:
|
||||||
total_day += value
|
total_day += value
|
||||||
for day_type in schedule.day_types:
|
for day_type in schedule.day_types:
|
||||||
total_lighting += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.lighting.density
|
total_lighting += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.lighting.density
|
||||||
lighting_demand.append(total_lighting * area)
|
lighting_demand.append(total_lighting * area)
|
||||||
|
|
||||||
total_appliances = 0
|
total_appliances = 0
|
||||||
for schedule in thermal_zone.appliances.schedules:
|
for schedule in thermal_zone.appliances.schedules:
|
||||||
total_day = 0
|
total_day = 0
|
||||||
for value in schedule.values:
|
for value in schedule.values:
|
||||||
total_day += value
|
total_day += value
|
||||||
for day_type in schedule.day_types:
|
for day_type in schedule.day_types:
|
||||||
total_appliances += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.appliances.density
|
total_appliances += total_day * _DAYS_A_MONTH[day_type][month] * thermal_zone.appliances.density
|
||||||
appliances_demand.append(total_appliances * area)
|
appliances_demand.append(total_appliances * area)
|
||||||
|
|
||||||
building.lighting_electrical_demand = pd.DataFrame(lighting_demand,
|
building.lighting_electrical_demand = pd.DataFrame(lighting_demand,
|
||||||
columns=[f'{building.name} lighting electrical demand Wh'])
|
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