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

Validation error for nans in TimeSeries/T3D/etc missing #433

Closed
veenstrajelmer opened this issue Dec 15, 2022 · 1 comment · Fixed by #460
Closed

Validation error for nans in TimeSeries/T3D/etc missing #433

veenstrajelmer opened this issue Dec 15, 2022 · 1 comment · Fixed by #460
Labels
type: enhancement Improvements to existing functionality
Milestone

Comments

@veenstrajelmer
Copy link
Collaborator

veenstrajelmer commented Dec 15, 2022

Describe the bug
When writing a TimeSeries (or ForcingModel) containing nans, there is no validation error. However, the FM kernel is not able to handle nan values and it will crash with some erro. Therefore, nans in the file are not valid FM input, so should be validated by hydrolib-core.

To Reproduce

from pathlib import Path
import numpy as np
import hydrolib.core.dflowfm as hcdfm

datablock = np.random.uniform(low=-40, high=130.3, size=(4,2))*np.nan
datablock_list = datablock.tolist()

steric = hcdfm.TimeSeries(
    name="east2_0001",
    quantityunitpair=[hcdfm.QuantityUnitPair(quantity="time", unit="seconds since 2022-01-01 00:00:00 +00:00"),
                      hcdfm.QuantityUnitPair(quantity="waterlevel", unit="m")],
    timeinterpolation=hcdfm.TimeInterpolation.linear,
    datablock=datablock_list, 
    )
bc_east = hcdfm.ForcingModel()
bc_east.forcing.append(steric)
bc_east.save(filepath=Path("./steric_east2_hydrolib.bc"))

Expected behavior
Error when nans in dataset.

Version info (please complete the following information):

  • OS: Windows, Spyder
  • Version 0.3.1 (main branch of today)
@arthurvd arthurvd added the type: enhancement Improvements to existing functionality label Mar 7, 2023
@arthurvd arthurvd added this to the Release 0.5 milestone Mar 7, 2023
@tim-vd-aardweg tim-vd-aardweg self-assigned this Mar 9, 2023
@tim-vd-aardweg
Copy link
Contributor

tim-vd-aardweg commented Mar 10, 2023

Discussed this issue with @arthurvd. Even though we know the requested change should be applied to more FM files, for now we will only fix the NaN validation in datablocks. We can create separate issues for the other files/locations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvements to existing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants