3 | | The following call to `loadECOMS` will load a time series of surface (2m) instantaneous temperature (`var = "tas"`, as defined in the [wiki vocabulary])at 12:00 for the coordinate -3.7E 40.4N, (`lonLim = -3.7`, `latLim = 40.4`) corresponding to the city of Madrid (Spain), corresponding to the summer (JJA, `season = 6:8`) of 2001 (`years = 2001`) as forecasted the previous March (`leadMonth = 2`) by the CFSv2 hindcast (`dataset = "CFSv2_seasonal_16"`). We will select the first 10 members (`members = 1:10`): |
| 3 | The following call to `loadECOMS` will load a time series of surface (2m) daily mean temperature (`var = "tas"`, as defined in the [http://meteo.unican.es/ecoms-udg/RPackage/Homogeneization vocabulary]) for the coordinate -3.7E 40.4N, (`lonLim = -3.7`, `latLim = 40.4`) corresponding to the city of Madrid (Spain), corresponding to the summer (JJA, `season = 6:8`) of 2001 (`years = 2001`) as forecasted the previous March (`leadMonth = 2`) by the CFSv2 hindcast (`dataset = "CFSv2_seasonal_16"`). We will select the first 10 members (`members = 1:10`). Note that the original variable is stored in the CFSv2 database as 6-hourly. Hence, we indicate to the funciton to compute the daily mean from the 6-hourly data using the argument `time = "DD".` |
6 | | > ex.point <- loadECOMS(dataset = "CFSv2_seasonal_16", var = "tas", members = 1:10, lonLim = -3.7, latLim = 40.4, season = 6:8, years = 2001, leadMonth = 2, time = "12") |
7 | | [2014-06-17 12:08:27] Defining homogeneization parameters for variable "tas" |
8 | | [2014-06-17 12:08:27] Defining geo-location parameters |
9 | | [2014-06-17 12:08:27] Defining initialization time parameters |
10 | | [2014-06-17 12:08:31] Retrieving data subset ... |
11 | | [2014-06-17 12:09:11] Done |
12 | | > print(object.size(ex.point)) |
| 6 | > point.cfs <- loadECOMS(dataset = "CFSv2_seasonal_16", var = "tas", members = 1:10, lonLim = -3.7, latLim = 40.4, season = 6:8, years = 2001, leadMonth = 2, time = "DD") |
| 7 | [2014-06-17 15:51:15] Defining homogeneization parameters for variable "tas" |
| 8 | NOTE: daily mean will be calculated from the 6-h instantaneous model output |
| 9 | [2014-06-17 15:51:15] Defining geo-location parameters |
| 10 | [2014-06-17 15:51:16] Defining initialization time parameters |
| 11 | [2014-06-17 15:51:20] Retrieving data subset ... |
| 12 | [2014-06-17 15:54:16] Done |
| 13 | > print(object.size(point.cfs)) |
27 | | > quartiles <- apply(ex.point$Data, MARGIN = 1, FUN = quantile, probs = c(.25,.75)) |
28 | | > ens.mean <- rowMeans(ex.point$Data) |
29 | | > dates <- ex.point$Dates$start |
30 | | > plot(dates, ens.mean, ylim = range(ex.point$Data), ty = 'n', ylab = "tas - 12UTC", xlab = "time") |
| 28 | > quartiles <- apply(point.cfs$Data, MARGIN = 1, FUN = quantile, probs = c(.25,.75)) |
| 29 | > ens.mean <- rowMeans(point.cfs$Data) |
| 30 | > dates <- point.cfs$Dates$start |
| 31 | > plot(dates, ens.mean, ylim = range(point.cfs$Data), ty = 'n', ylab = "tas - Daily Mean", xlab = "time") |
38 | | |
39 | | |
40 | | {{{#!comment |
41 | | == Loading and plotting various members using trellis plots |
42 | | |
43 | | The `spplot` methods of package `sp` allow the visualization of maps for different spatial classes using trellis (lattice) plots. In this example, total precipitation at the Gulf of Guinea for January 2010 forecasted in October 2009 (lead month 3) by the System4 model (seasonal range, 15 members) is represented for each member, using the `spplot` method for the `SpatialGridDataFrame` class: |
44 | | |
45 | | Data are loaded by introducing the required values for dataset, spatio-temporal window and lead month definition. Note that the argument `members` is omitted, which means that by default all available members (15 in this case, will be returned). |
| 39 | The interface `loadECOMS` is also used in the case of gridded observations. For instance, using the same geo-location and time arguments used in the previous selection, we can now retrieve the observed temperature for that particular grid cell accessing the WFDEI dataset: |
48 | | gg.pr <- loadSeasonalForecast("System4_seasonal_15", var="tp", lonLim=c(-30,20), latLim=c(-12,15), season=1, years=2010, leadMonth=3) |
| 42 | > point.wfdei <- loadECOMS(dataset = "WFDEI", var = "tas", lonLim = -3.7, latLim = 40.4, season = 6:8, years = 2001, time = "DD") |
| 43 | [2014-06-17 16:05:55] Defining homogeneization parameters for variable "tas" |
| 44 | [2014-06-17 16:06:55] Defining geo-location parameters |
| 45 | [2014-06-17 16:06:55] Defining time selection parameters |
| 46 | [2014-06-17 16:06:55] Done |
| 47 | > print(object.size(point.wfdei)) |
| 48 | 13360 bytes |
54 | | df <- sapply(gg.pr$MemberData, colSums) |
55 | | sgdf <- SpatialGridDataFrame(gg.pr$LonLatCoords, as.data.frame(df)) |
56 | | spplot(sgdf, scales=list(draw=TRUE), col.regions=rev(terrain.colors(50)), at=seq(0,ceiling(max(sgdf@data)),10)) |
| 54 | > lines(dates, point.wfdei$Data, col = "red", lwd = 1.5) |
58 | | |
59 | | [[Image(GulfOfGuinea15members.png)]] |
60 | | |
61 | | It is often useful to have a world map as a backdrop for visual reference. The dataset `world_map` is built-in in the `ecomsUDG.Raccess` package: |
62 | | |
63 | | {{{ |
64 | | data(world_map) |
65 | | wl <- as(world_map, "SpatialLines") |
66 | | l1 <- list("sp.lines", wl) |
67 | | }}} |
68 | | |
69 | | For the visualization of a subset of members we use the `zcol` argument. For instance, members 4, 9, 13 and 14 yield a high precipitation forecast in the southern region: |
70 | | |
71 | | {{{ |
72 | | spplot(sgdf, zcol=c(4,9,13,14), scales=list(draw=TRUE), col.regions=rev(terrain.colors(50)), at=seq(0, ceiling(max(sgdf@data)),10), sp.layout=list(l1)) |
73 | | }}} |
74 | | |
75 | | [[Image(GulfOfGuineaSubsetMember.png)]] |
| 56 | [[Image(image-20140617-161214.png)]] |