├── HowToMakeRpackage_LPJmL-MDI.R ├── LICENSE ├── LPJmLmdi.Rproj ├── LPJmLmdi ├── .Rhistory ├── DESCRIPTION ├── NAMESPACE ├── R │ ├── AggFun.R │ ├── AggregateNCDF.R │ ├── AllEqual.R │ ├── BarplotCost.R │ ├── BreakColours.R │ ├── Breaks.R │ ├── Cbalance.R │ ├── ChangeParamFile.R │ ├── ChangeSoilCodeFile.R │ ├── CheckLPJpar.R │ ├── CheckMemoryUsage.R │ ├── CombineLPJpar.R │ ├── CombineRescueFiles.R │ ├── CorrelationMatrixS.R │ ├── CostMDS.KGE.R │ ├── CostMDS.KGEw.R │ ├── CostMDS.SSE.R │ ├── CreateRestartFromRescue.R │ ├── DefaultParL.R │ ├── Df2optim.R │ ├── EstOptimUse.R │ ├── FileExistsWait.R │ ├── GridProperties.R │ ├── InfoCLM.R │ ├── InfoLPJ.R │ ├── InfoNCDF.R │ ├── IntegrationData.R │ ├── IntegrationData2Df.R │ ├── IntegrationDataset.R │ ├── LE2ET.R │ ├── LPJ2NCDF.R │ ├── LPJfiles.R │ ├── LPJpar.R │ ├── LPJparList.R │ ├── LPJpp.R │ ├── LPJppNBP.R │ ├── LWin2LWnet.R │ ├── LegendBar.R │ ├── MeanW.R │ ├── OptimizeLPJgenoud.R │ ├── PlotPar.R │ ├── PlotParPCA.R │ ├── PlotParUnc.R │ ├── PlotWorld110.R │ ├── PrepareRestartFiles.R │ ├── ReadBIN.R │ ├── ReadCLM.R │ ├── ReadGrid.R │ ├── ReadLPJ.R │ ├── ReadLPJ2IntegrationData.R │ ├── ReadLPJ2ts.R │ ├── ReadLPJinput.R │ ├── ReadLPJsim.R │ ├── ReadOutputvars.R │ ├── ReadPRO.R │ ├── RegridLPJinput.R │ ├── Rescue2Df.R │ ├── Rescue2LPJpar.R │ ├── RunLPJ.R │ ├── SSE.R │ ├── StandardError.R │ ├── StartingValues.R │ ├── Texture2Soilcode.R │ ├── Turnover.R │ ├── VarCovMatrix.R │ ├── WriteBIN.R │ ├── WriteCLM.R │ ├── WriteGrid.R │ ├── WriteLPJinput.R │ ├── WriteLPJpar.R │ ├── WriteNCDF4.R │ ├── plot.IntegrationData.R │ ├── plot.LPJpar.R │ ├── plot.LPJsim.R │ └── plot.rescue.R ├── data │ └── data110.RData ├── html │ ├── 00Index.html │ ├── AggFPCBoBS.html │ ├── AggFPCBoNE.html │ ├── AggFPCBoNS.html │ ├── AggFPCPoH.html │ ├── AggFPCTeBE.html │ ├── AggFPCTeBS.html │ ├── AggFPCTeH.html │ ├── AggFPCTeNE.html │ ├── AggFPCTrBE.html │ ├── AggFPCTrBR.html │ ├── AggMSC.html │ ├── AggMaxNULL.html │ ├── AggMeanMean.html │ ├── AggMeanNULL.html │ ├── AggNULLMean.html │ ├── AggQ09NULL.html │ ├── AggSumMean.html │ ├── AggSumNULL.html │ ├── AllEqual.html │ ├── BarplotCost.html │ ├── ChangeParamFile.html │ ├── ChangeSoilCodeFile.html │ ├── CheckLPJpar.html │ ├── CheckMemoryUsage.html │ ├── CombineRescueFiles.html │ ├── CorrelationMatrixS.html │ ├── CostMDS.KGE.html │ ├── CostMDS.KGEw.html │ ├── CostMDS.SSE.html │ ├── CreateRestartFromRescue.html │ ├── DefaultParL.html │ ├── Df2optim.html │ ├── EstOptimUse.html │ ├── FileExistsWait.html │ ├── GridProperties.html │ ├── InfoCLM.html │ ├── InfoLPJ.html │ ├── IntegrationData.html │ ├── IntegrationDataset.html │ ├── LE2ET.html │ ├── LPJfiles.html │ ├── LPJmLmdi-package.html │ ├── LPJpar.html │ ├── LWin2LWnet.html │ ├── OptimizeLPJgenoud.html │ ├── PlotPar.html │ ├── PlotParPCA.html │ ├── PlotWorld110.html │ ├── PrepareRestartFiles.html │ ├── R.css │ ├── ReadBIN.html │ ├── ReadCLM.html │ ├── ReadGrid.html │ ├── ReadLPJ.html │ ├── ReadLPJ2IntegrationData.html │ ├── ReadLPJ2ts.html │ ├── ReadLPJinput.html │ ├── ReadLPJsim.html │ ├── ReadOutputvars.html │ ├── ReadPRO.html │ ├── Rescue2Df.html │ ├── Rescue2LPJpar.html │ ├── RunLPJ.html │ ├── SSE.html │ ├── StandardError.html │ ├── StartingValues.html │ ├── Texture2Soilcode.html │ ├── VarCovMatrix.html │ ├── WriteBIN.html │ ├── WriteCLM.html │ ├── WriteGrid.html │ ├── WriteLPJinput.html │ ├── WriteLPJpar.html │ ├── plot.IntegrationData.html │ ├── plot.LPJpar.html │ ├── plot.LPJsim.html │ └── plot.rescue.html ├── inst_LPJmL35 │ ├── LPJmL-MDI_example.R │ ├── LPJmL_OFPC_parameters.csv │ ├── input_template.conf │ ├── lpjml_template.conf │ ├── param_template.conf │ ├── param_template.par │ ├── parameters_prior.txt │ └── pft_template.par ├── inst_gldas │ ├── LPJmL-MDI_example_gldas.R │ ├── LPJmL_parameter-table.csv │ ├── LPJmL_parameter-table.xlsx │ ├── input_template.js │ ├── lpjml_template.js │ ├── lpjparam_template.js │ ├── param_template.js │ └── pft_template.js └── man │ ├── AggFPCBoBS.Rd │ ├── AggFPCBoNE.Rd │ ├── AggFPCBoNS.Rd │ ├── AggFPCPoH.Rd │ ├── AggFPCTeBE.Rd │ ├── AggFPCTeBS.Rd │ ├── AggFPCTeH.Rd │ ├── AggFPCTeNE.Rd │ ├── AggFPCTrBE.Rd │ ├── AggFPCTrBR.Rd │ ├── AggMSC.Rd │ ├── AggMaxNULL.Rd │ ├── AggMeanMean.Rd │ ├── AggMeanNULL.Rd │ ├── AggNULLMean.Rd │ ├── AggQ09NULL.Rd │ ├── AggSumMean.Rd │ ├── AggSumNULL.Rd │ ├── AggregateNCDF.Rd │ ├── AllEqual.Rd │ ├── BarplotCost.Rd │ ├── BreakColors.Rd │ ├── BreakColours.Rd │ ├── Breaks.Rd │ ├── Cbalance.Rd │ ├── ChangeParamFile.Rd │ ├── ChangeSoilCodeFile.Rd │ ├── CheckLPJpar.Rd │ ├── CheckMemoryUsage.Rd │ ├── CombineLPJpar.Rd │ ├── CombineRescueFiles.Rd │ ├── CorW.Rd │ ├── CorrelationMatrixS.Rd │ ├── CostMDS.KGE.Rd │ ├── CostMDS.KGEw.Rd │ ├── CostMDS.SSE.Rd │ ├── CreateRestartFromRescue.Rd │ ├── DefaultParL.Rd │ ├── Df2optim.Rd │ ├── EstOptimUse.Rd │ ├── FileExistsWait.Rd │ ├── GridProperties.Rd │ ├── InfoCLM.Rd │ ├── InfoLPJ.Rd │ ├── InfoNCDF.Rd │ ├── IntegrationData.Rd │ ├── IntegrationData2Df.Rd │ ├── IntegrationDataset.Rd │ ├── LE2ET.Rd │ ├── LPJ2NCDF.Rd │ ├── LPJfiles.Rd │ ├── LPJmLmdi-package.Rd │ ├── LPJpar.Rd │ ├── LPJparList.Rd │ ├── LPJpp.Rd │ ├── LPJppNBP.Rd │ ├── LWin2LWnet.Rd │ ├── LegendBar.Rd │ ├── MeanW.Rd │ ├── OptimizeLPJgenoud.Rd │ ├── PlotPar.Rd │ ├── PlotParPCA.Rd │ ├── PlotParUnc.Rd │ ├── PlotWorld110.Rd │ ├── PrepareRestartFiles.Rd │ ├── ReadBIN.Rd │ ├── ReadCLM.Rd │ ├── ReadGrid.Rd │ ├── ReadLPJ.Rd │ ├── ReadLPJ2IntegrationData.Rd │ ├── ReadLPJ2ts.Rd │ ├── ReadLPJinput.Rd │ ├── ReadLPJsim.Rd │ ├── ReadOutputvars.Rd │ ├── ReadPRO.Rd │ ├── RegridLPJinput.Rd │ ├── Rescue2Df.Rd │ ├── Rescue2LPJpar.Rd │ ├── RunLPJ.Rd │ ├── SSE.Rd │ ├── SdW.Rd │ ├── StandardError.Rd │ ├── StartingValues.Rd │ ├── Texture2Soilcode.Rd │ ├── Turnover.Rd │ ├── VarCovMatrix.Rd │ ├── VarW.Rd │ ├── WriteBIN.Rd │ ├── WriteCLM.Rd │ ├── WriteGrid.Rd │ ├── WriteLPJinput.Rd │ ├── WriteLPJpar.Rd │ ├── WriteNCDF4.Rd │ ├── plot.Cbalance.Rd │ ├── plot.IntegrationData.Rd │ ├── plot.LPJpar.Rd │ ├── plot.LPJparList.Rd │ ├── plot.LPJsim.Rd │ └── plot.rescue.Rd ├── LPJmLmdi_1.0.tar.gz ├── LPJmLmdi_1.1.tar.gz ├── LPJmLmdi_1.2.tar.gz ├── LPJmLmdi_1.3.tar.gz ├── LPJmLmdi_1.31.tar.gz ├── LPJmLmdi_overview.ppt ├── MANUAL.pdf ├── R.sh ├── README.md └── slurm_opt.jcf /HowToMakeRpackage_LPJmL-MDI.R: -------------------------------------------------------------------------------- 1 | #-------------------------------------------- 2 | # Building and installation of an R package: 3 | # Matthias Forkel, 2017-08-02 4 | #-------------------------------------------- 5 | 6 | # package development is based on inlinedocs (for in-line documentation) 7 | library(inlinedocs) 8 | library(here) 9 | 10 | # name and directory of package 11 | pkg.name <- "LPJmLmdi" 12 | path <- paste(here::here(), sep="/") 13 | 14 | 15 | # BUILDING 16 | #--------- 17 | 18 | # Building is only required if you further develop the package, i.e. if you want to newly 19 | # create help files and perform tests. Continue with the next section if you just downloaded 20 | # the package and you want to install it. 21 | 22 | # build package structure and Rd files 23 | setwd(path) 24 | package.skeleton.dx(pkg.name) 25 | 26 | # check package 27 | cmd <- sprintf(paste("%s CMD check --as-cran", pkg.name), file.path(R.home("bin"), "R")) 28 | system(cmd, intern=TRUE) 29 | 30 | # build package 31 | cmd <- sprintf(paste("%s CMD build --resave-data", pkg.name), file.path(R.home("bin"), "R")) 32 | system(cmd, intern=TRUE) 33 | 34 | 35 | # INSTALLATION 36 | #------------- 37 | 38 | # installation 39 | cmd <- paste("R CMD INSTALL --html", pkg.name, "--resave-data") 40 | tryCatch(system(cmd), finally=setwd(path)) 41 | 42 | # load package 43 | library(pkg.name, character.only=TRUE) 44 | 45 | # check package help files: 46 | ?OptimizeLPJgenoud 47 | 48 | 49 | -------------------------------------------------------------------------------- /LPJmLmdi.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | -------------------------------------------------------------------------------- /LPJmLmdi/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: LPJmLmdi 2 | Title: Model-Data Integration for the LPJmL Dynamic Global Vegetation Model 3 | Version: 1.3.1 4 | Date: 2019-01-22 5 | Author: Matthias Forkel [aut, cre], Markus Drüke [aut] 6 | Maintainer: Matthias Forkel , Markus Drüke 7 | Description: Model-data integration framework for the LPJmL dynamic global vegetation model. Specifically, the package provides functions 1) to optimize LPJmL model parameters using the GENOUD genetic optimization algorithm, 2) to read and write LPJmL input data, and 3) to read LPJmL output files. 8 | Depends: R (>= 2.15.3), raster, plyr, rgenoud, ncdf4, ModelDataComp 9 | Imports: dplyr, plotrix, fields, tidyr 10 | License: GPL-2 11 | LazyLoad: yes 12 | Encoding: UTF-8 13 | -------------------------------------------------------------------------------- /LPJmLmdi/NAMESPACE: -------------------------------------------------------------------------------- 1 | importFrom("plotrix", "color.legend") 2 | importFrom("tidyr", "separate", "unite", "gather") 3 | importFrom("RColorBrewer", "brewer.pal") 4 | exportPattern("^[[:alpha:]]+") 5 | 6 | -------------------------------------------------------------------------------- /LPJmLmdi/R/AllEqual.R: -------------------------------------------------------------------------------- 1 | AllEqual <- structure(function( 2 | ##title<< 3 | ## Check if all values in a vector are the same 4 | ##description<< 5 | ## This function is used to check if all values in a vector are equal. It can be used for example to check if a time series contains only 0 or NA values. 6 | 7 | x 8 | ### numeric, character vector, or time series of type ts 9 | ) { 10 | res <- FALSE 11 | x <- na.omit(as.vector(x)) 12 | if (length(unique(x)) == 1 | length(x) == 0) res <- TRUE 13 | return(res) 14 | ### The function returns TRUE if all values are equal and FALSE if it contains different values. 15 | },ex=function(){ 16 | # check if all values are equal in the following vectors: 17 | AllEqual(1:10) 18 | AllEqual(rep(0, 10)) 19 | AllEqual(letters) 20 | AllEqual(rep(NA, 10)) 21 | }) 22 | -------------------------------------------------------------------------------- /LPJmLmdi/R/BreakColours.R: -------------------------------------------------------------------------------- 1 | BreakColours <- BreakColors <- structure(function( 2 | ##title<< 3 | ## Colours from class breaks 4 | ##description<< 5 | ## Creates colour palettes from a vector of class breaks 6 | 7 | x, 8 | ### numeric vector of class breaks 9 | 10 | pal = NULL, 11 | ### name of a colour palette from \code{\link{brewer.pal}} 12 | 13 | rev = FALSE, 14 | ### should the colour palette be reversed? 15 | 16 | cols = NULL, 17 | ### alternatively, a colour vector to be interpolated 18 | 19 | ... 20 | ### Further arguments (unused) 21 | 22 | ##details<< 23 | ## No details. 24 | 25 | ##references<< No reference. 26 | 27 | ##seealso<< 28 | ## \code{\link{BreakColours}} 29 | ){ 30 | if (is.null(pal)) { 31 | if (any(x < 0) & any(x > 0)) { 32 | pal <- "RdBu" 33 | } else { 34 | pal <- "OrRd" 35 | } 36 | } 37 | if (is.null(cols)) { 38 | suppressWarnings(cols <- brewer.pal(11, pal)) 39 | } 40 | if (rev) cols <- rev(cols) 41 | .fun <- colorRampPalette(cols) 42 | cols <- .fun(length(x)-1) 43 | 44 | return(cols) 45 | ### The function returns a vector of colours. 46 | }, ex=function() { 47 | 48 | brks1 <- seq(0, 10, 2) 49 | cols1 <- BreakColours(brks1) 50 | 51 | brks2 <- seq(-100, 100, 25) 52 | cols2 <- BreakColours(brks2) 53 | 54 | brks3 <- seq(-100, 100, 25) 55 | cols3 <- BreakColours(brks3, pal="BrBG") 56 | 57 | brks4 <- seq(0, 10, 1) 58 | cols4 <- BreakColours(brks4, cols=c("red", "green", "blue"), rev=TRUE) 59 | 60 | MapRb() 61 | LegendBarRb(brks=brks1, cols=cols1) 62 | LegendBarRb(brks=brks2, cols=cols2, pos="top", lon = c(-180, 180), lat = c(-20, -15)) 63 | LegendBarRb(brks=brks3, cols=cols3, pos="inside", lon = c(-180, 180), lat = c(15, 20)) 64 | LegendBarRb(brks=brks4, cols=cols4, pos="inside", lon = c(-180, 180), lat = c(30, 35)) 65 | 66 | }) 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /LPJmLmdi/R/Breaks.R: -------------------------------------------------------------------------------- 1 | Breaks <- structure(function( 2 | ##title<< 3 | ## Class breaks for plotting 4 | ##description<< 5 | ## Calculates class breakpoints based on quantiles. 6 | 7 | x, 8 | ### numeric vector 9 | 10 | n=12, 11 | ### number of breaks 12 | 13 | quantile=c(0.01, 0.99), 14 | ### lower and upper quantiles that should be used to exclude outliers 15 | 16 | zero.min=FALSE, 17 | ### should the minimum break be at 0? 18 | 19 | ... 20 | ### Further arguments (unused) 21 | 22 | ##details<< 23 | ## No details. 24 | 25 | ##references<< No reference. 26 | 27 | ##seealso<< 28 | ## \code{\link{BreakColours}} 29 | ){ 30 | x <- na.omit(as.vector(x)) 31 | 32 | # are all values the same? 33 | equal <- FALSE 34 | if (length(unique(x)) == 1 | length(x) == 0) equal <- TRUE 35 | 36 | if (equal) { 37 | brks <- c(NA, NA) 38 | } else { 39 | ext <- quantile(x, prob=quantile, na.rm=TRUE) 40 | x[x < ext[1]] <- ext[1] 41 | x[x > ext[2]] <- ext[2] 42 | if (any(ext < 0) & any(ext > 0) & (zero.min == FALSE)) { 43 | ext <- max(abs(ext)) 44 | brks <- c(ext * -1, x, ext) 45 | } else { 46 | brks <- x 47 | } 48 | brks <- pretty(brks, n=n) 49 | } 50 | return(brks) 51 | ### The function returns a vector of values. 52 | }, ex=function() { 53 | 54 | Breaks(rnorm(100, 50, 30)) 55 | Breaks(runif(100, 10, 30)) 56 | Breaks(rlnorm(100)) 57 | 58 | }) 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /LPJmLmdi/R/ChangeParamFile.R: -------------------------------------------------------------------------------- 1 | ChangeParamFile <- structure(function( 2 | ##title<< 3 | ## Change parameters in a parameter file 4 | ##description<< 5 | ## The function writes values to a parameter file. It requires a 'file.template' in which the positions of the new parameter values are marked with a flag. For example, instead of a parameter of 0.5 for alphaa in a parameter file the flag ALPHAA is written. The function substitutes this flag with the new parameter value in a new file 'file.new'. 6 | 7 | newpar, 8 | ### a named vector with new parameter values 9 | 10 | file.template, 11 | ### file name of the template parameter with flagged parameters 12 | 13 | file.new, 14 | ### file name of the new parameter file 15 | 16 | wait=FALSE, 17 | ### If TRUE wait 1 second to check if file.template exists in order to relax slow file writting. 18 | 19 | ... 20 | ### further arguments (currently not used) 21 | 22 | ##details<< 23 | ## The function works only on Unix systems because it is based on 'sed' 24 | 25 | ##references<< No reference. 26 | 27 | ) { 28 | 29 | if (wait) { 30 | check <- FileExistsWait(file.template, waitmin=0, waitinterval=0.5, waitmax=1) 31 | if (!check) stop(paste(file.template, "does not exist after waiting.", file.new, "is not produced.")) 32 | } 33 | 34 | if (length(newpar) == 1) { 35 | sed <- paste("sed 's;", names(newpar), ";", newpar, ";g' ", file.template, " > ", file.new, 36 | sep="") 37 | } else { 38 | sed <- paste("sed -e", paste(paste("'s;", names(newpar), ";", newpar, ";'", sep=""), collapse=" -e"), "<", file.template, ">", file.new) 39 | } 40 | #sed 41 | system(sed) 42 | }, ex=function() { 43 | 44 | # newpar <- c(ALPHAA_BoNE=0.8) 45 | # LPJChangeParamFile(newpar, file.template="pft_template.par", file.new="pft.par") 46 | 47 | }) 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /LPJmLmdi/R/ChangeSoilCodeFile.R: -------------------------------------------------------------------------------- 1 | ChangeSoilCodeFile <- structure(function( 2 | ##title<< 3 | ## Change soil code in LPJ soil code file 4 | ##description<< 5 | ## The function changes the soil code for the specified grid cells and writes a new LPJ soil code file. 6 | 7 | file.soilcode, 8 | ### original soil code file 9 | 10 | file.soilcode.new, 11 | ### new soil code file 12 | 13 | xy, 14 | ### matrix of grid cells (lon, lat) where the soil code should be changed 15 | 16 | newcode, 17 | ### new soil code at each grid cell (vector with length = nrow(xy)) 18 | 19 | file.grid="cru.grid", 20 | ### grid file for the original soil code file 21 | 22 | ... 23 | ### further arguments (currently not used) 24 | 25 | ##details<< 26 | ## No details. 27 | 28 | ##references<< No reference. 29 | 30 | ##seealso<< 31 | ## \code{\link{ReadBIN}} 32 | ) { 33 | 34 | 35 | # read soilcode file 36 | data.sp <- ReadBIN(file.soilcode, file.grid=file.grid) 37 | grid <- ReadGrid(file.grid) 38 | 39 | # check which grid cells to change 40 | xy.all <- grid 41 | change <- NULL 42 | for (i in 1:nrow(xy)) { 43 | change <- c(change, intersect(which(xy[i,1] == xy.all[,1]), which(xy[i,2] == xy.all[,2]))) 44 | } 45 | 46 | # change soilcode values 47 | if (length(change) > 0) { 48 | data.sp@data[change, ] <- newcode 49 | #plot(data.r) 50 | } 51 | 52 | # write new soilcode file 53 | WriteBIN(data.sp, file.soilcode.new) 54 | }) 55 | 56 | 57 | -------------------------------------------------------------------------------- /LPJmLmdi/R/CheckMemoryUsage.R: -------------------------------------------------------------------------------- 1 | CheckMemoryUsage <- structure(function( 2 | ##title<< 3 | ## Check usage of memory by R objects 4 | ##description<< 5 | ## Prints a message about the used memory and writes a file with the used memory per each R object. 6 | 7 | ... 8 | ### The function has no arguments. 9 | 10 | ##details<< 11 | ## 12 | 13 | ) { 14 | obj <- unique(c(ls(), ls(envir=.GlobalEnv))) 15 | siz <- sapply(obj, function(x){object.size(get(x))}) 16 | siz <- sort(siz) 17 | use.df <- data.frame(obj=names(siz), byte=siz, GB=signif(siz*1e-9, 4)) 18 | rownames(use.df) <- 1:nrow(use.df) 19 | write.table(use.df, file="memory_usage.txt") 20 | return(use.df) 21 | ### a data.frame 22 | }) 23 | -------------------------------------------------------------------------------- /LPJmLmdi/R/CombineLPJpar.R: -------------------------------------------------------------------------------- 1 | CombineLPJpar <- structure(function( 2 | ##title<< 3 | ## Combines several 'LPJpar' objects into one 4 | ##description<< 5 | ## The function takes several lpjpar objects and combines them into one LPJpar object 6 | 7 | lpjpar.l 8 | ### a list of \code{\link{LPJpar}} objects 9 | 10 | ##details<< 11 | ## No details. 12 | 13 | ##references<< No reference. 14 | 15 | ##seealso<< 16 | ## \code{\link{LPJpar}} 17 | ) { 18 | names <- sort(unique(unlist(llply(lpjpar.l, function(x) x$names)))) 19 | npar <- length(names) 20 | lpjpar2 <- list(names=names) 21 | for (i in 1:length(lpjpar.l)) { 22 | # which parameters were optimized? 23 | is.opt <- !is.na(lpjpar.l[[i]]$uncertainty.iqr) 24 | m1 <- match(lpjpar.l[[i]]$names, names) 25 | m2 <- match(lpjpar.l[[i]]$names[is.opt], names) 26 | for (j in 2:length(lpjpar.l[[i]])) { 27 | colmn <- names(lpjpar.l[[i]])[j] 28 | if (is.null(lpjpar2[[colmn]])) { 29 | vals <- rep(NA, npar) 30 | } else { 31 | vals <- lpjpar2[[colmn]] 32 | } 33 | if (colmn == "prior" | colmn == "upper" | colmn == "lower" | colmn == "pftspecif") { 34 | vals[m1] <- lpjpar.l[[i]][[j]] # take all parameters 35 | if (colmn == "prior" & i == 1) { 36 | lpjpar2$best <- lpjpar2$best.median <- vals 37 | } 38 | } else { 39 | vals[m2] <- lpjpar.l[[i]][[j]][is.opt] # take only optimized parameters 40 | } 41 | names(vals) <- names 42 | lpjpar2[[colmn]] <- vals 43 | } 44 | } 45 | class(lpjpar2) <- "LPJpar" 46 | return(lpjpar2) 47 | ### The function returns a list of class 'LPJparList' 48 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/CorrelationMatrixS.R: -------------------------------------------------------------------------------- 1 | CorrelationMatrixS <- structure(function( 2 | ##title<< 3 | ## plot a correlation matrix 4 | ##description<< 5 | ## 6 | 7 | data, 8 | ### a correlation matrix or a data.frame ( 9 | 10 | method = "spearman", 11 | ### method to compute the correlation 12 | 13 | iscor=NULL, 14 | ### Is 'data' a correlation matrix? 15 | 16 | main="", 17 | ### main title for the plot 18 | 19 | ... 20 | ### further arguments for \code{\link{plot}} 21 | 22 | ##details<< 23 | ## No details. 24 | 25 | ##references<< No reference. 26 | 27 | ##seealso<< 28 | ## \code{\link{CombineRescueFiles}} 29 | ) { 30 | require(fields) 31 | if (is.null(iscor)) { 32 | iscor <- FALSE 33 | if (colnames(data) == rownames(data)) { 34 | iscor <- TRUE 35 | } 36 | } 37 | if (!iscor) { 38 | m <- as.matrix(data) 39 | m <- apply(m, 2, as.numeric) 40 | r <- cor(m, method=method, use="pairwise.complete.obs") 41 | } else { 42 | r <- data 43 | } 44 | r2 <- r 45 | for (i in 1:nrow(r2)) r2[i, i] <- NA 46 | brks <- pretty(r2, 8) 47 | brks <- pretty(seq(max(abs(brks))*-1, max(abs(brks)), length=10), 8) 48 | .fun <- colorRampPalette(rev(brewer.pal(11, "RdBu"))) 49 | cols <- .fun(length(brks)-1) 50 | 51 | p <- par() 52 | DefaultParL() 53 | par(las=2, oma=c(5,5,1,1), mar=c(5, 5, 1, 1), fig=c(0, 0.85, 0, 1), new=FALSE) 54 | image(r, col=cols, breaks=brks, axes=FALSE, main=main) 55 | abline(0,1) 56 | x <- seq(0, 1, length=nrow(r)) 57 | axis(1, at=x, rownames(r)) 58 | axis(2, at=x, rownames(r)) 59 | if (ncol(r) <= 10) { 60 | xy <- expand.grid(x, x) 61 | r[is.nan(r)] <- NA 62 | text(xy[,1], xy[,2], signif(r, 2)) 63 | } 64 | box() 65 | par(fig=c(0.85, 1, 0, 1), mar=c(0.5, 0.5, 0.5, 3), new=TRUE) 66 | plot.new() 67 | image.plot(legend.only=TRUE, col=cols, breaks=brks, zlim=c(-1,1), lab.breaks=brks, smallplot=c(0, 0.3, 0.15, 0.9)) 68 | par(p) 69 | return(r) 70 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/DefaultParL.R: -------------------------------------------------------------------------------- 1 | DefaultParL <- structure(function( 2 | ##title<< 3 | ## default 'par' settings for plots 4 | ##description<< 5 | ## The function calls 'par' with some default settings to improve plots. See \code{\link{par}} for details. 6 | 7 | mfrow=c(1,1), 8 | ### number of rows/columns 9 | 10 | mar=c(3.7, 3.5, 2.5, 0.5), 11 | ### margins 12 | 13 | oma=c(0.8, 0.1, 0.1, 0.2), 14 | ### outer margins 15 | 16 | mgp=c(2.4, 1, 0), 17 | ### margin line for axis title, label and lines 18 | 19 | cex=1.3, 20 | ### text and symbol size 21 | 22 | cex.lab=cex*1.1, 23 | ### label size 24 | 25 | cex.axis=cex*1.1, 26 | ### axis anootation size 27 | 28 | cex.main=cex*1.1, 29 | ### title size 30 | 31 | ... 32 | ### further arguments to \code{\link{par}} 33 | 34 | ##details<< 35 | ## No details. 36 | 37 | ##references<< No reference. 38 | 39 | ##seealso<< 40 | ## \code{\link{par}} 41 | 42 | ) { 43 | par(mfrow=mfrow, mar=mar, mgp=mgp, cex.lab=cex.lab, cex.axis=cex.axis, cex.main=cex.main, oma=oma, ...) 44 | 45 | }, ex=function() { 46 | 47 | DefaultParL() 48 | plot(1:10) 49 | 50 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/EstOptimUse.R: -------------------------------------------------------------------------------- 1 | EstOptimUse <- structure(function( 2 | ##title<< 3 | ## Estimate optimal number of jobs given a number of cluster nodes 4 | 5 | nodes=16, 6 | ### number of cluster nodes that you want to use 7 | 8 | wish=1000 9 | ### approx. number of elements 10 | 11 | ##details<< 12 | ## No details. 13 | 14 | ##references<< No reference. 15 | 16 | ##seealso<< 17 | ## \code{\link{WriteCLM}} 18 | 19 | ) { 20 | real <- as.integer(ceiling(wish / nodes)) 21 | r <- real * nodes 22 | return(r) 23 | ### an integer value 24 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/FileExistsWait.R: -------------------------------------------------------------------------------- 1 | FileExistsWait <- structure(function( 2 | ##title<< 3 | ## Iterative checking and waiting for a file. 4 | ##description<< 5 | ## The function repeately checks if a file exists and returns TRUE if the file is existing. 6 | 7 | file, 8 | ### file for which checking and waiting should be applied 9 | 10 | waitmin=0, 11 | ### minimum waiting time (seconds) 12 | 13 | waitinterval=0.5, 14 | ### interval after which the existence of the file should be checked again (seconds) 15 | 16 | waitmax=2, 17 | ### maximum waiting time (seconds) 18 | 19 | ... 20 | ### further arguments (currently not used) 21 | 22 | ##details<< 23 | ## No details. 24 | 25 | ##references<< No reference. 26 | ) { 27 | Sys.sleep(waitmin) # minimum waiting time 28 | if (all(file.exists(file))) { 29 | return(TRUE) 30 | } else { 31 | # repeat checking and waiting for file 32 | n <- as.integer(waitmax / waitinterval) # maximum number of iterations 33 | i <- 1 34 | while (any(!file.exists(file)) & i <= n) { 35 | Sys.sleep(waitinterval) 36 | if (i == 1) message(paste(paste(file[!file.exists(file)], collapse=", "), "does not exist [waiting ...]", "\n")) 37 | i <- i + 1 38 | } 39 | if (all(file.exists(file))) { 40 | return(TRUE) 41 | } else { 42 | message(paste(paste(file[!file.exists(file)], collapse=", "), "does not exist after", waitmax+waitmin, "seconds. Waiting stopped.", "\n")) 43 | return(FALSE) 44 | } 45 | } 46 | }, ex=function() { 47 | 48 | FileExistsWait(system.file("external/rlogo.grd", package="raster")) 49 | FileExistsWait("nofile.txt") 50 | 51 | }) 52 | 53 | 54 | -------------------------------------------------------------------------------- /LPJmLmdi/R/GridProperties.R: -------------------------------------------------------------------------------- 1 | GridProperties <- structure(function( 2 | ##title<< 3 | ## Derive grid properties from an object of class 'LPJfiles' 4 | ##description<< 5 | ## The function reads the grid of the input files in 'LPJfiles' and computes the area per grid cell. 6 | 7 | lpjfiles, 8 | ### list of class 'LPJinput' 9 | 10 | res = 0.5, 11 | ### resolution of LPJmL 12 | 13 | ... 14 | ### further arguments (currently not used) 15 | 16 | ##details<< 17 | ## No details. 18 | 19 | ##references<< No reference. 20 | 21 | ##seealso<< 22 | ## \code{\link{LPJfiles}} 23 | ) { 24 | 25 | # is there already grid information 26 | has.grid <- !is.null(lpjfiles$grid) 27 | if (!has.grid) { 28 | grid.pos <- c(grep("grid", lpjfiles$input$name), grep("GRID", lpjfiles$input$name)) 29 | file.grid <- as.character(lpjfiles$input$file[grid.pos]) 30 | grid <- ReadGrid(file.grid) 31 | ll <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0") 32 | ncell <- nrow(grid) 33 | grid.sp <- SpatialPointsDataFrame(grid, data=data.frame(id=1:ncell), proj4string=ll) 34 | ext <- extent(grid.sp) 35 | res2 <- res / 2 36 | grid.r <- raster(xmn=ext@xmin-res2, xmx=ext@xmax+res2, ymn=ext@ymin-res2, ymx=ext@ymax+res2) 37 | res(grid.r) <- c(res, res) 38 | grid.r[] <- NA 39 | grid.r[cellFromXY(grid.r, grid)] <- 0:(ncell-1) 40 | area.r <- raster::area(grid.r) 41 | area.r <- mask(area.r, grid.r) 42 | grid <- list(grid=grid.r, area=area.r, ncell=nrow(grid)) 43 | } else { 44 | grid <- lpjfiles$grid 45 | } 46 | return(grid) 47 | ### the function returns a list with 'grid' (raster of grid cells), 'area' (vector of grid cell area) and 'ncell' (number of grid cells) 48 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/InfoNCDF.R: -------------------------------------------------------------------------------- 1 | InfoNCDF <- structure(function( 2 | ##title<< 3 | ## Get information about variables in a NetCDF 4 | 5 | file 6 | ### file name 7 | 8 | ##details<< 9 | ## 10 | 11 | ##references<< 12 | ## 13 | 14 | ##seealso<< 15 | ## \code{\link{WriteNCDF4}} 16 | 17 | ) { 18 | nc <- nc_open(file) 19 | 20 | # get variables 21 | nms <- unlist(llply(nc$var, function(v) v$name)) 22 | units <- unlist(llply(nc$var, function(v) v$units)) 23 | nms2 <- unlist(llply(nc$var, function(v) v$longname)) 24 | 25 | # get dimensions 26 | lon <- nc$dim$lon$vals 27 | lat <- nc$dim$lat$vals 28 | ti <- try(as.Date(gsub("days since ", "", nc$dim$time$units)) + nc$dim$time$vals, silent=TRUE) 29 | if (class(ti) == "try-error") { 30 | ti <- nc$dim$time$vals 31 | } 32 | 33 | # all dimensions 34 | dim <- llply(nc$dim, function(dim) { 35 | return(list(name=dim$name, length=length(dim$vals))) 36 | }) 37 | 38 | 39 | # get global attributes 40 | glob <- ncatt_get(nc, 0) 41 | 42 | nc_close(nc) 43 | info.l <- list( 44 | file = file, 45 | lat = lat, 46 | lon = lon, 47 | time = ti, 48 | dim = dim, 49 | global = glob, 50 | var = data.frame(name=nms, unit=units, longname=nms2) 51 | ) 52 | return(info.l) 53 | ### The function returns a list with information about the dimensions and variables in the NetCDF file. 54 | }) 55 | -------------------------------------------------------------------------------- /LPJmLmdi/R/LE2ET.R: -------------------------------------------------------------------------------- 1 | LE2ET <- structure(function( 2 | ##title<< 3 | ## Compute evapotranspiration (ET) from latent heat (LE). 4 | 5 | le, 6 | ### latent heat (W m-2) 7 | 8 | temp = 20, 9 | ### temperature (degC, default 20 degC) 10 | 11 | rho_w = 1000 12 | # density of water (kg m-3) 13 | 14 | ##details<< 15 | ## 16 | 17 | ##references<< 18 | ## FAO (1998): Crop evapotranspiration - Guidelines for computing crop water requirements - FAO Irrigation and drainage paper 56, http://www.fao.org/docrep/x0490e/x0490e04.htm 19 | 20 | ##seealso<< 21 | ## \code{\link{WriteLPJinput}} 22 | 23 | ) { 24 | # latent heat of vaporization 25 | lambda_v <- (5.147 * exp(-0.0004643 * temp) - 2.6466) # MJ/kg 26 | lambda_v <- lambda_v * 1E6 # (J/kg) 27 | 28 | # evapotranspiration (m s-1) 29 | et <- le / (rho_w * lambda_v) 30 | 31 | # evapotranspiration (m s-1) -> (mm day-1) 32 | et <- et * 1000 * 86400 33 | return(et) 34 | ### The function returns evapotranspiration (mm day-1) 35 | }, ex=function() { 36 | # Example from FAO (1998) 37 | le <- 12 # latent heat that is used to vapourize water (MJ m-2 day-1) 38 | le <- le / 86400 # MJ m-2 day-1 -> MJ m-2 sec-1 39 | le <- le * 1E6 # MJ m-2 sec-1 -> W m-2 40 | LE2ET(le=le) 41 | 42 | temp <- -30:40 43 | et <- LE2ET(le=le, temp=temp) 44 | plot(temp, et) 45 | }) 46 | -------------------------------------------------------------------------------- /LPJmLmdi/R/LPJpar.R: -------------------------------------------------------------------------------- 1 | LPJpar <- structure(function( 2 | ##title<< 3 | ## Create an object of class 'LPJpar' 4 | ##description<< 5 | ## The function creates a data.frame of class 'LPJpar' that defines the parameters for LPJ runs. 6 | 7 | par.prior, 8 | ### parameter vector (prior) 9 | 10 | par.lower, 11 | ### lower boundaries for parameters 12 | 13 | par.upper, 14 | ### upper boundaries for parameters 15 | 16 | par.pftspecif, 17 | ### Which parameter is PFT specific (TRUE) or global (FALSE)? 18 | 19 | par.names, 20 | ### parameter name 21 | 22 | is.int = rep(FALSE, length(par.prior)), 23 | ### is parameter a integer? 24 | 25 | ... 26 | ### further arguments for CheckLPJpar 27 | 28 | ##details<< 29 | ## No details. 30 | 31 | ##references<< No reference. 32 | 33 | ##seealso<< 34 | ## \code{\link{CheckLPJpar}} 35 | ) { 36 | 37 | names(par.prior) <- par.names 38 | names(par.lower) <- par.names 39 | names(par.upper) <- par.names 40 | names(par.pftspecif) <- par.names 41 | lpjpar <- data.frame(names=par.names, prior=par.prior, lower=par.lower, upper=par.upper, pftspecif=par.pftspecif, is.int=is.int) 42 | class(lpjpar) <- "LPJpar" 43 | lpjpar <- CheckLPJpar(lpjpar, ...) 44 | return(lpjpar) 45 | ### The function returns a list of class 'LPJpar' 46 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/LWin2LWnet.R: -------------------------------------------------------------------------------- 1 | LWin2LWnet <- structure(function( 2 | ##title<< 3 | ## Compute long-wave net radiation from long-wave incoming radiation and temperature. 4 | 5 | lwin, 6 | ### long-wave incoming radiation (Wm-2) 7 | 8 | temp, 9 | ### temperature (degC, conversion to K is done within the function) 10 | 11 | emissivity = 0.97 12 | ### emissivity of the surface. Values around 0.97 are valid for various natural surface types (leaves 0.94-0.99, soil 0.93-0.96, water 0.96) (Campbell and Norman 1998, p. 162-163, 177). 13 | 14 | ##details<< 15 | ## Long-wave net radiation is computed as the difference between long-wave incoming and long-wave outgoing radiation. Long-wave outgoing radiation is computed based on the Stefan-Boltzmann law and an emissivity factor (LWout = emissivity * sigma * temp^4), whereas sigma is the Stefan-Boltzmann constant (5.67037 * 10^(-8) Wm-2 K-4) (Campbell and Norman 1998, p. 162-163, 177). 16 | 17 | ##references<< Campbell GS, Norman JM (1998) An Introduction to Environmental Biophysics. Springer New York, New York, NY. 18 | 19 | ##seealso<< 20 | ## \code{\link{WriteLPJinput}} 21 | 22 | ) { 23 | sigma <- 5.67037 * 10^(-8) # Stefan-Boltzmann constant 24 | temp <- temp + 273.15 # degC -> K 25 | lwout <- sigma * emissivity * (temp^4) 26 | lwnet <- lwin - lwout 27 | return(lwnet) 28 | ### The function returns long-wave net radiation (Wm-2) 29 | }, ex=function() { 30 | lwin <- 200:380 # long-wave incoming radiation (Wm-2) 31 | temp <- 0.14 * lwin - 32 + rnorm(length(lwin), 0, 5) # temperature (degC) 32 | plot(lwin, temp) 33 | lwnet <- LWin2LWnet(lwin, temp) 34 | plot(temp, lwnet) 35 | plot(lwin, lwnet) 36 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/PlotParPCA.R: -------------------------------------------------------------------------------- 1 | PlotParPCA <- structure(function( 2 | ##title<< 3 | ## plot a PCA of optimized parameters 4 | ##description<< 5 | ## The function takes an object of class 'rescue' (see \code{\link{CombineRescueFiles}}), computes a PCA (principle component analysis) based on the model parameter sets and cost function values of the optimization, and plots PCA results as biplots. 6 | 7 | rescue.l, 8 | ### a list of class "rescue", see \code{\link{CombineRescueFiles}} 9 | 10 | ... 11 | ### further arguments for \code{\link{plot}} 12 | 13 | ##details<< 14 | ## No details. 15 | 16 | ##references<< No reference. 17 | 18 | ##seealso<< 19 | ## \code{\link{CombineRescueFiles}}, \code{\link{princomp}} 20 | ) { 21 | op <- par() 22 | 23 | r <- laply(rescue.l, function(l) length(l$dpar)) 24 | rescue.l <- rescue.l[r == modal(r)] 25 | 26 | # convert optimization results to data.frame 27 | optim.df <- ldply(rescue.l, function(l) { 28 | df <- data.frame(matrix(c(l$cost$total, as.vector(l$dpar)), nrow=1)) # , as.vector(l$cost$per.ds)[l$cost$use] 29 | colnames(df) <- c("cost", names(l$dpar)) #, paste0("cost.", names(l$cost$per.ds)[l$cost$use])) 30 | return(df) 31 | }) 32 | if (nrow(optim.df) > 10000) { 33 | optim.df <- optim.df[order(optim.df$cost), ] 34 | optim.df <- optim.df[1:10000, ] 35 | } 36 | 37 | # do PCA 38 | pc <- princomp(optim.df[,-1], scale=TRUE) 39 | ld <- loadings(pc) 40 | 41 | # plot PCA 42 | DefaultParL(mfrow=c(2,3)) 43 | explvar <- cumsum((pc$sdev^2) / sum(pc$sdev^2)) * 100 44 | barplot(explvar[1:min(c(length(explvar), 9))], ylab="Cumulative explained variance (%)", ylim=c(0, 100)) 45 | box() 46 | biplot(pc, c(1,2), xlabs=rep(".", nrow(optim.df))) 47 | biplot(pc, c(1,3), xlabs=rep(".", nrow(optim.df))) 48 | biplot(pc, c(2,3), xlabs=rep(".", nrow(optim.df))) 49 | biplot(pc, c(1,4), xlabs=rep(".", nrow(optim.df))) 50 | biplot(pc, c(2,4), xlabs=rep(".", nrow(optim.df))) 51 | 52 | par(op) 53 | return(pc) 54 | ### The function returns an object of class 'princomp'. 55 | }) 56 | -------------------------------------------------------------------------------- /LPJmLmdi/R/PlotWorld110.R: -------------------------------------------------------------------------------- 1 | PlotWorld110 <- structure(function( 2 | ##title<< 3 | ## Plot a world map based on 1:110Mio data 4 | 5 | admin=FALSE, 6 | ### Plot administrative boundaries? 7 | 8 | lakes=TRUE, 9 | ### Plot lakes? 10 | 11 | rivers=TRUE, 12 | ### Plot rivers? 13 | 14 | col=c("black", "blue", "red"), 15 | ### Colors for (1) coastlines, (2) rivers and (3) administrative boundaries 16 | 17 | bg=NA, 18 | ### background color, default: NA (no background) 19 | 20 | ... 21 | ### additional arguments to plot 22 | ) { 23 | data(data110) # loads coast110, land110, admin110, rivers110, lakes110 24 | 25 | plot(coast110, col=col[1], ...) 26 | if (!is.na(bg)) plot(land110, add=TRUE, col=bg) 27 | if (admin == TRUE) plot(admin110, border=col[3], add=TRUE) 28 | plot(coast110, col=col[1], add=TRUE) 29 | if (rivers == TRUE) plot(rivers110, col=col[2], add=TRUE) 30 | if (lakes == TRUE) plot(lakes110, border=col[2], col="powderblue", add=TRUE) 31 | }, ex=function(){ 32 | 33 | PlotWorld110() 34 | 35 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/ReadGrid.R: -------------------------------------------------------------------------------- 1 | ReadGrid <- structure(function( 2 | ##title<< 3 | ## Reads a binary input data grid file. 4 | 5 | file.grid="cru.grid", 6 | ### CLM file name with extension *.clm 7 | 8 | endian="little", 9 | ### endianess of the file 10 | 11 | ... 12 | ### Further arguments (currently not used). 13 | 14 | ##details<< 15 | ## No details. 16 | 17 | ##references<< No reference. 18 | 19 | ##seealso<< 20 | ## \code{\link{ReadCLM}} 21 | 22 | ) { 23 | is.ok <- FALSE # flag to check if grid is OK (no lat > 90 | < 90) 24 | iter <- 1 25 | while (!is.ok & iter <= 2) { 26 | 27 | # open file 28 | con <- file(file.grid, "rb") 29 | 30 | # get filetype name 31 | name <- readBin(con, character(), n=1, size=1, endian=endian) 32 | 33 | # skip/read header information - depending on file type version 34 | if (name == "LPJGRID") { # old LPJGRID files 35 | close(con) 36 | con <- file(file.grid, "rb") 37 | seek(con, where=15, origin = "start", rw = "read") 38 | } else if (name == "LPJGRID\001") { # new LPJGRID files V1 39 | x <- readBin(con, integer(), n=15, size=2, endian=endian) 40 | } else if (name == "LPJGRID\002") { # new LPJGRID files V2 41 | x <- readBin(con, integer(), n=17, size=2, endian=endian) 42 | } else if (name == "LPJGRID\003") { # new LPJGRID files V3 43 | x <- readBin(con, integer(), n=21, size=2, endian=endian) 44 | } else { 45 | stop(paste(file.grid, "is no valid LPJGRID file.")) 46 | } 47 | 48 | # read data 49 | grid <- readBin(con, integer(), n=(300000*2), size=2, endian=endian) 50 | grid <- data.frame(matrix(grid/100, ncol=2, byrow=TRUE)) 51 | close(con) 52 | 53 | # check grid - and swap endianness 54 | if (max(grid[,2]) > 90 | min(grid[,2]) < -90) { 55 | is.ok <- FALSE 56 | if (endian == "little") { 57 | endian <- "big" 58 | } else { 59 | endian <- "little" 60 | } 61 | iter <- iter + 1 62 | } else { 63 | is.ok <- TRUE 64 | } 65 | if (iter > 2) warning(paste("Coordinates in", file.grid, "might be wrong. Please check.")) 66 | } 67 | return(grid) 68 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/ReadPRO.R: -------------------------------------------------------------------------------- 1 | ReadPRO <- structure(function( 2 | ##title<< 3 | ## Read *.pro files as produced from GENOUD 4 | ##description<< 5 | ## The function is used within OptimizeLPJgenoud 6 | 7 | files.pro 8 | ### file names (*.pro) of genoud optimization results. 9 | 10 | ##details<< 11 | ## No details. 12 | 13 | ##references<< No reference. 14 | ) { 15 | 16 | # read all pro population files 17 | optim.df <- ldply(as.list(files.pro), function(file.pro) { 18 | if (file.info(file.pro)$size > 0) { 19 | m <- read.table(file.pro, comment.char='G') 20 | colnames(m) <- paste("X", 1:ncol(m)) 21 | return(m) 22 | } else { 23 | return(NULL) 24 | } 25 | }) 26 | 27 | # remove duplicates 28 | txt <- apply(optim.df, 1, function(x) { 29 | txt <- round(x[2:length(x)], 8) 30 | paste(x, collapse="-") 31 | }) 32 | optim.df <- optim.df[!duplicated(txt), ] 33 | 34 | # remove out-of-range individuals 35 | use <- optim.df[,2] != 1e+20 36 | optim.df <- optim.df[use, ] 37 | 38 | return(optim.df) 39 | ### The function returns a data.frame with number of individual, cost and parameer values 40 | }) 41 | 42 | 43 | -------------------------------------------------------------------------------- /LPJmLmdi/R/SSE.R: -------------------------------------------------------------------------------- 1 | SSE <- structure(function( 2 | ##title<< 3 | ## Sum-of-squared residuals error 4 | ##description<< 5 | ## The function implements the sum-of-squared residuals error as cost function 6 | 7 | sim, 8 | ### vector of simulations 9 | 10 | obs, 11 | ### vector of observations 12 | 13 | unc 14 | ### vector of observation uncertainties 15 | 16 | ##details<< 17 | ## No details. 18 | 19 | ##references<< No reference. 20 | ) { 21 | b <- is.na(obs) | is.na(unc) 22 | sim[b] <- NA 23 | unc[unc == 0] <- NA 24 | sum( (sim - obs)^2 / (unc^2), na.rm=TRUE) 25 | 26 | }, ex=function() { 27 | 28 | obs <- rnorm(10, 0, 2) 29 | sim <- obs + rnorm(10, 0.05, 0.01) 30 | unc <- 0.01 31 | SSE(sim, obs, unc) 32 | 33 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/StandardError.R: -------------------------------------------------------------------------------- 1 | StandardError <- structure(function( 2 | ##title<< 3 | ## Compute standard errors from a variance-covariance matrix 4 | ##description<< 5 | ## SE = sqrt(diag(vc) * cost^2 / (nobs - npar)) 6 | 7 | vc, 8 | ### variance-covariance matrix 9 | 10 | nobs, 11 | ### number of observations 12 | 13 | cost 14 | ### cost function value 15 | 16 | ##details<< 17 | ## No details. 18 | 19 | ##references<< No reference. 20 | ) { 21 | npar <- nrow(vc) 22 | s2 <- cost^2 / (nobs - npar) 23 | sqrt(diag(vc) * s2) # standard errors 24 | }) -------------------------------------------------------------------------------- /LPJmLmdi/R/StartingValues.R: -------------------------------------------------------------------------------- 1 | StartingValues <- structure(function( 2 | ##title<< 3 | ## Get starting values for genoud from *.pro file 4 | ##description<< 5 | ## The function extracts the best individuals trhat occured during a genoud optimization from a *.pro file. These best individuals can be used as starting values if a optimization is restarted. This function is called within \code{\link{OptimizeLPJgenoud}} is a restart is performed. 6 | 7 | file.optresult, 8 | ### genoud *.pro file with optimization results 9 | 10 | pop.size=NULL, 11 | ### population size 12 | 13 | ... 14 | ### further arguments (not used) 15 | 16 | ##details<< 17 | ## No details. 18 | 19 | ##references<< No reference. 20 | 21 | ##seealso<< 22 | ## \code{\link{OptimizeLPJgenoud}} 23 | ) { 24 | 25 | # read previous optimization results 26 | optim.df <- ReadPRO(file.optresult) 27 | niter <- nrow(optim.df) 28 | 29 | # pop.size 30 | if (is.null(pop.size)) { 31 | pop.size <- min(c(20, nrow(optim.df))) 32 | } 33 | 34 | # best individual from previous optimization 35 | cost <- optim.df[,2] 36 | best <- which.min(cost)[1] 37 | dpar.best <- as.vector(unlist(optim.df[best, 3:ncol(optim.df)])) 38 | 39 | # sample from best individuals 40 | cost.trs <- quantile(cost, 0.1) # threshold of best 41 | optim.best.df <- optim.df[cost <= cost.trs, ] 42 | size <- min(c(20, pop.size, nrow(optim.best.df))) 43 | dpar.other <- optim.best.df[sample(1:nrow(optim.best.df), size), 3:ncol(optim.best.df)] 44 | 45 | # median of best individuals 46 | dpar.med <- apply(optim.best.df[,3:ncol(optim.best.df)], 2, median) 47 | 48 | # parameter vectors to be introduced to genoud: best, some other best, median of best 49 | starting.values <- list(start=as.matrix(rbind(dpar.best, dpar.other, dpar.med)), niter=niter) 50 | return(starting.values) 51 | }) 52 | 53 | -------------------------------------------------------------------------------- /LPJmLmdi/R/Texture2Soilcode.R: -------------------------------------------------------------------------------- 1 | Texture2Soilcode <- structure(function( 2 | ##title<< 3 | ## Convert soil texture to a LPJ soilcode 4 | ##description<< 5 | ## The function takes fractions/percentages of sand, silt and clay and returns the correspondign LPJ soil code. The USDA soil classification is used. The function requires the package "soiltexture". 6 | 7 | sand, 8 | ### percentage of sand 9 | 10 | silt, 11 | ### percentage of silt 12 | 13 | clay, 14 | ### percentage of clay 15 | 16 | lpj.soilcodes = c("Cl", "SiCl", "SaCl", "ClLo", "SiClLo", "SaClLo", "Lo", "SiLo", "SaLo", "Si", "LoSa", "Sa"), 17 | ### LPJ soil codes 18 | 19 | plot=TRUE, 20 | ### plot soil triangle? 21 | 22 | ... 23 | ### Further arguments (currently not used). 24 | 25 | ##details<< 26 | ## No details. 27 | 28 | ##references<< No reference. 29 | 30 | ##seealso<< 31 | ## \code{\link{ReadBIN}} 32 | 33 | ) { 34 | # soil type 35 | require(soiltexture) 36 | texture <- data.frame(CLAY=clay, SILT=silt, SAND=sand) 37 | texture <- texture / rowSums(texture) * 100 38 | 39 | # get soil type of the side 40 | if (plot) TT.plot(class.sys = "USDA.TT", tri.data=texture, col="red") 41 | soil.type <- TT.points.in.classes(texture, class.sys = "USDA.TT") 42 | soil.type 43 | 44 | # LPJ soil code 45 | soilcode <- match(colnames(soil.type)[apply(soil.type, 1, which.max)], lpj.soilcodes) 46 | return(soilcode) 47 | ### The function returns the LPJ soilcode 48 | }, ex=function(){ 49 | 50 | # data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) 51 | # WriteBIN(data.sp, file="data.bin") 52 | 53 | }) 54 | -------------------------------------------------------------------------------- /LPJmLmdi/R/Turnover.R: -------------------------------------------------------------------------------- 1 | Turnover <- structure(function( 2 | ##title<< 3 | ## Calculate turnover time from stock and flux 4 | ##description<< 5 | ## Calculates turnover times. 6 | 7 | stock, 8 | ### stock, e.g. biomass 9 | 10 | flux, 11 | ### flux, e.g. NPP 12 | 13 | ... 14 | ### further arguments (currently not used) 15 | 16 | ##details<< 17 | ## turnover = stock / flux 18 | 19 | ##references<< No reference. 20 | ) { 21 | if (length(stock) == 1) { 22 | tau <- stock / flux 23 | } else { 24 | dstock <- c(NA, diff(stock)) 25 | tau <- - stock / (dstock - flux) 26 | } 27 | return(tau) 28 | }) 29 | -------------------------------------------------------------------------------- /LPJmLmdi/R/WriteBIN.R: -------------------------------------------------------------------------------- 1 | WriteBIN <- structure(function( 2 | ##title<< 3 | ## Write a BIN file from SpatialPointsDataFrame 4 | ##description<< 5 | ## The function writes BIN files from a SpatialPointsDataFrame or SpatialPixelsDataFrame. 6 | 7 | data.sp, 8 | ### SpatialPointsDataFrame or SpatialPixelsDataFrame with data 9 | 10 | file.bin, 11 | ### binary file name with extension *.bin 12 | 13 | size=1, 14 | ### The number of bytes per element in the byte stream. 15 | 16 | ... 17 | ### Further arguments (currently not used). 18 | 19 | ##details<< 20 | ## No details. 21 | 22 | ##references<< No reference. 23 | 24 | ##seealso<< 25 | ## \code{\link{ReadBIN}} 26 | 27 | ) { 28 | # write binary file 29 | con <- file(file.bin, "wb") 30 | writeBin(as.integer(unlist(data.sp@data)), file.bin, size=size) 31 | close(con) 32 | 33 | # write grid 34 | file.grid <- gsub(".bin", ".grid", file.bin) 35 | WriteGrid(coordinates(data.sp), file.grid=file.grid) 36 | 37 | return(file.exists(file.bin)) 38 | ### The function returns TRUE if the CLM file was created. 39 | }, ex=function(){ 40 | 41 | # data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) 42 | # WriteBIN(data.sp, file="data.bin") 43 | 44 | }) 45 | -------------------------------------------------------------------------------- /LPJmLmdi/R/WriteGrid.R: -------------------------------------------------------------------------------- 1 | WriteGrid <- structure(function( 2 | ##title<< 3 | ## Write a *.grid file from a matrix of coordiantes or a SpatialPointsDataFrame 4 | ##description<< 5 | ## Writes a grid file for LPJ input data. The functions needs the LPJmL module txt2grid to be installed. 6 | 7 | grid, 8 | ### SpatialPointsDataFrame; SpatialPixelsDataFrame, matrix or data.frame with coordinates 9 | 10 | file.grid, 11 | ### Grid file name 12 | 13 | ... 14 | ### Further arguments (currently not used). 15 | 16 | ##details<< 17 | ## No details. 18 | 19 | ##references<< No reference. 20 | 21 | ##seealso<< 22 | ## \code{\link{WriteLPJinput}} 23 | 24 | ) { 25 | 26 | if (!is.matrix(grid) | !is.data.frame(grid)) grid <- coordinates(grid) 27 | file.grid.txt <- paste0(file.grid, ".txt") 28 | 29 | # write grid as txt file 30 | grid.df <- data.frame(Id=1:nrow(grid), Lon=grid[,1], Lat=grid[,2]) 31 | write.table(grid.df, file=file.grid.txt, sep=",", row.names=FALSE) 32 | 33 | # write grid as binary file 34 | cmd <- paste("txt2grid", file.grid.txt, file.grid) 35 | system(cmd) 36 | file.remove(file.grid.txt) 37 | return(file.exists(file.grid)) 38 | ### The function returns TRUE if the grid file was created. 39 | }, ex=function(){ 40 | 41 | lon <- c(59.75, 68.25) 42 | lat <- c(61.25, 65.75) 43 | WriteGrid(cbind(lon, lat), "test.grid") 44 | 45 | }) 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /LPJmLmdi/R/WriteLPJinput.R: -------------------------------------------------------------------------------- 1 | WriteLPJinput <- structure(function( 2 | ##title<< 3 | ## Write an object of class 'LPJinput' to CLM files 4 | ##description<< 5 | ## The function writes CLM input files for LPJ. 6 | 7 | lpjinput, 8 | ### Object of class 'LPJinput' to be written. 9 | 10 | files=NULL, 11 | ### names of the output CLM or binary files. 12 | 13 | path.lpj=NULL, 14 | ### path to LPJ installation 15 | 16 | ... 17 | ### further arguments (currently not used) 18 | 19 | ##details<< 20 | ## No details. 21 | 22 | ##references<< No reference. 23 | 24 | ##seealso<< 25 | ## \code{\link{WriteLPJinput}} 26 | 27 | ) { 28 | 29 | # loop over datasets 30 | ndata <- length(lpjinput$data) 31 | res <- rep(FALSE, ndata) 32 | for (i in 1:ndata) { 33 | 34 | # get data information 35 | data.m <- lpjinput$data[[i]]$data 36 | nbands <- lpjinput$data[[i]]$nbands 37 | firstyear <- lpjinput$data[[i]]$firstyear 38 | fmt <- lpjinput$data[[i]]$fmt 39 | file.clm <- NULL 40 | if (is.null(file.clm)) file.clm <- files[i] 41 | if (is.null(file.clm)) file.clm <- lpjinput$data[[i]]$file.new 42 | if (is.null(file.clm)) stop("Provide file name for the output files.") 43 | 44 | # convert data to SpatialPointsDataFrame 45 | data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) 46 | 47 | # write CLM file and grid file 48 | if (fmt == "clm") { 49 | res[i] <- WriteCLM(data.sp, file.clm=file.clm, start=firstyear, nbands=nbands, size=2, path.lpj=path.lpj) 50 | } else if (fmt == "bin") { 51 | res[i] <- WriteBIN(data.sp, file.bin=file.clm, nbands=nbands, size=1, path.lpj=path.lpj) 52 | } 53 | } 54 | 55 | return(res) 56 | ### The function returns TRUE if the CLM file was created. 57 | }, ex=function() { 58 | 59 | # lpjinput <- ReadLPJinput("cru_ts_3.20.1901.2011.tmp.clm", grid=cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75))) 60 | # str(lpjinput) 61 | # WriteLPJinput(lpjinput) 62 | 63 | }) 64 | -------------------------------------------------------------------------------- /LPJmLmdi/data/data110.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/LPJmLmdi/data/data110.RData -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCBoBS.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for BoBS PFT: get BoBS from vector of... 2 | 3 | 4 | 5 | 6 |
AggFPCBoBS {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for BoBS PFT: get BoBS from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCBoBS(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCBoNE.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for BoNE PFT: get BoNE from vector of... 2 | 3 | 4 | 5 | 6 |
AggFPCBoNE {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for BoNE PFT: get BoNE from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCBoNE(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCBoNS.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for BoNS PFT: get BoNS from vector of... 2 | 3 | 4 | 5 | 6 |
AggFPCBoNS {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for BoNS PFT: get BoNS from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCBoNS(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCPoH.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for PoH PFT: get PoH from vector of all... 2 | 3 | 4 | 5 | 6 |
AggFPCPoH {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for PoH PFT: get PoH from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCPoH(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCTeBE.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for PFTs: get TeBE from vector of all... 2 | 3 | 4 | 5 | 6 |
AggFPCTeBE {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for PFTs: get TeBE from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCTeBE(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCTeBS.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for PFTs: get TeBS from vector of all... 2 | 3 | 4 | 5 | 6 |
AggFPCTeBS {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for PFTs: get TeBS from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCTeBS(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCTeH.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for PFTs: get TeH from vector of all... 2 | 3 | 4 | 5 | 6 |
AggFPCTeH {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for PFTs: get TeH from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCTeH(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCTeNE.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for PFTs: get TeNE from vector of all... 2 | 3 | 4 | 5 | 6 |
AggFPCTeNE {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for PFTs: get TeNE from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCTeNE(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCTrBE.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for PFTs: get TrBE from vector of all... 2 | 3 | 4 | 5 | 6 |
AggFPCTrBE {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for PFTs: get TrBE from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCTrBE(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggFPCTrBR.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation for PFTs: get TrBR from vector of all... 2 | 3 | 4 | 5 | 6 |
AggFPCTrBR {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation for PFTs: get TrBR from vector of all PFTs, average over years

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggFPCTrBR(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggMSC.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation: mean seasonal cycle 2 | 3 | 4 | 5 | 6 |
AggMSC {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation: mean seasonal cycle

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggMSC(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns the mean seasonal cycle

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggMaxNULL.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation: aggregate by using annual maximum 2 | 3 | 4 | 5 | 6 |
AggMaxNULL {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation: aggregate by using annual maximum

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggMaxNULL(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggMeanMean.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation: first mean, then mean = mean over all... 2 | 3 | 4 | 5 | 6 |
AggMeanMean {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation: first mean, then mean = mean over all values

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggMeanMean(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggMeanNULL.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation: first mean, then nothing = mean per... 2 | 3 | 4 | 5 | 6 |
AggMeanNULL {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation: first mean, then nothing = mean per group

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggMeanNULL(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggNULLMean.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation: mean over all values 2 | 3 | 4 | 5 | 6 |
AggNULLMean {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation: mean over all values

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggNULLMean(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggQ09NULL.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation: aggregate by using quantile with... 2 | 3 | 4 | 5 | 6 |
AggQ09NULL {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation: aggregate by using quantile with prob=0.9

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggQ09NULL(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggSumMean.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation: first sum, then mean 2 | 3 | 4 | 5 | 6 |
AggSumMean {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation: first sum, then mean

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggSumMean(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AggSumNULL.html: -------------------------------------------------------------------------------- 1 | R: Temporal aggregation: first sum, then nothing = sum per group 2 | 3 | 4 | 5 | 6 |
AggSumNULL {LPJmLmdi}R Documentation
7 | 8 |

Temporal aggregation: first sum, then nothing = sum per group

9 | 10 |

Description

11 | 12 |

This function can be provided to IntegrationDataset to aggregate model results to the temporal resolution of the observations.

13 | 14 | 15 |

Usage

16 | 17 |
AggSumNULL(x, agg)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
x 25 |

full time series

26 |
agg 29 |

vector of grouping elements (years)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

The function returns a the aggregated result.

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

IntegrationDataset

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/AllEqual.html: -------------------------------------------------------------------------------- 1 | R: Check if all values in a vector are the same 2 | 3 | 4 | 5 | 6 |
AllEqual {LPJmLmdi}R Documentation
7 | 8 |

Check if all values in a vector are the same

9 | 10 |

Description

11 | 12 |

This function is used to check if all values in a vector are equal. It can be used for example to check if a time series contains only 0 or NA values.

13 | 14 | 15 |

Usage

16 | 17 |
AllEqual(x)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 |
x 25 |

numeric, character vector, or time series of type ts

26 |
28 | 29 | 30 |

Value

31 | 32 |

The function returns TRUE if all values are equal and FALSE if it contains different values.

33 | 34 | 35 |

Author(s)

36 | 37 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

38 | 39 | 40 |

Examples

41 | 42 |
43 | # check if all values are equal in the following vectors:
44 | AllEqual(1:10)
45 | AllEqual(rep(0, 10))
46 | AllEqual(letters)
47 | AllEqual(rep(NA, 10))
48 | 
49 | 50 |
[Package LPJmLmdi version 1.0 Index]
51 | 52 | -------------------------------------------------------------------------------- /LPJmLmdi/html/CheckLPJpar.html: -------------------------------------------------------------------------------- 1 | R: Checks LPJ parameters 'LPJpar' 2 | 3 | 4 | 5 | 6 |
CheckLPJpar {LPJmLmdi}R Documentation
7 | 8 |

Checks LPJ parameters 'LPJpar'

9 | 10 |

Description

11 | 12 |

The function checks if LPJ parameters are within the lower and upper boundaries or are 0.

13 | 14 | 15 |

Usage

16 | 17 |
CheckLPJpar(lpjpar, correct = FALSE)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
lpjpar 25 |

object of class 'LPJpar'

26 |
correct 29 |

correct parameter values (TRUE) or return error message?

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

the function return an object of class 'LPJpar'

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

LPJpar

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/CheckMemoryUsage.html: -------------------------------------------------------------------------------- 1 | R: Check usage of memory by R objects 2 | 3 | 4 | 5 | 6 |
CheckMemoryUsage {LPJmLmdi}R Documentation
7 | 8 |

Check usage of memory by R objects

9 | 10 |

Description

11 | 12 |

The functions prints a message about the used memory and writes a file with the used memory per each R object.

13 | 14 | 15 |

Usage

16 | 17 |
CheckMemoryUsage()
18 | 19 | 20 |

Value

21 | 22 |

a data.frame

23 | 24 | 25 |

Author(s)

26 | 27 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

28 | 29 | 30 |

Examples

31 | 32 |
33 | CheckMemoryUsage()
34 | 
35 | 36 |
[Package LPJmLmdi version 1.0 Index]
37 | 38 | -------------------------------------------------------------------------------- /LPJmLmdi/html/CorrelationMatrixS.html: -------------------------------------------------------------------------------- 1 | R: plot a correlation matrix 2 | 3 | 4 | 5 | 6 |
CorrelationMatrixS {LPJmLmdi}R Documentation
7 | 8 |

plot a correlation matrix

9 | 10 |

Usage

11 | 12 |
CorrelationMatrixS(data, method = "spearman", iscor = NULL, main = "", 
13 |     ...)
14 | 15 | 16 |

Arguments

17 | 18 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 |
data 21 |

a correlation matrix or a data.frame (

22 |
method 25 |

method to compute the correlation

26 |
iscor 29 |

Is 'data' a correlation matrix?

30 |
main 33 |

main title for the plot

34 |
... 37 |

further arguments for plot

38 |
40 | 41 | 42 |

Details

43 | 44 |

No details.

45 | 46 | 47 |

Author(s)

48 | 49 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

50 | 51 | 52 |

References

53 | 54 |

No reference.

55 | 56 | 57 |

See Also

58 | 59 |

CombineRescueFiles

60 | 61 |
[Package LPJmLmdi version 1.0 Index]
62 | 63 | -------------------------------------------------------------------------------- /LPJmLmdi/html/CostMDS.KGE.html: -------------------------------------------------------------------------------- 1 | R: Cost function for multiple data streams based on Kling-Gupta... 2 | 3 | 4 | 5 | 6 |
CostMDS.KGE {LPJmLmdi}R Documentation
7 | 8 |

Cost function for multiple data streams based on Kling-Gupta efficiency

9 | 10 |

Description

11 | 12 |

The function computes for each grid cell and data stream in 'integrationdata' the cost besed on the Kling-Gupta efficiency (KGE, Gupta et al. 2009, J. Hydrology). See Forkel et al. (in prep.) for the specific use of KGE for multiple data streams.

13 | 14 | 15 |

Usage

16 | 17 |
CostMDS.KGE(integrationdata)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 |
integrationdata 25 |

object of class 'integrationdata', see IntegrationData

26 |
28 | 29 | 30 |

Details

31 | 32 |

No details.

33 | 34 | 35 |

Value

36 | 37 |

The function returns a list with the total cost (total), the cost per KGE component (per.cell), per data streams (per.ds), per KGE component and data stream (per.cell.ds), and the fractional contribution of a data stream and KGE component to the total cost (fractional).

38 | 39 | 40 |

Author(s)

41 | 42 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

43 | 44 | 45 |

References

46 | 47 |

No reference.

48 | 49 |
[Package LPJmLmdi version 1.0 Index]
50 | 51 | -------------------------------------------------------------------------------- /LPJmLmdi/html/CreateRestartFromRescue.html: -------------------------------------------------------------------------------- 1 | R: Create a *.pro file from binary rescue files to restart... 2 | 3 | 4 | 5 | 6 |
CreateRestartFromRescue {LPJmLmdi}R Documentation
7 | 8 |

Create a *.pro file from binary rescue files to restart optimization

9 | 10 |

Description

11 | 12 |

The function creates a *.pro file friom binary 'rescue' files. The *.pro file can be used to restart OptimizeLPJgenoud.

13 | 14 | 15 |

Usage

16 | 17 |
CreateRestartFromRescue(path.rescue, pop.size)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
path.rescue 25 |

directory where the resuce files from each iteration of the optimization are saved.

26 |
pop.size 29 |

(estimated) population size of the genetic optimization

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Author(s)

40 | 41 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

42 | 43 | 44 |

References

45 | 46 |

No reference.

47 | 48 | 49 |

See Also

50 | 51 |

genoudLPJrescue

52 | 53 |
[Package LPJmLmdi version 1.0 Index]
54 | 55 | -------------------------------------------------------------------------------- /LPJmLmdi/html/EstOptimUse.html: -------------------------------------------------------------------------------- 1 | R: Estimate optimal number of jobs given a number of cluster... 2 | 3 | 4 | 5 | 6 |
EstOptimUse {LPJmLmdi}R Documentation
7 | 8 |

Estimate optimal number of jobs given a number of cluster nodes

9 | 10 |

Usage

11 | 12 |
EstOptimUse(nodes = 16, wish = 1000)
13 | 14 | 15 |

Arguments

16 | 17 | 18 | 19 | 22 | 23 | 26 |
nodes 20 |

number of cluster nodes that you want to use

21 |
wish 24 |

approx. number of elements

25 |
27 | 28 | 29 |

Details

30 | 31 |

No details.

32 | 33 | 34 |

Value

35 | 36 |

an integer value

37 | 38 | 39 |

Author(s)

40 | 41 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

42 | 43 | 44 |

References

45 | 46 |

No reference.

47 | 48 | 49 |

See Also

50 | 51 |

WriteCLM

52 | 53 |
[Package LPJmLmdi version 1.0 Index]
54 | 55 | -------------------------------------------------------------------------------- /LPJmLmdi/html/GridProperties.html: -------------------------------------------------------------------------------- 1 | R: Derive grid properties from an object of class 'LPJfiles' 2 | 3 | 4 | 5 | 6 |
GridProperties {LPJmLmdi}R Documentation
7 | 8 |

Derive grid properties from an object of class 'LPJfiles'

9 | 10 |

Description

11 | 12 |

The function reads the grid of the input files in 'LPJfiles' and computes the area per grid cell.

13 | 14 | 15 |

Usage

16 | 17 |
GridProperties(lpjfiles, ...)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
lpjfiles 25 |

list of class 'LPJinput'

26 |
... 29 |

further arguments (currently not used)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Value

40 | 41 |

the function returns a list with 'grid' (raster of grid cells), 'area' (vector of grid cell area) and 'ncell' (number of grid cells)

42 | 43 | 44 |

Author(s)

45 | 46 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

47 | 48 | 49 |

References

50 | 51 |

No reference.

52 | 53 | 54 |

See Also

55 | 56 |

LPJfiles

57 | 58 |
[Package LPJmLmdi version 1.0 Index]
59 | 60 | -------------------------------------------------------------------------------- /LPJmLmdi/html/InfoCLM.html: -------------------------------------------------------------------------------- 1 | R: Returns information about a CLM file 2 | 3 | 4 | 5 | 6 |
InfoCLM {LPJmLmdi}R Documentation
7 | 8 |

Returns information about a CLM file

9 | 10 |

Usage

11 | 12 |
InfoCLM(file.clm, endian = "little", ...)
13 | 14 | 15 |

Arguments

16 | 17 | 18 | 19 | 22 | 23 | 26 | 27 | 30 |
file.clm 20 |

CLM file name with extension *.clm

21 |
endian 24 |

endianess of the file

25 |
... 28 |

Further arguments (currently not used).

29 |
31 | 32 | 33 |

Details

34 | 35 |

No details.

36 | 37 | 38 |

Author(s)

39 | 40 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

41 | 42 | 43 |

References

44 | 45 |

No reference.

46 | 47 | 48 |

See Also

49 | 50 |

WriteLPJinput

51 | 52 |
[Package LPJmLmdi version 1.0 Index]
53 | 54 | -------------------------------------------------------------------------------- /LPJmLmdi/html/LE2ET.html: -------------------------------------------------------------------------------- 1 | R: Compute evapotranspiration (ET) from latent heat (LE). 2 | 3 | 4 | 5 | 6 |
LE2ET {LPJmLmdi}R Documentation
7 | 8 |

Compute evapotranspiration (ET) from latent heat (LE).

9 | 10 |

Usage

11 | 12 |
LE2ET(le, temp = NULL)
13 | 14 | 15 |

Arguments

16 | 17 | 18 | 19 | 22 | 23 | 26 |
le 20 |

latent heat (W m-2)

21 |
temp 24 |

temperature (degC, conversion to K is done within the function)

25 |
27 | 28 | 29 |

Value

30 | 31 |

The function returns evapotranspiration (mm day-1)

32 | 33 | 34 |

Author(s)

35 | 36 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

37 | 38 | 39 |

See Also

40 | 41 |

WriteLPJinput

42 | 43 | 44 |

Examples

45 | 46 |
47 | le <- 0:200 # long-wave incoming radiation (W m-2)
48 | temp <- 0.14 * lwin - 32 + rnorm(length(lwin), 0, 5) # temperature (degC)
49 | 
50 | et <- LE2ET(le)
51 | plot(le, et)
52 | 
53 | 54 |
[Package LPJmLmdi version 1.0 Index]
55 | 56 | -------------------------------------------------------------------------------- /LPJmLmdi/html/LPJmLmdi-package.html: -------------------------------------------------------------------------------- 1 | R: Model-Data Integration for the LPJmL Dynamic Global... 2 | 3 | 4 | 5 | 6 |
LPJmLmdi-package {LPJmLmdi}R Documentation
7 | 8 |

Model-Data Integration for the LPJmL Dynamic Global Vegetation Model

9 | 10 |

Description

11 | 12 |

Model-data integration framework for the LPJmL dynamic global vegetation model. Specifically, the package provides functions 1) to optimize LPJmL model parameters using the GENOUD genetic optimization algorithm, 2) to read and write LPJmL input data, and 3) to read LPJmL output files.

13 | 14 | 15 |

Details

16 | 17 |

The DESCRIPTION file: 18 | This package was not yet installed at build time.
19 |

20 |

Index: This package was not yet installed at build time.
21 |

22 | 23 | 24 |

Author(s)

25 | 26 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

27 | 28 |
[Package LPJmLmdi version 1.0 Index]
29 | 30 | -------------------------------------------------------------------------------- /LPJmLmdi/html/PlotWorld110.html: -------------------------------------------------------------------------------- 1 | R: Plot a world map based on 1:110Mio data 2 | 3 | 4 | 5 | 6 |
PlotWorld110 {LPJmLmdi}R Documentation
7 | 8 |

Plot a world map based on 1:110Mio data

9 | 10 |

Usage

11 | 12 |
PlotWorld110(admin = FALSE, lakes = TRUE, rivers = TRUE, col = c("black", 
13 |     "blue", "red"), bg = NA, ...)
14 | 15 | 16 |

Arguments

17 | 18 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 39 | 40 | 43 |
admin 21 |

Plot administrative boundaries?

22 |
lakes 25 |

Plot lakes?

26 |
rivers 29 |

Plot rivers?

30 |
col 33 |

Colors for (1) coastlines, (2) rivers and (3) administrative boundaries

34 |
bg 37 |

background color, default: NA (no background)

38 |
... 41 |

additional arguments to plot

42 |
44 | 45 | 46 |

Author(s)

47 | 48 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

49 | 50 | 51 |

Examples

52 | 53 |
54 | 
55 | PlotWorld110()
56 | 
57 | 
58 | 59 |
[Package LPJmLmdi version 1.0 Index]
60 | 61 | -------------------------------------------------------------------------------- /LPJmLmdi/html/PrepareRestartFiles.html: -------------------------------------------------------------------------------- 1 | R: Prepare restart files to restart OptimizeLPJgenoud 2 | 3 | 4 | 5 | 6 |
PrepareRestartFiles {LPJmLmdi}R Documentation
7 | 8 |

Prepare restart files to restart OptimizeLPJgenoud

9 | 10 |

Description

11 | 12 |

The function prepares all files that are needed to restart OptimizeLPJgenoud

13 | 14 | 15 |

Usage

16 | 17 |
PrepareRestartFiles(file.optsetup, ...)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
file.optsetup 25 |

OptimizeLPJgenoud setup file, ends with "_optsetup.RData"

26 |
... 29 |

further arguments (currently not used)

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Author(s)

40 | 41 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

42 | 43 | 44 |

References

45 | 46 |

No reference.

47 | 48 | 49 |

See Also

50 | 51 |

LPJfiles

52 | 53 |
[Package LPJmLmdi version 1.0 Index]
54 | 55 | -------------------------------------------------------------------------------- /LPJmLmdi/html/R.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: white; 3 | color: black; 4 | } 5 | 6 | a:link { 7 | background: white; 8 | color: blue; 9 | } 10 | 11 | a:visited { 12 | background: white; 13 | color: rgb(50%, 0%, 50%); 14 | } 15 | 16 | h1 { 17 | background: white; 18 | color: rgb(55%, 55%, 55%); 19 | font-family: monospace; 20 | font-size: x-large; 21 | text-align: center; 22 | } 23 | 24 | h2 { 25 | background: white; 26 | color: rgb(40%, 40%, 40%); 27 | font-family: monospace; 28 | font-size: large; 29 | text-align: center; 30 | } 31 | 32 | h3 { 33 | background: white; 34 | color: rgb(40%, 40%, 40%); 35 | font-family: monospace; 36 | font-size: large; 37 | } 38 | 39 | h4 { 40 | background: white; 41 | color: rgb(40%, 40%, 40%); 42 | font-family: monospace; 43 | font-style: italic; 44 | font-size: large; 45 | } 46 | 47 | h5 { 48 | background: white; 49 | color: rgb(40%, 40%, 40%); 50 | font-family: monospace; 51 | } 52 | 53 | h6 { 54 | background: white; 55 | color: rgb(40%, 40%, 40%); 56 | font-family: monospace; 57 | font-style: italic; 58 | } 59 | 60 | img.toplogo { 61 | vertical-align: middle; 62 | } 63 | 64 | img.arrow { 65 | width: 30px; 66 | height: 30px; 67 | border: 0; 68 | } 69 | 70 | span.acronym { 71 | font-size: small; 72 | } 73 | 74 | span.env { 75 | font-family: monospace; 76 | } 77 | 78 | span.file { 79 | font-family: monospace; 80 | } 81 | 82 | span.option{ 83 | font-family: monospace; 84 | } 85 | 86 | span.pkg { 87 | font-weight: bold; 88 | } 89 | 90 | span.samp{ 91 | font-family: monospace; 92 | } 93 | 94 | div.vignettes a:hover { 95 | background: rgb(85%, 85%, 85%); 96 | } 97 | -------------------------------------------------------------------------------- /LPJmLmdi/html/ReadGrid.html: -------------------------------------------------------------------------------- 1 | R: Reads a binary input data grid file. 2 | 3 | 4 | 5 | 6 |
ReadGrid {LPJmLmdi}R Documentation
7 | 8 |

Reads a binary input data grid file.

9 | 10 |

Usage

11 | 12 |
ReadGrid(file.grid = "cru.grid", endian = "little", ...)
13 | 14 | 15 |

Arguments

16 | 17 | 18 | 19 | 22 | 23 | 26 | 27 | 30 |
file.grid 20 |

CLM file name with extension *.clm

21 |
endian 24 |

endianess of the file

25 |
... 28 |

Further arguments (currently not used).

29 |
31 | 32 | 33 |

Details

34 | 35 |

No details.

36 | 37 | 38 |

Author(s)

39 | 40 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

41 | 42 | 43 |

References

44 | 45 |

No reference.

46 | 47 | 48 |

See Also

49 | 50 |

ReadCLM

51 | 52 |
[Package LPJmLmdi version 1.0 Index]
53 | 54 | -------------------------------------------------------------------------------- /LPJmLmdi/html/ReadPRO.html: -------------------------------------------------------------------------------- 1 | R: Read *.pro files as produced from GENOUD 2 | 3 | 4 | 5 | 6 |
ReadPRO {LPJmLmdi}R Documentation
7 | 8 |

Read *.pro files as produced from GENOUD

9 | 10 |

Description

11 | 12 |

The function is used within OptimizeLPJgenoud

13 | 14 | 15 |

Usage

16 | 17 |
ReadPRO(files.pro)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 |
files.pro 25 |

file names (*.pro) of genoud optimization results

26 |
28 | 29 | 30 |

Details

31 | 32 |

No details.

33 | 34 | 35 |

Value

36 | 37 |

The function returns a data.frame with number of individual, cost and parameer values

38 | 39 | 40 |

Author(s)

41 | 42 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

43 | 44 | 45 |

References

46 | 47 |

No reference.

48 | 49 |
[Package LPJmLmdi version 1.0 Index]
50 | 51 | -------------------------------------------------------------------------------- /LPJmLmdi/html/SSE.html: -------------------------------------------------------------------------------- 1 | R: Sum-of-squared residuals error 2 | 3 | 4 | 5 | 6 |
SSE {LPJmLmdi}R Documentation
7 | 8 |

Sum-of-squared residuals error

9 | 10 |

Description

11 | 12 |

The function implements the sum-of-squared residuals error as cost function

13 | 14 | 15 |

Usage

16 | 17 |
SSE(sim, obs, unc)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 | 32 | 35 |
sim 25 |

vector of simulations

26 |
obs 29 |

vector of observations

30 |
unc 33 |

vector of observation uncertainties

34 |
36 | 37 | 38 |

Details

39 | 40 |

No details.

41 | 42 | 43 |

Author(s)

44 | 45 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

46 | 47 | 48 |

References

49 | 50 |

No reference.

51 | 52 | 53 |

Examples

54 | 55 |
56 | 
57 | obs <- rnorm(10, 0, 2)
58 | sim <- obs + rnorm(10, 0.05, 0.01)
59 | unc <- 0.01
60 | SSE(sim, obs, unc)
61 | 
62 | 
63 | 64 |
[Package LPJmLmdi version 1.0 Index]
65 | 66 | -------------------------------------------------------------------------------- /LPJmLmdi/html/StandardError.html: -------------------------------------------------------------------------------- 1 | R: Compute standard errors from a variance-covariance matrix 2 | 3 | 4 | 5 | 6 |
StandardError {LPJmLmdi}R Documentation
7 | 8 |

Compute standard errors from a variance-covariance matrix

9 | 10 |

Description

11 | 12 |

SE = sqrt(diag(vc) * cost^2 / (nobs - npar))

13 | 14 | 15 |

Usage

16 | 17 |
StandardError(vc, nobs, cost)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 | 32 | 35 |
vc 25 |

variance-covarianc ematrix

26 |
nobs 29 |

number of observations

30 |
cost 33 |

cost function value

34 |
36 | 37 | 38 |

Details

39 | 40 |

No details.

41 | 42 | 43 |

Author(s)

44 | 45 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

46 | 47 | 48 |

References

49 | 50 |

No reference.

51 | 52 |
[Package LPJmLmdi version 1.0 Index]
53 | 54 | -------------------------------------------------------------------------------- /LPJmLmdi/html/StartingValues.html: -------------------------------------------------------------------------------- 1 | R: Get starting values for genoud from *.pro file 2 | 3 | 4 | 5 | 6 |
StartingValues {LPJmLmdi}R Documentation
7 | 8 |

Get starting values for genoud from *.pro file

9 | 10 |

Description

11 | 12 |

The function extracts the best individuals trhat occured during a genoud optimization from a *.pro file. These best individuals can be used as starting values if a optimization is restarted. This function is called within OptimizeLPJgenoud is a restart is performed.

13 | 14 | 15 |

Usage

16 | 17 |
StartingValues(file.optresult, pop.size = NULL, ...)
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 | 32 | 35 |
file.optresult 25 |

genoud *.pro file with optimization results

26 |
pop.size 29 |

population size

30 |
... 33 |

further arguments (not used)

34 |
36 | 37 | 38 |

Details

39 | 40 |

No details.

41 | 42 | 43 |

Author(s)

44 | 45 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

46 | 47 | 48 |

References

49 | 50 |

No reference.

51 | 52 | 53 |

See Also

54 | 55 |

OptimizeLPJgenoud

56 | 57 |
[Package LPJmLmdi version 1.0 Index]
58 | 59 | -------------------------------------------------------------------------------- /LPJmLmdi/html/VarCovMatrix.html: -------------------------------------------------------------------------------- 1 | R: Compute variance-covariance matrix 2 | 3 | 4 | 5 | 6 |
VarCovMatrix {LPJmLmdi}R Documentation
7 | 8 |

Compute variance-covariance matrix

9 | 10 |

Description

11 | 12 |

The function computes the variance-covariance matrix from the hessian matrix. Parameters that have a hessian = 0 (in sensitive parameters) area removed from the matrix before calculating the variance-covariance matrix.

13 | 14 | 15 |

Usage

16 | 17 |
VarCovMatrix(hessian, nms = paste("P", 1:n, sep = ""))
18 | 19 | 20 |

Arguments

21 | 22 | 23 | 24 | 27 | 28 | 31 |
hessian 25 |

Hessian matrix

26 |
nms 29 |

names of the parameters (rows and columns in the matrix

30 |
32 | 33 | 34 |

Details

35 | 36 |

No details.

37 | 38 | 39 |

Author(s)

40 | 41 |

Matthias Forkel <mforkel@bgc-jena.mpg.de> [aut, cre]

42 | 43 | 44 |

References

45 | 46 |

No reference.

47 | 48 |
[Package LPJmLmdi version 1.0 Index]
49 | 50 | -------------------------------------------------------------------------------- /LPJmLmdi/inst_LPJmL35/param_template.conf: -------------------------------------------------------------------------------- 1 | /*********************************************************************/ 2 | /* */ 3 | /* p a r a m . c o n f */ 4 | /* */ 5 | /* Default input parameter file for LPJmL C Version 3.5.003 */ 6 | /* */ 7 | /* Last change: 17.01.2009 */ 8 | /* */ 9 | /*********************************************************************/ 10 | 11 | #include "PAR_FILE_CELL" /* LPJ parameter file */ 12 | #ifdef NEW_HYDROLOGY 13 | #include "par/soil_new.par" /* Soil parameter file */ 14 | #include "PAR_PFT_FILE_CELL" /* PFT parameter file */ 15 | #else 16 | #include "par/soil_2layers.par" /* Soil parameter file for original 2-layer hydrology */ 17 | #include "par/pft_2layers.par" /* PFT parameter file for original 2-layer hydrology (rootdist vs. beta_root) */ 18 | #endif 19 | 20 | 21 | #ifdef WITH_LANDUSE 22 | #ifdef WITH_LAIMAX_CFT 23 | #include "par/manage_laimax_alphaa_revision_1241_sc.par" /* Management parameter file */ 24 | #else 25 | #include "par/manage.par" /* Management parameter file */ 26 | #endif 27 | #include "par/manage_reg.par" /* Management parameter file for regions*/ 28 | #endif 29 | #include "par/outputvars.par" 30 | -------------------------------------------------------------------------------- /LPJmLmdi/inst_LPJmL35/param_template.par: -------------------------------------------------------------------------------- 1 | /**********************************************************************/ 2 | /** **/ 3 | /** p a r a m . p a r **/ 4 | /** **/ 5 | /** LPJ parameter file for LPJmL version 3.5.003 **/ 6 | /** **/ 7 | /** Last change: $Date:: 2013-08-19 12:43:56 +0200 (Mon, 19 Au#$ **/ 8 | /** By : $Author:: sibylls $ **/ 9 | /** **/ 10 | /**********************************************************************/ 11 | 12 | 0.3 /* k_litter10 (1/yr) */ 13 | 0.03 /* fast k_soil10 (1/yr) */ 14 | 0.001 /* slow k_soil10 (1/yr) */ 15 | 20000.0 /* max. snow pack (mm) */ 16 | 278.0 /* pre-industrial CO2 (ppmv) */ 17 | 0.0548 /* k */ 18 | 0.7 /* theta */ 19 | 0.5 /* k_beer */ 20 | ALPHAC3 /* alphac3 */ 21 | ALPHAC4 /* alphac4 */ 22 | 0.015 /* bc3 leaf respiration as fraction of Vmax for C3 plants */ 23 | 0.035 /* bc4 leaf respiration as fraction of Vmax for C4 plants */ 24 | 0.25 /* r_growth */ 25 | 3.26 /* GM */ 26 | 1.391 /* ALPHAM Priestlex-Taylor coefficient*/ 27 | 3.0e4 /* Michaelis constant for O2 (Pa) at 25 deg C */ 28 | 30 /* Michaelis constant for CO2 (Pa) at 25 deg C */ 29 | 0.7 /* atmfrac */ 30 | 0.98 /* fastfrac */ 31 | #ifdef WITH_LANDUSE 32 | 0.9 /* irrigation threshold */ 33 | 1.0 /* fraction of soil filled with water during irrigation event */ 34 | 5 /* maximum LAI */ 35 | 1 /* intercrops on setaside (0:FALSE, 1:TRUE) */ 36 | 0 /* remove residuals (0:FALSE, 1:TRUE) */ 37 | 1900 /* year in which sowing dates shall be fixed */ 38 | 2000 /* set landuse year for LANDUSE_CONST case */ 39 | #endif 40 | -------------------------------------------------------------------------------- /LPJmLmdi/inst_LPJmL35/pft_template.par: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/LPJmLmdi/inst_LPJmL35/pft_template.par -------------------------------------------------------------------------------- /LPJmLmdi/inst_gldas/LPJmL_parameter-table.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/LPJmLmdi/inst_gldas/LPJmL_parameter-table.xlsx -------------------------------------------------------------------------------- /LPJmLmdi/inst_gldas/param_template.js: -------------------------------------------------------------------------------- 1 | /**************************************************************************************/ 2 | /** \n**/ 3 | /** p a r a m . j s \n**/ 4 | /** \n**/ 5 | /** Default input parameter file for LPJmL C Version 4.0.001 \n**/ 6 | /** \n**/ 7 | /** (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file \n**/ 8 | /** authors, and contributors see AUTHORS file \n**/ 9 | /** This file is part of LPJmL and licensed under GNU AGPL Version 3 \n**/ 10 | /** or later. See LICENSE file or go to http://www.gnu.org/licenses/ \n**/ 11 | /** Contact: https://github.com/PIK-LPJmL/LPJmL \n**/ 12 | /** \n**/ 13 | /**************************************************************************************/ 14 | 15 | #include "PAR_FILE_CELL" /* LPJ parameter file */ 16 | #include "par/soil.js" /* Soil parameter file */ 17 | #include "PAR_PFT_FILE_CELL" /* PFT parameter file*/ 18 | 19 | #include "par/manage_laimax_alphaa_fao.y.1999.2009_date.2017-10-19_lpj.rev.4176-4184M.js" /* Management parameter file */ 20 | #include "par/manage_reg.js" /* Management parameter file for regions*/ 21 | #include "par/outputvars.js" 22 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCBoBS.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCBoBS} 2 | \alias{AggFPCBoBS} 3 | \title{Temporal aggregation for BoBS PFT: get BoBS from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCBoBS(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCBoNE.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCBoNE} 2 | \alias{AggFPCBoNE} 3 | \title{Temporal aggregation for BoNE PFT: get BoNE from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCBoNE(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCBoNS.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCBoNS} 2 | \alias{AggFPCBoNS} 3 | \title{Temporal aggregation for BoNS PFT: get BoNS from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCBoNS(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCPoH.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCPoH} 2 | \alias{AggFPCPoH} 3 | \title{Temporal aggregation for PoH PFT: get PoH from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCPoH(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCTeBE.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCTeBE} 2 | \alias{AggFPCTeBE} 3 | \title{Temporal aggregation for PFTs: get TeBE from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCTeBE(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCTeBS.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCTeBS} 2 | \alias{AggFPCTeBS} 3 | \title{Temporal aggregation for PFTs: get TeBS from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCTeBS(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCTeH.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCTeH} 2 | \alias{AggFPCTeH} 3 | \title{Temporal aggregation for PFTs: get TeH from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCTeH(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCTeNE.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCTeNE} 2 | \alias{AggFPCTeNE} 3 | \title{Temporal aggregation for PFTs: get TeNE from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCTeNE(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCTrBE.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCTrBE} 2 | \alias{AggFPCTrBE} 3 | \title{Temporal aggregation for PFTs: get TrBE from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCTrBE(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggFPCTrBR.Rd: -------------------------------------------------------------------------------- 1 | \name{AggFPCTrBR} 2 | \alias{AggFPCTrBR} 3 | \title{Temporal aggregation for PFTs: get TrBR from vector of all PFTs, average over years} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggFPCTrBR(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggMSC.Rd: -------------------------------------------------------------------------------- 1 | \name{AggMSC} 2 | \alias{AggMSC} 3 | \title{Temporal aggregation: mean seasonal cycle} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggMSC(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns the mean seasonal cycle} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggMaxNULL.Rd: -------------------------------------------------------------------------------- 1 | \name{AggMaxNULL} 2 | \alias{AggMaxNULL} 3 | \title{Temporal aggregation: aggregate by using annual maximum} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggMaxNULL(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggMeanMean.Rd: -------------------------------------------------------------------------------- 1 | \name{AggMeanMean} 2 | \alias{AggMeanMean} 3 | \title{Temporal aggregation: first mean, then mean = mean over all values} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggMeanMean(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggMeanNULL.Rd: -------------------------------------------------------------------------------- 1 | \name{AggMeanNULL} 2 | \alias{AggMeanNULL} 3 | \title{Temporal aggregation: first mean, then nothing = mean per group} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggMeanNULL(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggNULLMean.Rd: -------------------------------------------------------------------------------- 1 | \name{AggNULLMean} 2 | \alias{AggNULLMean} 3 | \title{Temporal aggregation: mean over all values} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggNULLMean(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggQ09NULL.Rd: -------------------------------------------------------------------------------- 1 | \name{AggQ09NULL} 2 | \alias{AggQ09NULL} 3 | \title{Temporal aggregation: aggregate by using quantile with prob=0.9} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggQ09NULL(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggSumMean.Rd: -------------------------------------------------------------------------------- 1 | \name{AggSumMean} 2 | \alias{AggSumMean} 3 | \title{Temporal aggregation: first sum, then mean} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggSumMean(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AggSumNULL.Rd: -------------------------------------------------------------------------------- 1 | \name{AggSumNULL} 2 | \alias{AggSumNULL} 3 | \title{Temporal aggregation: first sum, then nothing = sum per group} 4 | \description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} 5 | \usage{AggSumNULL(x, agg)} 6 | \arguments{ 7 | \item{x}{full time series} 8 | \item{agg}{vector of grouping elements (years)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a the aggregated result.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{IntegrationDataset}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/AllEqual.Rd: -------------------------------------------------------------------------------- 1 | \name{AllEqual} 2 | \alias{AllEqual} 3 | \title{Check if all values in a vector are the same} 4 | \description{This function is used to check if all values in a vector are equal. It can be used for example to check if a time series contains only 0 or NA values.} 5 | \usage{AllEqual(x)} 6 | \arguments{ 7 | \item{x}{numeric, character vector, or time series of type ts} 8 | } 9 | 10 | \value{The function returns TRUE if all values are equal and FALSE if it contains different values.} 11 | 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | 17 | \examples{ 18 | # check if all values are equal in the following vectors: 19 | AllEqual(1:10) 20 | AllEqual(rep(0, 10)) 21 | AllEqual(letters) 22 | AllEqual(rep(NA, 10)) 23 | } 24 | -------------------------------------------------------------------------------- /LPJmLmdi/man/BarplotCost.Rd: -------------------------------------------------------------------------------- 1 | \name{BarplotCost} 2 | \alias{BarplotCost} 3 | \title{plot a barplot of the cost change from prior to best parameter set} 4 | \description{The function plots two barplots that are showing the change in the cost per dataset.} 5 | \usage{BarplotCost(rescue.l, type = 1:2, ylim = NULL, set.par = TRUE, 6 | ...)} 7 | \arguments{ 8 | \item{rescue.l}{a list of class "rescue", see \code{\link{CombineRescueFiles}}} 9 | \item{type}{plot type: 1 barplot of total cost from prior and best, 2: change of cost per data set } 10 | \item{ylim}{limits of y-axis (works for type = 2)} 11 | \item{set.par}{set par() settings from \code{\link{DefaultParL}}} 12 | \item{\dots}{further arguments for \code{\link{plot}}} 13 | } 14 | \details{No details.} 15 | 16 | \references{No reference. } 17 | \author{Matthias Forkel [aut, cre]} 18 | 19 | 20 | 21 | \seealso{\code{\link{CombineRescueFiles}}} 22 | \examples{ 23 | # files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) 24 | # rescue.l <- CombineRescueFiles(files, remove=FALSE) 25 | # BarplotCost(rescue.l) 26 | } 27 | -------------------------------------------------------------------------------- /LPJmLmdi/man/BreakColors.Rd: -------------------------------------------------------------------------------- 1 | \name{BreakColors} 2 | \alias{BreakColors} 3 | \title{Colours from class breaks} 4 | \description{Creates colour palettes from a vector of class breaks} 5 | \usage{BreakColors(x, pal = NULL, rev = FALSE, cols = NULL, ...)} 6 | \arguments{ 7 | \item{x}{numeric vector of class breaks} 8 | \item{pal}{name of a colour palette from \code{\link{brewer.pal}}} 9 | \item{rev}{should the colour palette be reversed?} 10 | \item{cols}{alternatively, a colour vector to be interpolated} 11 | \item{\dots}{Further arguments (unused)} 12 | } 13 | \details{No details.} 14 | \value{The function returns a vector of colours.} 15 | \references{No reference. } 16 | \author{Matthias Forkel [aut, cre]} 17 | 18 | 19 | 20 | \seealso{\code{\link{BreakColours}}} 21 | \examples{ 22 | 23 | brks1 <- seq(0, 10, 2) 24 | cols1 <- BreakColours(brks1) 25 | 26 | brks2 <- seq(-100, 100, 25) 27 | cols2 <- BreakColours(brks2) 28 | 29 | brks3 <- seq(-100, 100, 25) 30 | cols3 <- BreakColours(brks3, pal="BrBG") 31 | 32 | brks4 <- seq(0, 10, 1) 33 | cols4 <- BreakColours(brks4, cols=c("red", "green", "blue"), rev=TRUE) 34 | 35 | MapRb() 36 | LegendBarRb(brks=brks1, cols=cols1) 37 | LegendBarRb(brks=brks2, cols=cols2, pos="top", lon = c(-180, 180), lat = c(-20, -15)) 38 | LegendBarRb(brks=brks3, cols=cols3, pos="inside", lon = c(-180, 180), lat = c(15, 20)) 39 | LegendBarRb(brks=brks4, cols=cols4, pos="inside", lon = c(-180, 180), lat = c(30, 35)) 40 | 41 | } 42 | -------------------------------------------------------------------------------- /LPJmLmdi/man/BreakColours.Rd: -------------------------------------------------------------------------------- 1 | \name{BreakColours} 2 | \alias{BreakColours} 3 | \title{Colours from class breaks} 4 | \description{Creates colour palettes from a vector of class breaks} 5 | \usage{BreakColours(x, pal = NULL, rev = FALSE, cols = NULL, ...)} 6 | \arguments{ 7 | \item{x}{numeric vector of class breaks} 8 | \item{pal}{name of a colour palette from \code{\link{brewer.pal}}} 9 | \item{rev}{should the colour palette be reversed?} 10 | \item{cols}{alternatively, a colour vector to be interpolated} 11 | \item{\dots}{Further arguments (unused)} 12 | } 13 | \details{No details.} 14 | \value{The function returns a vector of colours.} 15 | \references{No reference. } 16 | \author{Matthias Forkel [aut, cre]} 17 | 18 | 19 | 20 | \seealso{\code{\link{BreakColours}}} 21 | \examples{ 22 | 23 | brks1 <- seq(0, 10, 2) 24 | cols1 <- BreakColours(brks1) 25 | 26 | brks2 <- seq(-100, 100, 25) 27 | cols2 <- BreakColours(brks2) 28 | 29 | brks3 <- seq(-100, 100, 25) 30 | cols3 <- BreakColours(brks3, pal="BrBG") 31 | 32 | brks4 <- seq(0, 10, 1) 33 | cols4 <- BreakColours(brks4, cols=c("red", "green", "blue"), rev=TRUE) 34 | 35 | MapRb() 36 | LegendBarRb(brks=brks1, cols=cols1) 37 | LegendBarRb(brks=brks2, cols=cols2, pos="top", lon = c(-180, 180), lat = c(-20, -15)) 38 | LegendBarRb(brks=brks3, cols=cols3, pos="inside", lon = c(-180, 180), lat = c(15, 20)) 39 | LegendBarRb(brks=brks4, cols=cols4, pos="inside", lon = c(-180, 180), lat = c(30, 35)) 40 | 41 | } 42 | -------------------------------------------------------------------------------- /LPJmLmdi/man/Breaks.Rd: -------------------------------------------------------------------------------- 1 | \name{Breaks} 2 | \alias{Breaks} 3 | \title{Class breaks for plotting} 4 | \description{Calculates class breakpoints based on quantiles.} 5 | \usage{Breaks(x, n = 12, quantile = c(0.01, 0.99), zero.min = FALSE, 6 | ...)} 7 | \arguments{ 8 | \item{x}{numeric vector} 9 | \item{n}{number of breaks} 10 | \item{quantile}{lower and upper quantiles that should be used to exclude outliers} 11 | \item{zero.min}{should the minimum break be at 0? } 12 | \item{\dots}{Further arguments (unused)} 13 | } 14 | \details{No details.} 15 | \value{The function returns a vector of values.} 16 | \references{No reference. } 17 | \author{Matthias Forkel [aut, cre]} 18 | 19 | 20 | 21 | \seealso{\code{\link{BreakColours}}} 22 | \examples{ 23 | 24 | Breaks(rnorm(100, 50, 30)) 25 | Breaks(runif(100, 10, 30)) 26 | Breaks(rlnorm(100)) 27 | 28 | } 29 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ChangeParamFile.Rd: -------------------------------------------------------------------------------- 1 | \name{ChangeParamFile} 2 | \alias{ChangeParamFile} 3 | \title{Change parameters in a parameter file} 4 | \description{The function writes values to a parameter file. It requires a 'file.template' in which the positions of the new parameter values are marked with a flag. For example, instead of a parameter of 0.5 for alphaa in a parameter file the flag ALPHAA is written. The function substitutes this flag with the new parameter value in a new file 'file.new'.} 5 | \usage{ChangeParamFile(newpar, file.template, file.new, wait = FALSE, 6 | ...)} 7 | \arguments{ 8 | \item{newpar}{a named vector with new parameter values} 9 | \item{file.template}{file name of the template parameter with flagged parameters} 10 | \item{file.new}{file name of the new parameter file} 11 | \item{wait}{If TRUE wait 1 second to check if file.template exists in order to relax slow file writting.} 12 | \item{\dots}{further arguments (currently not used)} 13 | } 14 | \details{The function works only on Unix systems because it is based on 'sed'} 15 | 16 | \references{No reference.} 17 | \author{Matthias Forkel [aut, cre]} 18 | 19 | 20 | 21 | 22 | \examples{ 23 | 24 | # newpar <- c(ALPHAA_BoNE=0.8) 25 | # LPJChangeParamFile(newpar, file.template="pft_template.par", file.new="pft.par") 26 | 27 | } 28 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ChangeSoilCodeFile.Rd: -------------------------------------------------------------------------------- 1 | \name{ChangeSoilCodeFile} 2 | \alias{ChangeSoilCodeFile} 3 | \title{Change soil code in LPJ soil code file} 4 | \description{The function changes the soil code for the specified grid cells and writes a new LPJ soil code file.} 5 | \usage{ChangeSoilCodeFile(file.soilcode, file.soilcode.new, xy, newcode, 6 | file.grid = "cru.grid", ...)} 7 | \arguments{ 8 | \item{file.soilcode}{original soil code file} 9 | \item{file.soilcode.new}{new soil code file} 10 | \item{xy}{matrix of grid cells (lon, lat) where the soil code should be changed} 11 | \item{newcode}{new soil code at each grid cell (vector with length = nrow(xy))} 12 | \item{file.grid}{grid file for the original soil code file} 13 | \item{\dots}{further arguments (currently not used)} 14 | } 15 | \details{No details.} 16 | 17 | \references{No reference.} 18 | \author{Matthias Forkel [aut, cre]} 19 | 20 | 21 | 22 | \seealso{\code{\link{ReadBIN}}} 23 | 24 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CheckLPJpar.Rd: -------------------------------------------------------------------------------- 1 | \name{CheckLPJpar} 2 | \alias{CheckLPJpar} 3 | \title{Checks LPJ parameters 'LPJpar'} 4 | \description{The function checks if LPJ parameters are within the lower and upper boundaries or are 0. } 5 | \usage{CheckLPJpar(lpjpar, correct = FALSE)} 6 | \arguments{ 7 | \item{lpjpar}{object of class 'LPJpar'} 8 | \item{correct}{correct parameter values (TRUE) or return error message?} 9 | } 10 | \details{No details.} 11 | \value{the function return an object of class 'LPJpar'} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{LPJpar}} } 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CheckMemoryUsage.Rd: -------------------------------------------------------------------------------- 1 | \name{CheckMemoryUsage} 2 | \alias{CheckMemoryUsage} 3 | \title{Check usage of memory by R objects} 4 | \description{Prints a message about the used memory and writes a file with the used memory per each R object.} 5 | \usage{CheckMemoryUsage(...)} 6 | \arguments{ 7 | \item{\dots}{The function has no arguments.} 8 | } 9 | 10 | \value{a data.frame } 11 | 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CombineLPJpar.Rd: -------------------------------------------------------------------------------- 1 | \name{CombineLPJpar} 2 | \alias{CombineLPJpar} 3 | \title{Combines several 'LPJpar' objects into one} 4 | \description{The function takes several lpjpar objects and combines them into one LPJpar object} 5 | \usage{CombineLPJpar(lpjpar.l)} 6 | \arguments{ 7 | \item{lpjpar.l}{a list of \code{\link{LPJpar}} objects} 8 | } 9 | \details{No details.} 10 | \value{The function returns a list of class 'LPJparList'} 11 | \references{No reference.} 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | \seealso{\code{\link{LPJpar}}} 17 | 18 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CombineRescueFiles.Rd: -------------------------------------------------------------------------------- 1 | \name{CombineRescueFiles} 2 | \alias{CombineRescueFiles} 3 | \title{Combine single rescue files into one rescue file} 4 | \description{Within OptimizeLPJgenoud, RunLPJ creates rescue file ("_.rescue0.RData") that save the parameter vectors and cost of each individual during optimization. These files allow to create restart files to restart OptimizeLPJgenoud (\code{\link{CreateRestartFromRescue}}). During OptimizeLPJgenoud many rescue files can be created. The function CombineRescueFiles reads the individual files, combines the rescue objects, saves it in one "rescue.RData" file, and deletes the single files.} 5 | \usage{CombineRescueFiles(files.rescue, remove = TRUE)} 6 | \arguments{ 7 | \item{files.rescue}{file names} 8 | \item{remove}{save new rescue file and delete single rescue files?} 9 | } 10 | \details{No details.} 11 | \value{The function returns a list of class "rescue", whereby each element corresponds to one individual of the genetic optimization with two entries: 'cost' (cost of the individual) and 'dpar' (parameter scaled relative to the prior parameter).} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{CreateRestartFromRescue}}, \code{\link{plot.rescue}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CorW.Rd: -------------------------------------------------------------------------------- 1 | \name{CorW} 2 | \alias{CorW} 3 | \title{Weighted correlation} 4 | \description{Compute the correlation.} 5 | \usage{CorW(x, y, w = rep(1, length(x)))} 6 | \arguments{ 7 | \item{x}{a vector of x values} 8 | \item{y}{a vector of y values} 9 | \item{w}{vector of weights} 10 | } 11 | \details{No details.} 12 | 13 | \references{No reference. } 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{ObjFct}}} 19 | \examples{ 20 | 21 | x <- 1:5 22 | y <- x * -1 + rnorm(5) 23 | cor(x, y) 24 | CorW(x, y, w=c(1, 1, 1, 2, 2)) 25 | } 26 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CorrelationMatrixS.Rd: -------------------------------------------------------------------------------- 1 | \name{CorrelationMatrixS} 2 | \alias{CorrelationMatrixS} 3 | \title{plot a correlation matrix} 4 | 5 | \usage{CorrelationMatrixS(data, method = "spearman", iscor = NULL, main = "", 6 | ...)} 7 | \arguments{ 8 | \item{data}{a correlation matrix or a data.frame (} 9 | \item{method}{method to compute the correlation} 10 | \item{iscor}{Is 'data' a correlation matrix?} 11 | \item{main}{main title for the plot} 12 | \item{\dots}{further arguments for \code{\link{plot}}} 13 | } 14 | \details{No details.} 15 | 16 | \references{No reference. } 17 | \author{Matthias Forkel [aut, cre]} 18 | 19 | 20 | 21 | \seealso{\code{\link{CombineRescueFiles}}} 22 | 23 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CostMDS.KGE.Rd: -------------------------------------------------------------------------------- 1 | \name{CostMDS.KGE} 2 | \alias{CostMDS.KGE} 3 | \title{Cost function for multiple data streams based on Kling-Gupta efficiency} 4 | \description{The function computes for each grid cell and data stream in 'integrationdata' the cost besed on the Kling-Gupta efficiency (KGE, Gupta et al. 2009, J. Hydrology). See Forkel et al. (in prep.) for the specific use of KGE for multiple data streams.} 5 | \usage{CostMDS.KGE(integrationdata)} 6 | \arguments{ 7 | \item{integrationdata}{object of class 'integrationdata', see \code{\link{IntegrationData}}} 8 | } 9 | \details{No details.} 10 | \value{The function returns a list with the total cost (total), the cost per KGE component (per.cell), per data streams (per.ds), per KGE component and data stream (per.cell.ds), and the fractional contribution of a data stream and KGE component to the total cost (fractional).} 11 | \references{No reference. } 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CostMDS.KGEw.Rd: -------------------------------------------------------------------------------- 1 | \name{CostMDS.KGEw} 2 | \alias{CostMDS.KGEw} 3 | \title{Cost function for multiple data streams based on a weighted Kling-Gupta efficiency} 4 | \description{The function computes for each grid cell and data stream in 'integrationdata' the cost besed on the Kling-Gupta efficiency (KGE, Gupta et al. 2009, J. Hydrology). Thereby each component of KGE is weighted by the uncertainty of the observations (i.e. weighted mean, variance and correlation). See Forkel et al. (in prep.) for the specific use of KGE for multiple data streams.} 5 | \usage{CostMDS.KGEw(integrationdata)} 6 | \arguments{ 7 | \item{integrationdata}{object of class 'integrationdata', see \code{\link{IntegrationData}}} 8 | } 9 | \details{No details.} 10 | \value{The function returns a list with the total cost (total), the cost per KGE component (per.cell), per data streams (per.ds), per KGE component and data stream (per.cell.ds), and the fractional contribution of a data stream and KGE component to the total cost (fractional).} 11 | \references{No reference. } 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | 17 | \examples{ 18 | 19 | # load(paste0(path.me, "/lpj/LPJmL_131016/out_optim/opt_fpc/OFPC_BO-GI-BM_v1_all_0_59_posterior-best.RData")) 20 | # x <- result.post.lpj$integrationdata 21 | # plot(x, 2) 22 | 23 | # cost.see <- CostMDS.SSE(x) 24 | # cost.kge <- CostMDS.KGE(x) 25 | # cost.kgew <- CostMDS.KGEw(x) 26 | 27 | # DefaultParL(mfrow=c(1,3)) 28 | # barplot(cost.see$per.ds) 29 | # barplot(t(cost.kge$per.cell.ds)) 30 | # barplot(t(cost.kgew$per.cell.ds)) 31 | 32 | } 33 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CostMDS.SSE.Rd: -------------------------------------------------------------------------------- 1 | \name{CostMDS.SSE} 2 | \alias{CostMDS.SSE} 3 | \title{Cost function for multiple data streams based on SSE} 4 | \description{The function computes the cost for each grid cell and data stream in 'integrationdata'. Firstly, the cost per data stream and grid cell is computed using the defined 'CostFunction' for each \code{\link{IntegrationDataset}}. Secondly, the cost is weighted by (1) the dataset-specific weight, (2) the number of observations per grid cell and data streams, and (3) by the grid cell area.} 5 | \usage{CostMDS.SSE(integrationdata)} 6 | \arguments{ 7 | \item{integrationdata}{object of class 'integrationdata', see \code{\link{IntegrationData}}} 8 | } 9 | \details{No details.} 10 | \value{The function returns a list with the total cost, the cost per grid cell, per data streams, per grid cell and data stream, the error as computed with the defined CostFunction, the number of observations per grid cell and data stream, the weighting factors and grid cell area.} 11 | \references{No reference. } 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /LPJmLmdi/man/CreateRestartFromRescue.Rd: -------------------------------------------------------------------------------- 1 | \name{CreateRestartFromRescue} 2 | \alias{CreateRestartFromRescue} 3 | \title{Create a *.pro file from binary rescue files to restart optimization} 4 | \description{The function creates a *.pro file friom binary 'rescue' files. The *.pro file can be used to restart OptimizeLPJgenoud. } 5 | \usage{CreateRestartFromRescue(path.rescue, pop.size)} 6 | \arguments{ 7 | \item{path.rescue}{directory where the resuce files from each iteration of the optimization are saved.} 8 | \item{pop.size}{(estimated) population size of the genetic optimization} 9 | } 10 | \details{No details.} 11 | 12 | \references{No reference.} 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{genoudLPJrescue}} } 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/DefaultParL.Rd: -------------------------------------------------------------------------------- 1 | \name{DefaultParL} 2 | \alias{DefaultParL} 3 | \title{default 'par' settings for plots} 4 | \description{The function calls 'par' with some default settings to improve plots. See \code{\link{par}} for details.} 5 | \usage{DefaultParL(mfrow = c(1, 1), mar = c(3.7, 3.5, 2.5, 0.5), oma = c(0.8, 6 | 0.1, 0.1, 0.2), mgp = c(2.4, 1, 0), cex = 1.3, cex.lab = cex * 7 | 1.1, cex.axis = cex * 1.1, cex.main = cex * 1.1, ...)} 8 | \arguments{ 9 | \item{mfrow}{number of rows/columns} 10 | \item{mar}{margins} 11 | \item{oma}{outer margins} 12 | \item{mgp}{margin line for axis title, label and lines} 13 | \item{cex}{text and symbol size} 14 | \item{cex.lab}{label size} 15 | \item{cex.axis}{axis anootation size } 16 | \item{cex.main}{title size} 17 | \item{\dots}{further arguments to \code{\link{par}}} 18 | } 19 | \details{No details.} 20 | 21 | \references{No reference.} 22 | \author{Matthias Forkel [aut, cre]} 23 | 24 | 25 | 26 | \seealso{\code{\link{par}}} 27 | \examples{ 28 | 29 | DefaultParL() 30 | plot(1:10) 31 | 32 | } 33 | -------------------------------------------------------------------------------- /LPJmLmdi/man/Df2optim.Rd: -------------------------------------------------------------------------------- 1 | \name{Df2optim} 2 | \alias{Df2optim} 3 | \title{Convert a data.frame to a \code{\link{optim}} list } 4 | \description{The function takes a 'data.frame' as created by \code{\link{Rescue2DF}} and converts it to a list with the same structure like the results of the \code{\link{optim}} and \code{\link{genoud}} functions.} 5 | \usage{Df2optim(optim.df, pop.size = NA, ...)} 6 | \arguments{ 7 | \item{optim.df}{a 'data.frame' as created by \code{\link{Rescue2DF}}} 8 | \item{pop.size}{used population size. If NA, ngen (number of generations) and peak generation cannot be returned correctly. In this case both estimates will be 1.} 9 | \item{\dots}{further arguments (currently not used)} 10 | } 11 | \details{No details.} 12 | 13 | \references{No reference. } 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{CombineRescueFiles}}} 19 | \examples{ 20 | # files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) 21 | # rescue.l <- CombineRescueFiles(files, remove=FALSE) 22 | # optim.df <- Rescue2Df(rescue.l) 23 | # opt <- Rescue2optim(rescue.l) 24 | # opt 25 | } 26 | -------------------------------------------------------------------------------- /LPJmLmdi/man/EstOptimUse.Rd: -------------------------------------------------------------------------------- 1 | \name{EstOptimUse} 2 | \alias{EstOptimUse} 3 | \title{Estimate optimal number of jobs given a number of cluster nodes} 4 | 5 | \usage{EstOptimUse(nodes = 16, wish = 1000)} 6 | \arguments{ 7 | \item{nodes}{number of cluster nodes that you want to use} 8 | \item{wish}{approx. number of elements} 9 | } 10 | \details{No details.} 11 | \value{an integer value} 12 | \references{No reference.} 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{WriteCLM}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/FileExistsWait.Rd: -------------------------------------------------------------------------------- 1 | \name{FileExistsWait} 2 | \alias{FileExistsWait} 3 | \title{Iterative checking and waiting for a file.} 4 | \description{The function repeately checks if a file exists and returns TRUE if the file is existing.} 5 | \usage{FileExistsWait(file, waitmin = 0, waitinterval = 0.5, waitmax = 2, 6 | ...)} 7 | \arguments{ 8 | \item{file}{file for which checking and waiting should be applied} 9 | \item{waitmin}{minimum waiting time (seconds) } 10 | \item{waitinterval}{interval after which the existence of the file should be checked again (seconds)} 11 | \item{waitmax}{maximum waiting time (seconds)} 12 | \item{\dots}{further arguments (currently not used)} 13 | } 14 | \details{No details.} 15 | 16 | \references{No reference. } 17 | \author{Matthias Forkel [aut, cre]} 18 | 19 | 20 | 21 | 22 | \examples{ 23 | 24 | FileExistsWait(system.file("external/rlogo.grd", package="raster")) 25 | FileExistsWait("nofile.txt") 26 | 27 | } 28 | -------------------------------------------------------------------------------- /LPJmLmdi/man/GridProperties.Rd: -------------------------------------------------------------------------------- 1 | \name{GridProperties} 2 | \alias{GridProperties} 3 | \title{Derive grid properties from an object of class 'LPJfiles'} 4 | \description{The function reads the grid of the input files in 'LPJfiles' and computes the area per grid cell.} 5 | \usage{GridProperties(lpjfiles, res = 0.5, ...)} 6 | \arguments{ 7 | \item{lpjfiles}{list of class 'LPJinput'} 8 | \item{res}{resolution of LPJmL} 9 | \item{\dots}{further arguments (currently not used)} 10 | } 11 | \details{No details.} 12 | \value{the function returns a list with 'grid' (raster of grid cells), 'area' (vector of grid cell area) and 'ncell' (number of grid cells)} 13 | \references{No reference.} 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{LPJfiles}} } 19 | 20 | -------------------------------------------------------------------------------- /LPJmLmdi/man/InfoCLM.Rd: -------------------------------------------------------------------------------- 1 | \name{InfoCLM} 2 | \alias{InfoCLM} 3 | \title{Returns information about a CLM file} 4 | 5 | \usage{InfoCLM(file.clm, endian = "little", ...)} 6 | \arguments{ 7 | \item{file.clm}{CLM file name with extension *.clm} 8 | \item{endian}{endianess of the file} 9 | \item{\dots}{Further arguments (currently not used).} 10 | } 11 | \details{No details.} 12 | 13 | \references{No reference.} 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{WriteLPJinput}}} 19 | 20 | -------------------------------------------------------------------------------- /LPJmLmdi/man/InfoLPJ.Rd: -------------------------------------------------------------------------------- 1 | \name{InfoLPJ} 2 | \alias{InfoLPJ} 3 | \title{Information about a LPJmL binary file} 4 | \description{The function reads information about a LPJ binary output file.} 5 | \usage{InfoLPJ(file.bin = "fpc.bin", file.grid = "grid.bin", file.annual = c("vegc.bin", 6 | "litc.bin", "soilc.bin"), size = 4, data.type = numeric(), 7 | ...)} 8 | \arguments{ 9 | \item{file.bin}{binary LPJ output file} 10 | \item{file.grid}{binary LPJ grid file} 11 | \item{file.annual}{one of the binary LPJ output files with annual data} 12 | \item{size}{the number of bytes per element in the byte stream.} 13 | \item{data.type}{data type of the file (default=numeric())} 14 | \item{\dots}{further arguments (currently not used)} 15 | } 16 | \details{No details.} 17 | \value{The function returns a list with information about the LPJ binary file (number of grid cells, number of years, number of bands, spatial extent).} 18 | \references{No reference.} 19 | \author{Matthias Forkel [aut, cre]} 20 | 21 | 22 | 23 | \seealso{\code{\link{ReadLPJ}}} 24 | \examples{ 25 | 26 | # InfoLPJ("vegc.bin") 27 | 28 | } 29 | -------------------------------------------------------------------------------- /LPJmLmdi/man/InfoNCDF.Rd: -------------------------------------------------------------------------------- 1 | \name{InfoNCDF} 2 | \alias{InfoNCDF} 3 | \title{Get information about variables in a NetCDF} 4 | 5 | \usage{InfoNCDF(file)} 6 | \arguments{ 7 | \item{file}{file name} 8 | } 9 | 10 | \value{The function returns a list with information about the dimensions and variables in the NetCDF file.} 11 | 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | \seealso{\code{\link{WriteNCDF4}}} 17 | 18 | -------------------------------------------------------------------------------- /LPJmLmdi/man/IntegrationData.Rd: -------------------------------------------------------------------------------- 1 | \name{IntegrationData} 2 | \alias{IntegrationData} 3 | \title{Create an object of class 'IntegrationData'} 4 | \description{The function takes several objects of class \code{\link{IntegrationDataset}} and converts them to an object 'IntegrationData' that is used in \code{\link{RunLPJ}} and \code{\link{OptimizeLPJgenoud}}. } 5 | \usage{IntegrationData(...)} 6 | \arguments{ 7 | \item{\dots}{one or several objects of class 'IntegrationDataset'} 8 | } 9 | \details{No details.} 10 | \value{The function returns a list of class 'IntegrationData' } 11 | \references{No reference. } 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | \seealso{\code{\link{IntegrationDataset}}} 17 | \examples{ 18 | 19 | # # grid cells for which LPJmL should be run and for which the integration data should be extracted 20 | # xy <- cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75)) 21 | 22 | # # use monthly FAPAR in model-data integration 23 | # fapar <- IntegrationDataset(name="FAPAR", unit="", 24 | # data.val.file="GIMMS.FAPAR.1982.2011.nc", 25 | # data.unc.file=0.12, 26 | # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), 27 | # model.val.file="mfapar.bin", 28 | # model.agg=NULL, 29 | # xy=xy, 30 | # data.factor=NULL, 31 | # cost=TRUE, 32 | # CostFunction=SSE, 33 | # weight=1) 34 | 35 | # # use mean annual GPP in model-data integration 36 | # gpp <- IntegrationDataset(name="GPP", unit="gC m-2 yr-1", 37 | # data.val.file="MTE.GPP.1982.2011.meanannual.nc", 38 | # data.unc.file="MTE.GPPunc.1982.2011.meanannual.nc", 39 | # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), 40 | # model.val.file="mgpp.bin", 41 | # model.agg=AggSumMean, # sum of each year, mean over all years -> mean annual GPP 42 | # xy=xy, 43 | # data.factor=NULL, 44 | # cost=TRUE, 45 | # CostFunction=SSE, 46 | # weight=1) 47 | 48 | # integrationdata <- IntegrationData(fapar, gpp) 49 | 50 | } 51 | -------------------------------------------------------------------------------- /LPJmLmdi/man/IntegrationData2Df.Rd: -------------------------------------------------------------------------------- 1 | \name{IntegrationData2Df} 2 | \alias{IntegrationData2Df} 3 | \title{Converts IntegrationData to a data.frame} 4 | \description{The function takes an object of class \code{\link{IntegrationData}} and converts it into a data.frame in long format. The data.frame has the columns 'lon', 'lat', 'time' and 'id' (a combination of lon_lat_time), and columns for each variable in IntegrationData.} 5 | \usage{IntegrationData2Df(x, sim.name = "sim", ...)} 6 | \arguments{ 7 | \item{x}{object of class \code{\link{IntegrationData}}} 8 | \item{sim.name}{name that should be added to the variables for the simulation (e.g. use 'sim', or something like 'prior' or 'posterior' to create column names like 'FAPAR.sim')} 9 | \item{\dots}{further arguments (not used)} 10 | } 11 | \details{No details.} 12 | \value{a data.frame} 13 | \references{No reference. } 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{IntegrationData}}} 19 | 20 | -------------------------------------------------------------------------------- /LPJmLmdi/man/LE2ET.Rd: -------------------------------------------------------------------------------- 1 | \name{LE2ET} 2 | \alias{LE2ET} 3 | \title{Compute evapotranspiration (ET) from latent heat (LE).} 4 | 5 | \usage{LE2ET(le, temp = 20, rho_w = 1000)} 6 | \arguments{ 7 | \item{le}{latent heat (W m-2)} 8 | \item{temp}{temperature (degC, default 20 degC)} 9 | \item{rho_w}{ 10 | } 11 | } 12 | 13 | \value{The function returns evapotranspiration (mm day-1)} 14 | \references{FAO (1998): Crop evapotranspiration - Guidelines for computing crop water requirements - FAO Irrigation and drainage paper 56, http://www.fao.org/docrep/x0490e/x0490e04.htm} 15 | \author{Matthias Forkel [aut, cre]} 16 | 17 | 18 | 19 | \seealso{\code{\link{WriteLPJinput}}} 20 | \examples{ 21 | # Example from FAO (1998) 22 | le <- 12 # latent heat that is used to vapourize water (MJ m-2 day-1) 23 | le <- le / 86400 # MJ m-2 day-1 -> MJ m-2 sec-1 24 | le <- le * 1E6 # MJ m-2 sec-1 -> W m-2 25 | LE2ET(le=le) 26 | 27 | temp <- -30:40 28 | et <- LE2ET(le=le, temp=temp) 29 | plot(temp, et) 30 | } 31 | -------------------------------------------------------------------------------- /LPJmLmdi/man/LPJ2NCDF.Rd: -------------------------------------------------------------------------------- 1 | \name{LPJ2NCDF} 2 | \alias{LPJ2NCDF} 3 | \title{Convert binary LPJmL model output files to NetCDF} 4 | \description{The function converts a binary LPJmL output file to NetCDF } 5 | \usage{LPJ2NCDF(file, var.name, var.unit, start = 1982, end = 2011, 6 | sim.start.year = 1901, var.longname = var.name, run.name = "LPJmL", 7 | run.description = "LPJmL run", provider = "M. Forkel, matthias.forkel@geo.tuwien.ac.at", 8 | creator = provider, reference = "Sitch et al. 2003 GCB, Gerten et al. 2004 J. Hydrol., Thonicke et al. 2010 BG, Schaphoff et al. 2013 ERL, Forkel et al. 2014 BG", 9 | ...)} 10 | \arguments{ 11 | \item{file}{file name of LPJmL model output, e.g. "mgpp.bin"} 12 | \item{var.name}{variable name, e.g. "GPP"} 13 | \item{var.unit}{variable unit, e.g. "gC m-2 mon-1"} 14 | \item{start}{first year for which the data should be converted to NetCDF} 15 | \item{end}{last year for which the data should be converted to NetCDF} 16 | \item{sim.start.year}{first year of the simulation} 17 | \item{var.longname}{long variable name, e.g. "gross primary production"} 18 | \item{run.name}{name of the LPJmL run (will be part of the file names)} 19 | \item{run.description}{description of the LPJmL run} 20 | \item{provider}{name of the provider} 21 | \item{creator}{name of the creator} 22 | \item{reference}{ 23 | } 24 | \item{\dots}{further arguments (currently not used)} 25 | } 26 | \details{No details.} 27 | 28 | \references{No reference. } 29 | \author{Matthias Forkel [aut, cre]} 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /LPJmLmdi/man/LPJfiles.Rd: -------------------------------------------------------------------------------- 1 | \name{LPJfiles} 2 | \alias{LPJfiles} 3 | \title{Create an object of class 'LPJfiles'} 4 | \description{The function creates a list of class 'LPJfiles' that defines all paths, input files, and configurations files for a LPJ run.} 5 | \usage{LPJfiles(path.lpj, path.tmp, path.out, sim.start.year, sim.end.year = NA, 6 | lpj.conf, param.conf, pft.par, param.par, input.conf, input, 7 | ...)} 8 | \arguments{ 9 | \item{path.lpj}{path where LPJ is installed} 10 | \item{path.tmp}{path for temporary outputs } 11 | \item{path.out}{path for results} 12 | \item{sim.start.year}{start year of the LPJ simulation as defined in lpjml.conf} 13 | \item{sim.end.year}{last year of the LPJ simulation as defined in lpjml.conf} 14 | \item{lpj.conf}{template for LPJ configuration file (create a template from lpjml.conf)} 15 | \item{param.conf}{template for parameter configuration file (create a template from param.conf)} 16 | \item{pft.par}{template file for PFT-specific parameters (create a template from pft.par)} 17 | \item{param.par}{template file for global parameters (create a template from param.par)} 18 | \item{input.conf}{template file for input data (create a template from input.conf)} 19 | \item{input}{a data.frame of LPJ input files with 2 columns. The first coumn defines the flag as in written in the input.conf template file and the second column the file name, e.g. data.frame(name=c("GRID_FILE", "TMP_FILE"), file=c("cru.grid", "temp.bin"))} 20 | \item{\dots}{further arguments (currently not used)} 21 | } 22 | \details{No details.} 23 | 24 | \references{No reference. } 25 | \author{Matthias Forkel [aut, cre]} 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /LPJmLmdi/man/LPJmLmdi-package.Rd: -------------------------------------------------------------------------------- 1 | \name{LPJmLmdi-package} 2 | \alias{LPJmLmdi-package} 3 | \alias{LPJmLmdi} 4 | \docType{package} 5 | \title{Model-Data Integration for the LPJmL Dynamic Global Vegetation Model} 6 | } 7 | \description{Model-data integration framework for the LPJmL dynamic global vegetation model. Specifically, the package provides functions 1) to optimize LPJmL model parameters using the GENOUD genetic optimization algorithm, 2) to read and write LPJmL input data, and 3) to read LPJmL output files.} 8 | } 9 | \details{ 10 | 11 | The DESCRIPTION file: 12 | \packageDESCRIPTION{LPJmLmdi} 13 | \packageIndices{LPJmLmdi} 14 | } 15 | \author{Matthias Forkel [aut, cre]} 16 | 17 | Maintainer: \packageMaintainer{LPJmLmdi} 18 | } 19 | 20 | \keyword{ package } 21 | 22 | 23 | -------------------------------------------------------------------------------- /LPJmLmdi/man/LPJpar.Rd: -------------------------------------------------------------------------------- 1 | \name{LPJpar} 2 | \alias{LPJpar} 3 | \title{Create an object of class 'LPJpar'} 4 | \description{The function creates a data.frame of class 'LPJpar' that defines the parameters for LPJ runs.} 5 | \usage{LPJpar(par.prior, par.lower, par.upper, par.pftspecif, par.names, 6 | is.int = rep(FALSE, length(par.prior)), ...)} 7 | \arguments{ 8 | \item{par.prior}{parameter vector (prior)} 9 | \item{par.lower}{lower boundaries for parameters} 10 | \item{par.upper}{upper boundaries for parameters} 11 | \item{par.pftspecif}{Which parameter is PFT specific (TRUE) or global (FALSE)?} 12 | \item{par.names}{parameter name} 13 | \item{is.int}{is parameter a integer?} 14 | \item{\dots}{further arguments for CheckLPJpar} 15 | } 16 | \details{No details.} 17 | \value{The function returns a list of class 'LPJpar'} 18 | \references{No reference. } 19 | \author{Matthias Forkel [aut, cre]} 20 | 21 | 22 | 23 | \seealso{\code{\link{CheckLPJpar}} } 24 | 25 | -------------------------------------------------------------------------------- /LPJmLmdi/man/LPJparList.Rd: -------------------------------------------------------------------------------- 1 | \name{LPJparList} 2 | \alias{LPJparList} 3 | \title{Create a list of 'LPJpar' objects} 4 | \description{The function creates a list of \code{\link{LPJpar}} objects that can be used to compare parameters from different optimization experiments} 5 | \usage{LPJparList(...)} 6 | \arguments{ 7 | \item{\dots}{objects of class \code{\link{LPJpar}}} 8 | } 9 | \details{No details.} 10 | \value{The function returns a list of class 'LPJparList'} 11 | \references{No reference.} 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | \seealso{\code{\link{LPJpar}}} 17 | 18 | -------------------------------------------------------------------------------- /LPJmLmdi/man/LPJppNBP.Rd: -------------------------------------------------------------------------------- 1 | \name{LPJppNBP} 2 | \alias{LPJppNBP} 3 | \title{Post-process LPJmL model output: calculate NEE} 4 | \description{The function calculates NEE from LPJmL model output} 5 | \usage{LPJppNBP(path, start = 1982, end = 2011, sim.start.year = 1901, 6 | ...)} 7 | \arguments{ 8 | \item{path}{directory with LPJmL outputs in *.bin format} 9 | \item{start}{first year for which the data should be converted to NetCDF} 10 | \item{end}{last year for which the data should be converted to NetCDF} 11 | \item{sim.start.year}{first year of the simulation} 12 | \item{\dots}{further arguments (currently not used)} 13 | } 14 | 15 | 16 | \references{No reference. } 17 | \author{Matthias Forkel [aut, cre]} 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /LPJmLmdi/man/LWin2LWnet.Rd: -------------------------------------------------------------------------------- 1 | \name{LWin2LWnet} 2 | \alias{LWin2LWnet} 3 | \title{Compute long-wave net radiation from long-wave incoming radiation and temperature.} 4 | 5 | \usage{LWin2LWnet(lwin, temp, emissivity = 0.97)} 6 | \arguments{ 7 | \item{lwin}{long-wave incoming radiation (Wm-2)} 8 | \item{temp}{temperature (degC, conversion to K is done within the function)} 9 | \item{emissivity}{emissivity of the surface. Values around 0.97 are valid for various natural surface types (leaves 0.94-0.99, soil 0.93-0.96, water 0.96) (Campbell and Norman 1998, p. 162-163, 177). } 10 | } 11 | \details{Long-wave net radiation is computed as the difference between long-wave incoming and long-wave outgoing radiation. Long-wave outgoing radiation is computed based on the Stefan-Boltzmann law and an emissivity factor (LWout = emissivity * sigma * temp^4), whereas sigma is the Stefan-Boltzmann constant (5.67037 * 10^(-8) Wm-2 K-4) (Campbell and Norman 1998, p. 162-163, 177).} 12 | \value{The function returns long-wave net radiation (Wm-2)} 13 | \references{Campbell GS, Norman JM (1998) An Introduction to Environmental Biophysics. Springer New York, New York, NY.} 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{WriteLPJinput}}} 19 | \examples{ 20 | lwin <- 200:380 # long-wave incoming radiation (Wm-2) 21 | temp <- 0.14 * lwin - 32 + rnorm(length(lwin), 0, 5) # temperature (degC) 22 | plot(lwin, temp) 23 | lwnet <- LWin2LWnet(lwin, temp) 24 | plot(temp, lwnet) 25 | plot(lwin, lwnet) 26 | } 27 | -------------------------------------------------------------------------------- /LPJmLmdi/man/LegendBar.Rd: -------------------------------------------------------------------------------- 1 | \name{LegendBar} 2 | \alias{LegendBar} 3 | \title{Add a colour legend bar to a plot} 4 | \description{Adds a colour legend bar to a plot} 5 | \usage{LegendBar(x, y, brks = seq(0, 1, by = 0.2), cols = NULL, brks.txt = NULL, 6 | title = "", srt = NULL, col.txt = "black", cex.txt = 1, ...)} 7 | \arguments{ 8 | \item{x}{x coordinates for the legend bar} 9 | \item{y}{y coordinates for the legend bar} 10 | \item{brks}{class breaks for the legend bar} 11 | \item{cols}{colours for each class. If NULL grey scales are used.} 12 | \item{brks.txt}{text labels for the class breaks. If NULL, 'brks' are used} 13 | \item{title}{title for the legend bar} 14 | \item{srt}{rotation of breaks text labels} 15 | \item{col.txt}{colour for text labels} 16 | \item{cex.txt}{size of the text labels} 17 | \item{\dots}{arguments (unused)} 18 | } 19 | \details{No details.} 20 | 21 | \references{No reference. } 22 | \author{Matthias Forkel [aut, cre]} 23 | 24 | 25 | 26 | \seealso{\code{\link{CRSll}}} 27 | \examples{ 28 | 29 | plot.new() 30 | LegendBar(x=c(0.1, 0.9), y=c(0.4, 0.6)) 31 | LegendBar(x=c(0.1, 0.5), y=c(0.7, 0.8)) 32 | 33 | brks <- seq(-1, 1, 0.2) 34 | cols <- BreakColors(brks) 35 | LegendBar(x=c(0.6, 1), y=c(0.7, 0.8), brks=brks, cols=cols, title="My title") 36 | 37 | LegendBar(x=c(0.2, 0.8), y=c(0.1, 0.2), brks=brks, cols=cols, col.txt="purple", title="purple", srt=90) 38 | 39 | } 40 | -------------------------------------------------------------------------------- /LPJmLmdi/man/MeanW.Rd: -------------------------------------------------------------------------------- 1 | \name{MeanW} 2 | \alias{MeanW} 3 | \title{Weighted mean} 4 | \description{Compute the weighted mean.} 5 | \usage{MeanW(x, w = rep(1, length(x)))} 6 | \arguments{ 7 | \item{x}{a vector} 8 | \item{w}{vector of weights} 9 | } 10 | \details{No details.} 11 | 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{ObjFct}}} 18 | \examples{ 19 | 20 | x <- 1:5 21 | mean(x) 22 | MeanW(x, w=c(1, 1, 1, 2, 2)) 23 | } 24 | -------------------------------------------------------------------------------- /LPJmLmdi/man/PlotPar.Rd: -------------------------------------------------------------------------------- 1 | \name{PlotPar} 2 | \alias{PlotPar} 3 | \title{Plot parameter vs. cost} 4 | \description{The function takes an object of class 'rescue' (see \code{\link{CombineRescueFiles}}) (alternatively a 'data.frame' as created with \code{\link{Rescue2Df}}) and a 'LPJpar' object and plots different plots of cost vs. parameter value and parameter uncertainties.} 5 | \usage{PlotPar(rescue.l, lpjpar, par.name = NULL, ...)} 6 | \arguments{ 7 | \item{rescue.l}{a list of class "rescue" (\code{\link{CombineRescueFiles}}) or alternatively a data.frame as created with \code{\link{Rescue2Df}}.} 8 | \item{lpjpar}{a list of class "LPJpar" (see \code{\link{LPJpar}})} 9 | \item{par.name}{name(s) of the parameters that should be plotted } 10 | \item{\dots}{further arguments (currently not used)} 11 | } 12 | \details{No details.} 13 | 14 | \references{No reference. } 15 | \author{Matthias Forkel [aut, cre]} 16 | 17 | 18 | 19 | \seealso{\code{\link{CombineRescueFiles}}} 20 | \examples{ 21 | # files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) 22 | # rescue.l <- CombineRescueFiles(files, remove=FALSE) 23 | # PlotPar(rescue.l, lpjpar) 24 | } 25 | -------------------------------------------------------------------------------- /LPJmLmdi/man/PlotParPCA.Rd: -------------------------------------------------------------------------------- 1 | \name{PlotParPCA} 2 | \alias{PlotParPCA} 3 | \title{plot a PCA of optimized parameters} 4 | \description{The function takes an object of class 'rescue' (see \code{\link{CombineRescueFiles}}), computes a PCA (principle component analysis) based on the model parameter sets and cost function values of the optimization, and plots PCA results as biplots. } 5 | \usage{PlotParPCA(rescue.l, ...)} 6 | \arguments{ 7 | \item{rescue.l}{a list of class "rescue", see \code{\link{CombineRescueFiles}}} 8 | \item{\dots}{further arguments for \code{\link{plot}}} 9 | } 10 | \details{No details.} 11 | \value{The function returns an object of class 'princomp'.} 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{CombineRescueFiles}}, \code{\link{princomp}}} 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/PlotParUnc.Rd: -------------------------------------------------------------------------------- 1 | \name{PlotParUnc} 2 | \alias{PlotParUnc} 3 | \title{Plot the psoterior parameter uncertainty} 4 | \description{The function takes an object of class \code{\link{LPJpar}} and plots the relative uncertainty of the optimized parameters, i.e. uncertainty_best / uncertainty_prior} 5 | \usage{PlotParUnc(lpjpar, uncertainty = "uncertainty.005", ylab = "Relative parameter uncertainty", 6 | main = NULL, ...)} 7 | \arguments{ 8 | \item{lpjpar}{a list of class "LPJpar" (see \code{\link{LPJpar}})} 9 | \item{uncertainty}{name of the uncertainty estimate in LPJpar that should be used to compute posterior uncertainties} 10 | \item{ylab}{label of y-axis} 11 | \item{main}{title of plot} 12 | \item{\dots}{further arguments for plot} 13 | } 14 | \details{No details.} 15 | 16 | \references{No reference. } 17 | \author{Matthias Forkel [aut, cre]} 18 | 19 | 20 | 21 | \seealso{\code{\link{CombineRescueFiles}}} 22 | \examples{ 23 | # PlotParUnc(lpjpar) 24 | } 25 | -------------------------------------------------------------------------------- /LPJmLmdi/man/PlotWorld110.Rd: -------------------------------------------------------------------------------- 1 | \name{PlotWorld110} 2 | \alias{PlotWorld110} 3 | \title{Plot a world map based on 1:110Mio data} 4 | 5 | \usage{PlotWorld110(admin = FALSE, lakes = TRUE, rivers = TRUE, col = c("black", 6 | "blue", "red"), bg = NA, ...)} 7 | \arguments{ 8 | \item{admin}{Plot administrative boundaries?} 9 | \item{lakes}{Plot lakes?} 10 | \item{rivers}{Plot rivers?} 11 | \item{col}{Colors for (1) coastlines, (2) rivers and (3) administrative boundaries} 12 | \item{bg}{background color, default: NA (no background)} 13 | \item{\dots}{additional arguments to plot} 14 | } 15 | 16 | 17 | 18 | \author{Matthias Forkel [aut, cre]} 19 | 20 | 21 | 22 | 23 | \examples{ 24 | 25 | PlotWorld110() 26 | 27 | } 28 | -------------------------------------------------------------------------------- /LPJmLmdi/man/PrepareRestartFiles.Rd: -------------------------------------------------------------------------------- 1 | \name{PrepareRestartFiles} 2 | \alias{PrepareRestartFiles} 3 | \title{Prepare restart files to restart OptimizeLPJgenoud} 4 | \description{The function prepares all files that are needed to restart OptimizeLPJgenoud} 5 | \usage{PrepareRestartFiles(file.optsetup, ...)} 6 | \arguments{ 7 | \item{file.optsetup}{OptimizeLPJgenoud setup file, ends with "_optsetup.RData"} 8 | \item{\dots}{further arguments (currently not used)} 9 | } 10 | \details{No details.} 11 | 12 | \references{No reference.} 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{LPJfiles}} } 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadBIN.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadBIN} 2 | \alias{ReadBIN} 3 | \title{Read simple binary files without header Read a CLM file to a SpatialPixelsDataFrame} 4 | \description{The function is used to read for example the soil*.bin and drainclass.bin files} 5 | \usage{ReadBIN(file.bin, nbands = 1, size = 1, file.grid = NA, endian.data = "little", 6 | endian.grid = "little", data.type = integer(), ...)} 7 | \arguments{ 8 | \item{file.bin}{binary file name with extension *.bin} 9 | \item{nbands}{number of bands per year} 10 | \item{size}{The number of bytes per element in the byte stream.} 11 | \item{file.grid}{file name of the corresponding grid file} 12 | \item{endian.data}{endinaess of the data file} 13 | \item{endian.grid}{endianess of the grid file} 14 | \item{data.type}{type of the data} 15 | \item{\dots}{Further arguments (currently not used).} 16 | } 17 | \details{No details.} 18 | 19 | \references{No reference.} 20 | \author{Matthias Forkel [aut, cre]} 21 | 22 | 23 | 24 | \seealso{\code{\link{WriteCLM}}} 25 | \examples{ 26 | 27 | # ReadBIN("soil_new_67420.bin") 28 | 29 | } 30 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadCLM.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadCLM} 2 | \alias{ReadCLM} 3 | \title{Read a CLM file to a SpatialPixelsDataFrame} 4 | 5 | \usage{ReadCLM(file.clm, start = NA, end = NA, start.year = NA, grid = NULL, 6 | nbands = NA, size = NA, file.grid = NA, endian.data = NA, 7 | endian.grid = "big", data.type = integer(), ...)} 8 | \arguments{ 9 | \item{file.clm}{CLM file name with extension *.clm} 10 | \item{start}{first year to be read} 11 | \item{end}{last year to be read, reads until last year in case of NA} 12 | \item{start.year}{first year in the dataset, read from header information in case NA} 13 | \item{grid}{a matrix of coordinates (lon, lat) if data should be read only for specific cells, if NULL the data for all grid cells is read} 14 | \item{nbands}{number of bands per year, read from header information in case NA} 15 | \item{size}{The number of bytes per element in the byte stream.} 16 | \item{file.grid}{file name of the corresponding grid file} 17 | \item{endian.data}{endinaess of the data file} 18 | \item{endian.grid}{endianess of the grid file} 19 | \item{data.type}{type of the data} 20 | \item{\dots}{Further arguments (currently not used).} 21 | } 22 | \details{No details.} 23 | 24 | \references{No reference.} 25 | \author{Matthias Forkel [aut, cre]} 26 | 27 | 28 | 29 | \seealso{\code{\link{WriteCLM}}} 30 | 31 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadGrid.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadGrid} 2 | \alias{ReadGrid} 3 | \title{Reads a binary input data grid file.} 4 | 5 | \usage{ReadGrid(file.grid = "cru.grid", endian = "little", ...)} 6 | \arguments{ 7 | \item{file.grid}{CLM file name with extension *.clm} 8 | \item{endian}{endianess of the file} 9 | \item{\dots}{Further arguments (currently not used).} 10 | } 11 | \details{No details.} 12 | 13 | \references{No reference.} 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{ReadCLM}}} 19 | 20 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadLPJ.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadLPJ} 2 | \alias{ReadLPJ} 3 | \title{Read a LPJ binary file} 4 | \description{The function reads a binary LPJ output file and returns a SpatialPointsDataFrame} 5 | \usage{ReadLPJ(file.bin, file.grid = "grid.bin", sim.start.year = 1901, 6 | start = sim.start.year, end = NA, file.annual = c("vegc.bin", 7 | "litc.bin", "soilc.bin"), size = 4, data.type = numeric(), 8 | endian = "little", ...)} 9 | \arguments{ 10 | \item{file.bin}{binary LPJ output file} 11 | \item{file.grid}{binary LPJ grid file} 12 | \item{sim.start.year}{first year of the simulation} 13 | \item{start}{first year to read} 14 | \item{end}{last year to read, reads until last year if NA} 15 | \item{file.annual}{one of the binary LPJ output files with annual data} 16 | \item{size}{the number of bytes per element in the byte stream.} 17 | \item{data.type}{data type of the file (default=numeric())} 18 | \item{endian}{endianess of the binary file} 19 | \item{\dots}{further arguments (currently not used)} 20 | } 21 | \details{No details.} 22 | \value{The function returns a SpatialPointsDataFrame.} 23 | \references{No reference.} 24 | \author{Matthias Forkel [aut, cre]} 25 | 26 | 27 | 28 | \seealso{\code{\link{ReadLPJsim}}} 29 | \examples{ 30 | 31 | # ReadLPJ("mgpp.bin", start=1982, end=2011) 32 | 33 | } 34 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadLPJ2IntegrationData.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadLPJ2IntegrationData} 2 | \alias{ReadLPJ2IntegrationData} 3 | \title{Read LPJ model results into an of class IntegrationData} 4 | \description{The function reads for each dataset in \code{\link{IntegrationData}} the corresponding model output and performs temporal aggregation.} 5 | \usage{ReadLPJ2IntegrationData(integrationdata, xy, lpjfiles, ...)} 6 | \arguments{ 7 | \item{integrationdata}{object of class \code{\link{IntegrationData}}} 8 | \item{xy}{matrix of grid cell coordinates to run LPJ} 9 | \item{lpjfiles}{list of class \code{\link{LPJfiles}} that define all LPJ directories, input files, configuration template files} 10 | \item{\dots}{further arguments (currently not used)} 11 | } 12 | \details{No details.} 13 | \value{The function returns the same list oc class 'IntegrationData' but with added model outputs.} 14 | \references{No reference.} 15 | \author{Matthias Forkel [aut, cre]} 16 | 17 | 18 | 19 | \seealso{\code{\link{IntegrationData}}} 20 | 21 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadLPJ2ts.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadLPJ2ts} 2 | \alias{ReadLPJ2ts} 3 | \title{Read a LPJ binary file and returns a spatial averaged time series} 4 | \description{The function reads LPJ binary output files *.bin, aggregates (mean) the time series over all grid cells and returns the regional-averaged time series} 5 | \usage{ReadLPJ2ts(file.bin, sim.start.year = 1901, start = sim.start.year, 6 | end = NA, ...)} 7 | \arguments{ 8 | \item{file.bin}{binary LPJ output file} 9 | \item{sim.start.year}{first year of the simulation} 10 | \item{start}{first year to read} 11 | \item{end}{last year to read, reads until last year if NA} 12 | \item{\dots}{further arguments (currently not used)} 13 | } 14 | \details{No details.} 15 | \value{The function returns a time series of class 'ts'.} 16 | \references{No reference.} 17 | \author{Matthias Forkel [aut, cre]} 18 | 19 | 20 | 21 | \seealso{\code{\link{ReadLPJsim}}} 22 | \examples{ 23 | 24 | # gpp <- ReadLPJ2ts("mgpp.bin") 25 | 26 | } 27 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadLPJinput.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadLPJinput} 2 | \alias{ReadLPJinput} 3 | \title{Read and subset CLM files to LPJinput objects} 4 | \description{The functions reads a CLM file, selects the data according to the provided grid and returns an object of class LPJinput. } 5 | \usage{ReadLPJinput(files, grid = NULL, start = NA, ...)} 6 | \arguments{ 7 | \item{files}{character vector of CLM or binary file names} 8 | \item{grid}{Matrix of grid cells with 2 columns: longitude and latitude (optional). If NULL the data is returned for the grid of the first CLM file. If a grid is provided the data is subesetted for the specified grid cells.} 9 | \item{start}{first year to read} 10 | \item{\dots}{Further arguments to ReadCLM or ReadBIN} 11 | } 12 | \details{No details.} 13 | \value{The function returns a list of class "LPJinput".} 14 | \references{No reference.} 15 | \author{Matthias Forkel [aut, cre]} 16 | 17 | 18 | 19 | \seealso{\code{\link{WriteLPJinput}}} 20 | \examples{ 21 | 22 | # lpjinput <- ReadLPJinput("cru_ts_3.20.1901.2011.tmp.clm", grid=cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75))) 23 | # str(lpjinput) 24 | 25 | } 26 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadLPJsim.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadLPJsim} 2 | \alias{ReadLPJsim} 3 | \title{Read a LPJ simulation results} 4 | \description{The function reads all binary output files from a LPJ simulation and returns regional aggregated time series.} 5 | \usage{ReadLPJsim(sim.start.year = 1901, start = sim.start.year, end = NA, 6 | files = NA, outputvars.par = NULL, ...)} 7 | \arguments{ 8 | \item{sim.start.year}{first year of the simulation} 9 | \item{start}{first year to read} 10 | \item{end}{last year to read. If NA, reads until last year} 11 | \item{files}{Which LPJ binary output files should be read? If NA, all *.bin files in the current directory are read.} 12 | \item{outputvars.par}{path and file name to the LPJmL 'outputvars.par' file. If NULL the file is searched 1 level above or below the current working directory. } 13 | \item{\dots}{further arguments (currently not used)} 14 | } 15 | \details{No details.} 16 | \value{The function returns a list of class 'LPJsim'} 17 | \references{No reference.} 18 | \author{Matthias Forkel [aut, cre]} 19 | 20 | 21 | 22 | \seealso{\code{\link{ReadLPJ2ts}}} 23 | \examples{ 24 | 25 | # setwd(path.mylpjresult) 26 | # sim <- ReadLPJsim(start=1982, end=2011) 27 | 28 | } 29 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadOutputvars.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadOutputvars} 2 | \alias{ReadOutputvars} 3 | \title{Read 'outputvars.par' to get information about LPJmL output} 4 | \description{LPJmL output is defined in par/outputvars.par. This file contains for each variable the id, name, variable name, description, unit, and scale. This file can be used to correctly read LPJmL output. The function is for example used within \code{\link{ReadLPJsim}}.} 5 | \usage{ReadOutputvars(outputvars.par = NULL, ...)} 6 | \arguments{ 7 | \item{outputvars.par}{path and file name to the LPJmL 'outputvars.par' file. If NULL the file is searched 1 level above or below the current working directory. } 8 | \item{\dots}{further arguments (currently not used)} 9 | } 10 | \details{No details.} 11 | \value{The function returns a time series of class 'ts'.} 12 | \references{No reference.} 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{ReadLPJsim}}} 18 | \examples{ 19 | 20 | # ReadOutputvars() 21 | 22 | } 23 | -------------------------------------------------------------------------------- /LPJmLmdi/man/ReadPRO.Rd: -------------------------------------------------------------------------------- 1 | \name{ReadPRO} 2 | \alias{ReadPRO} 3 | \title{Read *.pro files as produced from GENOUD} 4 | \description{The function is used within OptimizeLPJgenoud} 5 | \usage{ReadPRO(files.pro)} 6 | \arguments{ 7 | \item{files.pro}{file names (*.pro) of genoud optimization results.} 8 | } 9 | \details{No details.} 10 | \value{The function returns a data.frame with number of individual, cost and parameer values} 11 | \references{No reference. } 12 | \author{Matthias Forkel [aut, cre]} 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /LPJmLmdi/man/RegridLPJinput.Rd: -------------------------------------------------------------------------------- 1 | \name{RegridLPJinput} 2 | \alias{RegridLPJinput} 3 | \title{Regrid or subset LPJmL input } 4 | \description{Subsets grid cells or regrids LPJmL input files.} 5 | \usage{RegridLPJinput(files, grid.clm, grid, path.out, overwrite = TRUE, 6 | ...)} 7 | \arguments{ 8 | \item{files}{character vector of CLM or binary file names} 9 | \item{grid.clm}{old grid *.clm file} 10 | \item{grid}{Matrix of new grid cells with 2 columns: longitude and latitude (optional). If NULL the data is returned for the grid of the first CLM file. If a grid is provided the data is subesetted for the specified grid cells.} 11 | \item{path.out}{directory where the new files should be saved} 12 | \item{overwrite}{overwrite existing files?} 13 | \item{\dots}{further arguments (currently not used)} 14 | } 15 | \details{No details.} 16 | \value{The function returns TRUE if the CLM file was created.} 17 | \references{No reference.} 18 | \author{Matthias Forkel [aut, cre]} 19 | 20 | 21 | 22 | \seealso{\code{\link{WriteLPJinput}}} 23 | \examples{ 24 | # no example 25 | } 26 | -------------------------------------------------------------------------------- /LPJmLmdi/man/Rescue2Df.Rd: -------------------------------------------------------------------------------- 1 | \name{Rescue2Df} 2 | \alias{Rescue2Df} 3 | \title{Convert a 'rescue' list to a data.frame} 4 | \description{The function takes an object of class 'rescue' (see \code{\link{CombineRescueFiles}}) and converts it to a data.frame including the total cost value (1st column), the parameter values (next columns), and the log-likelihood, Akaike's Information Criterion (AIC) and AIC differences (last columns). If 'lpjpar' it not specified the function returns just the scaled parameters (e.g. dpar = par / prior) otherwise it returns the parameters in the original units (e.g. par = dpar * prior).} 5 | \usage{Rescue2Df(rescue.l, lpjpar = NULL, ...)} 6 | \arguments{ 7 | \item{rescue.l}{a list of class "rescue", see \code{\link{CombineRescueFiles}}} 8 | \item{lpjpar}{a list of class "LPJpar" (see \code{\link{LPJpar}}) to convert the scaled parameters in rescue.l back to the original units (optional)} 9 | \item{\dots}{further arguments (currently not used)} 10 | } 11 | \details{No details.} 12 | \value{The function returns a data.frame.} 13 | \references{No reference. } 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{CombineRescueFiles}}} 19 | \examples{ 20 | # files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) 21 | # rescue.l <- CombineRescueFiles(files, remove=FALSE) 22 | # optim.df <- Rescue2Df(rescue.l) 23 | # summary(optim.df) 24 | } 25 | -------------------------------------------------------------------------------- /LPJmLmdi/man/SSE.Rd: -------------------------------------------------------------------------------- 1 | \name{SSE} 2 | \alias{SSE} 3 | \title{Sum-of-squared residuals error} 4 | \description{The function implements the sum-of-squared residuals error as cost function} 5 | \usage{SSE(sim, obs, unc)} 6 | \arguments{ 7 | \item{sim}{vector of simulations} 8 | \item{obs}{vector of observations} 9 | \item{unc}{vector of observation uncertainties} 10 | } 11 | \details{No details.} 12 | 13 | \references{No reference. } 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | 19 | \examples{ 20 | 21 | obs <- rnorm(10, 0, 2) 22 | sim <- obs + rnorm(10, 0.05, 0.01) 23 | unc <- 0.01 24 | SSE(sim, obs, unc) 25 | 26 | } 27 | -------------------------------------------------------------------------------- /LPJmLmdi/man/SdW.Rd: -------------------------------------------------------------------------------- 1 | \name{SdW} 2 | \alias{SdW} 3 | \title{Weighted standard deviation} 4 | \description{Compute the standard deviation.} 5 | \usage{SdW(x, w = rep(1, length(x)))} 6 | \arguments{ 7 | \item{x}{a vector} 8 | \item{w}{vector of weights} 9 | } 10 | \details{No details.} 11 | 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{ObjFct}}} 18 | \examples{ 19 | 20 | x <- 1:5 21 | sd(x) 22 | SdW(x, w=c(1, 1, 1, 2, 2)) 23 | } 24 | -------------------------------------------------------------------------------- /LPJmLmdi/man/StandardError.Rd: -------------------------------------------------------------------------------- 1 | \name{StandardError} 2 | \alias{StandardError} 3 | \title{Compute standard errors from a variance-covariance matrix} 4 | \description{SE = sqrt(diag(vc) * cost^2 / (nobs - npar))} 5 | \usage{StandardError(vc, nobs, cost)} 6 | \arguments{ 7 | \item{vc}{variance-covariance matrix} 8 | \item{nobs}{number of observations} 9 | \item{cost}{cost function value} 10 | } 11 | \details{No details.} 12 | 13 | \references{No reference. } 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /LPJmLmdi/man/StartingValues.Rd: -------------------------------------------------------------------------------- 1 | \name{StartingValues} 2 | \alias{StartingValues} 3 | \title{Get starting values for genoud from *.pro file} 4 | \description{The function extracts the best individuals trhat occured during a genoud optimization from a *.pro file. These best individuals can be used as starting values if a optimization is restarted. This function is called within \code{\link{OptimizeLPJgenoud}} is a restart is performed.} 5 | \usage{StartingValues(file.optresult, pop.size = NULL, ...)} 6 | \arguments{ 7 | \item{file.optresult}{genoud *.pro file with optimization results} 8 | \item{pop.size}{population size} 9 | \item{\dots}{further arguments (not used)} 10 | } 11 | \details{No details.} 12 | 13 | \references{No reference. } 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{OptimizeLPJgenoud}} } 19 | 20 | -------------------------------------------------------------------------------- /LPJmLmdi/man/Texture2Soilcode.Rd: -------------------------------------------------------------------------------- 1 | \name{Texture2Soilcode} 2 | \alias{Texture2Soilcode} 3 | \title{Convert soil texture to a LPJ soilcode} 4 | \description{The function takes fractions/percentages of sand, silt and clay and returns the correspondign LPJ soil code. The USDA soil classification is used. The function requires the package "soiltexture".} 5 | \usage{Texture2Soilcode(sand, silt, clay, lpj.soilcodes = c("Cl", "SiCl", 6 | "SaCl", "ClLo", "SiClLo", "SaClLo", "Lo", "SiLo", "SaLo", 7 | "Si", "LoSa", "Sa"), plot = TRUE, ...)} 8 | \arguments{ 9 | \item{sand}{percentage of sand} 10 | \item{silt}{percentage of silt} 11 | \item{clay}{percentage of clay} 12 | \item{lpj.soilcodes}{LPJ soil codes} 13 | \item{plot}{plot soil triangle?} 14 | \item{\dots}{Further arguments (currently not used).} 15 | } 16 | \details{No details.} 17 | \value{The function returns the LPJ soilcode} 18 | \references{No reference.} 19 | \author{Matthias Forkel [aut, cre]} 20 | 21 | 22 | 23 | \seealso{\code{\link{ReadBIN}}} 24 | \examples{ 25 | 26 | # data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) 27 | # WriteBIN(data.sp, file="data.bin") 28 | 29 | } 30 | -------------------------------------------------------------------------------- /LPJmLmdi/man/Turnover.Rd: -------------------------------------------------------------------------------- 1 | \name{Turnover} 2 | \alias{Turnover} 3 | \title{Calculate turnover time from stock and flux} 4 | \description{Calculates turnover times.} 5 | \usage{Turnover(stock, flux, ...)} 6 | \arguments{ 7 | \item{stock}{stock, e.g. biomass} 8 | \item{flux}{flux, e.g. NPP} 9 | \item{\dots}{further arguments (currently not used)} 10 | } 11 | \details{turnover = stock / flux} 12 | 13 | \references{No reference.} 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /LPJmLmdi/man/VarCovMatrix.Rd: -------------------------------------------------------------------------------- 1 | \name{VarCovMatrix} 2 | \alias{VarCovMatrix} 3 | \title{Compute variance-covariance matrix} 4 | \description{The function computes the variance-covariance matrix from the hessian matrix. Parameters that have a hessian = 0 (in sensitive parameters) area removed from the matrix before calculating the variance-covariance matrix.} 5 | \usage{VarCovMatrix(hessian, nms = paste("P", 1:n, sep = ""))} 6 | \arguments{ 7 | \item{hessian}{Hessian matrix} 8 | \item{nms}{names of the parameters (rows and columns in the matrix} 9 | } 10 | \details{No details.} 11 | 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /LPJmLmdi/man/VarW.Rd: -------------------------------------------------------------------------------- 1 | \name{VarW} 2 | \alias{VarW} 3 | \title{Weighted variance} 4 | \description{Compute the weighted variance.} 5 | \usage{VarW(x, w = rep(1, length(x)))} 6 | \arguments{ 7 | \item{x}{a vector} 8 | \item{w}{vector of weights} 9 | } 10 | \details{No details.} 11 | 12 | \references{No reference. } 13 | \author{Matthias Forkel [aut, cre]} 14 | 15 | 16 | 17 | \seealso{\code{\link{ObjFct}}} 18 | \examples{ 19 | 20 | x <- 1:5 21 | var(x) 22 | VarW(x, w=c(1, 1, 1, 2, 2)) 23 | } 24 | -------------------------------------------------------------------------------- /LPJmLmdi/man/WriteBIN.Rd: -------------------------------------------------------------------------------- 1 | \name{WriteBIN} 2 | \alias{WriteBIN} 3 | \title{Write a BIN file from SpatialPointsDataFrame} 4 | \description{The function writes BIN files from a SpatialPointsDataFrame or SpatialPixelsDataFrame. } 5 | \usage{WriteBIN(data.sp, file.bin, size = 1, ...)} 6 | \arguments{ 7 | \item{data.sp}{SpatialPointsDataFrame or SpatialPixelsDataFrame with data} 8 | \item{file.bin}{binary file name with extension *.bin} 9 | \item{size}{The number of bytes per element in the byte stream.} 10 | \item{\dots}{Further arguments (currently not used).} 11 | } 12 | \details{No details.} 13 | \value{The function returns TRUE if the CLM file was created.} 14 | \references{No reference.} 15 | \author{Matthias Forkel [aut, cre]} 16 | 17 | 18 | 19 | \seealso{\code{\link{ReadBIN}}} 20 | \examples{ 21 | 22 | # data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) 23 | # WriteBIN(data.sp, file="data.bin") 24 | 25 | } 26 | -------------------------------------------------------------------------------- /LPJmLmdi/man/WriteCLM.Rd: -------------------------------------------------------------------------------- 1 | \name{WriteCLM} 2 | \alias{WriteCLM} 3 | \title{Write a CLM file from SpatialPointsDataFrame} 4 | \description{The function writes CLM files from a SpatialPointsDataFrame or SpatialPixelsDataFrame. The LPJmL program cru2clm needs to be installed.} 5 | \usage{WriteCLM(data.sp, file.clm, start, nbands, size = 2, scale = 1, 6 | na.replace = -9999, path.lpj = NULL, res = 0.5, ...)} 7 | \arguments{ 8 | \item{data.sp}{SpatialPointsDataFrame or SpatialPixelsDataFrame with data} 9 | \item{file.clm}{CLM file name with extension *.clm} 10 | \item{start}{integer. First year in data.} 11 | \item{nbands}{Number of bands per year.} 12 | \item{size}{The number of bytes per element in the byte stream.} 13 | \item{scale}{Scaling factor to be written to the header of the CLM file. The factor will be not applied to the data.} 14 | \item{na.replace}{integer to replace NA values.} 15 | \item{path.lpj}{path to LPJ installation} 16 | \item{res}{spatial resolution of the grid cells } 17 | \item{\dots}{Further arguments (currently not used).} 18 | } 19 | \details{No details.} 20 | \value{The function returns TRUE if the CLM file was created.} 21 | \references{No reference.} 22 | \author{Matthias Forkel [aut, cre]} 23 | 24 | 25 | 26 | \seealso{\code{\link{WriteLPJinput}}} 27 | \examples{ 28 | 29 | # data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) 30 | # WriteCLM(data.sp, file="data.clm", start=1901, nbands=12, size=2) 31 | 32 | } 33 | -------------------------------------------------------------------------------- /LPJmLmdi/man/WriteGrid.Rd: -------------------------------------------------------------------------------- 1 | \name{WriteGrid} 2 | \alias{WriteGrid} 3 | \title{Write a *.grid file from a matrix of coordiantes or a SpatialPointsDataFrame} 4 | \description{Writes a grid file for LPJ input data. The functions needs the LPJmL module txt2grid to be installed.} 5 | \usage{WriteGrid(grid, file.grid, ...)} 6 | \arguments{ 7 | \item{grid}{SpatialPointsDataFrame; SpatialPixelsDataFrame, matrix or data.frame with coordinates} 8 | \item{file.grid}{Grid file name} 9 | \item{\dots}{Further arguments (currently not used).} 10 | } 11 | \details{No details.} 12 | \value{The function returns TRUE if the grid file was created.} 13 | \references{No reference.} 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{WriteLPJinput}}} 19 | \examples{ 20 | 21 | lon <- c(59.75, 68.25) 22 | lat <- c(61.25, 65.75) 23 | WriteGrid(cbind(lon, lat), "test.grid") 24 | 25 | } 26 | -------------------------------------------------------------------------------- /LPJmLmdi/man/WriteLPJinput.Rd: -------------------------------------------------------------------------------- 1 | \name{WriteLPJinput} 2 | \alias{WriteLPJinput} 3 | \title{Write an object of class 'LPJinput' to CLM files} 4 | \description{The function writes CLM input files for LPJ. } 5 | \usage{WriteLPJinput(lpjinput, files = NULL, path.lpj = NULL, ...)} 6 | \arguments{ 7 | \item{lpjinput}{Object of class 'LPJinput' to be written.} 8 | \item{files}{names of the output CLM or binary files. } 9 | \item{path.lpj}{path to LPJ installation} 10 | \item{\dots}{further arguments (currently not used)} 11 | } 12 | \details{No details.} 13 | \value{The function returns TRUE if the CLM file was created.} 14 | \references{No reference.} 15 | \author{Matthias Forkel [aut, cre]} 16 | 17 | 18 | 19 | \seealso{\code{\link{WriteLPJinput}}} 20 | \examples{ 21 | 22 | # lpjinput <- ReadLPJinput("cru_ts_3.20.1901.2011.tmp.clm", grid=cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75))) 23 | # str(lpjinput) 24 | # WriteLPJinput(lpjinput) 25 | 26 | } 27 | -------------------------------------------------------------------------------- /LPJmLmdi/man/WriteLPJpar.Rd: -------------------------------------------------------------------------------- 1 | \name{WriteLPJpar} 2 | \alias{WriteLPJpar} 3 | \title{Writes an object of class 'LPJpar' as parameter file or table.} 4 | \description{The function takes a 'LPJpar' object and writes 1) LPJ parameter files and 2) write *.txt files with parameter values in a table format.} 5 | \usage{WriteLPJpar(x, file = "LPJpar", pft.par = NULL, param.par = NULL, 6 | param.only = TRUE, ...)} 7 | \arguments{ 8 | \item{x}{object of class 'LPJpar'} 9 | \item{file}{basic file name for all output files, e.g. name of the optimization experiment} 10 | \item{pft.par}{template file for PFT-specific parameters (create a template from pft.par). If NULL, parameter files will be not written but only parameter tables.} 11 | \item{param.par}{template file for global parameters (create a template from param.par). If NULL, parameter files will be not written but only parameter tables.} 12 | \item{param.only}{write only parameters to table (TRUE) or also parameter prior ranges (FALSE)?} 13 | \item{\dots}{further arguments for CheckLPJpar} 14 | } 15 | \details{No details.} 16 | \value{The function returns a data.frame with an overview of the written files} 17 | \references{No reference. } 18 | \author{Matthias Forkel [aut, cre]} 19 | 20 | 21 | 22 | \seealso{\code{\link{LPJpar}}, \code{\link{CheckLPJpar}} } 23 | 24 | -------------------------------------------------------------------------------- /LPJmLmdi/man/WriteNCDF4.Rd: -------------------------------------------------------------------------------- 1 | \name{WriteNCDF4} 2 | \alias{WriteNCDF4} 3 | \title{Write NetCDF files} 4 | \description{Writes NetCDF files from rasters and makes sure that meta-information is properly defined.} 5 | \usage{WriteNCDF4(data.l, var.name, var.unit, time = as.Date("2000-01-01"), 6 | var.description = var.name, file = NULL, data.name = NA, 7 | region.name = NA, file.title = var.name, file.description = var.name, 8 | reference = "", provider = "", creator = "", missval = -9999, 9 | scale = 1, offset = 0, compression = 9, overwrite = FALSE)} 10 | \arguments{ 11 | \item{data.l}{a single Raster* object or a list of Raster* objects } 12 | \item{var.name}{vector of variable names} 13 | \item{var.unit}{vector of variable units} 14 | \item{time}{vector of time steps for each layer.} 15 | \item{var.description}{vector of variable descriptions} 16 | \item{file}{file name. If NULL the file name will be created from the variable name and the dimensions of the data.} 17 | \item{data.name}{name of the dataset} 18 | \item{region.name}{name of the region} 19 | \item{file.title}{title of the file} 20 | \item{file.description}{description of the file} 21 | \item{reference}{reference for the dataset} 22 | \item{provider}{dataset provider} 23 | \item{creator}{dataset creator} 24 | \item{missval}{flag for missing/NA values} 25 | \item{scale}{scaling values for the data} 26 | \item{offset}{offset value} 27 | \item{compression}{If set to an integer between 1 (least compression) and 9 (most compression), this enables compression for the variable as it is written to the file. Turning compression on forces the created file to be in netcdf version 4 format, which will not be compatible with older software that only reads netcdf version 3 files.} 28 | \item{overwrite}{overwrite existing file?} 29 | } 30 | 31 | 32 | 33 | \author{Matthias Forkel [aut, cre]} 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /LPJmLmdi/man/plot.Cbalance.Rd: -------------------------------------------------------------------------------- 1 | \name{plot.Cbalance} 2 | \alias{plot.Cbalance} 3 | \title{Plots a C balance} 4 | \description{The function takes an object of class \code{\link{Cbalance}} and creates time series plots or barplots.} 5 | \usage{\method{plot}{Cbalance}(x, what = NULL, trend = TRUE, baseunit = "PgC", 6 | ylab = NULL, ...)} 7 | \arguments{ 8 | \item{x}{object of class \code{\link{Cbalance}}} 9 | \item{what}{Which variables of C balance to plot? If NULL, sole plots are generated automatically.} 10 | \item{trend}{Compute trends?} 11 | \item{baseunit}{unit of C stocks} 12 | \item{ylab}{labels for y-axis} 13 | \item{\dots}{further arguments (currently not used)} 14 | } 15 | 16 | 17 | 18 | \author{Matthias Forkel [aut, cre]} 19 | 20 | 21 | 22 | 23 | \examples{ 24 | 25 | # with some typical numbers for the global C budget: 26 | cbal <- Cbalance(gpp=123, npp=61, rh=57, firec=2, vegc=400, soilc=2400) 27 | cbal 28 | plot(cbal) 29 | 30 | ## using time series:: 31 | #cbal <- Cbalance(gpp=118:128, npp=(118:128)*rnorm(11, 0.5, 0.1), rh=57, firec=runif(11, 0, 4), harvest=2, vegc=400, soilc=2400) 32 | #cbal 33 | #plot(cbal) 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /LPJmLmdi/man/plot.IntegrationData.Rd: -------------------------------------------------------------------------------- 1 | \name{plot.IntegrationData} 2 | \alias{plot.IntegrationData} 3 | \title{Plot an object of class IntegrationData} 4 | \description{The function plots an object of class \code{\link{IntegrationData}}, i.e. it produces a time series plots, scatterplots and a boxplot for the observations and LPJmL model outputs in \code{\link{IntegrationData}}.} 5 | \usage{\method{plot}{IntegrationData}(x, ds = 1:length(x), CostMDS = CostMDS.SSE, 6 | fits = "poly3", ...)} 7 | \arguments{ 8 | \item{x}{object of class \code{\link{IntegrationData}}} 9 | \item{ds}{Which data sets in x should be plotted (integer)} 10 | \item{CostMDS}{cost function for multiple data streams} 11 | \item{fits}{Fitting methods that should be used for scatter plots, see \code{\link{MultiFit}}} 12 | \item{\dots}{further arguments (currently not used)} 13 | } 14 | \details{No details.} 15 | 16 | \references{No reference.} 17 | \author{Matthias Forkel [aut, cre]} 18 | 19 | 20 | 21 | \seealso{\code{\link{IntegrationData}}} 22 | 23 | -------------------------------------------------------------------------------- /LPJmLmdi/man/plot.LPJpar.Rd: -------------------------------------------------------------------------------- 1 | \name{plot.LPJpar} 2 | \alias{plot.LPJpar} 3 | \title{Plot parameters in 'LPJpar' object.} 4 | 5 | \usage{\method{plot}{LPJpar}(x, par.name = NULL, uncertainty = "uncertainty.005", 6 | unc.change = FALSE, col = NULL, ylim = NULL, xlim = NULL, 7 | which.pft = NULL, if.opt = FALSE, names = FALSE, opt.val = TRUE, 8 | xaxt = "s", add = FALSE, xoff = 0)} 9 | \arguments{ 10 | \item{x}{object of class 'LPJpar'} 11 | \item{par.name}{name(s) of the parameters that should be plotted} 12 | \item{uncertainty}{name of the uncertainty estimate in LPJpar that should be used to plot posterior uncertainties} 13 | \item{unc.change}{plot the change in uncertainty? If TRUE the function plots the fraction of the posterior uncertainty relative to the prior, i.e. uncertainty / abs(upper - lower)} 14 | \item{col}{vector of colours for PFT-specific parameters} 15 | \item{ylim}{limits of the y-axis} 16 | \item{xlim}{limits of the x-axis} 17 | \item{which.pft}{character vector of PFT names that should be plotted. If NULL all } 18 | \item{if.opt}{plot parameters only if optimized (i.e. best) parameters are in LPJpar} 19 | \item{names}{plot PFT names within the plot? } 20 | \item{opt.val}{plot value of optimized parameter?} 21 | \item{xaxt}{x axis type. "n" suppresses the x axis.} 22 | \item{add}{add to existing plot?} 23 | \item{xoff}{offset for adjusting in x-direction} 24 | } 25 | \details{No details.} 26 | 27 | \references{No reference. } 28 | \author{Matthias Forkel [aut, cre]} 29 | 30 | 31 | 32 | \seealso{\code{\link{LPJpar}}, \code{\link{CheckLPJpar}} } 33 | \examples{ 34 | # plot(lpjpar, par.name="ALBEDO_LEAF_TeBS", uncertainty="uncertainty.iqr95") 35 | # plot(lpjpar, par.name="ALBEDO_LEAF", uncertainty="uncertainty.iqr") 36 | # plot(lpjpar, par.name="LIGHTEXTCOEFF", uncertainty="uncertainty.iqr") 37 | # par(mfrow=c(2,2)) 38 | # plot(lpjpar, par.name=c("ALPHAA", "LIGHTEXTCOEFF", "ALBEDO_LEAF", "ALBEDO_STEM")) 39 | } 40 | -------------------------------------------------------------------------------- /LPJmLmdi/man/plot.LPJparList.Rd: -------------------------------------------------------------------------------- 1 | \name{plot.LPJparList} 2 | \alias{plot.LPJparList} 3 | \title{Plots to compare LPJpar objects} 4 | \description{The function takes a \code{\link{LPJparList}} object and creates a plot to compare optimized parameters} 5 | \usage{\method{plot}{LPJparList}(x, par.name = NULL, ...)} 6 | \arguments{ 7 | \item{x}{object of class 'LPJparList'} 8 | \item{par.name}{name(s) of the parameters that should be plotted} 9 | \item{\dots}{further arguments to \code{\link{plot.LPJpar}} } 10 | } 11 | \details{No details.} 12 | 13 | \references{No reference.} 14 | \author{Matthias Forkel [aut, cre]} 15 | 16 | 17 | 18 | \seealso{\code{\link{LPJpar}}, \code{\link{plot.LPJpar}} } 19 | 20 | -------------------------------------------------------------------------------- /LPJmLmdi/man/plot.LPJsim.Rd: -------------------------------------------------------------------------------- 1 | \name{plot.LPJsim} 2 | \alias{plot.LPJsim} 3 | \title{Plots a LPJsim object} 4 | \description{The function plots a LPJsim object: monthly, annual time series or map of grid cells} 5 | \usage{\method{plot}{LPJsim}(x, what = "annual", start = NA, end = NA, omit0 = TRUE, 6 | AggFun = AggMeanNULL, ...)} 7 | \arguments{ 8 | \item{x}{an object of class 'LPJsim'} 9 | \item{what}{What type of plot should be created? 'annual' for yearly time series, 'monthly' for monthly time series, 'daily' for daily time series, and 'grid' for a map of grid cells} 10 | \item{start}{first year for time series plot} 11 | \item{end}{last year for time series plot} 12 | \item{omit0}{omit variables from plotting that are only 0?} 13 | \item{AggFun}{aggregation function to aggregate results to the temporal resolution as selected in 'what', for example \code{\link{AggMeanNULL}} for monthly or annual means, \code{\link{AggSumNULL}} for monthly or annual sums.} 14 | \item{\dots}{further arguments (currently not used)} 15 | } 16 | \details{No details.} 17 | 18 | \references{No reference.} 19 | \author{Matthias Forkel [aut, cre]} 20 | 21 | 22 | 23 | \seealso{\code{\link{ReadLPJ2ts}}, \code{\link{ReadLPJsim}}} 24 | \examples{ 25 | 26 | # setwd(path.mylpjresult) 27 | # sim <- ReadLPJ2ts(start=1982, end=2011) 28 | # plot(sim, what="annual") 29 | 30 | } 31 | -------------------------------------------------------------------------------- /LPJmLmdi/man/plot.rescue.Rd: -------------------------------------------------------------------------------- 1 | \name{plot.rescue} 2 | \alias{plot.rescue} 3 | \title{plot an object of class "rescue" / monitor OptimizeLPJgenoud} 4 | \description{The function plots the cost per data set for all individuals of the genetic optimization from an object of class "rescue". This function can be used to monitor the development of the optimization within OptimizeLPJgenoud. Therefor read the rescue files from your optimization with "rescue.l <- CombineRescueFiles(list.files(pattern=".RData"), remove=FALSE)" and call "plot(rescue.l)". } 5 | \usage{\method{plot}{rescue}(x, ylim = NULL, xlim = NULL, ylab = "Cost", xlab = "Individuals of genetic optimization", 6 | only.cost = FALSE, ...)} 7 | \arguments{ 8 | \item{x}{a list of class "rescue", see \code{\link{CombineRescueFiles}}} 9 | \item{ylim}{limits of the y-axis of the plot} 10 | \item{xlim}{limits of the x-axis of the plot} 11 | \item{ylab}{label for the y axis} 12 | \item{xlab}{label for the x axis} 13 | \item{only.cost}{plot all integration datasets (TRUE) or only these ones with cost=TRUE} 14 | \item{\dots}{further arguments for \code{\link{plot}}} 15 | } 16 | \details{No details.} 17 | 18 | \references{No reference. } 19 | \author{Matthias Forkel [aut, cre]} 20 | 21 | 22 | 23 | \seealso{\code{\link{CombineRescueFiles}}} 24 | 25 | -------------------------------------------------------------------------------- /LPJmLmdi_1.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/LPJmLmdi_1.0.tar.gz -------------------------------------------------------------------------------- /LPJmLmdi_1.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/LPJmLmdi_1.1.tar.gz -------------------------------------------------------------------------------- /LPJmLmdi_1.2.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/LPJmLmdi_1.2.tar.gz -------------------------------------------------------------------------------- /LPJmLmdi_1.3.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/LPJmLmdi_1.3.tar.gz -------------------------------------------------------------------------------- /LPJmLmdi_1.31.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/LPJmLmdi_1.31.tar.gz -------------------------------------------------------------------------------- /LPJmLmdi_overview.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/LPJmLmdi_overview.ppt -------------------------------------------------------------------------------- /MANUAL.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PIK-LPJmL/LPJmLmdi/8bbf83429111af2059059ff386b0c6b2932b330d/MANUAL.pdf -------------------------------------------------------------------------------- /R.sh: -------------------------------------------------------------------------------- 1 | module purge 2 | module load R 3 | module load intel/2018.1 4 | module load netcdf 5 | module load netcdf-c/4.2.1.1/serial 6 | module list 7 | module load udunits 8 | module load json-c/0.13 9 | module load intel/2018.1 10 | module load R 11 | unset I_MPI_DAPL_UD_PROVIDER 12 | export R_LIBS_USER=/p/projects/biodiversity/R 13 | R 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LPJmLmdi - model-data integration for the LPJmL dynamic global vegetation model (R package) 2 | 3 | LPJmLmdi is a R package that implements a model-data integration framework for the LPJmL dynamic global vegetation model. Specifically, the package provides functions 1) to optimize LPJmL model parameters using the GENOUD genetic optimization algorithm, 2) to read and write LPJmL input data, and 3) to read LPJmL output files. 4 | Depends: R (>= 2.15.3), raster, plyr, rgenoud, fields, numDeriv, RColorBrewer, quantreg, snow -------------------------------------------------------------------------------- /slurm_opt.jcf: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #SBATCH --qos=short 3 | #SBATCH --partition=broadwell 4 | #SBATCH --ntasks=5 5 | #SBATCH --cpus-per-task=2 # for 64GB total 6 | #SBATCH --job-name=LPJmLmdi 7 | #SBATCH --workdir=/p/projects/biodiversity/drueke/LPJmLmdi/LPJmLmdi 8 | ##SBATCH --output=outfile.%j.out 9 | ##SBATCH --error=outfile.%j.err 10 | #SBATCH --mail-type=end 11 | 12 | module purge 13 | module load R 14 | module load intel/2018.1 15 | module load netcdf 16 | module load netcdf-c/4.2.1.1/serial 17 | module list 18 | module load udunits 19 | module load json-c/0.13 20 | module load intel/2018.1 21 | module load mpi/intel/5.1.3 22 | module load R 23 | #unset I_MPI_DAPL_UD_PROVIDER 24 | export I_MPI_PMI_LIBRARY=/p/system/slurm/lib/libpmi.so 25 | export R_LIBS_USER=/p/projects/biodiversity/R 26 | 27 | # call R 28 | #R --no-save --file=.R --silent --slave 29 | R CMD BATCH --vanilla inst_gldas/LPJmL-MDI_example_gldas.R ./optim_experiment.Rout 30 | --------------------------------------------------------------------------------