PC2grid | R Documentation |
Convert a Principal Component to a 'time-series' grid.
PC2grid(
prinCompObj,
var = names(prinCompObj)[1],
pc.idx = 1,
scale = FALSE,
opp = FALSE
)
prinCompObj |
A PCA object as returned by |
var |
Character string. Name of the variable for which to extract the PC. Defaults to the first variable in |
pc.idx |
Index position of the PC to be converted to a grid. Default to the first PC ( |
scale |
Logical. Should the time series values be scaled?. Default to |
opp |
Logical. Default to |
The XY coordinates correspond to the centroid of the window used for the PCA analysis. Details on the extent of this
window are provided by the attributes domX
and domY
within the xyCoords
component.
Currently, only the start days are returned. The end dates are not returned by the prinComp
output.
A 'time series' grid (i.e., a grid with dimensions lon and lat of length 1). It can be a multimember.
J. Bedia
Other pca:
grid2PCs()
,
gridFromPCA()
,
prinComp()
require(climate4R.datasets)
data("CFS_Iberia_psl")
pc <- prinComp(CFS_Iberia_psl, v.exp = .95)
# Convert to grid the PC of the leading EOF (pc.idx = 1):
psl.index <- PC2grid(prinCompObj = pc, pc.idx = 1)
aggr.fun <- list(FUN = "mean", na.rm = TRUE)
psl.index <- aggregateGrid(psl.index, aggr.m = aggr.fun, aggr.y = aggr.fun,
aggr.mem = aggr.fun)
plot(as.Date(getRefDates(psl.index)), psl.index$Data, ty = "o",
xlab = "year", ylab = "SLP index")
abline(h=0, lty = 2)
title(main = "1st PC of multimember mean DJF SLP over Iberia")
# opp can be used to obtain the inverse:
psl.index.inv <- PC2grid(prinCompObj = pc, pc.idx = 1, opp = TRUE)
psl.index.inv <- aggregateGrid(psl.index.inv, aggr.m = aggr.fun, aggr.y = aggr.fun,
aggr.mem = aggr.fun)
lines(as.Date(getRefDates(psl.index.inv)), psl.index.inv$Data, ty = "o", col = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.