AreaWeighted
Hi @vagudets, @tkariyat, @abatalla
As discussed in today's meeting, I am creating this merge request to include the new AreaWeighted() function. You can find it in the develop-AreaWeighted branch: https://earth.bsc.es/gitlab/external/cstools/-/blob/develop-AreaWeighted/R/AreaWeighted.R
The function calculates the spatial area-weighted average of multidimensional arrays given data (climate data) and area (area per grid point of each region(s), which can be the output of ShapeToMask) arrays. The function already includes checks and documentation.
It is complementary to ClimProjDiags::WeightedMean(), which computes the spatial area-weighted average for a user-defined box. Unlike ClimProjDiags::WeightedMean() this function uses the actual grid-cell areas, which is needed when averaging regions that only partially overlap with grid points. For example, Barcelona may cover 30% of one grid cell and 20% of another (and the overlapped area may be different).
@apatra, would you like to test the new function?
Thank you!
Carlos
FYI @nperez