smoothGrid: Grid smoothing.

View source: R/smoothGrid.R

smoothGridR Documentation

Grid smoothing.

Description

Applies an aggregation function (typically the mean) to each grid-box by considering surrounding grid-boxes.

Usage

smoothGrid(
  grid,
  times = 5,
  aggr.fun = list(FUN = "mean", na.rm = TRUE),
  weight.by.lat = TRUE,
  parallel = FALSE,
  max.ncores = 16,
  ncores = NULL
)

Arguments

grid

a grid or multigrid.

times

numeric. An odd number.

aggr.fun

Spatial aggregation function. A list indicating the name of the aggregation function in first place, and other optional arguments to be passed to the aggregation function. To be on the safe side, the function in FUN should be always indicated as a character string.

weight.by.lat

Logical. Should latitudinal averages be weighted by the cosine of latitude?. Default to TRUE. Ignored if a function different from "mean" is applied.

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 ncpus = NULL (the default), or when maxcores exceeds the default ncores value.

Value

A grid or multigrid of the same resolution.

Parallel Processing

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.

Author(s)

M. Iturbide


SantanderMetGroup/transformeR documentation built on Oct. 28, 2023, 5:26 a.m.