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 albers_conical_equal_area projection #1344

Merged
merged 3 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/metpy/plots/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
class CFProjection(object):
"""Handle parsing CF projection metadata."""

# mapping from Cartopy to CF vocabulary
_default_attr_mapping = [('false_easting', 'false_easting'),
('false_northing', 'false_northing'),
('central_latitude', 'latitude_of_projection_origin'),
Expand Down Expand Up @@ -123,6 +124,18 @@ def make_lcc(attrs_dict, globe):
kwargs['standard_parallels'] = [kwargs['standard_parallels']]
return ccrs.LambertConformal(globe=globe, **kwargs)

@CFProjection.register('albers_conical_equal_area')
rsignell-usgs marked this conversation as resolved.
Show resolved Hide resolved
def make_aea(attrs_dict, globe):
"""Handle Albers Equal Area."""
attr_mapping = [('central_longitude', 'longitude_of_central_meridian'),
('standard_parallels', 'standard_parallel')]
kwargs = CFProjection.build_projection_kwargs(attrs_dict, attr_mapping)
if 'standard_parallels' in kwargs:
try:
len(kwargs['standard_parallels'])
except TypeError:
kwargs['standard_parallels'] = [kwargs['standard_parallels']]
return ccrs.AlbersEqualArea(globe=globe, **kwargs)

@CFProjection.register('latitude_longitude')
def make_latlon(attrs_dict, globe):
Expand Down
27 changes: 27 additions & 0 deletions tests/plots/test_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,33 @@ def test_globe_spheroid():
assert globe_params['a'] == 6367000
assert globe_params['b'] == 6360000

def test_aea():
rsignell-usgs marked this conversation as resolved.
Show resolved Hide resolved
"""Test handling albers equal area projection."""
attrs = {'grid_mapping_name': 'albers_conical_equal_area', 'earth_radius': 6367000,
'standard_parallel': [20, 50]}
proj = CFProjection(attrs)

crs = proj.to_cartopy()
assert isinstance(crs, ccrs.AlbersEqualArea)
assert crs.proj4_params['lat_1'] == 20
assert crs.proj4_params['lat_2'] == 50
assert crs.globe.to_proj4_params()['ellps'] == 'sphere'


def test_aea_minimal():
"""Test handling albers equal area projection with minimal attributes."""
attrs = {'grid_mapping_name': 'albers_conical_equal_area'}
crs = CFProjection(attrs).to_cartopy()
assert isinstance(crs, ccrs.AlbersEqualArea)


def test_aea_single_std_parallel():
"""Test albers equal area with one standard parallel."""
attrs = {'grid_mapping_name': 'albers_conical_equal_area', 'standard_parallel': 25}
crs = CFProjection(attrs).to_cartopy()
assert isinstance(crs, ccrs.AlbersEqualArea)
assert crs.proj4_params['lat_1'] == 20
Copy link
Collaborator

Choose a reason for hiding this comment

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

This does not seem to match with the attrs that was set (attrs says 25, this says 20), which is causing test suite to now fail after the fixes I'm working on in #1325. @dopplershift Can I update it there to get tests passing?

Copy link
Member

Choose a reason for hiding this comment

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

sigh Yes. This is why we need CI working, because I suck at code review.



def test_lcc():
"""Test handling lambert conformal conic projection."""
Expand Down