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

Interpret inverse_flattening = 0 as spherical datum in mapping.py #1920

Merged
merged 8 commits into from
Jul 1, 2021
11 changes: 9 additions & 2 deletions src/metpy/plots/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,23 @@ def cartopy_globe(self):
if 'earth_radius' in self._attrs:
kwargs = {'ellipse': 'sphere', 'semimajor_axis': self._attrs['earth_radius'],
'semiminor_axis': self._attrs['earth_radius']}

Copy link
Member

Choose a reason for hiding this comment

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

Looks like a stray change crept in here.

else:
attr_mapping = [('semimajor_axis', 'semi_major_axis'),
('semiminor_axis', 'semi_minor_axis'),
('inverse_flattening', 'inverse_flattening')]
kwargs = self._map_arg_names(self._attrs, attr_mapping)

# WGS84 with semi_major==semi_minor is NOT the same as spherical Earth
# Also need to handle the case where we're not given any spheroid
# Override CartoPy's default ellipse setting depending on whether
# we have any metadata to map about the spheroid.
kwargs['ellipse'] = None if kwargs else 'sphere'

# interpret the 0 inverse_flattening as a spherical datum
# and don't pass the value on.
if kwargs.get('inverse_flattening', None) == 0:
kwargs['ellipse'] = 'sphere'
kwargs.pop('inverse_flattening', None)

return ccrs.Globe(**kwargs)

@property
Expand Down