Skip to content

Commit

Permalink
fix: Ensure mesh_2d_edge_x and mesh_2d_edge_y are written to nc file. (
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielTollenaar authored Jul 9, 2024
1 parent 2e44a30 commit e8b5262
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions hydrolib/core/dflowfm/net/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,34 @@ def _set_2dmesh(self, ncfile: nc.Dataset, mesh2d: Mesh2d) -> None: # type: igno
(nc_mesh2d.edge_dimension, "Two"),
fill_value=self._fill_value_config.int32_fill_value,
)

# add edge x and y
mesh2d_ex = ncfile.createVariable(
"mesh2d_edge_x",
np.float64,
nc_mesh2d.edge_dimension,
)

mesh2d_ey = ncfile.createVariable(
"mesh2d_edge_y",
np.float64,
nc_mesh2d.edge_dimension,
)

for var, dim in zip([mesh2d_ex, mesh2d_ey], list("xy")):
setattr(var, "units", "m")
setattr(var, "mesh", "mesh2d")
setattr(var, "location", "edge")
setattr(
var,
"standard_name",
f"projection_{dim}_coordinate",
)
setattr(var, "long_name", f"{dim}-coordinate of the mesh edge")

mesh2d_ex[:] = mesh2d.mesh2d_edge_x
mesh2d_ey[:] = mesh2d.mesh2d_edge_y

mesh2d_en.cf_role = "edge_node_connectivity"
mesh2d_en.long_name = "maps every edge to the two nodes that it connects"
mesh2d_en.start_index = 1
Expand Down

0 comments on commit e8b5262

Please sign in to comment.