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


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

--

Legend:

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

    v28 v29  
    141141+                                      lonLim = -3.81, latLim = 43.43,
    142142+                                      season = 1, years = 1990:1999, leadMonth = 1)
    143 >madridData <- loadSeasonalForecast(dataset = "http://www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml",
     143> madridData <- loadSeasonalForecast(dataset = "http://www.meteo.unican.es/tds5/dodsC/system4/System4_Seasonal_15Members.ncml",
    144144+                                      standard.vars = TRUE, dictionary = "datasets/forecasts/System4/System4_Seasonal_15Members.dic",
    145145+                                      var = "tas", members = 1,
     
    159159
    160160
    161 
    162161= loadObservations =
    163162
    164 
    165 {{{#!comment
    166 setwd("/home/juaco/Desktop/r")
    167 
    168 }}}
    169 
    170163The function `loadObservations` is intended to deal with observational datasets from weather stations stored as csv files in a standard format.
    171 In the directory "./datasets/observations/Iberia_ECA" there is an example dataset.
     164In the directory ''meteoR/datasets/observations/Iberia_ECA'' there is an example dataset.
    172165
    173166{{{
     
    278271
    279272
    280 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:
    281 
    282 {{{
    283 > makeNcmlDataset(source.dir="datasets/reanalysis/Iberia_NCEP/", ncml.file="Iberia_NCEP_dataset.ncml")
     273The 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:
     274
     275{{{
     276> makeNcmlDataset(source.dir="datasets/reanalysis/Iberia_NCEP/", ncml.file="datasets/reanalysis/Iberia_NCEP/Iberia_NCEP.ncml")
    284277[2013-05-20 10:00:51]
    285278NcML file "Iberia_NCEP_dataset.ncml" created from 4 files corresponding to 4 variables
     
    295288
    296289{{{
    297 > inv.iberiaNCEP <- dataInventory("Iberia_NCEP_dataset.ncml")
     290> inv.iberiaNCEP <- dataInventory("datasets/reanalysis/Iberia_NCEP/Iberia_NCEP.ncml")
    298291# Structure of the inventory
    299292> str(inv.iberiaNCEP)
     
    417410[[Image(iberiaNCEPextent.png)]]
    418411
    419 = loadData =
    420 
    421 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.
     412= loadGCM
     413
     414Once 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.
    422415
    423416We have a look again to the description of the variable temperature, as provided by the `dataInventory`:
     
    452445}}}
    453446
    454 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.
    455 
    456 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.
    457 
    458 {{{
    459 > t850 <- loadData(dataset="Iberia_NCEP_dataset.ncml", var="T", level=850, startDate = "1990-01-01", endDate = "1999-12-31")
    460 > str(t850)
     447As 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.
     448
     449There 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.
     450
     451
     452{{{
     453> t850.ncep.iberia <- loadGCM(dataset = "./datasets/reanalysis/Iberia_NCEP/Iberia_NCEP.ncml", standard.vars=TRUE,
     454+        var="ta", lonLim = c(-10,5), latLim = c(35,45), level=850, season=1, years=1990:1999)
     455> str(t850.ncep.iberia)
    461456List of 5
    462  $ VarName     : chr "T"
     457 $ VarName     : chr "ta"
    463458 $ Level       : num 850
    464  $ Dates       : POSIXlt[1:3652], format: "1990-01-01" "1990-01-02" "1990-01-03" "1990-01-04" ...
    465  $ LatLonCoords: num [1:54, 1:2] 35 37.5 40 42.5 45 47.5 35 37.5 40 42.5 ...
     459 $ Dates       :List of 2
     460  ..$ Start: POSIXlt[1:310], format: "1990-01-01" "1990-01-02" "1990-01-03" "1990-01-04" ...
     461  ..$ End  : POSIXlt[1:310], format: "1990-01-01" "1990-01-02" "1990-01-03" "1990-01-04" ...
     462 $ LatLonCoords: num [1:35, 1:2] 35 37.5 40 42.5 45 35 37.5 40 42.5 45 ...
    466463  ..- attr(*, "dimnames")=List of 2
    467464  .. ..$ : NULL
    468465  .. ..$ : chr [1:2] "lat" "lon"
    469  $ Data        : num [1:3652, 1:54] 278 276 276 278 279 ...
    470 
    471 }}}
    472 
    473 
    474 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.
    475 
    476 = Using standard variables via vocabulary and dictionary =
    477 
    478 
    479 
     466 $ Data        : num [1:310, 1:35] 5.95 5.55 0.35 2.05 5.35 ...
     467
     468}}}
     469
     470Note 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''.