Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix checking for lite_restart and config test for lite_restart_directory #703

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/troute-config/troute/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,14 @@ def check_flowpath_edge_list(cls, values):
assert Path(flowpath_edge_list).suffix=='.json', "geo_file_path is json, but flowpath_edge_list is a different file type."

return values

@root_validator(skip_on_failure=True)
def check_lite_restart_directory(cls, values):
if values['output_parameters']:
lite_restart = values['output_parameters'].lite_restart
if lite_restart is not None:
lite_restart_directory = lite_restart.lite_restart_output_directory
assert lite_restart_directory, "lite_restart is present in output parameters, but no lite_restart_output_directory is provided."

return values

15 changes: 8 additions & 7 deletions src/troute-nwm/src/nwm_routing/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,14 @@ def main_v04(argv):
data_assimilation.update_after_compute(run_results, dt*nts)

# TODO move the conditional call to write_lite_restart to nwm_output_generator.
if output_parameters.get('lite_restart',{}).get('lite_restart_output_directory', None):
nhd_io.write_lite_restart(
network.q0,
network._waterbody_df,
t0 + timedelta(seconds = dt * nts),
output_parameters['lite_restart']
)
if output_parameters:
if output_parameters['lite_restart'] is not None:
nhd_io.write_lite_restart(
network.q0,
network._waterbody_df,
t0 + timedelta(seconds = dt * nts),
output_parameters['lite_restart']
)

# Prepare input forcing for next time loop simulation when mutiple time loops are presented.
if run_set_iterator < len(run_sets) - 1:
Expand Down