Skip to content

FIX: correct transform_vectors for angular coordinates - #2725

Open
greglucas wants to merge 1 commit into
SciTools:mainfrom
greglucas:fix/vector-transform-rewrite
Open

greglucas wants to merge 1 commit into
SciTools:mainfrom
greglucas:fix/vector-transform-rewrite

Conversation

@greglucas

Copy link
Copy Markdown
Contributor

Rationale

Uses central differencing, falling back to single-sided forward or backward if necessary, and the local Jacobian via pyproj.get_factors() as suggested in the notes of #1926. This removes the need for special cutouts for angular projections and different branches and generalizes the computations for any projection <-> projection pair.

closes #1179

Implications

A few more transforms due to central differencing, but performance was not significantly worse in my local experimentation.

Alternative to #2718

@domfrbassett

Copy link
Copy Markdown

Hi @greglucas, I checked this against the #2279 linearity case locally, and the transform is linear in the input components as expected. The #1179 near-pole PlateCarree case also gives the expected direction.

One thing I noticed while testing: when self == src_proj, the new Jacobian path still runs even though the vector transform should be the identity. Adding an early return for that case preserves the existing result while avoiding unnecessary work, and it also means the test_barbs_1d.png baseline doesn't need to change.

I think this could just be:

if self == src_proj:
    return (np.array(u, dtype=np.float64, copy=True),
            np.array(v, dtype=np.float64, copy=True))

…ystems

Replaces the single-direction finite-difference approximation with a
central difference (fallback to single-direction) and Jacobian rotation
based on PROJ's get_factors to get the local distortion.
@greglucas
greglucas force-pushed the fix/vector-transform-rewrite branch from 26e81de to aa86b4a Compare September 14, 2026 14:32
@greglucas

Copy link
Copy Markdown
Contributor Author

Good idea @domfrbassett! Just added that cut-out for identical CRS'

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quiver with all projections: bad direction of arrows

2 participants