Skip to content

Preserve bilinear coordinates for horizontal corner edges - #764

Open
antonsoo wants to merge 1 commit into
pytroll:mainfrom
antonsoo:fix/bilinear-horizontal-coordinate
Open

antonsoo wants to merge 1 commit into
pytroll:mainfrom
antonsoo:fix/bilinear-horizontal-coordinate

Conversation

@antonsoo

Copy link
Copy Markdown

The general bilinear calculation recovers s from the y coordinates after solving t. Horizontal corner edges make the y equation singular. With projection roundoff, the denominator can instead be tiny and return an apparently valid but incorrect weight.

Recover s from x coordinates, using the separation between the selected left and right corners. This fixes a 13x13 affine field resampled to a 7x9 geographic target: 12 of 63 output cells currently differ from the directly evaluated field, by up to 1.73. The regression checks the complete output.

Independent replays also check original packed NCEP temperatures through NumPy and Dask/xarray against a SciPy solution of both coordinate equations, plus an irregular SSMIS swath in LAEA projection. All checked values agree after the change on current dependencies and NumPy 1.26. The two existing helper expectations change from NaN to 0.5 because their valid solution is now obtained before the fallback.

  • Regression added and verified to fail numerically on the unmodified baseline.
  • Full suite: 1,251 passed, 60 skipped; 339 documentation examples pass.
  • Ruff and isort pass. Mypy diagnostics are identical to baseline in unchanged imported modules.
  • Independent native references and composition with the separate dtype/storage fixes checked.

@antonsoo

Copy link
Copy Markdown
Author

The Read the Docs failure is from four hashlib._Hash annotation warnings in geometry.py and future/resamplers/resampler.py. The same four warnings reproduce on unchanged main 0291a40, and those files and the docs configuration are unchanged by this PR. Existing #760 addresses these annotations.

Locally, all 339 doctest examples pass on both main and the fixed code. Read the Docs treats the warnings as errors, so its build is still failing; the upstream test workflows await approval.

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