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 doesn't like MET output files #1246

Closed
blaylockbk opened this issue Jan 30, 2020 · 1 comment
Closed

xarray doesn't like MET output files #1246

blaylockbk opened this issue Jan 30, 2020 · 1 comment
Assignees
Labels
MET: Library Code priority: high High Priority requestor: Community General Community type: task An actionable item of work

Comments

@blaylockbk
Copy link

blaylockbk commented Jan 30, 2020

I'm working through the MET tutorial and I just wanted to point out that Python's xarray package (used to read NetCDF files) does not liking MET's NetCDF output.

For instance, when loading an output file with xarray in Python

import xarray
x = xarray.open_dataset('MET_Tutorial/output/gen_vx_mask/cirlce_mask.nc')

results in this error...

MissingDimensionsError: 'lat' has more than 1-dimension and the same name as one of its dimensions ('lat', 'lon'). xarray disallows such variables because they conflict with the coordinates used to label dimensions.

The issue arises from lat and lon being both dimension names and variable names.

This is related to pydata/xarray#2233. It sounds like the xarray developers are addressing this.

A simple workaround is to drop the lat and lon variable when loading the data, but that sacrifices the grid data.

mask =  xr.open_dataset('MET_Tutorial/output/gen_vx_mask/cirlce_mask.nc', drop_variables=['lat','lon'])

I'm not sure if this issue has been brought up to the MET developers before, but given xarray's widespread use in the python community, I wanted to suggest MET change the output variable names to be latitude and longitude instead of lat and lon, or change the lat and lon dimension name to x and y.

@blaylockbk
Copy link
Author

Resolved in xarray v2023.08.0, fixed by pydata/xarray#7989

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MET: Library Code priority: high High Priority requestor: Community General Community type: task An actionable item of work
Projects
None yet
Development

No branches or pull requests

2 participants