Skip to content

Commit

Permalink
Merge pull request #92 from noaa-ocs-modeling/bugfix/subset
Browse files Browse the repository at this point in the history
Improve subsetting by removing out-of-buffer zone elements
  • Loading branch information
SorooshMani-NOAA authored Jun 16, 2023
2 parents f15f5f3 + 4aa9b50 commit 6d47248
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ python ./setup.py develop # Run this if you are a developer.
```

#### Requirements
* 3.7 <= Python < 3.10
* 3.9 <= Python
* CMake
* C/C++ compilers

Expand Down
15 changes: 15 additions & 0 deletions ocsmesh/cli/subset_n_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,21 @@ def _generate_mesh_for_buffer_region(
jig_mesh.value = np.zeros((jig_mesh.vert2.shape[0], 1))
self._transform_mesh(jig_mesh, crs)

# NOTE: Remove out of domain elements (some corner cases!)
elems = jig_mesh.tria3['index']
coord = jig_mesh.vert2['coord']

gdf_elems = gpd.GeoDataFrame(
geometry=[Polygon(tri) for tri in coord[elems]],
crs=jig_mesh.crs
)
idx = gdf_elems.representative_point().sindex.query(
seam.get_multipolygon(), predicate='intersects'
)
flag = np.zeros(len(gdf_elems), dtype=bool)
flag[idx] = True
jig_mesh.tria3 = jig_mesh.tria3[flag]

return jig_mesh


Expand Down

0 comments on commit 6d47248

Please sign in to comment.