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

Xarray: Add warning if lat/lon is assumed for projection #1065

Merged
merged 1 commit into from Jun 19, 2019
Merged
Changes from all commits
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
2 changes: 2 additions & 0 deletions metpy/xarray.py
Expand Up @@ -370,6 +370,8 @@ def parse_cf(self, varname=None, coordinates=None):
# If we found them, create a lat/lon projection as the crs coord
if has_lat and has_lon:
var.coords['crs'] = CFProjection({'grid_mapping_name': 'latitude_longitude'})
log.warning('Found lat/lon values, assuming latitude_longitude '
Copy link
Member

Choose a reason for hiding this comment

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

Should we mention that we haven't already found a projection, like "No projection found but found lat/lon values"?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That is already given with the warning that is issued when it doesn't find any valid projection details in the file, just above this part in the code.

try:
    proj_var = self._dataset.variables[proj_name]
    var = self._dataset.variables[proj_name]
except KeyError:
    log.warning('Could not find variable corresponding to the value of '
                'grid_mapping: {}'.format(proj_name))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So both warnings would show up if there isn't a CRS but lat/lon values exist - which I think would be the ideal message to users here. @dopplershift do you want any changes to this still?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, nope, we're good.

'for projection grid_mapping variable')

# Assign coordinates if the coordinates argument is given
if coordinates is not None:
Expand Down