# Changes between Version 28 and Version 29 of udg/ecoms/RPackage/examples

Ignore:
Timestamp:
May 24, 2013 6:26:57 PM (9 years ago)
Comment:

--

### Legend:

Unmodified
 v28 +                                      lonLim = -3.81, latLim = 43.43, +                                      season = 1, years = 1990:1999, leadMonth = 1) >madridData <- loadSeasonalForecast(dataset = "http://www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml", > madridData <- loadSeasonalForecast(dataset = "http://www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml", +                                      standard.vars = TRUE, dictionary = "datasets/forecasts/System4/System4_Seasonal_15Members.dic", +                                      var = "tas", members = 1, = loadObservations = {{{#!comment setwd("/home/juaco/Desktop/r") }}} The function loadObservations is intended to deal with observational datasets from weather stations stored as csv files in a standard format. In the directory "./datasets/observations/Iberia_ECA" there is an example dataset. In the directory ''meteoR/datasets/observations/Iberia_ECA'' there is an example dataset. {{{ The function makeNcmlDataset is used to conveniently aggregate the required information so that the inventory/loading functions point to the NcML rather that to the netCDF files. The following call to the function wll create the NcML file in the current working directory: {{{ > makeNcmlDataset(source.dir="datasets/reanalysis/Iberia_NCEP/", ncml.file="Iberia_NCEP_dataset.ncml") The function makeNcmlDataset is used to conveniently aggregate the required information so that the inventory/loading functions point to the NcML rather that to the netCDF files. The following call to the function wll create the NcML file in the same directory where the netCDF files are stored: {{{ > makeNcmlDataset(source.dir="datasets/reanalysis/Iberia_NCEP/", ncml.file="datasets/reanalysis/Iberia_NCEP/Iberia_NCEP.ncml") [2013-05-20 10:00:51] NcML file "Iberia_NCEP_dataset.ncml" created from 4 files corresponding to 4 variables {{{ > inv.iberiaNCEP <- dataInventory("Iberia_NCEP_dataset.ncml") > inv.iberiaNCEP <- dataInventory("datasets/reanalysis/Iberia_NCEP/Iberia_NCEP.ncml") # Structure of the inventory > str(inv.iberiaNCEP) [[Image(iberiaNCEPextent.png)]] = loadData = Once the NcML dataset is created and we get an idea of the nature of the variables stored, the loadData function is used to retrieve the variables desired at selected dimensional slices. In this particular example, we will load the temperature data from the NCEP reanalysis in the Iberian Peninsula. = loadGCM Once the NcML dataset is created and we get an idea of the nature of the variables stored, the loadGCM function is used to retrieve the variables desired at selected dimensional slices. Although the name of the function may result somewhat misleading, the function is intended for loading many kinds of gridded datasets, and not only GCM data, including reanalysis, RCM data and observational gridded datasets, for instance. In this particular example, we will load the temperature data from the NCEP reanalysis in the Iberian Peninsula, provided in the example datasets of the meteoR package. We have a look again to the description of the variable temperature, as provided by the dataInventory: }}} As we can see, the variable T has vertical levels. In this case, the only level available is at 850 mb. The variable is daily, as we can see in the TimeStep element of the list, and the original units are Kelvin. There are several options for spatial selection using the loadData function. For instance, if we want the whole domain of the dataset, there is no need for specifying the lonLim and latLim arguments. In the next example, we will load T850 for the whole Iberian Peninsula for the period 1990-1999. {{{ > t850 <- loadData(dataset="Iberia_NCEP_dataset.ncml", var="T", level=850, startDate = "1990-01-01", endDate = "1999-12-31") > str(t850) As we can see, the variable T has vertical levels. In this case, the only level available is at 850 mb. The variable is daily, as we can see in the TimeStep element of the list, and the original units are Kelvin. There are several options for spatial selection using the loadGCM function, as in the case of loadSeasonalForecast. For instance, if we want the whole domain of the dataset, there is no need for specifying the lonLim and latLim arguments. Alternatively, it is possible to select smaller rectangular domains or single points. In the next example, we will load T850 for January in a similar domain than previously with the SYstem4 dataset, centered on the Iberian Peninsula, encompassing the period 1990-1999. {{{ > t850.ncep.iberia <- loadGCM(dataset = "./datasets/reanalysis/Iberia_NCEP/Iberia_NCEP.ncml", standard.vars=TRUE, +        var="ta", lonLim = c(-10,5), latLim = c(35,45), level=850, season=1, years=1990:1999) > str(t850.ncep.iberia) List of 5 $VarName : chr "T"$ VarName     : chr "ta" $Level : num 850$ Dates       : POSIXlt[1:3652], format: "1990-01-01" "1990-01-02" "1990-01-03" "1990-01-04" ... $LatLonCoords: num [1:54, 1:2] 35 37.5 40 42.5 45 47.5 35 37.5 40 42.5 ...$ Dates       :List of 2 ..$Start: POSIXlt[1:310], format: "1990-01-01" "1990-01-02" "1990-01-03" "1990-01-04" ... ..$ End  : POSIXlt[1:310], format: "1990-01-01" "1990-01-02" "1990-01-03" "1990-01-04" ... $LatLonCoords: num [1:35, 1:2] 35 37.5 40 42.5 45 35 37.5 40 42.5 45 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : NULL .. ..$: chr [1:2] "lat" "lon"$ Data        : num [1:3652, 1:54] 278 276 276 278 279 ... }}} The matrix in the Data element of the returned list contains a matrix with 54 columns, one for each grid point of the dataset, and 3652 rows, corresponding to the daily time series. = Using standard variables via vocabulary and dictionary = \$ Data        : num [1:310, 1:35] 5.95 5.55 0.35 2.05 5.35 ... }}} Note that in this particular case, we are loading standard variables, as defined in the vocabulary (by setting the argument standard.vars = TRUE), but we did not specify a path to the dictionary (default to NULL). By default, the function searches the dictionary in the same directory where the ''ncml'' file has been created, assuming that this is a file with extension ''.dic'' and the same name as the ''ncml''.