I've found myself writing a wrapper method around Filter#apply that works for both DataArrays and Datasets (applying to all variables that have the given dims):
def apply(filter, ds, dims=['y','x']):
if isinstance(ds, xr.Dataset):
filtered = ds.copy()
for k, v in ds.variables.items():
if all(d in v.dims for d in dims):
filtered[k] = filter.apply(ds[k], dims=dims)
return filtered
else:
return filter.apply(ds, dims=dims)
I've found myself writing a wrapper method around
Filter#apply
that works for bothDataArray
s andDataset
s (applying to all variables that have the givendims
):Would it make sense to make a PR that wraps the current definition of
Filter#apply
with a helper of this kind?