Version 2 (modified by juaco, 8 years ago) (diff)

--

## Analysing model drift in the African Horn

This example analyses model drift of mean surface temperature at the African Horn. As an example we will use the first member of the System4 seasonal model of 15 members, and will analyse the mean temperature of June, considering the 20-year period 1991-2010.

First, we load the reference data that will be used as a benchmark for quantifying the drift, corresponding to the prediction with lead month 1:

lm1 <- loadSeasonalForecast("System4_seasonal_15", var="tas", members=1, lonLim=c(30,52), latLim=c(-5,20), season=6, years=1991:2010, leadMonth=1)


Next, we load the data corresponding to the first member for lead months 2 to 6. Note that we retain only the MemberData element of the output, since the spatial reference and the times are identical to the ones already available in object lm1

lm2_6 <- lapply(2:6, function(lead.month) loadSeasonalForecast("System4_seasonal_15", var="tas", members=1, lonLim=c(30,52), latLim=c(-5,20), season=6, years=1991:2010, leadMonth=lead.month)$MemberData[])  In the next lines of code we compute the grid-point and spatial means of temperature for the reference forecast of lead month 1: # Calculation of the mean at each grid point: t.mean <- colMeans(lm1$MemberData$Member_1) # Calculation of the spatial mean: sp.mean.ref <- mean(t.mean)  And next the reference climatology using lead month 1 is plotted: data(world_map) wl <- as(world_map, "SpatialLines") l1 <- list("sp.lines", wl) l2 <- list("sp.text", c(47, -2), paste("mean =", round(sp.mean.ref, 2)), cex = 1.5) ref <- SpatialGridDataFrame(lm1$LonLatCoords, as.data.frame(t.mean))
spplot(ref, col.regions=rev(heat.colors(21)), scales = list(draw = TRUE), sp.layout = list(l1, l2), main = "Mean 2m temp June (1991-2010) - Lead Month 1")



The following function computes drift in terms of anomalies with the reference ()in this case the lead month 1 forecast):

delta.drift <- function(x, ref) {
delta <- colMeans(x) - ref
return(delta)
}
df.deltas <- sapply(lm2_6, FUN=delta.drift, ref = t.mean)
colnames(df.deltas) <- paste("LeadMonth_", 2:6, sep = "")


The next steps allow the visualization of the model drift, considering the anomalies of different lead month forecasts with regard to the lead month 1 reference:

# Preparation of the panel text showing the mean values
for (x in 1:5) {
assign(paste("l", x+1, sep=""), list("sp.text", c(43, -2), paste("mean =", round(sp.mean.ref + colMeans(df.deltas), 2)[x]), which = x))
}
delta.sgdf <- SpatialGridDataFrame(lm1\$LonLatCoords, as.data.frame(df.deltas))
delta.colors <- colorRampPalette(c("red", "white", "blue"))
spplot(delta.sgdf, scales = list(draw = TRUE), sp.layout =list(l1,l2,l3,l4,l5,l6), col.regions = delta.colors(41), as.table = TRUE, at = seq(-2,2,.1))