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

DIMR, RainfallRunoffModel & FMModel are not read #223

Closed
d2hydro opened this issue Apr 7, 2022 · 3 comments · Fixed by #225
Closed

DIMR, RainfallRunoffModel & FMModel are not read #223

d2hydro opened this issue Apr 7, 2022 · 3 comments · Fixed by #225
Assignees

Comments

@d2hydro
Copy link
Contributor

d2hydro commented Apr 7, 2022

Describe the bug
This model runs perfectly fine in DHYDRO, but won't be read by HYDROLIB-core v0.2.1: https://we.tl/t-GWED4R2YLX

To Reproduce
Steps to reproduce the behavior:

  1. download and unzip, run it with DHYDRO dimr -> it runs
  2. import the hydrolib.core models DIMR, FMModel and RainfallRunoffModel in python
  3. Try:
  • DIMR(filepath=Path("path_to/dimr_config.xml")) --> ❗ TODO
  • RainfallRunoffModel(filepath=Path("path_to/Sobek_3b.fnm")) --> Fixed by cf20bc3
  • FMModel(filepath=Path("path_to/dellen.mdu"))
    • --> ✅ the "partitionFile error" must be fixed in input: there may be only one single line with partitionFile, now there's two.
    • --> ✅ the forcing error was fixed by 63fa0c6
  1. See all giving validation errors

Expected behavior
All models are accepted as they are by DHYDRO

Screenshots
image

image

image

Version info (please complete the following information):

  • OS: windows
  • Version: 0.2.1

Additional context
Please help

@d2hydro
Copy link
Contributor Author

d2hydro commented Apr 7, 2022

@arthurvd regarding the error DIMR(filepath=Path("path_to/dimr_config.xml")); could it be that an RTC-component is not implemented yet? I guess as it would be expected below this line in the dimr-model:

class FMComponent(Component):
.

If so, is there a work-around?

@d2hydro
Copy link
Contributor Author

d2hydro commented Apr 7, 2022

regarding the error in RainfallRunoffModel; tracked it to this line:

substring = get_substring_between(line, key_start, key_end)
:

substring = get_substring_between(line, key_start, key_end)

key_start = BRCH, key_end = brch.

The file send contains brch in the nm property, which effectively results in a substring containing only id.
image

Suggest the following fix:
replace: index_end = source.find(end, index_start)
in line:

index_end = source.find(end, index_start)

by: index_end = source.rfind(end, index_start)

then the function get_substring_between will find the substring between the most left key_start and the most right key_end

@d2hydro
Copy link
Contributor Author

d2hydro commented Apr 7, 2022

regarding the issue at FMModel: HYDROLIB does not seem to be able to handle bc-files with only 1x [Forcing] as in the example:

image

Solved it by adding _split_to_list = make_list_validator("forcing") in ForcingModel:

_split_to_list = make_list_validator("forcing")

d2hydro pushed a commit that referenced this issue Apr 7, 2022
improvement as suggested here: #223 (comment)
@d2hydro d2hydro linked a pull request Apr 8, 2022 that will close this issue
arthurvd pushed a commit that referenced this issue Apr 8, 2022
* Update utils.py

improvement as suggested here: #223 (comment)

* Update models.py

allow a single [forcing]  block in bc-files

* autoformat: isort & black

Co-authored-by: d2hydro <d2hydro@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant