jbusecke/xarrayutils

Function for aggregating along dimensions: eg. agg into 5deg latitude bands

AndrewILWilliams opened this issue · 3 comments

Hi!

In my own work recently I've come across something which I thought might be nice to have included in xarrayutils. Basically, it's often useful to be able to not just take the zonal mean of data, but to also be able to aggregate the data into, say, 5 degree latitude bands and then .mean() this new dimension.

I've been doing this using xarray's da.groupby_bins() method, and it's currently a bit hacky, but if this was something you'd be interested in including in your package I could try and tidy it up and submit a pull request?

# Example, aggregate into 5 degree lat bands
daa = agg_zonmean(da, dlat=5)

It's not a complicated function in and of itself it might just be a bit of work to think about all the different grid setups.

Anyways, let me know. I'd be keen to try my hand at contributing if this is something you'd find useful! :)

Oops, I think I just found out you can do this with the aggregate function you've already made! My bad! I'll close this

Hi @AndrewWilliams3142, thanks for checking xarrayutils out!

Xarray actually does this now with .coarsen(). I encourage you to use their implementation.
And also I should add a DeprecationWarning.

In case you want to to aggregate/coarsen complexer grids (e.g. nonuniform lon-lat), I recommend the excellent xesmf.

Ill go ahead and close this. Feel free to reopen when needed.