wiki:udg/ecoms/RPackage

Version 5 (modified by juaco, 8 years ago) (diff)

--

Overview of the R package under development

Since the R language has been adopted for some key tasks in the EUPORIAS and SPECS projects (including the development of comprehensive validation and statistical-downscaling packages) a R package is currently under development. In the current status of this task, some functions for data exploration and access have been created. These functions allow the creation of accessible datasets from locally stored climate files, the creation of data inventories providing an overview of the characteristics of the data (variables stored, units, time resolution ...) and accessing local and remote datasets in a straightforward manner by means of simple arguments, allowing the retrieval of dimensional slices of observational, reanalysis and forecast (System4) climate data. A full R package with added capabilities (including specific plot methods) and access to new datasets will be soon released for the SPECS/EUPORIAS community, as soon as new databases are incorporated into the SPECS-EUPORIAS THREDDS Data Server and new user's needs and requirements are identified and discussed.

Vocabulary definition

In order to set a common framework with a precise definition of the variables, the R package is based on the use of a vocabulary. Essentially, the vocabulary is simply a table containing the standard names of a number of variables commonly used in impact studies and downscaling applications. The naming conventions and the units are based on the standard name table provided by the NetCDF Climate and Forecast Metadata Convention. The vocabulary consists of a table with:

  • Identifier: this is the standard name that the loading functions require as argument when we set the standard.vars argument to TRUE.
  • Standard_name: standard name of the variable as defined by the CF convention.
  • Units: units in which the standard variable is returned
"identifier","standard_name","units"
"ta","temperature","degrees Celsius"
"tas","2-meter temperature","degrees Celsius"
"tasmax","maximum 2-m temperature","degrees Celsius"
"tasmin","minimum 2-m temperature","degrees Celsius"
"pr","Precipitation amount","mm"
"zg","geopotential_height","m"
"plev","air_pressure","Pa"
"psl","air_pressure_at_sea_level","Pa"
"ps","surface_air_pressure","Pa"
"hus","specific_humidity","kg kg-1"
"hur","relative_humidity","1"
"ua","eastward_wind","m s-1"
"va","northward_wind","m s-1"

Dictionary

The dictionary is a table that defines the conversion between the variables of the model and the standard variables defined in the Vocabulary. The dictionary is a comma-sepparated text file (csv), that is identified with the same name than the dataset, and the extension .dic. In addition, it should be stored in the same directory that the dataset. The creation of the dictionary must be made by the user 'by hand', because it requires knowledge about the characteristics of the data stored in the dataset. The columns of the dictionary are next described:

  • identifier: this is the name of the standard variable, as defined in the vocabulary
  • short_name: this is the name with which the original variable has been coded in the dataset
  • time_step: the time interval between consecutive times in the time dimension axis (in hours)
  • lower_time_bound: lower time bound of the variable
  • upper_time_bound: upper time bound of the variable. For instance, if a variable has identical lower and upper time bounds, it means that it is instantaneous.
  • aggr_fun: time aggregation function. Type of aggregation function applied to the variable between the lower and upper time bound.
  • offset: constant summed to the original variable for units conversion (e.g.: offset = -273.15 for conversion from Kelvin to Celsius)
  • scale: scale factor applied to the original variable for units conversion (e.g.: scale = 0.001 for conversion from m to mm)
  identifier short_name time_step lower_time_bound upper_time_bound aggr_fun  offset scale
1         ta        air        6h                0                0     none -273.15  1.00
2         zg        hgt        6h                0                0     none    0.00  1.00
3        hur       rhum        6h                0                0     none    0.00  0.01
4        hus       shum        6h                0                0     none    0.00  1.00
5        psl        slp        6h                0                0     none    0.00  1.00
6         ua       uwnd        6h                0                0     none    0.00  1.00
7         va       vwnd        6h                0                0     none    0.00  1.00

Note that the names of the columns are important (not so their relative order), because the loadData and loadObservations R functions will perform the conversion of the variable to the standard format by finding the corresponding values by the name of the columns.

Forecast Datasets

There is a special case in which the use of the dictionary is not needed. Because of the large size of the forecast databases, it is assumed that these data will never be locally stored, but accessed through the SPECS-EUPORIAS THREDDS Data Server. For this reason, for instance the variables of the System4 model, loaded via the loadSystem4 function, will always be automatically transformed by the function in order to match the units defined in the vocabulary.

Attachments (9)