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
12 changes: 11 additions & 1 deletion src/metpy/plots/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,28 @@ def _map_arg_names(source, mapping):
return {cartopy_name: source[cf_name] for cartopy_name, cf_name in mapping
if cf_name in source}

## issue 1844 deals with this block - changes made by lbunting
@property
def cartopy_globe(self):
"""Initialize a `cartopy.crs.Globe` from the metadata."""
if 'earth_radius' in self._attrs:
# kwargs['ellipse'] = 'sphere'
# kwargs['semimajor_axis']=self._attrs['earth_radius']
# kwargs['semiminor_axis']=self._attrs['earth_radius']

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)

#kwargs.update(self._map_arg_names(self._attrs, attr_mapping))

if kwargs.get('inverse_flattening', None) == 0:
kwargs['ellipse'] = 'sphere'
kwargs.pop('inverse_flattening', None)
# 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
kwargs['ellipse'] = None if kwargs else 'sphere'
Copy link
Member

Choose a reason for hiding this comment

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

Ok, this is the source of the current test failure. You should move this line (and it's comment) up to line 63 (in the else) to have it say:

            # 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'

Expand Down