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

Unclear error message from bc-validation #560

Open
veenstrajelmer opened this issue Jul 26, 2023 · 0 comments
Open

Unclear error message from bc-validation #560

veenstrajelmer opened this issue Jul 26, 2023 · 0 comments
Labels

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Jul 26, 2023

Describe the bug
I received a faulty bc file from a client, which I got working with help from the HYDROLIB-core validation, but the error messages I got can be clearer.

To Reproduce
The (simplified) bc-file Velocity3D_west_small.bc looks like this:

Time-interpolation              = linear
Vertical position type          = percentage from bed
Vertical position               = 3.6, 27.7
Quantity                        = time
Unit                            = seconds since 1994-01-01 00:00:00
Quantity                        = velocitybnd
Unit                            = m/s
verticalPositionIndex           = 1
Quantity                        = velocitybnd
Unit                            = m/s
verticalPositionIndex           = 2
  16858800 -0.005 0.000 
  16869600 -0.003 -0.003
  16880400 0.003 -0.003 
  16891200 0.017 0.011 
  16902000 0.017 0.016 
  16912800 0.002 0.010 

The file can be read+validated with HYDROLIB-core with this code:

import hydrolib.core.dflowfm as hcdfm
file_bc = 'Velocity3D_west_small.bc'
fm_bc = hcdfm.ForcingModel(file_bc)

A clear error message is thrown:

ValidationError: 1 validation error for ForcingModel
Velocity3D_west_small.bc -> forcing -> 0 -> west_0001 -> __root__
  vertPositions is not provided (type=value_error)

Action: replace Vertical position with vertPositions and try again. In the uxuy example bc-file, this quantity is named Vertical position specification

Another error message is thrown:

ValidationError: 1 validation error for ForcingModel
Velocity3D_west_small.bc -> forcing -> 0 -> west_0001 -> __root__
  Vertical position index should be between 1 and 2, but None was given (type=value_error)

After a bit of puzzling, I figured out that verticalPositionIndex should be replaced with vertPositionIndex. In the uxuy example bc-file, this quantity is named Vertical position. This is confusingly similar to vertPositions above.

After replacing, we get this error message:

ValidationError: 1 validation error for ForcingModel
Velocity3D_west_small.bc -> forcing -> 0 -> west_0001 -> vertPositions -> 0
  value is not a valid float (type=type_error.float)

I figured that the comma's should be removed from the Vertpositions value.

Expected behavior
A bit clearer error messages, so the user knows what should be changed. Also, the similarity of vertPositions and Vertical position (which are the indices and the position values) is a bit confusing.

Version info (please complete the following information):

  • OS: Windows
  • Version HYDROLIB-core 0.5.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants