Coverage for C:\src\imod-python\imod\flow\bas.py: 97%
39 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-08 13:27 +0200
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-08 13:27 +0200
1import scipy.ndimage
3from imod.flow.pkgbase import Package
6class Boundary(Package):
7 """
8 Specify the locations of active, inactive, and specified head in cells
10 Parameters
11 ----------
12 ibound: xr.DataArray of ints
13 is the boundary variable with dimensions ``("layer", "y", "x")``.
15 * If IBOUND(J,I,K) < 0, cell J,I,K has a constant head.
16 * If IBOUND(J,I,K) = 0, cell J,I,K is inactive.
17 * If IBOUND(J,I,K) > 0, cell J,I,K is active.
18 """
20 _pkg_id = "bnd"
21 _variable_order = ["ibound"]
23 def __init__(self, ibound):
24 super().__init__()
25 self.dataset["ibound"] = ibound
27 def _pkgcheck(self, active_cells=None):
28 _, nlabels = scipy.ndimage.label(active_cells.values)
29 if nlabels > 1:
30 raise ValueError(
31 f"{nlabels} disconnected model domain detected in the ibound"
32 )
35class Top(Package):
36 """
37 The top of the aquifers
39 Parameters
40 ----------
41 top: xr.DataArray of floats
42 is the top elevation with dimensions ``("layer", "y", "x")``. For the
43 common situation in which the top layer represents a water-table
44 aquifer, it may be reasonable to set`top` equal to land-surface
45 elevation. The DataArray should at least include the `layer`
46 dimension.
47 """
49 _pkg_id = "top"
50 _variable_order = ["top"]
52 def __init__(self, top):
53 super().__init__()
54 self.dataset["top"] = top
56 def _pkgcheck(self, active_cells=None):
57 vars_to_check = ["top"]
58 self._check_if_nan_in_active_cells(
59 active_cells=active_cells, vars_to_check=vars_to_check
60 )
63class Bottom(Package):
64 """
65 The bottom of the aquifers
67 Parameters
68 ----------
69 bottom: xr.DataArray of floats
70 is the bottom elevation of model layers or Quasi-3d confining beds,
71 with dimensions ``("layer", "y", "x")``. The DataArray should at least
72 include the `layer` dimension.
73 """
75 _pkg_id = "bot"
76 _variable_order = ["bottom"]
78 def __init__(self, bottom):
79 super().__init__()
80 self.dataset["bottom"] = bottom
82 def _pkgcheck(self, active_cells=None):
83 vars_to_check = ["bottom"]
84 self._check_if_nan_in_active_cells(
85 active_cells=active_cells, vars_to_check=vars_to_check
86 )
89class StartingHead(Package):
90 """
91 The initial head in all cells
93 Parameters
94 ----------
95 starting_head: float or xr.DataArray of floats
96 is initial (starting) head—that is, head at the beginning of the
97 simulation (SHD). starting_head must be specified for all simulations,
98 including steady-state simulations. One value is read for every model
99 cell. Usually, these values are read a layer at a time.
100 """
102 _pkg_id = "shd"
103 _variable_order = ["starting_head"]
105 def __init__(self, starting_head):
106 super().__init__()
107 self.dataset["starting_head"] = starting_head
109 def _pkgcheck(self, active_cells=None):
110 vars_to_check = ["starting_head"]
111 self._check_if_nan_in_active_cells(
112 active_cells=active_cells, vars_to_check=vars_to_check
113 )