From a8adfb028259458811b510c384ebc73ee497526f Mon Sep 17 00:00:00 2001 From: Majid Rezaei Date: Mon, 24 Jun 2024 18:55:20 -0400 Subject: [PATCH] feature: add converting to csv to simultaneity factor calculations --- main.py | 36 +++++++++---------- .../simultinity_factor.py | 6 ++++ 2 files changed, 24 insertions(+), 18 deletions(-) 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..11686de9 100644 --- a/scripts/district_heating_network/simultinity_factor.py +++ b/scripts/district_heating_network/simultinity_factor.py @@ -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)