Hello,
I am wondering if there is some nice decorator or dataarray method which can be used to make arbitrary shape-preserving transformations of the data. For example, scipy.ndimage is loaded with potentially useful functions for dealing with xarray dataarrays. I am often doing something like a gaussian_filter on xarray data, but my current method for doing this is ugly:
tempblur = temperature.copy()
tempblur.values = gaussian_filter(tempblur, 2.0).
Obviously, this is pretty ugly code, and editing arrays in-place like this can be confusing, especially if these two lines of code get separated somehow. I could of course implement a decorator to handle this circumstance, but then it would be necessary to call the decorator on every function I plan to use. A better alternative by my lights would be something like
tempblur = temperature.apply(lambda x: gaussian_filter(x, 2.0)).
I have looked in the documentation, but I cannot seem to find a suggested workflow.
On another note, I think it would be really cool if xarray implemented its own wrapper around scipy.ndimage which could handle interpolating the data to a regular grid, calling scipy.ndimage functions, and keeping track of attributes and dimensions. Then something like "temperature.gaussian_filter(2.0)" would be possible.