from pathlib import Path import subprocess from hub.imports.geometry_factory import GeometryFactory from scripts.geojson_creator import process_geojson from hub.helpers.dictionaries import Dictionaries from hub.imports.weather_factory import WeatherFactory from hub.imports.results_factory import ResultFactory from hub.exports.exports_factory import ExportsFactory def pv_feasibility(current_x, current_y, current_diff, selected_buildings): new_diff = current_diff * 5 geojson_file = process_geojson(x=current_x, y=current_y, diff=new_diff, expansion=True) file_path = (Path(__file__).parent.parent / 'input_files' / 'output_buildings_expanded.geojson') output_path = (Path(__file__).parent.parent / 'out_files').resolve() city = GeometryFactory('geojson', path=file_path, height_field='height', year_of_construction_field='year_of_construction', function_field='function', function_to_hub=Dictionaries().montreal_function_to_hub_function).city WeatherFactory('epw', city).enrich() ExportsFactory('sra', city, output_path).export() sra_path = (output_path / f'{city.name}_sra.xml').resolve() subprocess.run(['sra', str(sra_path)]) ResultFactory('sra', city, output_path).enrich() for selected_building in selected_buildings: for building in city.buildings: if selected_building.name == building.name: selected_building.roofs[0].global_irradiance = building.roofs[0].global_irradiance