Open DanielTollenaar opened 5 months ago
It is a bit tricky where this issue should land. It is indeed about meshkernel(py), but the issue lays in the fact that meshkernel does not support z-values at the moment. Hydrolib-core does have z-values, but these are the only properties that have to be carried around next to the meshkernel instance. They cannot be clipped with the meshkernel algorithm at the moment. I think the best way to fix this properly is to add z-values in meshkernel(py), but I am not sure if that is within the scope. Alternatively, we could do some interpolation of z-values in hydrolib core, since the new nodes/faces will be on the exact same locations as the old ones, this will probably result in identical values, but it would also require refactorings in other functions which would be more work than adding it in meshkernel. I will discuss this with @lucacarniato
Describe the bug When clipping a netcdf over a geometrylist the
mesh2d_node_x
,mesh2d_node_y
are clipped, butmesh2d_node_z
isn'tTo Reproduce Steps to reproduce the behavior:
nc_path = Path(file).parent / "ovd-j98_6-v1a_net.nc"
read mesh using hydrolib-core
network = Network.from_file(Path(nc_path)) mesh2d = network._mesh2d
show node x/y/z
print("before") print(f"x: {mesh2d.mesh2d_node_x.shape}") print(f"y: {mesh2d.mesh2d_node_y.shape}") print(f"z: {mesh2d.mesh2d_node_z.shape}")
define gometrylist
x_coordinates = np.array( [219032.36821211, 219415.05146748, 236135.84080332, 257422.06085974, 257935.46607711, 221483.69564399, 219032.36821211], dtype=np.double)
y_coordinates = np.array( [502669.83347292, 504635.40577414, 520870.43426807, 522115.73282761, 511205.87195854, 495803.7154375, 502669.83347292], dtype=np.double)
geometrylist = GeometryList(x_coordinates, y_coordinates)
clip mesh
mesh2d.meshkernel.mesh2d_delete( geometry_list=geometrylist, delete_option=mk.DeleteMeshOption.INSIDE_NOT_INTERSECTED, invert_deletion=True, )
show_result
print("after") print(f"x: {mesh2d.mesh2d_node_x.shape}") print(f"y: {mesh2d.mesh2d_node_y.shape}") print(f"z: {mesh2d.mesh2d_node_z.shape}")