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

Added winkel tripel projection class #2442

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AgentOxygen
Copy link

Rationale

Winkel-Tripel is a popular projection that would be used by multiple users (my group at UT and folks at NCAR). It is also the primary projection for the National Geographic Society.

Implications

I have created a new CRS projection object without modifying any code by utilizing existing class objects and the pyproj backend.

Checklist

  1. The new class object can be utilized in similar fashion to the other projection classes.
  2. I am unsure how to integrate this into the existing test suite, however I imagine it would undergo the same testing as other projections. I am happy to assist with that integration if I could be pointed in the right direction.

This is my first pull request! I am open to input how on to properly contribute.

@CLAassistant
Copy link

CLAassistant commented Sep 25, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@greglucas greglucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this looks like a great start.

Regarding the tests: Probably add a test similar to one of the other crs's here containing some transform points and initialization expectations: https://github.com/SciTools/cartopy/tree/main/lib/cartopy/tests/crs

Add the projection to the parameterization list here and add a comparison image.

@pytest.mark.parametrize('proj', [
ccrs.Aitoff,
ccrs.EckertI,
ccrs.EckertII,
ccrs.EckertIII,
ccrs.EckertIV,
ccrs.EckertV,
ccrs.EckertVI,
ccrs.EqualEarth,
ccrs.Gnomonic,
ccrs.Hammer,
pytest.param((ccrs.InterruptedGoodeHomolosine, dict(emphasis='land')),
id='InterruptedGoodeHomolosine'),
ccrs.LambertCylindrical,
pytest.param((ccrs.Mercator, dict(min_latitude=-85, max_latitude=85)),
id='Mercator'),
ccrs.Miller,
ccrs.Mollweide,
ccrs.NorthPolarStereo,
ccrs.Orthographic,
pytest.param((ccrs.OSGB, dict(approx=True)), id='OSGB'),
ccrs.PlateCarree,
ccrs.Robinson,
pytest.param((ccrs.RotatedPole,
dict(pole_latitude=45, pole_longitude=180)),
id='RotatedPole'),
ccrs.Stereographic,
ccrs.SouthPolarStereo,
pytest.param((ccrs.TransverseMercator, dict(approx=True)),
id='TransverseMercator'),
pytest.param(
(ccrs.ObliqueMercator, dict(azimuth=0.)), id='ObliqueMercator_default'
),
pytest.param(
(ccrs.ObliqueMercator, dict(azimuth=90., central_latitude=-22)),
id='ObliqueMercator_rotated',
),
])
@pytest.mark.mpl_image_compare(style='mpl20')
def test_global_map(proj):

A PR you can look at for updating one of the other projections is #1561

lib/cartopy/crs.py Outdated Show resolved Hide resolved
globe = globe or Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS)
proj4_params = [('proj', 'wintri'),
('lon_0', central_longitude),
('lat_0', 0.0)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to pass in the lat_0 parameter even if 0 is the default, and does that even work, it looks like it is lat_1 in the documentation: https://proj.org/en/9.4/operations/projections/wintri.html

@@ -2493,6 +2493,33 @@ def transform_points(self, src_crs, x, y, z=None, trap=False):
return result


class WinkelTripel(_WarpedRectangularProjection):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do any of the nan handling here like we are doing in the Robinson projection? i.e. should this subclass Robinson instead if it is similar to that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to generate maps containing maps with no problem. Are there other tests for nans that I would need to do?

Co-authored-by: Greg Lucas <greg.m.lucas@gmail.com>
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.

3 participants