-
Notifications
You must be signed in to change notification settings - Fork 59
Accessing Gridded Datasets
Before opening and loading the data, it is advisable to get an overview of the variables stored, time and spatial extent, units etc. This is done by the dataInventory
function, which receives as argument the path to the file storing the data (this can be either a netcdf file or a NcML). In the following examples the built-in dataset in downscaleR
will be illustrated. This dataset comes from the NCEP-NCAR reanalysis encompassing the period 1961-2010 for the Iberian Peninsula domain.
> dataset = "inst/datasets/reanalysis/Iberia_NCEP/Iberia_NCEP.ncml"
> di <- dataInventory(dataset)
[2014-06-03 11:21:22] Doing inventory ...
[2014-06-03 11:21:24] Retrieving info for '2T' (5 vars remaining)
[2014-06-03 11:21:24] Retrieving info for 'SLP' (4 vars remaining)
[2014-06-03 11:21:24] Retrieving info for 'TP' (3 vars remaining)
[2014-06-03 11:21:24] Retrieving info for 'Q' (2 vars remaining)
[2014-06-03 11:21:24] Retrieving info for 'T' (1 vars remaining)
[2014-06-03 11:21:24] Retrieving info for 'Z' (0 vars remaining)
[2014-06-03 11:21:25] Done.
The inventory returns a list named of length n, being n the number of variables stored in the dataset named as the variables:
> names(di)
[1] "2T" "SLP" "TP" "Q" "T" "Z"
For each variable (e.g., Q), the following information is given:
> str(di$Q)
List of 4
$ Description: chr "Specific humidity"
$ DataType : chr "float"
$ Units : chr "kg kg**-1"
$ Dimensions :List of 4
..$ time :List of 4
.. ..$ Type : chr "Time"
.. ..$ TimeStep : chr "1.0 days"
.. ..$ Units : chr "days since 1950-01-01 00:00:00"
.. ..$ Date_range: chr "1961-01-01T00:00:00Z - 2010-12-31T00:00:00Z"
..$ level:List of 3
.. ..$ Type : chr "Pressure"
.. ..$ Units : chr "millibar"
.. ..$ Values: num [1:3] 500 850 1000
..$ lat :List of 3
.. ..$ Type : chr "Lat"
.. ..$ Units : chr "degrees north"
.. ..$ Values: num [1:6] 35 37.5 40 42.5 45 47.5
..$ lon :List of 3
.. ..$ Type : chr "Lon"
.. ..$ Units : chr "degrees east"
.. ..$ Values: num [1:9] -15 -12.5 -10 -7.5 -5 -2.5 0 2.5 5
So Q is specific humidity, and has three vertical levels (500, 800 and 1000 millibar).
In the following example we will load specific humidity at 850 mb level for a selected rectangular domain, considering winter (DJF) for the period 1981-2000.
> example1.grid <- loadGridDataset(dataset = "inst/datasets/reanalysis/Iberia_NCEP/Iberia_NCEP.ncml", var = "hus", lonLim = c(-10,7), latLim=c(36,43), level=850, season=c(12,1,2), years = 1981:2000)
[2014-06-03 11:43:43] - Done.
> str(example1.grid)
List of 6
$ VarName : chr "Q"
$ isStandard : logi TRUE
$ Level : num 850
$ Dates :List of 2
..$ Start: POSIXct[1:1805], format: "1980-12-01" "1980-12-02" "1980-12-03" "1980-12-04" ...
..$ End : POSIXct[1:1805], format: "1980-12-02" "1980-12-03" "1980-12-04" "1980-12-05" ...
$ LonLatCoords:List of 2
..$ x: num [1:7] -10 -7.5 -5 -2.5 0 2.5 5
..$ y: num [1:4] 35 37.5 40 42.5
$ Data : num [1:7, 1:4, 1:1805] 0.00075 0.00043 0.0023 0.00244 0.00067 ...
..- attr(*, "dimensions")= chr [1:3] "lon" "lat" "time"
The output is a N-dimensional array, where N is the number of dimensions depending on the type of request. In this case, the vertical dimension is dropped as it is of length one (850 mb), so the returned array is 3-dimensional, with the dimension names stored as an attribute named "dimensions":
> str(example1.grid$Data)
num [1:7, 1:4, 1:1805] 0.00075 0.00043 0.0023 0.00244 0.00067 ...
- attr(*, "dimensions")= chr [1:3] "lon" "lat" "time"
> attr(example1.grid$Data, "dimensions")
[1] "lon" "lat" "time"
downscaleR - Santander MetGroup (Univ. Cantabria - CSIC)