Changes between Version 6 and Version 7 of udg/ecoms/RPackage/examples


Ignore:
Timestamp:
Apr 16, 2013 11:11:02 AM (9 years ago)
Author:
juaco
Comment:

--

Legend:

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

    v6 v7  
    1 In the next lines we describe an illustrative example considering SYSTEM4, one-month lead time forecasts of minimum surface temperature for January over a window centered in Europe (0^o^W - 30^o^E and 35^o^S - 65^o^N). A more elaborated example describing a multi-model selection of a similar dataset is presented in the tutorial, which can be downloaded [https://www.meteo.unican.es/trac/meteo/attachment/wiki/SpecsEuporias/DataPortal_Tutorial.pdf here]. 
    2 
    3 The request is simply formulated via the `loadSystem4` function in the following way:
    4 {{{
    5 > ds <- "http://www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml";
    6 > openDAP.query <- loadSystem4(dataset = ds, var = "tasmin", members = 1,
    7 +      lonLim = c(0,30), latLim = c(35,65),
    8 +      season = 1, years = 1981:2000, leadMonth = 1)
    9 }}}
    10 
    11 The arguments of the function are the next described:
    12 
    13 * `dataset`: A character string indicating the full URL path to the OPeNDAP dataset. Currently, the accepted values correspond to the System4 datasets described in Section [https://www.meteo.unican.es/trac/meteo/wiki/SpecsEuporias/DataServer/Datasets Datasets], as specified in the above example, but using the `System4_Seasonal_15Members.ncml`, `System4_Seasonal_51Members.ncml` or `System4_Annual_15Members.ncml` ending strings.
    14 * `var`: Variable code. Argument values currently accepted are `tas`, `tasmin`, `tasmax`, `pr` or `mslp`, as internally defined in the dictionary defined for System4 following the nomenclature displayed in the table below. However, note that new variables and datasets will be progressively included. Note that System4 precipitation is internally deaccumulated by the function to return daily accumulated values.
    15 
    16 ||='''Short Name'''=||='''Dataset variable'''=||
    17 ||tasmax ||Maximum temperature at 2 metres since last 24 hours surface ||
    18 ||tasmin ||Minimum temperature at 2 metres since last 24 hours surface ||
    19 ||tas ||Mean temperature at 2 metres since last 24 hours surface ||
    20 ||pr ||Total precipitation surface ||
    21 ||mslp ||Mean sea level pressure surface ||
    22 
    23 * `members`: Optional. Default to all members. In the above case, a single member (the first) of the System4 ensemble is loaded, but additional members could be also specified  (e.g. `members=NULL` for all members, or `members=1:5` for the first five members).
    24 * `lonLim`: Vector of length = 2, with minimum and maximum longitude coordinates, in decimal degrees, of the bounding box selected.
    25 * `latLim`: Vector of length = 2, with minimum and maximum latitude coordinates, in decimal degrees, of the bounding box selected.
    26 * `season`: A vector of integers specifying the desired season (in months, January=1, etc.) of analysis. Options include a single month (as in the above example) or a standard season (e.g. `period = c(12,1,2)` for standard Boreal winter, DJF).
    27 * `years`: Optional. Default to all available years. Vector of years to select. Note that in cases with year-crossing seasons (e.g. winter DJF, `season = c(12,1,2)`, for a particular year period `years = 1981:2000`), by convention the first season would be DJF 1980/81, if available (otherwise a warning message is given).
    28 * `loadMonth`: Lead month forecast time corresponding to the first month of the specified season. Note that `leadMonth = 1` for `season = 1` (January) corresponds to the December initialization forecasts. In this way the effect of the lead time forecast in the analysis of a particular season can be analyzed by just changing this parameter.
    29 
    30 
    31 The output of the function is a data structure with all the requested information as follows.
     1In the next lines we describe an illustrative example of the `loadSystem4` function. We will retrieve System4 simulation data for the Iberian Peninsula, considering mean surface temperature for January and the first simulation member, for the three-year period 1981-1983. This simple example has been chosen because of the fast data access (note that this also depends on the connection speed). Using a standard broadband connection, running this example took approximately 6 seconds.
    322
    333{{{
    34 > str(openDAP.query)
    35 List of 4
    36  $ MemberData   :List of 1
    37   ..$ : num [1:930, 1:1600] 275 277 278 279 277 ...
    38  $ Coordinates  : num [1:1600, 1:2] 64.5 63.7 63 62.2 61.5 ...
    39   ..- attr(*, "dimnames")=List of 2
    40   .. ..$ : NULL
    41   .. ..$ : chr [1:2] "lat" "lon"
    42  $ RunDates     : POSIXlt[1:30], format: "1981-12-01" "1982-12-01" "1983-12-01" ...
    43  $ ForecastDates: Date[1:930], format: "1982-01-01" "1982-01-02" "1982-01-03" ...
     4openDAP.query <- loadSystem4(dataset = "http://www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml",
     5                             var = "tas", members = 1,
     6                             lonLim = c(-10,5), latLim = c(35,45),
     7                             season = 1, years = 1981:1983, leadMonth = 1)
     8mean.field <- colMeans(openDAP.query$MemberData[[1]])
     9lat <- openDAP.query$Coordinates[ ,1]
     10lon <- openDAP.query$Coordinates[ ,2]
     11# Requires package "akima"
     12library(akima)
     13filled.contour(interp(lon, lat, mean.field), asp=1,
     14               plot.title = title (main = "Mean surface T January 1981-83",ylab = "latitude", xlab = "longitude"),
     15               key.title = title(main = "degK"),
     16               key.axes = axis(4, seq(273,289,1)))
    4417}}}
    45 
    46 The output consists of a list with the following 4 elements:
    47 
    48 * `MemberData`: This is a list of length ''n'', where ''n'' = number of members of the ensemble selected by the `member` argument. Each element of the dataset is a 2-D matrix of ''i'' rows `x` ''j'' columns, of ''i'' forecast times and ''j'' grid-points
    49 * `Coordinates`: A 2-D matrix of ''j'' rows (where ''j'' = number of grid points selected) and two columns corresponding to the latitude and longitude coordinates respectively.
    50 * `RunDates`: A `POSIXlt` time object corresponding to the initialization times selected.
    51 * `ForecastDates`: A vector of class `Date` of length ''i'', corresponding to the rows of each matrix in `MemberData`, containing the verification dates.