Skip to content

Commit

Permalink
updated docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlassere committed Apr 3, 2024
1 parent 09e9c67 commit c020d26
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions afc/externalConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -62,15 +80,14 @@ 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'],
room_width=config['room_width'],
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'],
Expand All @@ -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}'
Expand Down Expand Up @@ -138,4 +155,4 @@ def config_from_dict(config):
# Update parameter wrapper
parameter['wrapper']['log_dir'] = './logs'

return parameter
return parameter

0 comments on commit c020d26

Please sign in to comment.