Skip to content

Commit

Permalink
updated with suggestions of @Kreef
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Jul 5, 2024
1 parent 08b8294 commit 48c06f5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
12 changes: 3 additions & 9 deletions hydrolib/core/dflowfm/net/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,9 @@ def _process(self) -> None:
self.link1d2d_contact_type = np.append(
self.link1d2d_contact_type, np.full(contacts.mesh1d_indices.size, 3)
)
self.link1d2d_id = np.append(
self.link1d2d_id,
np.array([f"{n1d:d}_{f2d:d}" for n1d, f2d in self.link1d2d]),
)
self.link1d2d_long_name = np.append(
self.link1d2d_long_name,
np.array([f"{n1d:d}_{f2d:d}" for n1d, f2d in self.link1d2d]),
)

self.link1d2d_id = np.array([f"{n1d:d}_{f2d:d}" for n1d, f2d in self.link1d2d])
self.link1d2d_long_name = np.array([f"{n1d:d}_{f2d:d}" for n1d, f2d in self.link1d2d])

def _link_from_1d_to_2d(
self, node_mask: np.ndarray, polygon: mk.GeometryList = None
):
Expand Down
25 changes: 25 additions & 0 deletions hydrolib/core/dflowfm/net/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,31 @@ def _set_1dmesh(self, ncfile: nc.Dataset, mesh1d: Mesh1d) -> None: # type: igno
mesh1d_node_offset.units = "m"
mesh1d_node_offset[:] = mesh1d.mesh1d_node_branch_offset


mesh_edge_x = ncfile.createVariable("mesh1d_edge_x", np.float64, "mesh1d_nEdges")
mesh_edge_x.standard_name = "projection_x_coordinate"
mesh_edge_x.long_name = "Characteristic x-coordinate of the mesh edge (e.g. midpoint)"
mesh_edge_x.units = "m"
mesh_edge_x[:] = mesh1d.mesh1d_edge_x

mesh_edge_y = ncfile.createVariable("mesh1d_edge_y", np.float64, "mesh1d_nEdges")
mesh_edge_y.standard_name = "projection_y_coordinate"
mesh_edge_y.long_name = "Characteristic y-coordinate of the mesh edge (e.g. midpoint)"
mesh_edge_y.units = "m"
mesh_edge_y[:] = mesh1d.mesh1d_edge_y

mesh_node_x = ncfile.createVariable("mesh1d_node_x", np.float64, "mesh1d_nNodes")
mesh_node_x.standard_name = "projection_x_coordinate"
mesh_node_x.long_name = "x coordinates of mesh nodes"
mesh_node_x.units = "m"
mesh_node_x[:] = mesh1d.mesh1d_node_x

mesh_node_y = ncfile.createVariable("mesh1d_node_y", np.float64, "mesh1d_nNodes")
mesh_node_y.standard_name = "projection_y_coordinate"
mesh_node_y.long_name = "y coordinates of mesh nodes"
mesh_node_y.units = "m"
mesh_node_y[:] = mesh1d.mesh1d_node_y

def _set_2dmesh(self, ncfile: nc.Dataset, mesh2d: Mesh2d) -> None: # type: ignore[import]

nc_mesh2d = ncfile.createVariable("mesh2d", "i4", ())
Expand Down

0 comments on commit 48c06f5

Please sign in to comment.