Fix vector transform linearity for angular coordinate systems - #2718
Open
domfrbassett wants to merge 2 commits into
Open
Fix vector transform linearity for angular coordinate systems#2718domfrbassett wants to merge 2 commits into
domfrbassett wants to merge 2 commits into
Conversation
Member
|
@greglucas Does this relate to #1920? |
Contributor
|
Thanks for reminding me about those PRs @QuLogic, they had dropped off my radar. This PR is an improvement over #1920, but I still think it can be generalized even more and doesn't need the fallback/cutout. I've updated the other PRs I had addressing that as an alternative to this approach if anyone wants to take a look at those generalizations in #2725. |
Author
|
@greglucas I agree #2725 is the more general version of this fix. I’ll take a look there and see whether I can help with the remaining test/benchmark coverage, especially for the #2279 linearity case. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
CRS.transform_vectors()estimates output directions by perturbing each point in the direction of the full input vector. This can make the result non-linear in the input components. For example, in aRotatedPole -> PlateCarreetransform, transforming(1, 0) + (0, 1)does not necessarily match transforming(1, 1).This changes angular/geodetic-like source or target CRS cases to estimate the transformed local eastward and northward basis directions separately, then apply the resulting local rotation to the input vector components. The existing approximation is retained as a fallback for projected-to-projected and singular cases.
Implications
This improves vector directions for rotated latitude/longitude and near-pole cases used by quiver, barbs, and streamplot. The affected image baselines were updated.
The new path is slower because it uses two basis perturbations rather than one vector-direction perturbation. In local benchmarks it was about 1.5–1.8x slower for affected cases, but still sub-millisecond for typical quiver-sized fields.
Validation
65 passed.ruff checkon changed Python files.