Skip to content

WIP: Changes to speed up BoundaryForcing calls#616

Open
kthyng wants to merge 3 commits into
CWorthy-ocean:mainfrom
kthyng:boundary_forcing_changes
Open

WIP: Changes to speed up BoundaryForcing calls#616
kthyng wants to merge 3 commits into
CWorthy-ocean:mainfrom
kthyng:boundary_forcing_changes

Conversation

@kthyng

@kthyng kthyng commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This PR introduces a source-fill and regrid-engine API for BoundaryForcing, and deprecates the apply_2d_horizontal_fill boolean flag. Users can now explicitly control source-side filling (prefill: None (default), "2d_lateral_fill", "inverse_dist", "nearest_s2d", "nearest_neighbor") and choose the horizontal regrid engine independently (regrid_method: "auto" (default = xESMF if installed, else scipy), "xesmf", "scipy"). The default path is xESMF masked-bilinear interpolation with inverse-distance-weighted destination extrapolation when available, with a nearest-neighbor source pre-fill + scipy interp fallback on Windows/pip installs. When a prefill is set, the source is pre-filled so that nan's are not present (matching the legacy AMG precedent) before per-boundary regridding with plain bilinear, making extrap_method irrelevant. The deprecated apply_2d_horizontal_fill=True/False still works with a clear DeprecationWarning, mapping to the equivalent prefill values for backward compatibility.

Scope and testing: Changes are confined to BoundaryForcing only; InitialConditions, SurfaceForcing, Topography, and TidalForcing are intentionally unchanged and produce numerically equivalent output to pre-change. Shared validation helpers (validate_prefill, validate_extrap, resolve_regrid_engine) and an apply_prefill dispatcher on the dataset class enable forward-compatible rollout to other classes later. Comprehensive test coverage includes deprecation mapping, conflict detection, xESMF-availability gating, YAML round-trip compat (old and new formats), per-prefill-method NaN-free assertions, and cross-engine tolerances. All boundary/fill/prefill tests pass; 135 untouched-class tests pass. The physics boundary forcing regression fixture reflects the new xESMF default; BGC fixtures are pinned to regrid_method="scipy" for byte-reproducibility with pre-v4 outputs.

Kristen Thyng added 2 commits June 9, 2026 16:32
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant