Stream: dask
Topic: running average over sub regions
Ufuk Turuncoglu (Nov 19 2020 at 22:45):
Hi All,
This is my first post to list and i am exciting about it. I am trying to learn dask and xarray by trying following operation
import xarray as xr import dask.array as da import numpy as np def box_average(x): return np.average(x+np.roll(x, -1)+np.roll(x, -1, axis=0)+np.roll(x, -1, axis=1)+np.roll(x, [-1,-1], axis=(0, 1))) tmp = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] arr = da.from_array(tmp, chunks=5) print(arr.compute()) arr2 = arr.map_overlap(box_average, depth=1, boundary=0) print(arr2.compute())
i am aiming to calculate average over 2d field by using its neighbors. I found map_overlap function to do it but it won't produce that i want . Do you know any good example about it. Actually, this is just demo code that i try something but eventually this will be used in very high resolution dataset and i am not sure about its performance at this point. Any comments could be helpful since i am beginer
Ufuk Turuncoglu (Nov 20 2020 at 16:30):
i think i solved the problem. thanks
Last updated: Jan 30 2022 at 12:01 UTC