Skip to content

Commit

Permalink
Merge pull request #279 from UMEP-dev/sunt05/issue275
Browse files Browse the repository at this point in the history
to implement the debug mode
  • Loading branch information
sunt05 authored Jul 5, 2024
2 parents c4798f3 + e2c0f9d commit c9737de
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/supy/_supy_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def load_SampleData() -> Tuple[pandas.DataFrame, pandas.DataFrame]:
"""
from ._env import trv_supy_module

trv_SampleData = trv_supy_module / "sample_run"
path_runcontrol = trv_SampleData / "RunControl.nml"
df_state_init = init_supy(path_runcontrol, force_reload=False)
Expand All @@ -280,7 +281,7 @@ def run_supy(
logging_level=logging.INFO,
check_input=False,
serial_mode=False,
debug_mode=False, # TODO: #275 to be implemented to enable debug mode
debug_mode=False, # TODO: #275 to be implemented to enable debug mode
) -> Tuple[pandas.DataFrame, pandas.DataFrame]:
"""Perform supy simulation.
Expand Down Expand Up @@ -348,6 +349,14 @@ def run_supy(
if isinstance(res_check_state, pd.DataFrame):
df_state_init = res_check_state

# enable debug mode if set
if debug_mode:
logging_level = logging.DEBUG
logger_supy.setLevel(logging_level)
df_state_init.loc[:, ("debug", "0")] = 1
else:
df_state_init.loc[:, ("debug", "0")] = 0

# set up a timer for simulation time
start = time.time()

Expand Down Expand Up @@ -376,13 +385,9 @@ def run_supy(
else:
logger_supy.info(f"SuPy is running in serial mode")
try:
res_supy = run_supy_ser(
df_forcing, df_state_init, save_state, chunk_day
)
res_supy = run_supy_ser(df_forcing, df_state_init, save_state, chunk_day)
except:
res_supy = run_supy_ser(
df_forcing, df_state_init, save_state, chunk_day
)
res_supy = run_supy_ser(df_forcing, df_state_init, save_state, chunk_day)

# show simulation time
end = time.time()
Expand All @@ -396,7 +401,6 @@ def run_supy(
return df_output, df_state_final, res_debug



##############################################################################
# 3. save results of a supy run
def save_supy(
Expand Down

0 comments on commit c9737de

Please sign in to comment.