Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mesh_2d_edge_x and mesh_2d_edge_y to writer #645

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading