-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate during initialization Improve Node representation Adapt type hint Minimal version of `Model` Add existing methods to `Model` Continue Fix remaining problems
- Loading branch information
1 parent
7ee3f1a
commit 491911b
Showing
7 changed files
with
434 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,3 +154,4 @@ report.xml | |
|
||
# Designated working dir for working on Ribasim models | ||
models/ | ||
playground/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# %% | ||
import shutil | ||
from pathlib import Path | ||
|
||
from pandas import DataFrame | ||
from ribasim.add import Basins, Model | ||
from ribasim.config import Basin | ||
|
||
# %% | ||
output_dir = Path(__file__).parent / "output" | ||
shutil.rmtree(output_dir, ignore_errors=True) | ||
# %% | ||
|
||
basins = Basins( | ||
[ | ||
Basin( | ||
profile=DataFrame({"area": [1.0, 3.0], "level": [1.1, 2.2]}), | ||
# static=DataFrame( | ||
# {"precipitation": [1.0, 3.0], "control_state": [1.1, 2.2]} | ||
# ), | ||
node={ | ||
"node_id": 2, | ||
"geometry": (2.0, 3.6), | ||
"name": "IJsselmeer", | ||
"subnetwork_id": 5, | ||
}, | ||
), | ||
Basin( | ||
profile=DataFrame({"area": [2.0, 4.0], "level": [6.1, 7.2]}), | ||
# static=DataFrame( | ||
# {"precipitation": [1.0, 3.0], "control_state": [1.1, 2.2]} | ||
# ), | ||
node={ | ||
"node_id": 1, | ||
"geometry": (5.0, 3.6), | ||
"name": "Zoetermeer", | ||
"subnetwork_id": 6, | ||
}, | ||
), | ||
] | ||
) | ||
basins | ||
# %% | ||
model = Model( | ||
starttime="2020-01-01 00:00:00", endtime="2021-01-01 00:00:00", basins=basins | ||
) | ||
model | ||
# %% | ||
toml_path = output_dir / "ribasim.toml" | ||
model.write(toml_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# %% | ||
import tempfile | ||
from pathlib import Path | ||
|
||
import geopandas | ||
import pandas as pd | ||
from pandas import DataFrame | ||
from ribasim.add import Basins, Model | ||
from ribasim.config import Basin | ||
|
||
basins = Basins( | ||
[ | ||
Basin( | ||
profile=DataFrame({"area": [1.0, 3.0], "level": [1.1, 2.2]}), | ||
# static=DataFrame( | ||
# {"precipitation": [1.0, 3.0], "control_state": [1.1, 2.2]} | ||
# ), | ||
node={ | ||
"id": 2, | ||
# allow tuples, call gpd.points_from_xy ourselves | ||
"geometry": (2.0, 3.6), | ||
"name": "IJsselmeer", | ||
"allocation_network_id": 5, | ||
}, | ||
) | ||
] | ||
) | ||
basins | ||
# %% | ||
model = Model( | ||
starttime="2020-01-01 00:00:00", endtime="2021-01-01 00:00:00", basins=basins | ||
) | ||
model | ||
# %% | ||
with tempfile.TemporaryDirectory() as tmpdirname: | ||
toml_path = Path(tmpdirname) / "ribasim.toml" | ||
model.write(toml_path) | ||
print(toml_path.read_text()) |
Oops, something went wrong.