Changes between Initial Version and Version 1 of udg/ecoms/RPackage/examples/globalSelection


Ignore:
Timestamp:
Feb 20, 2014 10:02:07 AM (8 years ago)
Author:
juaco
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • udg/ecoms/RPackage/examples/globalSelection

    v1 v1  
     1== Analysing model drift in the African Horn
     2
     3This 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.
     4
     5First, we load the reference data that will be used as a benchmark for quantifying the drift, corresponding to the prediction with lead month 1:
     6
     7{{{
     8lm1 <- loadSeasonalForecast("System4_seasonal_15", var="tas", members=1, lonLim=c(30,52), latLim=c(-5,20), season=6, years=1991:2010, leadMonth=1)
     9}}}
     10
     11Next, 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`
     12
     13{{{
     14lm2_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[[1]])
     15}}}
     16
     17In the next lines of code we compute the grid-point and spatial means of temperature for the reference forecast of lead month 1:
     18
     19{{{
     20# Calculation of the mean at each grid point:
     21t.mean <- colMeans(lm1$MemberData$Member_1)
     22# Calculation of the spatial mean:
     23sp.mean.ref <- mean(t.mean)
     24}}}
     25
     26And next the reference climatology using lead month 1 is plotted:
     27
     28{{{
     29data(world_map)
     30wl <- as(world_map, "SpatialLines")
     31l1 <- list("sp.lines", wl)
     32l2 <- list("sp.text", c(47, -2), paste("mean =", round(sp.mean.ref, 2)), cex = 1.5)
     33ref <- SpatialGridDataFrame(lm1$LonLatCoords, as.data.frame(t.mean))
     34spplot(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")
     35}}}
     36
     37
     38