WikiPrint - from Polar Technologies

We will take as reference for measuring the drift the lead-month 0 forecast (i.e. the July initializations)

> ref <- loadECOMS(dataset = "CFSv2_seasonal_16", var = "tas", lonLim = c(-10,-1), latLim = c(36,40), season = 7, years = 2006, leadMonth = 0) > plotMeanField(ref) > ref.field <- apply(ref$Data, MARGIN = c(4,3), FUN = mean, na.rm = TRUE)

Next, we will load the forecast of the target variable recursively for lead month values from 1 to 6 (i.e., the initializations from January to June). The different objects are arranged in a list:

> cfs.list <- lapply(1:6, function(lead.month) { loadECOMS(dataset = "CFSv2_seasonal_16", var = "tas", lonLim = c(-10,-1), latLim = c(36,40), season = 7, years = 2006, leadMonth = lead.month) })

In order to visualize the departures of each lead month from the reference in the same range of values, we will use the `spplot` method for plotting spatial objects of the library `sp`. To this aim, we will first compute the multi-member spatial mean for each lead month forecast, and then we will arrange the data in a matrix of 6 columns (one for each month), and x*y coordinates rows:

> require(sp) > # Matrix of anomalies between lead month and reference > aux.mat <- matrix(ncol = length(cfs.list), nrow = length(ref$xyCoords$x)*length(ref$xyCoords$y)) + for (i in 1:length(cfs.list)) { + mm.field <- apply(cfs.list[[i]]$Data, MARGIN = c(4,3), FUN = mean, na.rm = TRUE) + aux.mat[ ,i] <- mm.field - ref.field + } > # 2D coordinates > xy <- expand.grid(ref$xyCoords$x, ref$xyCoords$y) > xy.coords <- coordinates(points2grid(points = SpatialPoints(xy), tolerance = .003)) > df <- cbind.data.frame(xy.coords, aux.mat) > names(df) <- c("x","y",paste("LeadMonth_",1:6, sep = "")) > str(df) 'data.frame': 55 obs. of 8 variables: $ x : num -10.31 -9.38 -8.44 -7.5 -6.56 ... $ y : num 40.2 40.2 40.2 40.2 40.2 ... $ LeadMonth_1: num 0.0398 0.0691 0.1427 0.116 0.1935 ... $ LeadMonth_2: num 0.386 0.451 0.472 0.311 0.161 ... $ LeadMonth_3: num 0.0428 0.0787 0.0707 -0.125 -0.2751 ... $ LeadMonth_4: num 0.261 0.258 0.131 -0.177 -0.464 ... $ LeadMonth_5: num 0.0576 0.154 0.1327 -0.1282 -0.3963 ... $ LeadMonth_6: num 0.0789 0.192 0.0989 -0.2667 -0.6457 ... > Conversion of the data.frame to a Spatial gridded object: > coordinates(df) <- c(1,2) > class(df) [1] "SpatialPixelsDataFrame" attr(,"package") [1] "sp"

In the next lines we use the `spplot` method of package `sp`, generating a lattice-type map. In first place, we will also load a `SpatialLines` dataset remotely stored at Santander Met Group server, in order to represent the grographical lines in the lattice map generated:

> load(url("http://meteo.unican.es/work/downscaler/aux/wlines.rda"), verbose = TRUE) Loading objects: wlines > l1 <- list("sp.lines", wlines) > spplot(df, as.table = TRUE, col.regions = colorRampPalette(c("blue","white","red")), at = seq(-2.5,2.5,.25), scales = list(draw = TRUE), sp.layout = list(l1))

The results show how a increasing lead month leads to a negative bias of the forecast, demonstrating that the mean state of a variable of a forecast is not stationary through time.