pyfvcom2.bathy_smoother module
- class pyfvcom2.bathy_smoother.BathymetrySmoother[source]
Bases:
ABCAbstract base class for FVCOM bathymetry smoothers.
All concrete smoothers must implement
smooth(). The sharedr_factor()method computes the Haney r-factor distribution for the current grid bathymetry.Note
Only cold-start workflows are supported. Smoothing the bathymetry after a hot-start restart file has been generated would produce an internally inconsistent restart because the stored 3-D fields are referenced to the original sigma-coordinate depths. Apply smoothing before generating any forcing or restart files.
- r_factor(grid: Grid) np.ndarray[source]
Return the Haney r-factor for every inter-element edge.
Edges adjacent to at least one intertidal element (element-mean depth ≤ 0) are returned as
numpy.nanand excluded from the assessment. Usenumpy.nanmax()/numpy.nanmean()to compute statistics, and note thatr > thresholdcomparisons naturally treat NaN asFalse.- Args:
grid:
Gridinstance to evaluate.- Returns:
Array of r-factor values, one per shared edge. Values near zero indicate a smooth transition; values near 1 indicate a near-step change. Intertidal edges are
numpy.nan. A commonly used threshold is \(r < 0.2\).
- class pyfvcom2.bathy_smoother.GlobalBathymetrySmoother(passes: int = 1)[source]
Bases:
BathymetrySmootherGlobal ping-pong bathymetry smoother.
Applies one or more passes of a two-step linear interpolation:
Interpolate node depths → element-centroid depths (
LinearNDInterpolatorover the node positions).Interpolate the smoothed element depths → node depths (
LinearNDInterpolatorover the centroid positions).
Each pass is mathematically equivalent to one iteration of graph-Laplacian smoothing, reducing sharp depth gradients uniformly across the entire mesh. Boundary nodes that fall outside the convex hull of the centroids (step 2) retain their original depth.
- Args:
- passes: Number of complete node→centroid→node round-trips to apply.
More passes produce stronger smoothing but progressively erode bathymetric features. Defaults to
1.