Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize and (slightly) speedup boundary and limit calculations #1167

Merged
merged 5 commits into from
Nov 6, 2018

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Nov 3, 2018

Rationale

Projections are currently inconsistent in how they calculate the boundary and projection limits. Some projections calculate the boundary a point at a time and this is slow (though only on the order of tenths of milliseconds). Private variables are named differently, etc.

Try to normalize the calculations by:

  • Using transform_points instead of transform_point.
  • Calculating the boundary in the correct orientation from the beginning.
  • Using NumPy to calculate limits from boundary array instead of routing through Shapely.
  • Use _ellipse_boundary for Stereographic even for circular projections. It's twice as fast and higher resolution by default, too.
  • Always produce LinearRing boundaries instead of sometimes LineStrings.

Implications

The Stereographic boundary is slightly higher resolution in the default case, and all boundaries are rings; this causes a few minor differences in antialiased lines in the test figures. Times for creating the affected projections are approximately 100 microseconds less on my machine (a small benefit, but it's about 30-45% less than the original time.)

I'm also trying to write a 'How to add a projection' doc, so the more consistency the better.

* Calculate the boundary in the correct orientation from the beginning.
* Use NumPy to calculate limits from boundary array instead of routing
  through Shapely.
* Use _ellipse_boundary for Stereographic even for circular projections.
  It's twice as fast and higher resolution by default, too.

These are rather small (10-50 microseconds saving each), but they
all add up to the affected projections initializing in about 60-70% of
the original time.
* Calculate the boundary in the correct orientation from the beginning.
* Use NumPy to calculate limits from boundary array instead of routing
  through Shapely.

These make for approximately 100 microseconds per projection improvement
(40-50% of time for most of them, except IGH, which is slower overall).
Use NumPy to determine limits, and always create LinearRings, not
LineStrings.
@QuLogic
Copy link
Member Author

QuLogic commented Nov 4, 2018

I made a small tweak of reverting the change to the multiple_projections5.png test image and instead increased the tolerance, because I want to add some new projections which will mean regenerating the image again.

@QuLogic QuLogic added this to the 0.17 milestone Nov 4, 2018
@dopplershift dopplershift merged commit 493aeae into SciTools:master Nov 6, 2018
@QuLogic QuLogic deleted the boundary-norm branch November 6, 2018 21:31
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.

None yet

2 participants