Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
e107c90
Write first utility functions to allocate river cells
JoerivanEngelen Apr 2, 2024
d7819a0
Add docstring
JoerivanEngelen Apr 3, 2024
be9d2c8
Shorter and concise names, at extra allocation functions for specific…
JoerivanEngelen Apr 3, 2024
93d4b92
Make functions semi-private
JoerivanEngelen Apr 3, 2024
639092e
Move module to better name and location
JoerivanEngelen Apr 3, 2024
d980d7f
Move functions to new module and throw deprecation warning when being…
JoerivanEngelen Apr 3, 2024
87c8de0
Import at module level
JoerivanEngelen Apr 3, 2024
e44b7da
Add topsystem functions to public API
JoerivanEngelen Apr 3, 2024
14ecd58
Add first test for allocation
JoerivanEngelen Apr 3, 2024
30902f2
Generalize utility functions and work around circular imports
JoerivanEngelen Apr 8, 2024
1ae56a7
Add utility functions to preserve gridtype and to enforce dim order
JoerivanEngelen Apr 8, 2024
54337c5
Add decorator to enforce dim order
JoerivanEngelen Apr 8, 2024
6cced53
Apply decorator to preserve gridtype
JoerivanEngelen Apr 8, 2024
e248274
format
JoerivanEngelen Apr 8, 2024
1ec16d9
Add tests for allocation functions
JoerivanEngelen Apr 8, 2024
c918177
Fix bugs where cells were incorrectly allocated when looking at riv s…
JoerivanEngelen Apr 8, 2024
f9caec5
Add docstring with explanation
JoerivanEngelen Apr 8, 2024
16e3369
Tidy up docstring
JoerivanEngelen Apr 8, 2024
9a93004
Tidy up docstring
JoerivanEngelen Apr 8, 2024
44cc5db
format
JoerivanEngelen Apr 8, 2024
8ba80fe
Add tests for allocation drn, rch, ghb cells
JoerivanEngelen Apr 9, 2024
ea613d6
Return grid instead of tuple for rch
JoerivanEngelen Apr 9, 2024
e3a613c
rename river to riv and drain to drn
JoerivanEngelen Apr 9, 2024
47c5ba9
Add tests for enforced_dim_order decorator
JoerivanEngelen Apr 9, 2024
d3ca2ec
Enforce unstructured grid in preserve_gridtype
JoerivanEngelen Apr 9, 2024
67ed07a
Add tests to preserve gridtype and enforce dim order
JoerivanEngelen Apr 9, 2024
0f64560
Format
JoerivanEngelen Apr 9, 2024
6f0325d
Fix bug where optional geopandas throws error in type annotation
JoerivanEngelen Apr 9, 2024
9f65a01
Update changelog
JoerivanEngelen Apr 9, 2024
1071d10
Type annotation
JoerivanEngelen Apr 10, 2024
39108ca
Extend docstring create_layered_top and import in prepare module
JoerivanEngelen Apr 10, 2024
1a44531
Add create_layered_top to API docs
JoerivanEngelen Apr 10, 2024
c2485ed
Add ValueError in case wrong option is applied for ALLOCATION_OPTION …
JoerivanEngelen Apr 10, 2024
5d92bb0
Fix typos
JoerivanEngelen Apr 10, 2024
b8adfac
Format
JoerivanEngelen Apr 10, 2024
96776e4
Move enforcing of layered top to separate helper function
JoerivanEngelen Apr 12, 2024
ec9957f
Add helper functions to distribute conductance
JoerivanEngelen Apr 12, 2024
dd88728
Fix bugs while implementing the tests
JoerivanEngelen Apr 18, 2024
c4c7ebd
Expose conductance functions to public API
JoerivanEngelen Apr 18, 2024
03dcf80
Add first version of tests for conductance utility
JoerivanEngelen Apr 18, 2024
866021d
Rename test utilities
JoerivanEngelen Apr 18, 2024
c05d264
Move fixtures to fixtures section
JoerivanEngelen Apr 18, 2024
f167960
Move cases to separate source file, use tags and prefixes instead of …
JoerivanEngelen Apr 18, 2024
decf57b
Remove unused imports
JoerivanEngelen Apr 18, 2024
730ac1f
format
JoerivanEngelen Apr 18, 2024
9c7c4e7
Add docstrings
JoerivanEngelen Apr 18, 2024
723509d
Expose distributing functions to public API
JoerivanEngelen Apr 18, 2024
202417e
Add docstrings
JoerivanEngelen Apr 18, 2024
1a51a68
Add example code snippets in docstring
JoerivanEngelen Apr 18, 2024
1749bf1
Merge branch 'master' into issue_950_distribute_conductances
JoerivanEngelen Apr 18, 2024
5879a6a
Delete duplicate tests
JoerivanEngelen Apr 18, 2024
f7aa808
Format
JoerivanEngelen Apr 18, 2024
765cda5
Ensure weights are same shape as allocation grid for distribution equ…
JoerivanEngelen Apr 19, 2024
d86ce6a
Rename 'take_first_planar_cell' to 'take_first_cell_in_xy_plane'
JoerivanEngelen Apr 19, 2024
c413cef
Extend docstrings
JoerivanEngelen Apr 19, 2024
3f96bbb
Extend docstrings
JoerivanEngelen Apr 19, 2024
31311f5
Set italics options to code in docstring
JoerivanEngelen Apr 19, 2024
0f859e9
Add test cases for first active and third layer only active
JoerivanEngelen Apr 19, 2024
e99761b
Enforce dim order, preserve gridtype, where allocated only in by_cros…
JoerivanEngelen Apr 19, 2024
f5e0813
format
JoerivanEngelen Apr 19, 2024
62384ef
Extend docstrings further
JoerivanEngelen Apr 19, 2024
558dcda
Add test cases for allocated layer True False True False
JoerivanEngelen Apr 19, 2024
e261281
Format
JoerivanEngelen Apr 19, 2024
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
6 changes: 6 additions & 0 deletions docs/api/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Added
:func:`imod.prepare.allocate_rch_cells`,
:func:`imod.prepare.allocate_riv_cells`, for this multiple options can be
selected, available in :func:`imod.prepare.ALLOCATION_OPTION`.
- Added functions to distribute conductances of planar grids over layers for the
topsystem in :func:`imod.prepare.distribute_riv_conductance`,
:func:`imod.prepare.distribute_drn_conductance`,
:func:`imod.prepare.distribute_ghb_conductance`, for this multiple options can
be selected, available in :func:`imod.prepare.DISTRIBUTION_OPTION`.


Fixed
~~~~~
Expand Down
6 changes: 5 additions & 1 deletion docs/api/prepare.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ Prepare model input
create_layered_top

ALLOCATION_OPTION
DISTRIBUTION_OPTION
allocate_drn_cells
allocate_ghb_cells
allocate_rch_cells
allocate_riv_cells
c_leakage
c_radial
c_radial
distribute_drn_conductance
distribute_ghb_conductance
distribute_riv_conductance
4 changes: 4 additions & 0 deletions imod/prepare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@
)
from imod.prepare.topsystem import (
ALLOCATION_OPTION,
DISTRIBUTING_OPTION,
allocate_drn_cells,
allocate_ghb_cells,
allocate_rch_cells,
allocate_riv_cells,
c_leakage,
c_radial,
distribute_drn_conductance,
distribute_ghb_conductance,
distribute_riv_conductance,
)
from imod.prepare.voxelize import Voxelizer
from imod.prepare.wells import assign_wells
6 changes: 6 additions & 0 deletions imod/prepare/topsystem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@
allocate_rch_cells,
allocate_riv_cells,
)
from imod.prepare.topsystem.conductance import (
DISTRIBUTING_OPTION,
distribute_drn_conductance,
distribute_ghb_conductance,
distribute_riv_conductance,
)
from imod.prepare.topsystem.resistance import c_leakage, c_radial
45 changes: 23 additions & 22 deletions imod/prepare/topsystem/allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ def _is_layered(grid: GridDataArray):
return "layer" in grid.sizes and grid.sizes["layer"] > 1


def _enforce_layered_top(top: GridDataArray, bottom: GridDataArray):
if _is_layered(top):
return top
else:
return create_layered_top(bottom, top)


@enforced_dim_order
def _allocate_cells__stage_to_riv_bot(
top: GridDataArray,
Comment thread
JoerivanEngelen marked this conversation as resolved.
Expand All @@ -155,9 +162,11 @@ def _allocate_cells__stage_to_riv_bot(
bottom: GridDataArray
bottom of model layers
stage: GridDataArray
river stage
river stage, cannot contain a layer dimension. Can contain a time
dimension.
bottom_elevation: GridDataArray
river bottom elevation
river bottom elevation, cannot contain a layer dimension. Can contain a
time dimension.

Returns
-------
Expand All @@ -167,10 +176,7 @@ def _allocate_cells__stage_to_riv_bot(
PLANAR_GRID.validate(stage)
PLANAR_GRID.validate(bottom_elevation)

if _is_layered(top):
top_layered = top
else:
top_layered = create_layered_top(bottom, top)
top_layered = _enforce_layered_top(top, bottom)

riv_cells = (stage > bottom) & (bottom_elevation < top_layered)

Expand Down Expand Up @@ -200,7 +206,8 @@ def _allocate_cells__first_active_to_riv_bot(
bottom: GridDataArray
bottom of model layers
bottom_elevation: GridDataArray
river bottom elevation
river bottom elevation, cannot contain a layer dimension. Can contain a
time dimension.

Returns
-------
Expand All @@ -212,10 +219,7 @@ def _allocate_cells__first_active_to_riv_bot(
upper_active_layer = get_upper_active_layer_number(active)
layer = active.coords["layer"]

if _is_layered(top):
top_layered = top
else:
top_layered = create_layered_top(bottom, top)
top_layered = _enforce_layered_top(top, bottom)

riv_cells = (upper_active_layer <= layer) & (bottom_elevation < top_layered)

Expand Down Expand Up @@ -247,9 +251,11 @@ def _allocate_cells__first_active_to_riv_bot__drn(
bottom: GridDataArray
bottom of model layers
stage: GridDataArray
river stage
river stage, cannot contain a layer dimension. Can contain a time
dimension.
bottom_elevation: GridDataArray
river bottom elevation
river bottom elevation, cannot contain a layer dimension. Can contain a
time dimension.

Returns
-------
Expand All @@ -262,10 +268,7 @@ def _allocate_cells__first_active_to_riv_bot__drn(
PLANAR_GRID.validate(stage)
PLANAR_GRID.validate(bottom_elevation)

if _is_layered(top):
top_layered = top
else:
top_layered = create_layered_top(bottom, top)
top_layered = _enforce_layered_top(top, bottom)

upper_active_layer = get_upper_active_layer_number(active)
layer = active.coords["layer"]
Expand Down Expand Up @@ -294,7 +297,8 @@ def _allocate_cells__at_elevation(
bottom: GridDataArray
bottom of model layers
elevation: GridDataArray
elevation. Can be river bottom, drain elevation or head of GHB.
elevation. Can be river bottom, drain elevation or head of GHB. Cannot
contain a layer dimension. Can contain a time dimension.

Returns
-------
Expand All @@ -304,10 +308,7 @@ def _allocate_cells__at_elevation(

PLANAR_GRID.validate(elevation)

if _is_layered(top):
top_layered = top
else:
top_layered = create_layered_top(bottom, top)
top_layered = _enforce_layered_top(top, bottom)

riv_cells = (elevation < top_layered) & (elevation >= bottom)

Expand Down
Loading