Changes between Version 11 and Version 12 of udg/ecoms/RPackage/examples/continentalSelection


Ignore:
Timestamp:
Sep 2, 2014 5:00:03 PM (7 years ago)
Author:
juaco
Comment:

--

Legend:

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

    v11 v12  
    11= Regional-Continental domain selections
    22
    3 In this example we will load data for Europe for the variable surface (2m) minimum temperature (`var = tasmin`), for the first two members (`members = 1:2`) of the CFSv2 hindcast (dataset = `CFSv2_seasonal_16`), considering the wintertime (DJF, `season = c(12,1,2)`) for the 10-year period 2001-2010 (`years = 2001:2010`), according to the forecast of previous September (`leadMonth = 3`). The original variable is stored as 6-hourly data for this particular dataset. Instead of loading the whole 6-hourly time series, or filtering by a particular time as in the [http://meteo.unican.es/ecoms-udg/RPackage/Examples/pointSelection previous example] we will retrieve the daily mean values, by setting the argument `time = "DD"`, that internally computes the daily mean from the 6-hourly instantaneous values.
     3In this example we will load data for Europe for the variable surface (2m) minimum temperature (`var = tasmin`), for the first two members (`members = 1:2`) of the CFSv2 hindcast (dataset = `CFSv2_seasonal_16`), considering the wintertime (DJF, `season = c(12,1,2)`) for the 10-year period 2001-2010 (`years = 2001:2010`), according to the forecast of previous September (`leadMonth = 3`). The original variable is stored as 6-hourly data for this particular dataset. We will retrieve the daily mean values, by setting the argument `time = "DD"`, that internally computes the daily minimum from the 6-hourly instantaneous values (see the NOTE below when executing the command):
    44
    55{{{
    66#!text/R
    77> ex2 <- loadECOMS(dataset = "CFSv2_seasonal_16", var = "tasmin", members = 1:2, lonLim = c(-15,35), latLim = c(32, 75), season = c(12,1,2), years = 2001:2010, leadMonth = 3, time = "DD")
    8 [2014-06-17 12:47:49] Defining homogeneization parameters for variable "tasmin"
    9 NOTE: daily mean will be calculated from the 6-h instantaneous model output
    10 [2014-06-17 12:47:49] Defining geo-location parameters
    11 [2014-06-17 12:47:49] Defining initialization time parameters
    12 [2014-06-17 12:47:54] Retrieving data subset ...
    13 [2014-06-17 12:54:33] Done
     8[2014-09-02 16:45:58] Defining homogeneization parameters for variable "tasmin"
     9NOTE: daily minimum will be calculated from the 6-h model output
     10[2014-09-02 16:45:58] Defining geo-location parameters
     11[2014-09-02 16:45:58] Defining initialization time parameters
     12[2014-09-02 16:46:03] Retrieving data subset ...
     13[2014-09-02 16:52:57] Done
    1414> print(object.size(ex2), units = "Mb")
    151535 Mb
    1616}}}
    1717
    18 In this case, the data are stored in a 4D-array, with the dimensions indicated by the `dimensions`attribute:
     18In this case, the data are stored in a 4D-array, with the dimensions indicated by the `dimensions`attribute, always following the canonical ordering of dimensions:
    1919
    2020{{{
    2121#!text/R
    2222> str(ex2$Data)
    23  num [1:902, 1:54, 1:47, 1:2] 17.4 16.4 17.4 18.7 18.4 ...
    24  - attr(*, "dimensions")= chr [1:4] "time" "lon" "lat" "member"
     23 num [1:2, 1:902, 1:47, 1:54] 17.4 17.2 16.4 18.7 17.4 ...
     24 - attr(*, "dimensions")= chr [1:4] "member" "time" "lat" "lon"
    2525}}}
    2626
    27 This is an example on how to plot the members selected as spatial means for the 10-year period. Note that this example uses the library `fields`, not attached on load of the `ecomUDG.Raccess` package:
     27Members can be plottede individually by setting `multimember = TRUE` in the `plotMeanField` function of the `downscaleR`package:
    2828
    2929{{{
    3030#!text/R
    31 > library(fields) # Install if not available to reproduce the example
    32 > member1 <- apply(ex2$Data[,,,1], FUN = mean, MARGIN = c(2,3))
    33 > member2 <- apply(ex2$Data[,,,2], FUN = mean, MARGIN = c(2,3))
    34 > x <- ex2$xyCoords$x
    35 > y <- ex2$xyCoords$y
    36 > par(mfrow = c(1,2))
    37 > image.plot(x,y,member1, asp = 1, main = "Member 1")
    38 > world(add = TRUE)
    39 > image.plot(x,y,member2, asp = 1, main = "Member 2")
    40 > world(add = TRUE)
     31plotMeanField(ex2, multi.member = TRUE)
    4132}}}
    4233