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

Also allow Missing in basin.static #1079

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/src/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions core/test/run_models_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
62 changes: 46 additions & 16 deletions docs/schema/BasinStatic.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -37,11 +72,6 @@
}
},
"required": [
"node_id",
"drainage",
"potential_evaporation",
"infiltration",
"precipitation",
"urban_runoff"
"node_id"
]
}
10 changes: 5 additions & 5 deletions python/ribasim/ribasim/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
10 changes: 5 additions & 5 deletions python/ribasim_testmodels/ribasim_testmodels/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading