Description Usage Arguments Details Value Author(s) Examples
Get a nearest neighbour interpolation of a 2D map from a current mask into a new one
1 | nnNewMask(z2D, imask, omask, newdef=0)
|
z2D |
REAL (:,:), input matrix |
imask |
LOGICAL (:,:), input mask |
omask |
LOGICAL (:,:), output mask |
newdef |
REAL, default value for cropped areas. That is, areas where imask is TRUE but omask is FALSE |
This functions is to ease adaptation to new masks in CESM where both the input and the output share the grid. For example this has been used for interpolation from a preindustrial simulation to be used as initial conditions for a LGM climate situation, where the lans-sea mask has been modified. z2D, imask and omask are matrices or the same size.
A 2D matrix
Javier Garcia-Pintado
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | library(rdafCESM)
nx <- 100
ny <- 200
oo <- c(50,100)
sig <- 30
xmat <- matrix(1:nx,nx,ny)
ymat <- matrix(rep(1:ny,each=nx),nx,ny)
dis2oosq <- (xmat - oo[1])^2 + (ymat - oo[2])^2
A <- matrix(exp(-dis2oosq/(2*sig^2)),nx,ny)
imask <- matrix(FALSE,nx,ny)
omask <- matrix(FALSE,nx,ny)
imask[50:90,50:100] <- TRUE
omask[40:80,60:120] <- TRUE
A[!imask] <- 0
Ao <- nnNewMask(A, imask, omask)
if (1 > 2) {
rdafPlot::imageF(A)
rdafPlot::imageF(Ao)
rdafPlot::imageF(Ao-A)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.