Skip to content

Commit

Permalink
Merge branch 'main' into 598-add-support-for-python-311
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer authored Feb 9, 2024
2 parents ccd77ca + 3d5fa34 commit 86fa0f6
Show file tree
Hide file tree
Showing 4 changed files with 656 additions and 671 deletions.
18 changes: 8 additions & 10 deletions hydrolib/core/dflowfm/net/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import netCDF4 as nc
import numpy as np
from meshkernel import Contacts

from hydrolib.core.basemodel import BaseModel

Expand Down Expand Up @@ -123,16 +124,13 @@ def read_link1d2d(self, link1d2d: Link1d2d) -> None:
for meshkey, nckey in self._explorer.link1d2d_var_name_mapping.items():
setattr(link1d2d, meshkey, self._read_nc_attribute(ds[nckey]))

# TODO: setting contacts is not possible yet in meshkernel
# https://github.com/Deltares/MeshKernelPy/issues/107
# https://github.com/Deltares/HYDROLIB-core/issues/575
# so misalignment between link1d2d.link1d2d and
# empty _link1d2d.meshkernel.contacts_get().mesh2d_indices
# mesh1d_indices = link1d2d.link1d2d[:,0]
# mesh2d_indices = link1d2d.link1d2d[:,1]
# import meshkernel as mk
# contacts = mk.Contacts(mesh1d_indices=mesh1d_indices, mesh2d_indices=mesh2d_indices)
# link1d2d.meshkernel.contacts_set(contacts)
# set contacts on meshkernel, use .copy() to avoid strided arrays
mesh1d_indices = link1d2d.link1d2d[:, 0].copy()
mesh2d_indices = link1d2d.link1d2d[:, 1].copy()
contacts = Contacts(
mesh1d_indices=mesh1d_indices, mesh2d_indices=mesh2d_indices
)
link1d2d.meshkernel.contacts_set(contacts)

ds.close()

Expand Down
Loading

0 comments on commit 86fa0f6

Please sign in to comment.