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

Don't add Basin / static if there are no flows #1135

Merged
merged 1 commit into from
Feb 16, 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
42 changes: 3 additions & 39 deletions docs/python/examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,8 @@
"static = pd.DataFrame(\n",
" data={\n",
" \"node_id\": [0],\n",
" \"drainage\": [0.0],\n",
" \"potential_evaporation\": [evaporation],\n",
" \"infiltration\": [0.0],\n",
" \"precipitation\": [precipitation],\n",
" \"urban_runoff\": [0.0],\n",
" }\n",
")\n",
"static = static.iloc[[0, 0, 0, 0]]\n",
Expand Down Expand Up @@ -736,20 +733,9 @@
" }\n",
")\n",
"\n",
"static = pd.DataFrame(\n",
" data={\n",
" \"node_id\": [1],\n",
" \"drainage\": [0.0],\n",
" \"potential_evaporation\": [0.0],\n",
" \"infiltration\": [0.0],\n",
" \"precipitation\": [0.0],\n",
" \"urban_runoff\": [0.0],\n",
" }\n",
")\n",
"\n",
"state = pd.DataFrame(data={\"node_id\": [1], \"level\": [20.0]})\n",
"\n",
"basin = ribasim.Basin(profile=profile, static=static, state=state)"
"basin = ribasim.Basin(profile=profile, state=state)"
]
},
{
Expand Down Expand Up @@ -1162,25 +1148,14 @@
" data={\"node_id\": [2, 2], \"level\": [0.0, 1.0], \"area\": [1000.0, 1000.0]}\n",
")\n",
"\n",
"static = pd.DataFrame(\n",
" data={\n",
" \"node_id\": [2],\n",
" \"drainage\": [0.0],\n",
" \"potential_evaporation\": [0.0],\n",
" \"infiltration\": [0.0],\n",
" \"precipitation\": [0.0],\n",
" \"urban_runoff\": [0.0],\n",
" }\n",
")\n",
"\n",
"state = pd.DataFrame(\n",
" data={\n",
" \"node_id\": [2],\n",
" \"level\": [6.0],\n",
" }\n",
")\n",
"\n",
"basin = ribasim.Basin(profile=profile, static=static, state=state)"
"basin = ribasim.Basin(profile=profile, state=state)"
]
},
{
Expand Down Expand Up @@ -1553,20 +1528,9 @@
" }\n",
")\n",
"\n",
"static = pd.DataFrame(\n",
" data={\n",
" \"node_id\": [2, 5, 12],\n",
" \"drainage\": 0.0,\n",
" \"potential_evaporation\": 0.0,\n",
" \"infiltration\": 0.0,\n",
" \"precipitation\": 0.0,\n",
" \"urban_runoff\": 0.0,\n",
" }\n",
")\n",
"\n",
"state = pd.DataFrame(data={\"node_id\": [2, 5, 12], \"level\": 1.0})\n",
"\n",
"basin = ribasim.Basin(profile=profile, static=static, state=state)"
"basin = ribasim.Basin(profile=profile, state=state)"
]
},
{
Expand Down
109 changes: 6 additions & 103 deletions python/ribasim_testmodels/ribasim_testmodels/allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,9 @@ def user_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,
}
)

state = pd.DataFrame(data={"node_id": [1], "level": 1.0})

basin = ribasim.Basin(profile=profile, static=static, state=state)
basin = ribasim.Basin(profile=profile, state=state)

# Setup the users:
user = ribasim.User(
Expand Down Expand Up @@ -199,20 +188,9 @@ def subnetwork_model():
data={"node_id": [2, 2, 6, 6, 8, 8], "area": 100000.0, "level": 3 * [0.0, 1.0]}
)

static = pd.DataFrame(
data={
"node_id": [2, 6, 8],
"drainage": 0.0,
"potential_evaporation": 0.0,
"infiltration": 0.0,
"precipitation": 0.0,
"urban_runoff": 0.0,
}
)

state = pd.DataFrame(data={"node_id": [2, 6, 8], "level": 10.0})

basin = ribasim.Basin(profile=profile, static=static, state=state)
basin = ribasim.Basin(profile=profile, state=state)

# Setup the flow boundary:
flow_boundary = ribasim.FlowBoundary(
Expand Down Expand Up @@ -450,20 +428,9 @@ def looped_subnetwork_model():
}
)

static = pd.DataFrame(
data={
"node_id": [2, 7, 11, 9, 15, 17, 21],
"drainage": 0.0,
"potential_evaporation": 0.0,
"infiltration": 0.0,
"precipitation": 0.0,
"urban_runoff": 0.0,
}
)

state = pd.DataFrame(data={"node_id": [2, 7, 9, 11, 15, 17, 21], "level": 1.0})

basin = ribasim.Basin(profile=profile, static=static, state=state)
basin = ribasim.Basin(profile=profile, state=state)

# Setup the flow boundary:
flow_boundary = ribasim.FlowBoundary(
Expand Down Expand Up @@ -601,20 +568,9 @@ def minimal_subnetwork_model():
}
)

static = pd.DataFrame(
data={
"node_id": [2, 4],
"drainage": 0.0,
"potential_evaporation": 0.0,
"infiltration": 0.0,
"precipitation": 0.0,
"urban_runoff": 0.0,
}
)

state = pd.DataFrame(data={"node_id": [2, 4], "level": 1.0})

basin = ribasim.Basin(profile=profile, static=static, state=state)
basin = ribasim.Basin(profile=profile, state=state)

# Setup the flow boundary:
flow_boundary = ribasim.FlowBoundary(
Expand Down Expand Up @@ -758,20 +714,9 @@ def fractional_flow_subnetwork_model():
}
)

static = pd.DataFrame(
data={
"node_id": [2, 5, 8],
"drainage": 0.0,
"potential_evaporation": 0.0,
"infiltration": 0.0,
"precipitation": 0.0,
"urban_runoff": 0.0,
}
)

state = pd.DataFrame(data={"node_id": [2, 5, 8], "level": 1.0})

basin = ribasim.Basin(profile=profile, static=static, state=state)
basin = ribasim.Basin(profile=profile, state=state)

# Setup the flow boundary:
flow_boundary = ribasim.FlowBoundary(
Expand Down Expand Up @@ -954,20 +899,9 @@ def allocation_example_model():
}
)

static = pd.DataFrame(
data={
"node_id": [2, 5, 12],
"drainage": 0.0,
"potential_evaporation": 0.0,
"infiltration": 0.0,
"precipitation": 0.0,
"urban_runoff": 0.0,
}
)

state = pd.DataFrame(data={"node_id": [2, 5, 12], "level": 1.0})

basin = ribasim.Basin(profile=profile, static=static, state=state)
basin = ribasim.Basin(profile=profile, state=state)

flow_boundary = ribasim.FlowBoundary(
static=pd.DataFrame(
Expand Down Expand Up @@ -1514,36 +1448,6 @@ def main_network_with_subnetworks_model():
}
)

static = pd.DataFrame(
data={
"node_id": [
2,
4,
6,
8,
10,
12,
16,
18,
25,
28,
31,
35,
40,
44,
42,
48,
50,
54,
],
"drainage": 0.0,
"potential_evaporation": 0.0,
"infiltration": 0.0,
"precipitation": 0.0,
"urban_runoff": 0.0,
}
)

state = pd.DataFrame(
data={
"node_id": [
Expand Down Expand Up @@ -1591,7 +1495,6 @@ def main_network_with_subnetworks_model():

basin = ribasim.Basin(
profile=profile,
static=static,
state=state,
)

Expand Down
12 changes: 1 addition & 11 deletions python/ribasim_testmodels/ribasim_testmodels/backwater.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,8 @@ def backwater_model():
"level": [0.0, 1.0] * n_basin,
}
)
static = pd.DataFrame(
data={
"node_id": basin_ids,
"drainage": 0.0,
"potential_evaporation": 0.0,
"infiltration": 0.0,
"precipitation": 0.0,
"urban_runoff": 0.0,
}
)
state = pd.DataFrame(data={"node_id": basin_ids, "level": 0.05})
basin = ribasim.Basin(profile=profile, static=static, state=state)
basin = ribasim.Basin(profile=profile, state=state)

manning_resistance = ribasim.ManningResistance(
static=pd.DataFrame(
Expand Down
20 changes: 1 addition & 19 deletions python/ribasim_testmodels/ribasim_testmodels/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ def basic_model() -> ribasim.Model:
static = pd.DataFrame(
data={
"node_id": [0],
"drainage": [0.0],
"potential_evaporation": [evaporation],
"infiltration": [0.0],
"precipitation": [precipitation],
"urban_runoff": [0.0],
}
)
static = static.iloc[[0, 0, 0, 0]]
Expand Down Expand Up @@ -307,11 +304,7 @@ def tabulated_rating_curve_model() -> ribasim.Model:
static = pd.DataFrame(
data={
"node_id": [1, 4],
"drainage": 0.0,
"potential_evaporation": 0.0,
"infiltration": 0.0,
"precipitation": [precipitation, 0.0],
"urban_runoff": 0.0,
}
)
state = pd.DataFrame(
Expand Down Expand Up @@ -451,20 +444,9 @@ def outlet_model():
}
)

static = pd.DataFrame(
data={
"node_id": [3],
"drainage": 0.0,
"potential_evaporation": 0.0,
"infiltration": 0.0,
"precipitation": 0.0,
"urban_runoff": 0.0,
}
)

state = pd.DataFrame(data={"node_id": [3], "level": 1e-3})

basin = ribasim.Basin(profile=profile, static=static, state=state)
basin = ribasim.Basin(profile=profile, state=state)

# Setup the level boundary:
level_boundary = ribasim.LevelBoundary(
Expand Down
Loading
Loading