filterGrid | R Documentation |
Apply a filter along the time dimension of a grid
filterGrid(
grid,
window.width,
method = c("convolution", "recursive"),
sides = 1,
parallel = FALSE,
max.ncores = 16,
ncores = NULL,
...
)
grid |
Input grid (possibly multimember) |
window.width |
An integer specifying the moving window width. This is in the same temporal units
as the input grid. The function internally converts this value to a vector of filter coefficients of the
form |
method |
Either |
sides |
Used for |
parallel |
Logical. Should parallel execution be used? |
max.ncores |
Integer. Upper bound for user-defined number of cores. |
ncores |
Integer number of cores used in parallel computation. Self-selected number of
cores is used when |
... |
Further arguments passed to |
A wrapper of function filter
A time-filtered grid.
Parallel processing is enabled using the parallel package.
Parallelization is undertaken by a FORK-type parallel socket cluster formed by ncores
.
If ncores
is not specified (default), ncores
will be one less than the autodetected number of cores.
The maximum number of cores used for parallel processing can be set with the max.ncores
argument,
although this will be reset to the auto-detected number of cores minus 1 if this number is exceeded. Note that not all
code, but just some critical loops within the function are parallelized.
In practice, parallelization does not always result in smaller execution times, due to the parallel overhead. However, parallel computing may potentially provide a significant speedup for the particular case of large multimember datasets or large grids.
Parallel computing is currently not available for Windows machines.
J Bedia
require(climate4R.datasets)
data(NCEP_Iberia_ta850)
plot(NCEP_Iberia_ta850[["Data"]][,3,3], ty = 'l')
# Apply a moving average considering 2 different window widths of 30 and 90 days
fgrid30 <- filterGrid(NCEP_Iberia_ta850, method = "convolution", window.width = 30, sides = 1)
lines(fgrid30[["Data"]][,3,3], col = 'red')
fgrid90 <- filterGrid(NCEP_Iberia_ta850, method = "convolution", window.width = 90, sides = 1)
lines(fgrid90[["Data"]][,3,3], col = 'green')
legend("top", c("raw","30-day MA", "90-day MA"), lty = 1, col = c(1,2,3), ncol = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.