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


Ignore:
Timestamp:
Apr 16, 2013 1:29:31 PM (9 years ago)
Author:
juaco
Comment:

--

Legend:

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

    v7 v8  
    1 In 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.
     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 1990-1999. 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 21 seconds.
    22
    33{{{
    4 openDAP.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)
    8 mean.field <- colMeans(openDAP.query$MemberData[[1]])
    9 lat <- openDAP.query$Coordinates[ ,1]
    10 lon <- openDAP.query$Coordinates[ ,2]
    11 # Requires package "akima"
    12 library(akima)
    13 filled.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)))
     4> openDAP.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 = 1990:1999, leadMonth = 1)
    178}}}
     9
     10Data are now loaded into the R session:
     11
     12{{{
     13> str(openDAP.query)
     14List of 7
     15 $ VarName      : chr "Mean_temperature_at_2_metres_since_last_24_hours_surface"
     16 $ VarUnits     : chr "degC"
     17 $ TimeStep     : chr "24h"
     18 $ MemberData   :List of 1
     19  ..$ : num [1:310, 1:280] 13.3 13.9 12.5 13 13 ...
     20 $ LatLonCoords : num [1:280, 1:2] 45 44.2 43.5 42.7 42 ...
     21  ..- attr(*, "dimnames")=List of 2
     22  .. ..$ : NULL
     23  .. ..$ : chr [1:2] "lat" "lon"
     24 $ RunDates     : POSIXlt[1:310], format: "1989-12-01" "1989-12-01" "1989-12-01" "1989-12-01" ...
     25 $ ForecastDates: POSIXlt[1:310], format: "1990-01-01" "1990-01-02" "1990-01-03" "1990-01-04" ...
     26}}}
     27
     28A simple representation of data consists of mapping the spatial mean for the period considered:
     29
     30{{{
     31> mean.field <- colMeans(openDAP.query$MemberData[[1]])
     32> lat <- openDAP.query$LatLonCoords[ ,1]
     33> lon <- openDAP.query$LatLonCoords[ ,2]
     34> # Requires package "akima"
     35> library(akima)
     36> filled.contour(interp(lon, lat, mean.field), asp=1,
     37+               plot.title = title (main = "Mean surface T January 1990-99",ylab = "latitude", xlab = "longitude"),
     38+               key.title = title(main = "degC"),
     39+               key.axes = axis(4, seq(-1,16,1)),
     40+               color.palette = topo.colors)
     41}}}