From cb47e0cb892ebdeb60bce4188aa668d5f03a4687 Mon Sep 17 00:00:00 2001 From: daanvaningen Date: Wed, 23 Oct 2024 14:10:13 +0200 Subject: [PATCH 1/4] fix interception settings in new schema version bug --- CHANGES.rst | 2 +- threedigrid_builder/interface/db.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 41fde0ab..0dbabe7e 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ Changelog of threedigrid-builder 1.20.1 (unreleased) ------------------- -- Nothing changed yet. +- Fix interception file settings not being read properly in new schema version. 1.20.0 (2024-10-14) diff --git a/threedigrid_builder/interface/db.py b/threedigrid_builder/interface/db.py index e8f75cd6..118072e0 100644 --- a/threedigrid_builder/interface/db.py +++ b/threedigrid_builder/interface/db.py @@ -199,13 +199,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( From c29bec7283dc67f24b46cbf2e0266ed397a7d089 Mon Sep 17 00:00:00 2001 From: daanvaningen Date: Wed, 23 Oct 2024 14:11:02 +0200 Subject: [PATCH 2/4] Preparing release 1.20.1 --- CHANGES.rst | 2 +- threedigrid_builder/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 0dbabe7e..661954cc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,7 +2,7 @@ Changelog of threedigrid-builder ================================ -1.20.1 (unreleased) +1.20.1 (2024-10-23) ------------------- - Fix interception file settings not being read properly in new schema version. diff --git a/threedigrid_builder/__init__.py b/threedigrid_builder/__init__.py index 5e754a4b..5899f3a2 100644 --- a/threedigrid_builder/__init__.py +++ b/threedigrid_builder/__init__.py @@ -2,5 +2,5 @@ from .exceptions import * # NOQA # fmt: off -__version__ = '1.20.1.dev0' +__version__ = '1.20.1' # fmt: on From 7eab34789fa015a38ee1ddbdcc51790d288a8ea5 Mon Sep 17 00:00:00 2001 From: daanvaningen Date: Wed, 23 Oct 2024 14:11:13 +0200 Subject: [PATCH 3/4] Back to development: 1.20.2 --- CHANGES.rst | 6 ++++++ threedigrid_builder/__init__.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 661954cc..3433d427 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -2,6 +2,12 @@ Changelog of threedigrid-builder ================================ +1.20.2 (unreleased) +------------------- + +- Nothing changed yet. + + 1.20.1 (2024-10-23) ------------------- diff --git a/threedigrid_builder/__init__.py b/threedigrid_builder/__init__.py index 5899f3a2..ac4705cb 100644 --- a/threedigrid_builder/__init__.py +++ b/threedigrid_builder/__init__.py @@ -2,5 +2,5 @@ from .exceptions import * # NOQA # fmt: off -__version__ = '1.20.1' +__version__ = '1.20.2.dev0' # fmt: on From b27fa13a7c33d2344fb5d40789b7f1aa51f446ea Mon Sep 17 00:00:00 2001 From: martijn-siemerink Date: Wed, 6 Nov 2024 11:53:02 +0100 Subject: [PATCH 4/4] [DONE] Martijn quarters admin (#394) --- CHANGES.rst | 2 +- libthreedigrid/cells.f90 | 1 + threedigrid_builder/grid/quadtree.py | 4 +- threedigrid_builder/interface/gridadmin.py | 2 +- threedigrid_builder/tests/test_quadtree.py | 128 ++++++++++----------- 5 files changed, 69 insertions(+), 68 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 3433d427..60f21f3d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,7 +5,7 @@ Changelog of threedigrid-builder 1.20.2 (unreleased) ------------------- -- Nothing changed yet. +- Set nodata value for neighbour nodes to 0 in quarters admin. 1.20.1 (2024-10-23) diff --git a/libthreedigrid/cells.f90 b/libthreedigrid/cells.f90 index a9c6ec29..2d1930a8 100644 --- a/libthreedigrid/cells.f90 +++ b/libthreedigrid/cells.f90 @@ -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 diff --git a/threedigrid_builder/grid/quadtree.py b/threedigrid_builder/grid/quadtree.py index 64123cbf..4999c828 100644 --- a/threedigrid_builder/grid/quadtree.py +++ b/threedigrid_builder/grid/quadtree.py @@ -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, diff --git a/threedigrid_builder/interface/gridadmin.py b/threedigrid_builder/interface/gridadmin.py index 0acdb507..be695a0c 100644 --- a/threedigrid_builder/interface/gridadmin.py +++ b/threedigrid_builder/interface/gridadmin.py @@ -581,7 +581,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) diff --git a/threedigrid_builder/tests/test_quadtree.py b/threedigrid_builder/tests/test_quadtree.py index 8e6787a6..39dd95a1 100644 --- a/threedigrid_builder/tests/test_quadtree.py +++ b/threedigrid_builder/tests/test_quadtree.py @@ -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], @@ -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], @@ -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], @@ -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], @@ -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)