Some changes to adapt to new names of imports folders

This commit is contained in:
Pilar 2021-06-08 12:50:38 -04:00
parent 81b46fb5c4
commit 4b2dfea2a4
4 changed files with 15 additions and 14 deletions

View File

@ -4,7 +4,7 @@ from pathlib import Path
import pandas as pd
import csv
from imports.weather_feeders.helpers.weather import Weather as wt
from imports.weather.helpers.weather import Weather as wt
class MonthlyEnergyBalance:

15
main.py
View File

@ -74,12 +74,13 @@ if populated_city.buildings is None:
print('begin_weather_time', datetime.datetime.now())
# Step 3: Populate city adding climate-related parameters
weather_format = 'epw'
weather_step_in_pickle = ast.literal_eval(args.weather_step_in_pickle)
if not weather_step_in_pickle:
city.climate_reference_city = args.climate_reference_city
path = (Path(args.project_folder) / 'tmp').resolve()
city.climate_file = (path / f'{args.climate_reference_city}.cli').resolve()
WeatherFactory('epw', populated_city, file_name=args.weather_file_name).enrich()
WeatherFactory(weather_format, populated_city, file_name=args.weather_file_name).enrich()
for building in populated_city.buildings:
if 'hour' not in building.external_temperature:
print('No external temperature found')
@ -87,7 +88,7 @@ if not weather_step_in_pickle:
if 'month' not in building.external_temperature:
building.external_temperature['month'] = mv.MonthlyValues().\
get_mean_values(building.external_temperature['hour'][['epw']])
get_mean_values(building.external_temperature['hour'][[weather_format]])
max_buildings_handled_by_sra = 500
for building in city.buildings:
@ -104,30 +105,28 @@ if not weather_step_in_pickle:
for building in city.buildings:
new_city = city.region(building.centroid, radius)
sra_new = SimplifiedRadiosityAlgorithm(new_city, Path(args.project_folder).resolve(), args.weather_file_name)
sra_new.call_sra(keep_files=True)
sra_new.call_sra(weather_format, keep_files=True)
sra_new.set_irradiance_surfaces(populated_city, building_name=building.name)
else:
sra.call_sra(keep_files=keep_files)
sra.call_sra(weather_format, keep_files=keep_files)
sra.set_irradiance_surfaces(populated_city)
pickle_file = Path(str(pickle_file).replace('.pickle', '_weather.pickle'))
populated_city.save(pickle_file)
weather_format = 'epw'
print('begin_user_assignment_time', datetime.datetime.now())
# Step 4: Assign user defined parameters
for building in populated_city.buildings:
building.heated = True
building.cooled = False
building.attic_heated = 2
building.basement_heated = 0
# for value in building.heating['month']['INSEL']:
print('begin_insel_time', datetime.datetime.now())
# Step 5: Demand calculation calling INSEL
MonthlyDemandCalculation(city, args.project_folder, weather_format).monthly_demand()
print('begin_write_results_time', datetime.datetime.now())
# Step 5: Print results
print_results = None
file = 'city name: ' + city.name + '\n'
for building in populated_city.buildings:

View File

@ -4,7 +4,7 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es
"""
from imports.physics_factory import PhysicsFactory
from imports.construction_factory import ConstructionFactory
from imports.usage_factory import UsageFactory
from city_model_structure.city import City
@ -34,7 +34,7 @@ class Populate:
tmp_city = City(self._city.lower_corner, self._city.upper_corner, self._city.srs_name)
# todo: just for Rabeehs case!!
#PhysicsFactory(self.handler, self._city)
PhysicsFactory('ca', self._city).enrich()
ConstructionFactory('ca', self._city).enrich()
print('original:', len(self._city.buildings))
for building in self._city.buildings:
# infiltration_rate_system_off is a mandatory parameter.

View File

@ -65,9 +65,10 @@ class TestMebWorkflow(TestCase):
def _get_citygml_with_weather(self, use_pickle):
if self._city_with_weather is None:
weather_format = 'epw'
self._city_with_weather = self._get_citygml(use_pickle=use_pickle)
weather_path = (self._example_path / 'weather').resolve()
WeatherFactory('epw', self._city_with_weather, base_path=weather_path)
WeatherFactory(weather_format, self._city_with_weather, base_path=weather_path)
for building in self._city_with_weather.buildings:
building.external_temperature['month'] = mv.MonthlyValues(). \
get_mean_values(building.external_temperature['hour'][['epw']])
@ -78,11 +79,12 @@ class TestMebWorkflow(TestCase):
if self._use_cached_sra_file:
sra.results()
else:
sra.call_sra(keep_files=True)
sra.call_sra(weather_format, keep_files=True)
sra.set_irradiance_surfaces(self._city_with_weather)
return self._city_with_weather
def _get_cli_single_building(self, building_name, radius, use_pickle):
weather_format = 'epw'
self._city_with_cli = self._get_citygml(use_pickle=use_pickle)
building = self._city_with_cli.city_object(building_name)
new_city = self._city_with_cli.region(building.centroid, radius)
@ -92,7 +94,7 @@ class TestMebWorkflow(TestCase):
full_path_cli = (self._example_path / 'weather' / 'inseldb_Summerland.cli').resolve()
sra = sralgorithm(Path(self._project_folder).resolve(), sra_file_name, full_path_cli, new_city.city_objects,
lower_corner=new_city.lower_corner)
sra.call_sra(keep_files=True)
sra.call_sra(weather_format, keep_files=True)
sra.set_irradiance_surfaces(self._city_with_cli, building_name=building_name)
return self._city_with_cli