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

bmi.get_current_time and bmi.get_end_time are broken. #307

Closed
2 tasks done
BSchilperoort opened this issue Oct 25, 2023 · 3 comments · Fixed by #306
Closed
2 tasks done

bmi.get_current_time and bmi.get_end_time are broken. #307

BSchilperoort opened this issue Oct 25, 2023 · 3 comments · Fixed by #306
Assignees
Labels
bug Something isn't working

Comments

@BSchilperoort
Copy link

BSchilperoort commented Oct 25, 2023

Wflow version checks

  • I have checked that this issue has not already been reported.

  • I have checked that this bug exists on the latest version of Wflow.

Reproducible Example

After bmi model initialization:

BMI.get_current_time(model)
BMI.get_end_time(model)

Current behaviour

Gives MethodError: no method matching value -(::String) (or similar)

Desired behaviour

Gives the end/current time.

Additional Context

The subtractions don't work because model.config.starttime and model.config.endtime are strings:

function BMI.get_current_time(model::Model)
    0.001 * Dates.value(model.clock.time - model.config.starttime)
end
function BMI.get_end_time(model::Model)
    0.001 * Dates.value(model.config.endtime - model.config.starttime)
end
@BSchilperoort BSchilperoort added the bug Something isn't working label Oct 25, 2023
@verseve
Copy link
Contributor

verseve commented Oct 25, 2023

Hi, I cannot reproduce this issue, it is also part of the tests, see for example test/bmi.j. Could you perhaps provide a bit more info on how this was tested? model.config.starttime and model.config.endtime are not string but DateTime types.

@verseve verseve self-assigned this Oct 25, 2023
@BSchilperoort
Copy link
Author

BSchilperoort commented Oct 25, 2023

I think it has to do with the specific config file I am using. This is the start of the config for the Humber case that Tycho Bovenschen provided us:

casename = "wflow_sbm"
calendar = "proleptic_gregorian"
starttime = "2013-11-25T00:00:00"
endtime = "2013-12-15T00:00:00"
time_units = "days since 1900-01-01 00:00:00"
timestepsecs = 3600

While the moselle sbm example has the following:

calendar = "proleptic_gregorian"
endtime = 2000-02-01T00:00:00
starttime = 2000-01-02T00:00:00
time_units = "days since 1900-01-01 00:00:00"
timestepsecs = 86400

The top configuration loads fine, and updates fine. However, the BMI functions do not work due to the misconfiguration.
So I guess the problem is not in the BMI, but in the config parsing.

@visr
Copy link
Member

visr commented Oct 25, 2023

Yeah TOML has datetime support. If that is used it is working fine. But Wflow also accepts strings here, which are converted to datetime, though not in these BMI functions.

@verseve verseve mentioned this issue Oct 25, 2023
5 tasks
@verseve verseve linked a pull request Oct 25, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants