From c020d26fab531e6914cc3453417bfa210581d0eb Mon Sep 17 00:00:00 2001 From: Jean Lassere Date: Tue, 2 Apr 2024 17:36:49 -0700 Subject: [PATCH] updated docstrings --- afc/externalConfig.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/afc/externalConfig.py b/afc/externalConfig.py index fa822e1..3c71442 100644 --- a/afc/externalConfig.py +++ b/afc/externalConfig.py @@ -23,7 +23,18 @@ root = os.getcwd() def read_json_config(config_path, json_conly=False): - """Utility function to parse a json configuration file.""" + """Utility function to parse a json configuration file. + + Args: + config_path (str): path to the json configuration file + json_conly (bool): boolean determining whether to return only the json configuration data or use it to update the AFC parameters. + + Returns: + if json_conly == TRUE: + dict: dictionary containing the json file data + else: + dict: dictionary containing AFC parameters updated using to the json configuration + """ # Import and read the new configuration from the json file with open(config_path, encoding='utf8') as f: @@ -36,7 +47,14 @@ def read_json_config(config_path, json_conly=False): DEFAULT_DICT = read_json_config(DEFAULT_JSON_PATH, json_conly=True) def config_from_dict(config): - """Utility function to make configuration from a dictionary.""" + """Utility function to make configuration from a dictionary. + + Arg: + config (dict): dictionary containing the json file data + + Returns: + dict: dictionary containing AFC parameters updated using to the json configuration + """ for k in read_json_config(DEFAULT_JSON_PATH, json_conly=True): if k not in config: @@ -62,7 +80,6 @@ def config_from_dict(config): wpi_min = 250 + max(0, (config['occupant_brightness'] - 80) * 5) # Upload default_parameter with arguments from json - window_full_width = config['window_width'] * config['window_count'] parameter = default_parameter(tariff_name=config['tariff_name'], facade_type=config['system_type'], room_height=config['room_height'], @@ -70,7 +87,7 @@ def config_from_dict(config): room_depth=config['room_depth'], window_height=config['window_height'], window_sill=config['window_sill'], - window_width=window_full_width, + window_width=config['room_width'], system_cooling_eff=1/config['system_cooling_eff'], location_latitude=config['location_latitude'], location_longitude=config['location_longitude'], @@ -91,11 +108,11 @@ def config_from_dict(config): # Update windows position and dimensions for wz in parameter['facade']['windows']: # all windows have same width - window_width = ft_to_m(window_full_width) + window_width = ft_to_m(config['window_width']) # all windows have same height window_height = ft_to_m(config['window_height'] / len(parameter['facade']['windows'])) # need to make sure windows are centered - x_origin = ft_to_m((config['room_width'] - window_full_width) / 2) + x_origin = ft_to_m((config['room_width'] - config['window_width']) / 2) # new window starts at sill + X*windows y_origin = ft_to_m(config['window_sill']) + wz * window_height window = f'{x_origin} {y_origin} {window_width} {window_height}' @@ -138,4 +155,4 @@ def config_from_dict(config): # Update parameter wrapper parameter['wrapper']['log_dir'] = './logs' - return parameter + return parameter \ No newline at end of file