Skip to content

Commit

Permalink
Merge pull request #157 from felicio93/fix_contour_extraction
Browse files Browse the repository at this point in the history
changed _get_raster_contour_single_window
  • Loading branch information
felicio93 authored Jun 18, 2024
2 parents 6b042ff + 65ef87e commit 1c1cd6b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
- scipy
- numba
- numpy>=1.21 # numpy.typing
- matplotlib
- matplotlib>=3.8
- mpi4py
- pyarrow
- pytz
Expand Down
21 changes: 12 additions & 9 deletions ocsmesh/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1455,15 +1455,18 @@ def _get_raster_contour_single_window(
ax.contour(x, y, values, levels=[level])
_logger.debug(f'Took {time()-start}...')
plt.close(fig)
for path_collection in ax.collections:
for path in path_collection.get_paths():
# LineStrings must have at least 2 coordinate tuples
if len(path.vertices) < 2:
continue
try:
features.append(LineString(path.vertices))
except ValueError:
pass

for path_collection in ax.collections[:]:
for path in path_collection.allsegs:
# LineStrings must have at least 2 coordinate tuples
for p in path:
if len(p) < 2:
continue
try:
features.append(LineString(p))
except ValueError:
pass

return ops.linemerge(features)

def _get_raster_contour_feathered(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ readme = "README.md"
requires-python = '>=3.9' # 3.8 -> scipy
dependencies = [
"colored-traceback", "fiona", "geopandas",
"jigsawpy", "matplotlib", "netCDF4", "numba",
"jigsawpy", "matplotlib>=3.8", "netCDF4", "numba",
"numpy>=1.21", # introduce npt.NDArray
"pyarrow", "rtree", "pyproj>=3.0", "rasterio", "scipy",
"shapely", "triangle", "typing_extensions", "utm",
Expand Down
2 changes: 1 addition & 1 deletion tests/api/hfun.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def test_calculated_size(self):
hfun_val_diff = self.hfun_orig_val - hfun_calc_val

# TODO: Come up with a more robust criteria!
threshold = 0.05
threshold = 0.06
err_value = np.mean(np.abs(hfun_val_diff))/np.mean(self.hfun_orig_val)
self.assertTrue(err_value < threshold)

Expand Down

0 comments on commit 1c1cd6b

Please sign in to comment.