wrf-python icon indicating copy to clipboard operation
wrf-python copied to clipboard

Improve xarray support

Open bladwig1 opened this issue 8 years ago • 9 comments

Current support for xarray is fairly primitive. Some features that would be nice are:

  • Add support for using xarray.Dataset directly instead of extracting the NetCDF object.
    • Being able to subset the Dataset's data prior to reading so the entire array isn't used.
    • Some of this may be better handled using input iterables classes as wrappers.
    • See also issue #6
  • Add multidimensional indexing support by using the latlon_to_xy routines.
  • Make isel, sel, and other indexing features work correctly.

This list will be updated as needed.

bladwig1 avatar Apr 12 '17 21:04 bladwig1

It would be nice to have this as an extension to xarray. That way you could call something like

with xr.open_dataset('/path/to/file.nc') as xd:
    t = xd.wrf.getvar('temp')
    proj4 = xd.wrf.proj4
    cart_proj = xd.wrf.cartopy

See: http://xarray.pydata.org/en/stable/internals.html#extending-xarray

I have used it here: https://github.com/snowman2/pangaea/blob/master/pangaea/xlsm.py

snowman2 avatar Apr 21 '17 01:04 snowman2

Looks like it would not be bad to try to merge with salem. See: https://github.com/fmaussion/salem/issues/82

snowman2 avatar Jul 10 '17 14:07 snowman2

Any news about an improved xarray support ? It would be nice at first to be able to get data from xarray datasets, like

with xr.open_dataset('/path/to/file.nc') as ds:
    t = wrf.getvar(ds, 'temp')

honnorat avatar Sep 10 '19 09:09 honnorat

I'm also wondering about this one. It's not straightforward to use getvar on a large number of WRF output files (see issue 94); seems xarray could help with this.

Timothy-W-Hilton avatar Jan 09 '20 21:01 Timothy-W-Hilton

@Timothy-W-Hilton Thanks for bumping this!

I'd be interested in hearing about the wrf-python maintainers' perspective on this as well. I've been working a fair bit with WRF output in xarray (especially in the context of MetPy and CF conventions, see this abstract), and would be glad to collaborate on these efforts going forward if it seems to be a good fit.

jthielen avatar Jan 09 '20 21:01 jthielen

We, the GeoCAT team at NCAR, do have plans to refactor wrf-python to be compatible with Xarray. However, the team's priority at the moment is rolling out model-agnostic computational routines (called GeoCAT.comp). These new functions operate directly on Xarray data arrays. The repo for these new functions is here: https://github.com/NCAR/geocat-comp

We don't yet have a timeframe for turning our focus back to wrf-python. However, if this is something that someone in the community wanted to bite off we'd be happy to provide guidance.

clyne avatar Jan 09 '20 23:01 clyne

@clyne Thank you for the update! After the hecticness of the AMS Meeting and a few pending projects settle down, I'll see if (and in what ways) I could be of any help with this.

jthielen avatar Jan 10 '20 05:01 jthielen

Terrific. BTW much of the GeoCAT Team will be at AMS, and there will be talk on the GeoCAT project:

"GeoCAT: The NCL Pivot to Python" Monday, January 13, 2020 2:00 PM - 2:15 PM Boston Convention and Exhibition Center - 157AB

On Jan 9, 2020, at 10:03 PM, Jon Thielen [email protected] wrote:

@clyne Thank you for the update! After the hecticness of the AMS Meeting and a few pending projects settle down, I'll see if (and in what ways) I could be of any help with this.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

John Clyne National Center for Atmospheric Research 303.497.1236 (w), 303.809.1922 (c) [email protected]

clyne avatar Jan 10 '20 14:01 clyne

Thanks, @clyne, for the update! It's nice to know that the slowdown in wrf-python development these past six months doesn't indicate it's being phased out. I'm also open to helping out, though 2020 doesn't really have a lot of space for a large new project for me.

Timothy-W-Hilton avatar Jan 10 '20 16:01 Timothy-W-Hilton