Skip to content

Commit

Permalink
convert time steps to seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
eadlg2 committed Mar 26, 2024
1 parent 0a4f600 commit e13b7ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/music_box_model_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
10 changes: 5 additions & 5 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e13b7ee

Please sign in to comment.