Skip to content

Commit

Permalink
Merge branch 'master' into margriet_389_schema_300_1D
Browse files Browse the repository at this point in the history
  • Loading branch information
margrietpalm committed Nov 11, 2024
2 parents 981e2ea + b27fa13 commit 14b1e9f
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 77 deletions.
10 changes: 8 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ Changelog of threedigrid-builder
================================


1.20.1 (unreleased)
1.20.2 (unreleased)
-------------------

- Nothing changed yet.
- Set nodata value for neighbour nodes to 0 in quarters admin.


1.20.1 (2024-10-23)
-------------------

- Fix interception file settings not being read properly in new schema version.


1.20.0 (2024-10-14)
Expand Down
1 change: 1 addition & 0 deletions libthreedigrid/cells.f90
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ subroutine set_quarter_admin(nodk, nodm, nodn, line, kcu, quarter_line, quarter_
! When adjacent cells differ in size due to refinement, each quadrant is associated with its own line for the larger cell. The smaller cell will have the same flow line for both quadrants. Hence the "if" structure.
! Same logic applies to finding neighbouring nodes for quarters.
! The cell quadrant index is illustrated above.

do l=1, liutot
nodd = line(l, 1) + 1 ! This is a 0-based python index, therefore +1
nodu = line(l, 2) + 1
Expand Down
2 changes: 1 addition & 1 deletion threedigrid_builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from .exceptions import * # NOQA

# fmt: off
__version__ = '1.20.1.dev0'
__version__ = '1.20.2.dev0'
# fmt: on
4 changes: 2 additions & 2 deletions threedigrid_builder/grid/quadtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ def get_quarters_admin(self, nodes, lines):
np.isin(nodes.node_type, NodeType.NODE_2D_BOUNDARIES)
)

quarter_line = np.full((4 * n_2d_nodes, 2), -9999, dtype=np.int32, order="F")
neighbour_node = np.full((4 * n_2d_nodes, 2), -9999, dtype=np.int32, order="F")
quarter_line = np.full((4 * n_2d_nodes, 2), 0, dtype=np.int32, order="F")
neighbour_node = np.full((4 * n_2d_nodes, 2), 0, dtype=np.int32, order="F")

m_cells.set_quarter_admin(
nodes.nodk,
Expand Down
15 changes: 8 additions & 7 deletions threedigrid_builder/interface/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,14 @@ def get_settings(self) -> dict:
"friction_coefficient",
default=AVERAGE if model_settings["friction_averaging"] else NO_AGG,
)
_set_initialization_type(
interception,
"interception",
file_field="interception_file",
type_field="interception_type",
default=NO_AGG,
)
if interception:
_set_initialization_type(
interception,
"interception",
file_field="interception_file",
type_field="interception_type",
default=NO_AGG,
)
if interflow:
_set_initialization_type(interflow, "porosity", default=NO_AGG)
_set_initialization_type(
Expand Down
2 changes: 1 addition & 1 deletion threedigrid_builder/interface/gridadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def write_quarters(self, quarters, group_name="quarters"):
quarters.line[mask] = quarters.line[mask] + 1
self.write_dataset(group, "line", quarters.line.T)

mask = quarters.neighbour_node != -9999
mask = quarters.neighbour_node != 0
quarters.neighbour_node[mask] = quarters.neighbour_node[mask] + 1
self.write_dataset(group, "neighbour_node", quarters.neighbour_node.T)

Expand Down
128 changes: 64 additions & 64 deletions threedigrid_builder/tests/test_quadtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,28 +341,28 @@ def test_quarter_administration(quadtree_line_refinement, subgrid_meta):

# fmt: off
neighbours = [
[-9999, -9999],
[5, -9999],
[-9999, 1],
[0, 0],
[5, 0],
[0, 1],
[6, 3],
[-9999, 0],
[0, 0],
[3, 0],
[-9999, 2],
[0, 2],
[3, 2],
[-9999, 1],
[0, 1],
[4, 1],
[-9999, -9999],
[4, -9999],
[0, 0],
[4, 0],
[1, 0],
[7, 0],
[1, 4],
[7, 4],
[2, 3],
[10, 3],
[2, -9999],
[11, -9999],
[0, -9999],
[8, -9999],
[2, 0],
[11, 0],
[0, 0],
[8, 0],
[0, 6],
[8, 6],
[0, 5],
Expand All @@ -373,30 +373,30 @@ def test_quarter_administration(quadtree_line_refinement, subgrid_meta):
[14, 6],
[3, 10],
[15, 12],
[5, -9999],
[-9999, -9999],
[5, 0],
[0, 0],
[5, 9],
[-9999, 9],
[0, 9],
[6, 8],
[-9999, 8],
[0, 8],
[6, 14],
[-9999, 18],
[0, 18],
[4, 7],
[12, 7],
[4, 11],
[12, 11],
[4, 10],
[13, 10],
[4, -9999],
[13, -9999],
[4, 0],
[13, 0],
[10, 7],
[16, 7],
[10, 13],
[16, 13],
[11, 12],
[17, 12],
[11, -9999],
[17, -9999],
[11, 0],
[17, 0],
[7, 9],
[18, 9],
[7, 15],
Expand All @@ -411,49 +411,49 @@ def test_quarter_administration(quadtree_line_refinement, subgrid_meta):
[20, 17],
[13, 16],
[21, 16],
[13, -9999],
[21, -9999],
[13, 0],
[21, 0],
[14, 9],
[-9999, 9],
[0, 9],
[14, 19],
[-9999, 19],
[0, 19],
[15, 18],
[-9999, 18],
[0, 18],
[15, 20],
[-9999, 20],
[0, 20],
[16, 19],
[-9999, 19],
[0, 19],
[16, 21],
[-9999, 21],
[0, 21],
[17, 20],
[-9999, 20],
[17, -9999],
[-9999, -9999]
[0, 20],
[17, 0],
[0, 0]
]

lines = [
[-9999, -9999],
[0, -9999],
[-9999, 19],
[0, 0],
[0, 0],
[0, 19],
[1, 20],
[-9999, 19],
[0, 19],
[2, 19],
[-9999, 21],
[0, 21],
[2, 21],
[-9999, 21],
[0, 21],
[3, 21],
[-9999, -9999],
[3, -9999],
[0, 0],
[3, 0],
[2, 20],
[4, 20],
[2, 22],
[4, 22],
[3, 22],
[5, 22],
[3, -9999],
[6, -9999],
[0, -9999],
[7, -9999],
[3, 0],
[6, 0],
[0, 0],
[7, 0],
[0, 23],
[7, 23],
[1, 23],
Expand All @@ -464,30 +464,30 @@ def test_quarter_administration(quadtree_line_refinement, subgrid_meta):
[9, 24],
[4, 25],
[10, 26],
[7, -9999],
[-9999, -9999],
[7, 0],
[0, 0],
[7, 27],
[-9999, 27],
[0, 27],
[8, 27],
[-9999, 27],
[0, 27],
[8, 28],
[-9999, 29],
[0, 29],
[5, 25],
[11, 25],
[5, 30],
[11, 30],
[6, 30],
[12, 30],
[6, -9999],
[12, -9999],
[6, 0],
[12, 0],
[11, 26],
[13, 26],
[11, 31],
[13, 31],
[12, 31],
[14, 31],
[12, -9999],
[14, -9999],
[12, 0],
[14, 0],
[9, 28],
[15, 28],
[9, 32],
Expand All @@ -502,24 +502,24 @@ def test_quarter_administration(quadtree_line_refinement, subgrid_meta):
[17, 34],
[14, 34],
[18, 34],
[14, -9999],
[18, -9999],
[14, 0],
[18, 0],
[15, 29],
[-9999, 29],
[0, 29],
[15, 35],
[-9999, 35],
[0, 35],
[16, 35],
[-9999, 35],
[0, 35],
[16, 36],
[-9999, 36],
[0, 36],
[17, 36],
[-9999, 36],
[0, 36],
[17, 37],
[-9999, 37],
[0, 37],
[18, 37],
[-9999, 37],
[18, -9999],
[-9999, -9999]
[0, 37],
[18, 0],
[0, 0]
]
# fmt: on
assert_array_equal(quarters.line, lines)
Expand Down

0 comments on commit 14b1e9f

Please sign in to comment.