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

Add rotated latitude longitude projection to mapping.py #3123

Merged
merged 5 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/metpy/plots/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,14 @@ def make_polar_stereo(attrs_dict, globe):
kwargs = CFProjection.build_projection_kwargs(attrs_dict, attr_mapping)

return ccrs.Stereographic(globe=globe, **kwargs)


@CFProjection.register('rotated_latitude_longitude')
def make_rotated_latlon(attrs_dict, globe):
"""Handle rotated latitude/longitude projection."""
attr_mapping = [('pole_longitude', 'grid_north_pole_longitude'),
('pole_latitude', 'grid_north_pole_latitude'),
('central_rotated_longitude', 'north_pole_grid_longitude')]
kwargs = CFProjection.build_projection_kwargs(attrs_dict, attr_mapping)

return ccrs.RotatedPole(globe=globe, **kwargs)
16 changes: 16 additions & 0 deletions tests/plots/test_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,22 @@ def test_polar_stereographic_std_parallel():
assert crs.proj4_params['lat_ts'] == 60


def test_rotated_latitude_longitude():
"""Test handling a rotated latitude longitude projection."""
attrs = {
'grid_mapping_name': 'rotated_latitude_longitude',
'grid_north_pole_latitude': 36,
'grid_north_pole_longitude': 65,
'north_pole_grid_longitude': 0.0,
}
crs = CFProjection(attrs).to_cartopy()

assert isinstance(crs, ccrs.RotatedPole)
assert crs.proj4_params['o_lon_p'] == 0
assert crs.proj4_params['o_lat_p'] == 36
assert crs.proj4_params['lon_0'] == 180 + 65


def test_lat_lon():
"""Test handling basic lat/lon projection."""
attrs = {'grid_mapping_name': 'latitude_longitude'}
Expand Down