Coder Social home page Coder Social logo

santandermetgroup / convertr Goto Github PK

View Code? Open in Web Editor NEW
0.0 9.0 1.0 487 KB

A climate4R package for unit conversion and variable derivation

Home Page: https://github.com/SantanderMetGroup/climate4R

License: GNU General Public License v3.0

R 100.00%

convertr's Introduction

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.

function Definition psl ps tas dpds tdps zgs huss hurs rsds rlds
psl2ps Sea-level pressure to surface pressure X X X
ps2psl Surface pressure to sea-level pressure X X X
rad2cc Radiation to cloud cover X X
huss2hurs Specific humidity to relative humidity X X X
hurs2huss Relative humidity from specific humidity X X X
tas2ws Saturation vapor pressure from temperature X X
hurs2w Water vapor mixing ratio from relative humidity X X X
dpds2hurs* Relative humidity from dew-point depression X X X
tdps2hurs Relative humidity from dew-point temperature X X
hurs2tdps Dew-point temperature from relative humidity X X
huss2pvp Partial vapor pressure from specific humidity X X

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.

convertr's People

Contributors

jbedia avatar miturbide avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

cofinoa

convertr's Issues

precipitation conversion

Hi,

a very common conversion for precipitation is from kg/m2/s to mm/day. This currently fails as the water density is required to convert the kg into volume.

One final attempt to convert the units could be included for precipitation variables here:

if (!ud.are.convertible(u1[x], new.units[x])) stop("Non-convertible units \'ud.are.convertible\' returned FALSE)")

Simply by multiplying the units by the specific volume of water (1 l/kg):

> ud.convert(1, "kg/m^2/s", "mm/day")
Error in ud.convert(1, "kg/m^2/s", "mm/day") :
  Units kg/m^2/s and mm/day are not convertible
> ud.convert(1, "kg/m^2/s*l/kg", "mm/day")
[1] 86400

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.