Home

Awesome

convertR: A climate4R package for unit conversion and variable derivation

convertR is an R package performing unit conversion and variable derivation using the climate4R Common Data Model.

Installation and requirements

Physical quantity handling is done via the Unidata's UDUNITS-2 software libraries, tailoring the functionalities of the R package udunits2 to the climate4R framework. Thus, the C-based UDUNITS-2 package must be installed in your system prior to package installation (link to installation instructions).

Then, install_github can be used:

devtools::install_github("SantanderMetGroup/convertR")

Unit conversion

The function udConvertGrid is used for unit conversion. An example follows:

library(convertR)
data("ps.iberia")
transformeR::getGridUnits(ps.iberia)
## [1] "Pascals"
range(ps.iberia$Data)
## [1]  86657.5 105690.0
ps.mmHg <- udConvertGrid(ps.iberia, new.units = "mmHg")
transformeR::getGridUnits(ps.mmHg)
## [1] "mmHg"
range(ps.mmHg$Data)
## [1] 649.9846 792.7401

Derivation of physical quantities

In the following table the available variable derivations are summarized, including the input variables. The nomenclature of the input variables to calculate the derivations is according to the climate4R vocabulary (see loadeR::c4R.vocabulary())

The (*) symbol indicates that the function is planned but not yet available.

functionDefinitionpslpstasdpdstdpszgshusshursrsdsrlds
psl2psSea-level pressure to surface pressureXXX
ps2pslSurface pressure to sea-level pressureXXX
rad2ccRadiation to cloud coverXX
huss2hursSpecific humidity to relative humidityXXX
hurs2hussRelative humidity from specific humidityXXX
tas2wsSaturation vapor pressure from temperatureXX
hurs2wWater vapor mixing ratio from relative humidityXXX
dpds2hurs*Relative humidity from dew-point depressionXXX
tdps2hursRelative humidity from dew-point temperatureXX
hurs2tdpsDew-point temperature from relative humidityXX
huss2pvpPartial vapor pressure from specific humidityXX

The input variables do not require to be in specific units, as all the necessary unit conversions are internally undertaken by the unit converter utility.

<a href="https://unidata.ucar.edu/software/udunits" title="UDUnits"><img src="https://unidata.ucar.edu/images/logos/badges/badge_udunits_100.jpg" width="100px"></a>