wiki:udg/ecoms/RPackage/examples

Version 9 (modified by juaco, 9 years ago) (diff)

--

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 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.

> openDAP.query <- loadSystem4(dataset = "http://www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml", 
+                             var = "tas", members = 1,
+                             lonLim = c(-10,5), latLim = c(35,45),
+                             season = 1, years = 1990:1999, leadMonth = 1)

Data are now loaded into the R session:

> str(openDAP.query)
List of 7
 $ VarName      : chr "Mean_temperature_at_2_metres_since_last_24_hours_surface"
 $ VarUnits     : chr "degC"
 $ TimeStep     : chr "24h"
 $ MemberData   :List of 1
  ..$ : num [1:310, 1:280] 13.3 13.9 12.5 13 13 ...
 $ LatLonCoords : num [1:280, 1:2] 45 44.2 43.5 42.7 42 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : NULL
  .. ..$ : chr [1:2] "lat" "lon"
 $ RunDates     : POSIXlt[1:310], format: "1989-12-01" "1989-12-01" "1989-12-01" "1989-12-01" ...
 $ ForecastDates: POSIXlt[1:310], format: "1990-01-01" "1990-01-02" "1990-01-03" "1990-01-04" ...

A simple representation of data consists of mapping the spatial mean for the period considered:

> mean.field <- colMeans(openDAP.query$MemberData[[1]])
> lat <- openDAP.query$LatLonCoords[ ,1]
> lon <- openDAP.query$LatLonCoords[ ,2]
> # Requires package "akima"
> library(akima)
> filled.contour(interp(lon, lat, mean.field), asp=1,
+               plot.title = title (main = "Mean surface T January 1990-99",ylab = "latitude", xlab = "longitude"),
+               key.title = title(main = "degC"),
+               key.axes = axis(4, seq(-1,16,1)),
+               color.palette = topo.colors)

No image "tracFig.png" attached to udg/ecoms/RPackage/examples