Deltares / Deltares/MeshKernelPy
mesh2d_delete doesn't delete mesh2d_node_z
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 27
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
When clipping a netcdf over a geometrylist the mesh2d_node_x, mesh2d_node_y are clipped, but mesh2d_node_z isn't
To Reproduce
Steps to reproduce the behavior:
- Download the mesh and reproduce-script we've created: https://we.tl/t-XHuUUF83RC
- Run the clip_mesh.py executing the code below (we use hydrolib-core to read the nc-file):
from pathlib import Path
import numpy as np
from meshkernel import GeometryList
import meshkernel as mk
from hydrolib.core.dflowfm.net.models import Network
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}")
- Note the size of
mesh_node2d_x,mesh_node2d_yandmesh_node2d_zbefore and aftermesh2d_delete:
Expected behavior
A length of mesh2d_node_z of 226161 as are mesh2d_node_x and mesh2d_node_y.
Screenshots
We do think deletion of x and y is as expected. Running network.plot() after executing the script above gives a plausible result:
Version info (please complete the following information):
- OS: Windows
- Versions:
- Python: 3.8.19
- hydrolib.core: 0.7.0
- meshkernel: 4.1.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reproduction in clip_mesh.py with the supplied NetCDF mesh and inspect mesh2d_delete's handling of mesh2d_node_x, mesh2d_node_y, and mesh2d_node_z. Done means node_z has the same length as node_x and node_y after clipping, with a regression test covering the reported deletion option.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100