I have a 3D array of float64, called A, with shape [396,380,1016]. 380 and 1016 are latitude (latmin=30.1875, latmax=45.9792) and longitude (lonmin=-6, lonmax=36.2917), respectively, representing a grid with resolution of ca. 0.041 degree. 396 is the 3rd dimension and accounts for monthly data.
I need an upscaled 3D array, B, achieved by resizing A to the new shape [396,128,344]; which actually have a resolution of 0.125 degree with (latmin=30.0626, latmax=45.9375) and (lonmin=-5.9375, lonmax=36.9375). The proportion with respect to A should be something like (1, 0.338, 0.339).
The new array should have the values on axis=0 [396] averaged among themselves according to the new (coarser) resolution. I thought about the conservative interpolation method in CDO, but unfortunately i'm not able to use it with Windows due to several errors, as well as i cannot use xESMF on Windows. There is a way by using xarray? should i have to regrid on a 2D level and then loop across the 3rd dimension?
Also consider that axis=0 contains several nan grid points, which must still be averaged as well and preserved in the 3D structure since represents the land mask.
what can be the best solution? Thanks