diff --git a/hisim/json_generator.py b/hisim/json_generator.py index c134bbe0b..e42e08ffd 100644 --- a/hisim/json_generator.py +++ b/hisim/json_generator.py @@ -42,7 +42,7 @@ class ConfigFile(JSONWizard): component_entries: List[ComponentEntry] = field(default_factory=list) my_simulation_parameters: Optional[SimulationParameters] = None my_module_config: Optional[Dict[str, Any]] = None - pyam_data_information: Optional[Dict[str, Any]] = None + scenario_data_information: Optional[Dict[str, Any]] = None class JsonConfigurationGenerator: @@ -65,11 +65,11 @@ def set_module_config(self, my_module_config_path: str) -> None: config_dict = json.load(openfile) self.config_file.my_module_config = config_dict - def set_pyam_data_information_dict( - self, pyam_data_information_dict: Dict[str, Any] + def set_scenario_data_information_dict( + self, scenario_data_information_dict: Dict[str, Any] ) -> None: - """Sets some pyam information concerning the data.""" - self.config_file.pyam_data_information = pyam_data_information_dict + """Sets some scenario information concerning the result data.""" + self.config_file.scenario_data_information = scenario_data_information_dict def add_component(self, config: Type[ConfigBase]) -> ComponentEntry: """Adds a component and returns a component entry.""" diff --git a/hisim/postprocessing/postprocessing_main.py b/hisim/postprocessing/postprocessing_main.py index 5386a831b..15cda5fa0 100644 --- a/hisim/postprocessing/postprocessing_main.py +++ b/hisim/postprocessing/postprocessing_main.py @@ -44,7 +44,7 @@ def __init__(self): self.dirname: str self.chapter_counter: int = 1 self.figure_counter: int = 1 - self.pyam_data_folder: str = "" + self.result_data_folder_for_scenario_evaluation: str = "" self.model: str = "HiSim" self.scenario: str = "" self.region: str = "" @@ -289,13 +289,13 @@ def run(self, ppdt: PostProcessingDataTransfer) -> None: # noqa: MC0001 + f"{duration:1.2f}s." ) - # Write Outputs to pyam.IAMDataframe format for scenario evaluation + # Write Outputs to specific format for scenario evaluation (idea for format from pyam package) if ( - PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION_WITH_PYAM + PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION in ppdt.post_processing_options ): - log.information("Prepare results for scenario evaluation with pyam.") - self.prepare_results_for_scenario_evaluation_with_pyam(ppdt) + log.information("Prepare results for scenario evaluation.") + self.prepare_results_for_scenario_evaluation(ppdt) # Open file explorer if ( @@ -755,20 +755,20 @@ def export_sankeys(self): """ pass # noqa: unnecessary-pass - def prepare_results_for_scenario_evaluation_with_pyam( + def prepare_results_for_scenario_evaluation( self, ppdt: PostProcessingDataTransfer ) -> None: - """Prepare the results for the scenario evaluation with pyam.""" + """Prepare the results for the scenario evaluation.""" - # create pyam data foler - self.pyam_data_folder = os.path.join( - ppdt.simulation_parameters.result_directory, "pyam_data" + # create result data folder + self.result_data_folder_for_scenario_evaluation = os.path.join( + ppdt.simulation_parameters.result_directory, "result_data_for_scenario_evaluation" ) - if os.path.exists(self.pyam_data_folder) is False: - os.makedirs(self.pyam_data_folder) + if os.path.exists(self.result_data_folder_for_scenario_evaluation) is False: + os.makedirs(self.result_data_folder_for_scenario_evaluation) else: log.information( - "This pyam_data path exists already: " + self.pyam_data_folder + "This result data path exists already: " + self.result_data_folder_for_scenario_evaluation ) # -------------------------------------------------------------------------------------------------------------------------------------------------------------- @@ -794,7 +794,7 @@ def prepare_results_for_scenario_evaluation_with_pyam( "year": [], "value": [], } - # set pyam model name + # set model name self.model = "".join(["HiSim_", ppdt.module_filename]) # set pyam scenario name @@ -807,7 +807,7 @@ def prepare_results_for_scenario_evaluation_with_pyam( else: self.scenario = "" - # set pyam region + # set region if SingletonSimRepository().exist_entry(key=SingletonDictKeyEnum.LOCATION): self.region = SingletonSimRepository().get_entry( key=SingletonDictKeyEnum.LOCATION @@ -815,7 +815,7 @@ def prepare_results_for_scenario_evaluation_with_pyam( else: self.region = "" - # set pyam year or timeseries + # set year or timeseries self.year = ppdt.simulation_parameters.year timeseries_hourly = ppdt.results_hourly.index timeseries_daily = ppdt.results_daily.index @@ -825,15 +825,15 @@ def prepare_results_for_scenario_evaluation_with_pyam( PostProcessingOptions.COMPUTE_AND_WRITE_KPIS_TO_REPORT in ppdt.post_processing_options ): - self.write_kpis_in_pyam_dict( + self.write_kpis_in_dict( ppdt=ppdt, simple_dict_cumulative_data=simple_dict_hourly_data) - self.write_kpis_in_pyam_dict( + self.write_kpis_in_dict( ppdt=ppdt, simple_dict_cumulative_data=simple_dict_daily_data ) - self.write_kpis_in_pyam_dict( + self.write_kpis_in_dict( ppdt=ppdt, simple_dict_cumulative_data=simple_dict_monthly_data ) - self.write_kpis_in_pyam_dict( + self.write_kpis_in_dict( ppdt=ppdt, simple_dict_cumulative_data=simple_dict_cumulative_data ) @@ -846,7 +846,7 @@ def prepare_results_for_scenario_evaluation_with_pyam( ) self.write_filename_and_save_to_csv( dataframe=dataframe_hourly_data, - folder=self.pyam_data_folder, + folder=self.result_data_folder_for_scenario_evaluation, module_filename=ppdt.module_filename, simulation_duration=ppdt.simulation_parameters.duration.days, simulation_year=ppdt.simulation_parameters.year, @@ -861,7 +861,7 @@ def prepare_results_for_scenario_evaluation_with_pyam( ) self.write_filename_and_save_to_csv( dataframe=dataframe_daily_data, - folder=self.pyam_data_folder, + folder=self.result_data_folder_for_scenario_evaluation, module_filename=ppdt.module_filename, simulation_duration=ppdt.simulation_parameters.duration.days, simulation_year=ppdt.simulation_parameters.year, @@ -876,7 +876,7 @@ def prepare_results_for_scenario_evaluation_with_pyam( ) self.write_filename_and_save_to_csv( dataframe=dataframe_monthly_data, - folder=self.pyam_data_folder, + folder=self.result_data_folder_for_scenario_evaluation, module_filename=ppdt.module_filename, simulation_duration=ppdt.simulation_parameters.duration.days, simulation_year=ppdt.simulation_parameters.year, @@ -907,7 +907,7 @@ def prepare_results_for_scenario_evaluation_with_pyam( simple_df_yearly_data = pd.DataFrame(simple_dict_cumulative_data) self.write_filename_and_save_to_csv( dataframe=simple_df_yearly_data, - folder=self.pyam_data_folder, + folder=self.result_data_folder_for_scenario_evaluation, module_filename=ppdt.module_filename, time_resolution_of_data="yearly", simulation_duration=ppdt.simulation_parameters.duration.days, @@ -916,7 +916,7 @@ def prepare_results_for_scenario_evaluation_with_pyam( ) # -------------------------------------------------------------------------------------------------------------------------------------------------------------- - # create dictionary with all import pyam information + # create dictionary with all import data information data_information_dict = { "model": self.model, "scenario": self.scenario, @@ -934,8 +934,8 @@ def prepare_results_for_scenario_evaluation_with_pyam( json_generator_config.set_module_config( my_module_config_path=ppdt.my_module_config_path ) - json_generator_config.set_pyam_data_information_dict( - pyam_data_information_dict=data_information_dict + json_generator_config.set_scenario_data_information_dict( + scenario_data_information_dict=data_information_dict ) for component in ppdt.wrapped_components: json_generator_config.add_component(config=component.my_component.config) @@ -943,7 +943,7 @@ def prepare_results_for_scenario_evaluation_with_pyam( # save the json config json_generator_config.save_to_json( filename=os.path.join( - self.pyam_data_folder, "data_information_for_pyam.json" + self.result_data_folder_for_scenario_evaluation, "data_information_for_scenario_evaluation.json" ) ) @@ -961,12 +961,12 @@ def write_component_configurations_to_json( ) ) - def write_kpis_in_pyam_dict( + def write_kpis_in_dict( self, ppdt: PostProcessingDataTransfer, simple_dict_cumulative_data: Dict[str, Any], ) -> None: - """Write kpis in pyam dictionary.""" + """Write kpis in dictionary.""" kpi_compute_return = compute_kpis( components=ppdt.wrapped_components, diff --git a/hisim/postprocessing/scenario_evaluation/result_data_collection.py b/hisim/postprocessing/scenario_evaluation/result_data_collection.py index 79703ea6b..01d6500d4 100644 --- a/hisim/postprocessing/scenario_evaluation/result_data_collection.py +++ b/hisim/postprocessing/scenario_evaluation/result_data_collection.py @@ -36,11 +36,11 @@ def __init__( ) # in each system_setups/results folder should be one system setup that was executed with the default config - self.path_of_pyam_results_executed_with_default_config: str = "" + self.path_of_scenario_data_executed_with_default_config: str = "" log.information(f"Checking results from folder: {result_folder}") - list_with_pyam_data_folders = self.get_only_useful_data( + list_with_result_data_folders = self.get_only_useful_data( result_path=result_folder ) @@ -86,7 +86,7 @@ def __init__( else: raise ValueError( - "Analysis mode is not part of the PyamDataProcessingModeEnum class." + "Analysis mode is not part of the ResultDataProcessingModeEnum class." ) log.information(f"Data Collection Mode is {data_processing_mode}") @@ -96,11 +96,11 @@ def __init__( if path_to_default_config is None: list_with_parameter_key_values = None - list_with_csv_files = list_with_pyam_data_folders + list_with_csv_files = list_with_result_data_folders list_with_module_config_dicts = None else: - # path to default config is given (which means there should be also a module config dict in the json file in the pyam folder which has read the config) + # path to default config is given (which means there should be also a module config dict in the json file in the result folder which has read the config) default_config_dict = self.get_default_config( path_to_default_config=path_to_default_config @@ -110,8 +110,8 @@ def __init__( list_with_csv_files, list_with_parameter_key_values, list_with_module_config_dicts, - ) = self.go_through_all_pyam_data_folders_and_collect_file_paths_according_to_parameters( - list_with_pyam_data_folders=list_with_pyam_data_folders, + ) = self.go_through_all_result_data_folders_and_collect_file_paths_according_to_parameters( + list_with_result_data_folders=list_with_result_data_folders, default_config_dict=default_config_dict, parameter_key=parameter_key, ) @@ -146,31 +146,31 @@ def get_only_useful_data(self, result_path: str) -> List[str]: # go through result path and if the dirs do not contain finished.flag ask for deletion self.clean_result_directory_from_unfinished_results(result_path=result_path) - # get result folders with pyam data folder - list_with_all_paths_to_check = self.get_list_of_all_relevant_pyam_data_folders( + # get result folders with result data folder + list_with_all_paths_to_check = self.get_list_of_all_relevant_scenario_data_folders( result_path=result_path ) print( - "len of list with all paths to containing pyam data ", + "len of list with all paths to containing result data ", len(list_with_all_paths_to_check), ) # filter out results that had buildings that were too hot or too cold list_with_all_paths_to_check_after_filtering = self.filter_results_that_failed_to_heat_or_cool_building_sufficiently( - list_of_result_path_that_contain_pyam_data=list_with_all_paths_to_check + list_of_result_path_that_contain_scenario_data=list_with_all_paths_to_check ) print( "len of list with all paths after filtering ", len(list_with_all_paths_to_check), ) # check if duplicates are existing and ask for deletion - list_with_pyam_data_folders = self.go_through_all_pyam_data_folders_and_check_if_module_configs_are_double_somewhere( - list_of_pyam_folder_paths_to_check=list_with_all_paths_to_check_after_filtering + list_with_result_data_folders = self.go_through_all_scenario_data_folders_and_check_if_module_configs_are_double_somewhere( + list_of_result_folder_paths_to_check=list_with_all_paths_to_check_after_filtering ) print( "len of list with all paths after double checking for duplicates ", - len(list_with_pyam_data_folders), + len(list_with_result_data_folders), ) - return list_with_pyam_data_folders + return list_with_result_data_folders def clean_result_directory_from_unfinished_results(self, result_path: str) -> None: """When a result folder does not contain the finished_flag, it will be removed from the system_setups/result folder.""" @@ -212,7 +212,7 @@ def clean_result_directory_from_unfinished_results(self, result_path: str) -> No # print("The answer must be yes or no.") def filter_results_that_failed_to_heat_or_cool_building_sufficiently( - self, list_of_result_path_that_contain_pyam_data: List[str] + self, list_of_result_path_that_contain_scenario_data: List[str] ) -> List[str]: """When a result shows too high or too low building temperatures, it will be filtered and removed from further analysis.""" list_of_unsuccessful_folders = [] @@ -237,17 +237,17 @@ def filter_results_that_failed_to_heat_or_cool_building_sufficiently( "temp deviation below set heating [°C*h]," "temp deviation above set cooling [°C*h], folder \n" ) - for folder in list_of_result_path_that_contain_pyam_data: - pyam_data_information = os.path.join( - folder, "data_information_for_pyam.json" + for folder in list_of_result_path_that_contain_scenario_data: + scenario_data_information = os.path.join( + folder, "data_information_for_scenario_evaluation.json" ) main_folder = os.path.normpath(folder + os.sep + os.pardir) webtool_kpis_file = os.path.join(main_folder, "webtool_kpis.json") # get set temperatures used in the simulation - if os.path.exists(pyam_data_information): + if os.path.exists(scenario_data_information): with open( - pyam_data_information, "r", encoding="utf-8" + scenario_data_information, "r", encoding="utf-8" ) as data_info_file: json_file = json.load(data_info_file) component_entries = json_file["componentEntries"] @@ -266,7 +266,7 @@ def filter_results_that_failed_to_heat_or_cool_building_sufficiently( break else: raise FileNotFoundError( - f"The file {pyam_data_information} could not be found. " + f"The file {scenario_data_information} could not be found. " ) # open the webtool kpis and check if building got too hot or too cold @@ -355,7 +355,7 @@ def filter_results_that_failed_to_heat_or_cool_building_sufficiently( ) if answer.upper() in ["N", "NO"]: for folder in list_of_unsuccessful_folders: - list_of_result_path_that_contain_pyam_data.remove(folder) + list_of_result_path_that_contain_scenario_data.remove(folder) print( "The folders with too low or too high building temperatures will be discarded from the further analysis." ) @@ -366,21 +366,21 @@ def filter_results_that_failed_to_heat_or_cool_building_sufficiently( else: print("The answer must be yes or no.") - return list_of_result_path_that_contain_pyam_data + return list_of_result_path_that_contain_scenario_data - def get_list_of_all_relevant_pyam_data_folders(self, result_path: str) -> List[str]: - """Get a list of all pyam data folders which you want to analyze.""" + def get_list_of_all_relevant_scenario_data_folders(self, result_path: str) -> List[str]: + """Get a list of all scenario data folders which you want to analyze.""" # choose which path to check - path_to_check = os.path.join(result_path, "**", "pyam_data") + path_to_check = os.path.join(result_path, "**", "result_data_for_scenario_evaluation") list_of_paths_first_order = list(glob.glob(path_to_check)) - # if in these paths no pyam data folder can be found check in subfolders for it - path_to_check = os.path.join(result_path, "**", "**", "pyam_data") # type: ignore + # if in these paths no result data folder can be found check in subfolders for it + path_to_check = os.path.join(result_path, "**", "**", "result_data_for_scenario_evaluation") # type: ignore list_of_paths_second_order = list(glob.glob(path_to_check)) - path_to_check = os.path.join(result_path, "**", "**", "**", "pyam_data") # type: ignore + path_to_check = os.path.join(result_path, "**", "**", "**", "result_data_for_scenario_evaluation") # type: ignore list_of_paths_third_order = list(glob.glob(path_to_check)) list_with_all_paths_to_check = ( @@ -395,7 +395,7 @@ def import_data_from_file( self, paths_to_check: List[str], analyze_yearly_or_hourly_data: Any ) -> List: """Import data from result files.""" - log.information("Importing pyam_data from csv files.") + log.information("Importing result_data_for_scenario_evaluation from csv files.") all_csv_files = [] @@ -409,7 +409,7 @@ def import_data_from_file( kind_of_data_set = "monthly" else: raise ValueError( - "analyze_yearly_or_hourly_data was not found in the pyamdatacollectorenum class." + "analyze_yearly_or_hourly_data was not found in the datacollectorenum class." ) for folder in paths_to_check: # type: ignore @@ -432,7 +432,6 @@ def make_dictionaries_with_simulation_duration_keys( # open file config and check if they have wanted simulation duration for file in all_csv_files: - parent_folder = os.path.abspath(os.path.join(file, os.pardir)) # type: ignore for file1 in os.listdir(parent_folder): if ".json" in file1: @@ -440,13 +439,16 @@ def make_dictionaries_with_simulation_duration_keys( os.path.join(parent_folder, file1), "r", encoding="utf-8" ) as openfile: json_file = json.load(openfile) - simulation_duration = json_file["pyamDataInformation"].get( + simulation_duration = json_file["scenarioDataInformation"].get( "duration in days" ) if int(simulation_duration_to_check) == int( simulation_duration ): dict_of_csv_data[f"{simulation_duration}"].append(file) + else: + raise ValueError(f"The simulation_duration_to_check of {simulation_duration_to_check} is different," + f"to the simulation duration of {simulation_duration} found in the scenario data information json in the result folders.") # raise error if dict is empty if bool(dict_of_csv_data) is False: @@ -519,9 +521,9 @@ def read_csv_and_generate_pandas_dataframe( list_with_parameter_key_values: Optional[List[Any]] = None, list_with_module_config_dicts: Optional[List[Any]] = None, ) -> None: - """Read the csv files and generate the pyam dataframe.""" + """Read the csv files and generate the result dataframe.""" log.information( - f"Read csv files and generate pyam dataframes for {time_resolution_of_data_set}." + f"Read csv files and generate result dataframes for {time_resolution_of_data_set}." ) appended_dataframe = pd.DataFrame() @@ -587,7 +589,7 @@ def read_csv_and_generate_pandas_dataframe( dataframe=appended_dataframe ) - filename = self.store_pyam_data_with_the_right_name_and_in_the_right_path( + filename = self.store_scenario_data_with_the_right_name_and_in_the_right_path( result_data_folder=self.result_data_folder, simulation_duration_key=simulation_duration_key, time_resolution_of_data_set=time_resolution_of_data_set, @@ -595,14 +597,14 @@ def read_csv_and_generate_pandas_dataframe( ) appended_dataframe.to_csv(filename) - def store_pyam_data_with_the_right_name_and_in_the_right_path( + def store_scenario_data_with_the_right_name_and_in_the_right_path( self, result_data_folder: str, simulation_duration_key: str, time_resolution_of_data_set: Any, parameter_key: Optional[str] = None, ) -> str: - """Store csv files in the pyam data folder with the right filename and path.""" + """Store csv files in the result data folder with the right filename and path.""" if time_resolution_of_data_set == ResultDataTypeEnum.HOURLY: kind_of_data_set = "hourly" @@ -614,7 +616,7 @@ def store_pyam_data_with_the_right_name_and_in_the_right_path( kind_of_data_set = "monthly" else: raise ValueError( - "This kind of data was not found in the pyamdatacollectorenum class." + "This kind of data was not found in the datacollectorenum class." ) if parameter_key is not None: @@ -631,11 +633,11 @@ def store_pyam_data_with_the_right_name_and_in_the_right_path( ) if os.path.exists(path_for_file) is False: os.makedirs(path_for_file) - log.information(f"Saving pyam dataframe in {path_for_file} folder") + log.information(f"Saving result dataframe in {path_for_file} folder") filename = os.path.join( path_for_file, - f"pyam_dataframe_for_{simulation_duration_key}_days_{kind_of_data_set}_data.csv", + f"result_dataframe_for_{simulation_duration_key}_days_{kind_of_data_set}_data.csv", ) return filename @@ -652,21 +654,21 @@ def get_default_config(self, path_to_default_config: Optional[str]) -> Any: return default_config_dict - def read_pyam_data_json_config_and_compare_to_default_config( + def read_scenario_data_json_config_and_compare_to_default_config( self, default_config_dict: Dict[str, Any], - path_to_pyam_data_folder: str, + path_to_scenario_data_folder: str, list_with_csv_files: List[Any], list_with_parameter_key_values: List[Any], list_with_module_configs: List[Any], parameter_key: str, ) -> tuple[List[Any], List[Any], List[Any]]: - """Read json config in pyam_data folder and compare with default config.""" + """Read json config in result_data_for_scenario_evaluation folder and compare with default config.""" - for file in os.listdir(path_to_pyam_data_folder): + for file in os.listdir(path_to_scenario_data_folder): if ".json" in file: - with open(os.path.join(path_to_pyam_data_folder, file), "r", encoding="utf-8") as openfile: # type: ignore + with open(os.path.join(path_to_scenario_data_folder, file), "r", encoding="utf-8") as openfile: # type: ignore config_dict = json.load(openfile) my_module_config_dict = config_dict["myModuleConfig"] scenario_name = config_dict["systemName"] @@ -683,7 +685,8 @@ def read_pyam_data_json_config_and_compare_to_default_config( # check if module config and default config have any keys in common if len(set(default_config_dict).intersection(my_module_config_dict)) == 0: raise KeyError( - f"The module config of the folder {path_to_pyam_data_folder} should contain the keys of the default config, otherwise their values cannot be compared." + f"The module config of the folder {path_to_scenario_data_folder} should contain the keys of the default config,", + "otherwise their values cannot be compared." ) # check if there is a module config which is equal to default config @@ -691,8 +694,8 @@ def read_pyam_data_json_config_and_compare_to_default_config( item in my_module_config_dict.items() for item in default_config_dict.items() ): - self.path_of_pyam_results_executed_with_default_config = ( - path_to_pyam_data_folder + self.path_of_scenario_data_executed_with_default_config = ( + path_to_scenario_data_folder ) # for each parameter different than the default config parameter, get the respective path to the folder @@ -700,16 +703,16 @@ def read_pyam_data_json_config_and_compare_to_default_config( # if my_module_config_dict[parameter_key] != default_config_dict[parameter_key]: - list_with_csv_files.append(path_to_pyam_data_folder) + list_with_csv_files.append(path_to_scenario_data_folder) list_with_parameter_key_values.append(my_module_config_dict[parameter_key]) list_with_module_configs.append(my_module_config_dict) # add to each item in the dict also the default system setup if the default system setup exists - if self.path_of_pyam_results_executed_with_default_config != "": + if self.path_of_scenario_data_executed_with_default_config != "": list_with_csv_files.append( - self.path_of_pyam_results_executed_with_default_config + self.path_of_scenario_data_executed_with_default_config ) list_with_parameter_key_values.append(default_config_dict[parameter_key]) @@ -724,36 +727,37 @@ def read_pyam_data_json_config_and_compare_to_default_config( def read_module_config_if_exist_and_write_in_dataframe( self, default_config_dict: Dict[str, Any], - path_to_pyam_data_folder: str, + path_to_scenario_data_folder: str, list_with_module_configs: List[Any], list_with_csv_files: List[Any], ) -> Tuple[List, List]: """Read module config if possible and write to dataframe.""" - for file in os.listdir(path_to_pyam_data_folder): + for file in os.listdir(path_to_scenario_data_folder): if ".json" in file: - with open(os.path.join(path_to_pyam_data_folder, file), "r", encoding="utf-8") as openfile: # type: ignore + with open(os.path.join(path_to_scenario_data_folder, file), "r", encoding="utf-8") as openfile: # type: ignore config_dict = json.load(openfile) my_module_config_dict = config_dict["myModuleConfig"] # check if module config and default config have any keys in common if len(set(default_config_dict).intersection(my_module_config_dict)) == 0: raise KeyError( - f"The module config of the folder {path_to_pyam_data_folder} should contain the keys of the default config, otherwise their values cannot be compared." + f"The module config of the folder {path_to_scenario_data_folder} should contain the keys of the default config,", + "otherwise their values cannot be compared." ) list_with_module_configs.append(my_module_config_dict) - list_with_csv_files.append(path_to_pyam_data_folder) + list_with_csv_files.append(path_to_scenario_data_folder) return ( list_with_module_configs, list_with_csv_files, ) - def go_through_all_pyam_data_folders_and_collect_file_paths_according_to_parameters( + def go_through_all_result_data_folders_and_collect_file_paths_according_to_parameters( self, - list_with_pyam_data_folders: List[str], + list_with_result_data_folders: List[str], default_config_dict: Dict[str, Any], parameter_key: Optional[str], ) -> tuple[List[Any], List[Any], List[Any]]: @@ -763,7 +767,7 @@ def go_through_all_pyam_data_folders_and_collect_file_paths_according_to_paramet list_with_csv_files: List = [] list_with_parameter_key_values: List = [] - for folder in list_with_pyam_data_folders: # type: ignore + for folder in list_with_result_data_folders: # type: ignore if parameter_key is None: ( @@ -771,7 +775,7 @@ def go_through_all_pyam_data_folders_and_collect_file_paths_according_to_paramet list_with_csv_files, ) = self.read_module_config_if_exist_and_write_in_dataframe( default_config_dict=default_config_dict, - path_to_pyam_data_folder=folder, + path_to_scenario_data_folder=folder, list_with_module_configs=list_with_module_configs, list_with_csv_files=list_with_csv_files, ) @@ -783,9 +787,9 @@ def go_through_all_pyam_data_folders_and_collect_file_paths_according_to_paramet list_with_csv_files, list_with_parameter_key_values, list_with_module_configs, - ) = self.read_pyam_data_json_config_and_compare_to_default_config( + ) = self.read_scenario_data_json_config_and_compare_to_default_config( default_config_dict=default_config_dict, - path_to_pyam_data_folder=folder, + path_to_scenario_data_folder=folder, list_with_csv_files=list_with_csv_files, list_with_parameter_key_values=list_with_parameter_key_values, list_with_module_configs=list_with_module_configs, @@ -811,14 +815,14 @@ def check_for_duplicates_in_dict( return indices_of_duplicates - def go_through_all_pyam_data_folders_and_check_if_module_configs_are_double_somewhere( - self, list_of_pyam_folder_paths_to_check: List[str] + def go_through_all_scenario_data_folders_and_check_if_module_configs_are_double_somewhere( + self, list_of_result_folder_paths_to_check: List[str] ) -> List[Any]: - """Go through all pyam folders and remove the system_setups that are duplicated.""" + """Go through all result folders and remove the system_setups that are duplicated.""" list_of_all_module_configs = [] - list_of_pyam_folders_which_have_only_unique_configs = [] - for folder in list_of_pyam_folder_paths_to_check: + list_of_result_folders_which_have_only_unique_configs = [] + for folder in list_of_result_folder_paths_to_check: for file in os.listdir(folder): if ".json" in file: @@ -828,16 +832,16 @@ def go_through_all_pyam_data_folders_and_check_if_module_configs_are_double_some my_module_config_dict.update( { "duration in days": config_dict[ - "pyamDataInformation" + "scenarioDataInformation" ].get("duration in days") } ) my_module_config_dict.update( - {"model": config_dict["pyamDataInformation"].get("model")} + {"model": config_dict["scenarioDataInformation"].get("model")} ) my_module_config_dict.update( { - "model": config_dict["pyamDataInformation"].get( + "model": config_dict["scenarioDataInformation"].get( "scenario" ) } @@ -846,13 +850,13 @@ def go_through_all_pyam_data_folders_and_check_if_module_configs_are_double_some # prevent to add modules with same module config and same simulation duration twice if my_module_config_dict not in list_of_all_module_configs: list_of_all_module_configs.append(my_module_config_dict) - list_of_pyam_folders_which_have_only_unique_configs.append( + list_of_result_folders_which_have_only_unique_configs.append( os.path.join(folder) ) # get folders with duplicates list_with_duplicates = [] - if folder not in list_of_pyam_folders_which_have_only_unique_configs: + if folder not in list_of_result_folders_which_have_only_unique_configs: whole_parent_folder = os.path.abspath(os.path.join(folder, os.pardir)) list_with_duplicates.append(whole_parent_folder) @@ -871,12 +875,12 @@ def go_through_all_pyam_data_folders_and_check_if_module_configs_are_double_some else: print("The answer must be yes or no.") - return list_of_pyam_folders_which_have_only_unique_configs + return list_of_result_folders_which_have_only_unique_configs class ResultDataTypeEnum(enum.Enum): - """PyamDataTypeEnum class. + """ResultDataTypeEnum class. Here it is defined what kind of data you want to collect. """ @@ -889,7 +893,7 @@ class ResultDataTypeEnum(enum.Enum): class ResultDataProcessingModeEnum(enum.Enum): - """PyamDataProcessingModeEnum class. + """ResultDataProcessingModeEnum class. Here it is defined what kind of data processing you want to make. """ diff --git a/hisim/postprocessing/scenario_evaluation/result_data_plotting.py b/hisim/postprocessing/scenario_evaluation/result_data_plotting.py index 87460a728..78e97cf63 100644 --- a/hisim/postprocessing/scenario_evaluation/result_data_plotting.py +++ b/hisim/postprocessing/scenario_evaluation/result_data_plotting.py @@ -97,7 +97,7 @@ def __init__( result_path_strip = "results_different_number_of_dwellings_per_buildings" else: - raise ValueError("PyamDataProcessingMode not known.") + raise ValueError("DataProcessingMode not known.") self.data_folder_path = os.path.join( folder_from_which_data_will_be_collected, @@ -164,7 +164,7 @@ def make_plots_with_specific_kind_of_data( sub_results_folder = f"simulation_duration_of_{simulation_duration_key}_days" sub_sub_results_folder = ( - f"pyam_results_{time_resolution_of_data_set.value}_{self.datetime_string}" + f"scenario_comparison_{time_resolution_of_data_set.value}_{self.datetime_string}" ) self.path_for_plots = os.path.join( @@ -296,7 +296,7 @@ def make_plots_with_specific_kind_of_data( else: raise ValueError( - "This kind of data was not found in the pyamdatacollectorenum class." + "This kind of data was not found in the datacollectorenum class." ) def make_line_plot_for_pandas_dataframe( diff --git a/hisim/postprocessing/scenario_evaluation/result_data_processing.py b/hisim/postprocessing/scenario_evaluation/result_data_processing.py index 551245ba5..c0c426f11 100644 --- a/hisim/postprocessing/scenario_evaluation/result_data_processing.py +++ b/hisim/postprocessing/scenario_evaluation/result_data_processing.py @@ -36,10 +36,10 @@ def get_dataframe_and_create_pandas_dataframe_for_all_data( kind_of_data_set = "monthly" else: raise ValueError( - "This kind of data was not found in the pyamdaacollectorenum class." + "This kind of data was not found in the datacollectorenum class." ) log.information( - f"Read csv files and create one big pyam dataframe for {kind_of_data_set} data." + f"Read csv files and create one big dataframe for {kind_of_data_set} data." ) for file in glob.glob( @@ -140,7 +140,7 @@ def check_if_scenario_exists_and_filter_dataframe_for_scenarios( ) in aggregated_scenario_dict.items(): if given_scenario == []: raise ValueError( - f"Scenarios containing {key_scenario_to_check} were not found in the pyam dataframe." + f"Scenarios containing {key_scenario_to_check} were not found in the dataframe." ) concat_df = pd.DataFrame() diff --git a/hisim/postprocessing/scenario_evaluation/scenario_analysis_complete.py b/hisim/postprocessing/scenario_evaluation/scenario_analysis_complete.py index 4afac70e7..86720602c 100644 --- a/hisim/postprocessing/scenario_evaluation/scenario_analysis_complete.py +++ b/hisim/postprocessing/scenario_evaluation/scenario_analysis_complete.py @@ -12,7 +12,7 @@ class ScenarioAnalysis: - """ScenarioAnalysis class which executes pyam data collection and processing.""" + """ScenarioAnalysis class which executes result data collection, processing and plotting.""" def __init__( self, @@ -44,9 +44,9 @@ def __init__( def main(): - """Main function to execute the pyam data analysis.""" + """Main function to execute the scenario analysis.""" - # Inputs for pyam analysis + # Inputs for scenario analysis # ------------------------------------------------------------------------------------------------------------------------------------- time_resolution_of_data_set = result_data_collection.ResultDataTypeEnum.YEARLY diff --git a/hisim/postprocessingoptions.py b/hisim/postprocessingoptions.py index e99d3c428..0967256b7 100644 --- a/hisim/postprocessingoptions.py +++ b/hisim/postprocessingoptions.py @@ -27,6 +27,6 @@ class PostProcessingOptions(IntEnum): COMPUTE_OPEX = 18 COMPUTE_CAPEX = 19 COMPUTE_AND_WRITE_KPIS_TO_REPORT = 20 - PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION_WITH_PYAM = 21 + PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION = 21 MAKE_RESULT_JSON_WITH_KPI_FOR_WEBTOOL = 22 WRITE_COMPONENT_CONFIGS_TO_JSON = 23 diff --git a/system_setups/household_cluster_advanced_hp_pv_battery_ems.py b/system_setups/household_cluster_advanced_hp_pv_battery_ems.py index 4cb8f8651..721eb3399 100644 --- a/system_setups/household_cluster_advanced_hp_pv_battery_ems.py +++ b/system_setups/household_cluster_advanced_hp_pv_battery_ems.py @@ -97,7 +97,7 @@ def setup_function( year=year, seconds_per_timestep=seconds_per_timestep ) my_simulation_parameters.post_processing_options.append( - PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION_WITH_PYAM + PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION ) my_simulation_parameters.post_processing_options.append( PostProcessingOptions.COMPUTE_OPEX diff --git a/system_setups/household_cluster_reference_advanced_hp.py b/system_setups/household_cluster_reference_advanced_hp.py index 64923e3f0..d6e5bac18 100644 --- a/system_setups/household_cluster_reference_advanced_hp.py +++ b/system_setups/household_cluster_reference_advanced_hp.py @@ -123,7 +123,7 @@ def setup_function( year=year, seconds_per_timestep=seconds_per_timestep ) my_simulation_parameters.post_processing_options.append( - PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION_WITH_PYAM + PostProcessingOptions.PREPARE_OUTPUTS_FOR_SCENARIO_EVALUATION ) my_simulation_parameters.post_processing_options.append( PostProcessingOptions.COMPUTE_OPEX