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

mesh2d_delete doesn't delete mesh2d_node_z #326

Open
DanielTollenaar opened this issue Apr 23, 2024 · 0 comments
Open

mesh2d_delete doesn't delete mesh2d_node_z #326

DanielTollenaar opened this issue Apr 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@DanielTollenaar
Copy link

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:

  1. Download the mesh and reproduce-script we've created: https://we.tl/t-XHuUUF83RC
  2. 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}")
  1. Note the size of mesh_node2d_x, mesh_node2d_y and mesh_node2d_z before and after mesh2d_delete:
    image

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:
image

Version info (please complete the following information):

  • OS: Windows
  • Versions:
    • Python: 3.8.19
    • hydrolib.core: 0.7.0
    • meshkernel: 4.1.0
@DanielTollenaar DanielTollenaar added the bug Something isn't working label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant