diff --git a/core/src/validation.jl b/core/src/validation.jl index 98d99d03c..adfcc1da6 100644 --- a/core/src/validation.jl +++ b/core/src/validation.jl @@ -175,11 +175,11 @@ end @version BasinStaticV1 begin node_id::Int - drainage::Float64 - potential_evaporation::Float64 - infiltration::Float64 - precipitation::Float64 - urban_runoff::Float64 + drainage::Union{Missing, Float64} + potential_evaporation::Union{Missing, Float64} + infiltration::Union{Missing, Float64} + precipitation::Union{Missing, Float64} + urban_runoff::Union{Missing, Float64} end @version BasinTimeV1 begin diff --git a/core/test/run_models_test.jl b/core/test/run_models_test.jl index bc93285f8..74f74668c 100644 --- a/core/test/run_models_test.jl +++ b/core/test/run_models_test.jl @@ -111,6 +111,11 @@ end @test ispath(toml_path) model = Ribasim.run(toml_path) @test model isa Ribasim.Model + @test model.integrator.u.storage ≈ [1000] + @test model.integrator.p.basin.precipitation == [0.0] + @test model.integrator.p.basin.potential_evaporation == [0.0] + @test model.integrator.p.basin.drainage == [0.0] + @test model.integrator.p.basin.infiltration == [0.0] @test successful_retcode(model) end diff --git a/docs/schema/BasinStatic.schema.json b/docs/schema/BasinStatic.schema.json index 2d8366e7f..747de6602 100644 --- a/docs/schema/BasinStatic.schema.json +++ b/docs/schema/BasinStatic.schema.json @@ -10,24 +10,59 @@ "type": "integer" }, "drainage": { - "format": "double", - "type": "number" + "format": "default", + "anyOf": [ + { + "type": "null" + }, + { + "type": "number" + } + ] }, "potential_evaporation": { - "format": "double", - "type": "number" + "format": "default", + "anyOf": [ + { + "type": "null" + }, + { + "type": "number" + } + ] }, "infiltration": { - "format": "double", - "type": "number" + "format": "default", + "anyOf": [ + { + "type": "null" + }, + { + "type": "number" + } + ] }, "precipitation": { - "format": "double", - "type": "number" + "format": "default", + "anyOf": [ + { + "type": "null" + }, + { + "type": "number" + } + ] }, "urban_runoff": { - "format": "double", - "type": "number" + "format": "default", + "anyOf": [ + { + "type": "null" + }, + { + "type": "number" + } + ] }, "remarks": { "description": "a hack for pandera", @@ -37,11 +72,6 @@ } }, "required": [ - "node_id", - "drainage", - "potential_evaporation", - "infiltration", - "precipitation", - "urban_runoff" + "node_id" ] } diff --git a/python/ribasim/ribasim/models.py b/python/ribasim/ribasim/models.py index f5c63246d..d0e8c341b 100644 --- a/python/ribasim/ribasim/models.py +++ b/python/ribasim/ribasim/models.py @@ -25,11 +25,11 @@ class BasinState(BaseModel): class BasinStatic(BaseModel): node_id: int - drainage: float - potential_evaporation: float - infiltration: float - precipitation: float - urban_runoff: float + drainage: float | None = None + potential_evaporation: float | None = None + infiltration: float | None = None + precipitation: float | None = None + urban_runoff: float | None = None remarks: str = Field("", description="a hack for pandera") diff --git a/python/ribasim_testmodels/ribasim_testmodels/bucket.py b/python/ribasim_testmodels/ribasim_testmodels/bucket.py index f16e06319..3d4fdd6de 100644 --- a/python/ribasim_testmodels/ribasim_testmodels/bucket.py +++ b/python/ribasim_testmodels/ribasim_testmodels/bucket.py @@ -60,11 +60,11 @@ def bucket_model() -> ribasim.Model: static = pd.DataFrame( data={ "node_id": [1], - "drainage": [0.0], - "potential_evaporation": [0.0], - "infiltration": [0.0], - "precipitation": [0.0], - "urban_runoff": [0.0], + "drainage": [np.nan], + "potential_evaporation": [np.nan], + "infiltration": [np.nan], + "precipitation": [np.nan], + "urban_runoff": [np.nan], } ) basin = ribasim.Basin(profile=profile, static=static, state=state)