diff --git a/main.py b/main.py index 3edb5482..d0941e93 100644 --- a/main.py +++ b/main.py @@ -16,22 +16,22 @@ file_path = (Path(__file__).parent / 'input_files' / 'processed_output.geojson') output_path = (Path(__file__).parent / 'out_files').resolve() # Create city object from GeoJSON file -# 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 -# -# # Enrich city data -# ConstructionFactory('nrcan', city).enrich() -# UsageFactory('nrcan', city).enrich() -# WeatherFactory('epw', city).enrich() -# -# energy_plus_workflow(city) -# -# processor = DemandShiftProcessor(city) -# processor.process_demands() +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 + +# Enrich city data +ConstructionFactory('nrcan', city).enrich() +UsageFactory('nrcan', city).enrich() +WeatherFactory('epw', city).enrich() + +energy_plus_workflow(city) + +processor = DemandShiftProcessor(city) +processor.process_demands() location = [45.436749057834206, -73.66282803816682] @@ -44,5 +44,5 @@ networkx_to_geojson(network_graph) dhn_creator.plot_network_graph() -# print("Simultaneity Factor Heating:", city.simultaneity_factor_heating) -# print("Simultaneity Factor Cooling:", city.simultaneity_factor_cooling) \ No newline at end of file +print("Simultaneity Factor Heating:", city.simultaneity_factor_heating) +print("Simultaneity Factor Cooling:", city.simultaneity_factor_cooling) \ No newline at end of file diff --git a/scripts/district_heating_network/simultinity_factor.py b/scripts/district_heating_network/simultinity_factor.py index c97932b5..f998f6f1 100644 --- a/scripts/district_heating_network/simultinity_factor.py +++ b/scripts/district_heating_network/simultinity_factor.py @@ -13,7 +13,7 @@ class DemandShiftProcessor: heating_dfs = [] cooling_dfs = [] - for building in self.city.buildings: + for building_name, building in self.city.buildings.items(): heating_df = self.convert_building_to_dataframe(building, 'heating') cooling_df = self.convert_building_to_dataframe(building, 'cooling') heating_df.set_index('Date/Time', inplace=True) @@ -30,6 +30,9 @@ class DemandShiftProcessor: self.calculate_and_set_simultaneity_factor(combined_heating_df, 'heating') self.calculate_and_set_simultaneity_factor(combined_cooling_df, 'cooling') + self.save_demands_to_csv(combined_heating_df, 'heating_demands.csv') + self.save_demands_to_csv(combined_cooling_df, 'cooling_demands.csv') + def convert_building_to_dataframe(self, building, demand_type): if demand_type == 'heating': data = { @@ -78,3 +81,6 @@ class DemandShiftProcessor: self.city.simultaneity_factor_heating = peak_total_demand_original / sum_individual_peak_demands else: # cooling self.city.simultaneity_factor_cooling = peak_total_demand_original / sum_individual_peak_demands + + def save_demands_to_csv(self, df, filename): + df.to_csv(filename)