Skip to content

[in3Utils] (geotrans) fill bilinear remesh edge NaNs with nearest fallback#1266

Merged
fso42 merged 2 commits intomasterfrom
fixRemeshNan
Apr 28, 2026
Merged

[in3Utils] (geotrans) fill bilinear remesh edge NaNs with nearest fallback#1266
fso42 merged 2 commits intomasterfrom
fixRemeshNan

Conversation

@fso42
Copy link
Copy Markdown
Contributor

@fso42 fso42 commented Apr 28, 2026

Problem

Fixes a remeshing bug where release rasters could contain artificial NaNs at grid borders after interpolation onto DEM resolution/extent. These NaNs triggered:

AssertionError: ... nan values found inside DEM extent - this is not allowed

in deriveParameterSet.checkExtentAndCellSize().

Root cause:

geoTrans.resizeData() used bilinear projection only. Bilinear interpolation excludes cells without a full neighbors at boundaries, leaving edge NaNs in remeshed outputs.

What was implemented:

  • Enforce strict NaN/no-data handling for non-DEM rasters in com1DFA: input rasters (e.g. release/entrainment/resistance/friction) are now validated before remeshing and an error is raised if any NaNs are present. DEM is exempt (NaNs allowed).
  • Make remeshing more robust: geoTrans.resizeData() now fills NaNs produced by bilinear interpolation using a nearest-neighbor fallback.

@fso42 fso42 requested a review from awirb April 28, 2026 07:31
@fso42 fso42 self-assigned this Apr 28, 2026
@fso42 fso42 added the bugfix label Apr 28, 2026
@fso42 fso42 changed the title fix(geoTrans): fill bilinear remesh edge NaNs with nearest fallback [in3Utils] (geotrans) fill bilinear remesh edge NaNs with nearest fallback Apr 28, 2026
- Added additional test cases for resizing and interpolating raster data in `test_geoTrans`.
- Adjusted assertions in `test_deriveParameterSet` to reflect new logic for handling `nan` values.
- Enhanced bilinear interpolation in `geoTrans` to fill `nan` values using nearest-neighbor interpolation.
@qltysh
Copy link
Copy Markdown
Contributor

qltysh Bot commented Apr 28, 2026

Qlty


Coverage Impact

This PR will not change total coverage.

Modified Components (1)

RatingComponent% Diff
Coverage rating: C Coverage rating: C
com1DFA87.5%

Modified Files with Diff Coverage (2)

RatingFile% DiffUncovered Line #s
Coverage rating: B Coverage rating: B
avaframe/com1DFA/deriveParameterSet.py87.5%898
Coverage rating: A Coverage rating: A
avaframe/in3Utils/geoTrans.py100.0%
Total93.3%
🤖 Increase coverage with AI coding...
In the `fixRemeshNan` branch, add test coverage for this new code:

- `avaframe/com1DFA/deriveParameterSet.py` -- Line 898

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

…orce NaN validation

- Updated documentation to explicitly state that no-data values are not allowed in configuration descriptions for shapefiles and raster files.
- Added tests to validate that NaN values are not permitted in non-DEM input rasters, with appropriate error handling.
- Adjusted `deriveParameterSet` logic to raise errors for NaN values in non-DEM input files while allowing them for DEM files.
@fso42 fso42 added this to the Version 2.0 milestone Apr 28, 2026
@fso42 fso42 merged commit c330cb9 into master Apr 28, 2026
4 checks passed
@fso42 fso42 deleted the fixRemeshNan branch April 28, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants