JGCRI / fldgen

Given a global mean temperature pathway, generate random global climate fields consistent with it and with spatial and temporal correlation derived from an ESM
https://jgcri.github.io/fldgen/
GNU General Public License v2.0
12 stars 6 forks source link
climate climate-science climate-variability downscaling

fldgen 2.0: Climate variable field generator with internal variability and spatial, temporal, and inter-variable correlation.

Travis-CI Build Status AppVeyor Build Status Coverage Status DOI

The fldgen package provides functions to learn the spatial, temporal, and inter-variable correlation of the variability in an earth system model (ESM) and generate random two-variable fields (e.g., temperature and precipitation) with equivalent properties.

Installation

The easiest way to install fldgen is using install_github from the devtools package.

install_github('JGCRI/fldgen', build_vignettes=TRUE)

This will get you the latest stable development version of the model. If you wish to install a specific release, you can do so by specifying the desired release as the ref argument to this function call.
Current and past releases are listed in the release table at our GitHub repository.

Example

The data used in this example are installed with the package. They can be found in system.file('extdata', package='fldgen').

library(fldgen)
datadir <- system.file('extdata', package='fldgen')

infileT <- file.path(datadir, 'tas_annual_esm_rcp_r2i1p1_2006-2100.nc')
infileP <- file.path(datadir, 'pr_annual_esm_rcp_r2i1p1_2006-2100.nc')
emulator <- trainTP(c(infileT, infileP),
                    tvarname = "tas", tlatvar='lat', tlonvar='lon',
                    tvarconvert_fcn = NULL,
                    pvarname = "pr", platvar='lat', plonvar='lon',
                    pvarconvert_fcn = log)

residgrids <- generate.TP.resids(emulator, ngen = 3)

fullgrids <- generate.TP.fullgrids(emulator, residgrids,
                                   tgav = tgav,
                                   tvarunconvert_fcn = NULL,
                                   pvarunconvert_fcn = exp,
                                   reconstruction_function = pscl_apply)

A more detailed example can be found in the tutorial vignette included with the package.

vignette('tutorial2','fldgen')