From e13b7ee6781c2439d0d343d22ac22d4c7c34ef9e Mon Sep 17 00:00:00 2001 From: Evan De la Garza Date: Tue, 26 Mar 2024 12:02:01 -0500 Subject: [PATCH] convert time steps to seconds --- src/music_box_model_options.py | 2 +- src/utils.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/music_box_model_options.py b/src/music_box_model_options.py index b6d4a10b..fec0ed7c 100644 --- a/src/music_box_model_options.py +++ b/src/music_box_model_options.py @@ -37,7 +37,7 @@ def from_UI_JSON(cls, UI_JSON): Returns: BoxModelOptions: A new instance of the BoxModelOptions class. """ - chem_step_time = utils.convert_time(UI_JSON['conditions']['box model options'], 'chemistry time step') * 60 * 60 + chem_step_time = utils.convert_time(UI_JSON['conditions']['box model options'], 'chemistry time step') output_step_time = utils.convert_time(UI_JSON['conditions']['box model options'], 'output time step') simulation_length = utils.convert_time(UI_JSON['conditions']['box model options'], 'simulation length') diff --git a/src/utils.py b/src/utils.py index d43a499d..5abd1b12 100644 --- a/src/utils.py +++ b/src/utils.py @@ -7,20 +7,20 @@ def convert_time(data, key): key (str): The key for the time in the input data. Returns: - float: The time in hours. + float: The time in seconds. """ time = None for unit in ['sec', 'min', 'hour', 'day']: if f'{key} [{unit}]' in data: time_value = float(data[f'{key} [{unit}]']) if unit == 'sec': - time = time_value / 3600 + time = time_value elif unit == 'min': - time = time_value / 60 + time = time_value * 60 elif unit == 'hour': - time = time_value + time = time_value * 3600 elif unit == 'day': - time = time_value * 24 + time = time_value * 86400 break return time