Skip to content

Keep one-dimensional NumPy bilinear data in a single row - #763

Open
antonsoo wants to merge 1 commit into
pytroll:mainfrom
antonsoo:fix/numpy-bilinear-point-lists
Open

antonsoo wants to merge 1 commit into
pytroll:mainfrom
antonsoo:fix/numpy-bilinear-point-lists

Conversation

@antonsoo

Copy link
Copy Markdown

NumpyBilinearResampler raises IndexError for a one-dimensional single-channel swath. Its lookup stores point positions as columns in row zero, but input normalization creates an (N, 1) column. Expand the input along axis zero so both use (1, N), matching the XArray path.

import numpy as np
from pyresample import create_area_def
from pyresample.geometry import SwathDefinition
from pyresample.bilinear import NumpyBilinearResampler

lons, lats = np.meshgrid([0., 1.], [1., 0.])
source = SwathDefinition(lons=lons.ravel(), lats=lats.ravel())
target = create_area_def('target', 'EPSG:4326', shape=(2, 2),
                         area_extent=(0, 0, 1, 1))
data = np.array([[3., 4.], [1., 2.]]).ravel()
r = NumpyBilinearResampler(source, target, 200000,
                          neighbours=4, reduce_data=False)
result = r.resample(data)
np.testing.assert_allclose(result, [[2.75, 3.25], [1.75, 2.25]])

The regression covers nonconstant input and reuse of the lookup tables for another image. A 45,322-point subset of the bundled SSMIS 37V swath now resamples in eight geographic/LAEA, source-order and dtype configurations. Complete outputs match the identical measurements stored in two dimensions; all previously successful controls remain exact.

  • Tests added.
  • Full suite: 1,251 passed, 60 skipped; the shared documentation build passes 339 examples.
  • Ruff and isort pass; sibling-worktree mypy diagnostics match the unchanged baseline.
  • Independent affine-field reproduction and combined NumPy 1.26/current-dependency checks pass.

@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