diff --git a/HowToMakeRpackage_LPJmL-MDI.R b/HowToMakeRpackage_LPJmL-MDI.R new file mode 100644 index 0000000..f5620a8 --- /dev/null +++ b/HowToMakeRpackage_LPJmL-MDI.R @@ -0,0 +1,48 @@ +#-------------------------------------------- +# Building and installation of an R package: +# Matthias Forkel, 2017-08-02 +#-------------------------------------------- + +# package development is based on inlinedocs (for in-line documentation) +library(inlinedocs) +library(here) + +# name and directory of package +pkg.name <- "LPJmLmdi" +path <- paste(here::here(), sep="/") + + +# BUILDING +#--------- + +# Building is only required if you further develop the package, i.e. if you want to newly +# create help files and perform tests. Continue with the next section if you just downloaded +# the package and you want to install it. + +# build package structure and Rd files +setwd(path) +package.skeleton.dx(pkg.name) + +# check package +cmd <- sprintf(paste("%s CMD check --as-cran", pkg.name), file.path(R.home("bin"), "R")) +system(cmd, intern=TRUE) + +# build package +cmd <- sprintf(paste("%s CMD build --resave-data", pkg.name), file.path(R.home("bin"), "R")) +system(cmd, intern=TRUE) + + +# INSTALLATION +#------------- + +# installation +cmd <- paste("R CMD INSTALL --html", pkg.name, "--resave-data") +tryCatch(system(cmd), finally=setwd(path)) + +# load package +library(pkg.name, character.only=TRUE) + +# check package help files: +?OptimizeLPJgenoud + + diff --git a/LPJmLmdi.Rproj b/LPJmLmdi.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/LPJmLmdi.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/LPJmLmdi/.Rhistory b/LPJmLmdi/.Rhistory new file mode 100644 index 0000000..965d0e7 --- /dev/null +++ b/LPJmLmdi/.Rhistory @@ -0,0 +1,86 @@ +install.packages("bfast") +install.packages("phenopix") +here() +setwd("~/shares/home/code/R/_gitlab/") +pkgs <- c("RobinsonMaps") +i <- 1 +setwd(pkgs[i]) +cmd <- paste("R CMD INSTALL --html ", pkgs[i], " --resave-data") +tryCatch(system(cmd), finally=setwd(path)) +getwd() +pkgs <- c("RobinsonMaps", "ModelDataComp") +setwd("..") +setwd(pkgs[i]) +cmd <- paste("R CMD INSTALL --html ", pkgs[i], " --resave-data") +tryCatch(system(cmd)) +setwd("..") +getwd() +pkgs <- c("RobinsonMaps", "ModelDataComp") +i <- 2 +setwd(pkgs[i]) +cmd <- paste("R CMD INSTALL --html ", pkgs[i], " --resave-data") +tryCatch(system(cmd)) +setwd("..") +install.packages("lhs") +setwd("~/shares/home/code/R/_gitlab/") +pkgs <- c("RobinsonMaps", "ModelDataComp") +i <- 2 +setwd(pkgs[i]) +cmd <- paste("R CMD INSTALL --html ", pkgs[i], " --resave-data") +tryCatch(system(cmd)) +setwd("..") +install.packages("randomForest") +i <- 2 +setwd(pkgs[i]) +cmd <- paste("R CMD INSTALL --html ", pkgs[i], " --resave-data") +tryCatch(system(cmd)) +setwd("..") +pkgs <- c("RobinsonMaps", "ModelDataComp", "Raster4ML") +i <- 3 +setwd(pkgs[i]) +cmd <- paste("R CMD INSTALL --html ", pkgs[i], " --resave-data") +tryCatch(system(cmd)) +setwd("..") +install.packages("ICEbox") +install.packages("ff") +setwd("~/shares/home/code/R/greenbrown") +cmd <- paste("R CMD INSTALL --html greenbrown --resave-data") +tryCatch(system(cmd)) +setwd("~/shares/home/code/R/_gitlab/") +pkgs <- c("RobinsonMaps", "ModelDataComp", "Raster4ML") +i <- 3 +setwd(pkgs[i]) +cmd <- paste("R CMD INSTALL --html ", pkgs[i], " --resave-data") +tryCatch(system(cmd)) +setwd("..") +setwd("~/shares/home/code/R/_gitlab-pik/LPJmLmdi/") +tryCatch(system("R CMD INSTALL --html LPJmLmdi --resave-data")) +grep("o", letters) +# package development is based on inlinedocs (for in-line documentation) +library(inlinedocs) +library(here) +# name and directory of package +pkg.name <- "LPJmLmdi" +path <- paste(here::here(), sep="/") +# Building is only required if you further develop the package, i.e. if you want to newly +# create help files and perform tests. Continue with the next section if you just downloaded +# the package and you want to install it. +# build package structure and Rd files +setwd(path) +package.skeleton.dx(pkg.name) +# check package +cmd <- sprintf(paste("%s CMD check --as-cran", pkg.name), file.path(R.home("bin"), "R")) +system(cmd, intern=TRUE) +# check package +cmd <- sprintf(paste("%s CMD check --as-cran", pkg.name), file.path(R.home("bin"), "R")) +system(cmd, intern=TRUE) +# build package +cmd <- sprintf(paste("%s CMD build --resave-data", pkg.name), file.path(R.home("bin"), "R")) +system(cmd, intern=TRUE) +# installation +setwd(here::here()) +cmd <- paste("R CMD INSTALL --html", pkg.name, "--resave-data") +tryCatch(system(cmd), finally=setwd(path)) +# load package +library(pkg.name, character.only=TRUE) +?PlotParUnc diff --git a/LPJmLmdi/DESCRIPTION b/LPJmLmdi/DESCRIPTION new file mode 100644 index 0000000..751e429 --- /dev/null +++ b/LPJmLmdi/DESCRIPTION @@ -0,0 +1,12 @@ +Package: LPJmLmdi +Title: Model-Data Integration for the LPJmL Dynamic Global Vegetation Model +Version: 1.3 +Date: 2019-01-22 +Author: Matthias Forkel [aut, cre], Markus Drüke [aut] +Maintainer: Matthias Forkel , Markus Drüke +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. +Depends: R (>= 2.15.3), raster, plyr, rgenoud, ncdf4, ModelDataComp +Imports: dplyr, plotrix, fields, tidyr +License: GPL-2 +URL: +LazyLoad: yes diff --git a/LPJmLmdi/NAMESPACE b/LPJmLmdi/NAMESPACE new file mode 100644 index 0000000..cefc890 --- /dev/null +++ b/LPJmLmdi/NAMESPACE @@ -0,0 +1,5 @@ +importFrom("plotrix", "color.legend") +importFrom("tidyr", "separate", "unite", "gather") +importFrom("RColorBrewer", "brewer.pal") +exportPattern("^[[:alpha:]]+") + diff --git a/LPJmLmdi/R/AggFun.R b/LPJmLmdi/R/AggFun.R new file mode 100644 index 0000000..5f29aa3 --- /dev/null +++ b/LPJmLmdi/R/AggFun.R @@ -0,0 +1,460 @@ +AggSumMean <- structure(function( + ##title<< + ## Temporal aggregation: first sum, then mean + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(aggregate(x, list(agg), FUN=sum, na.rm=TRUE)$x) + ### The function returns a the aggregated result. +}) + + +AggMeanMean <- structure(function( + ##title<< + ## Temporal aggregation: first mean, then mean = mean over all values + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(aggregate(x, list(agg), FUN=mean, na.rm=TRUE)$x) + ### The function returns a the aggregated result. +}) + + +AggMeanNULL <- structure(function( + ##title<< + ## Temporal aggregation: first mean, then nothing = mean per group + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + x2 <- aggregate(x, list(agg), FUN=mean, na.rm=TRUE) + x2 <- x2[match(unique(agg), x2[,1]), 2] + return(x2) + ### The function returns a the aggregated result. +}) + + +AggSumNULL <- structure(function( + ##title<< + ## Temporal aggregation: first sum, then nothing = sum per group + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + x2 <- aggregate(x, list(agg), FUN=sum, na.rm=TRUE) + x2 <- x2[match(unique(agg), x2[,1]), 2] + return(x2) + ### The function returns a the aggregated result. +}) + + +AggQ09NULL <- structure(function( + ##title<< + ## Temporal aggregation: aggregate by using quantile with prob=0.9 + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + x2 <- aggregate(x, list(agg), FUN=quantile, prob=0.9, na.rm=TRUE) + x2 <- x2[match(unique(agg), x2[,1]), 2] + return(x2) + ### The function returns a the aggregated result. +}) + + +AggMaxNULL <- structure(function( + ##title<< + ## Temporal aggregation: aggregate by using annual maximum + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + x2 <- aggregate(x, list(agg), FUN=max, na.rm=TRUE) + x2 <- x2[match(unique(agg), x2[,1]), 2] + return(x2) + ### The function returns a the aggregated result. +}) + + +AggMSC <- structure(function( + ##title<< + ## Temporal aggregation: mean seasonal cycle + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + nyear <- length(unique(agg)) # number of years + nmonths <- length(agg) / nyear # number of months per year + agg2 <- rep(1:nmonths, length=length(x)) # aggregation vector + aggregate(x, list(agg2), FUN=mean, na.rm=TRUE)$x + ### The function returns the mean seasonal cycle +}) + + + +AggNULLMean <- structure(function( + ##title<< + ## Temporal aggregation: mean over all values + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x, na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCPoH <- structure(function( + ##title<< + ## Temporal aggregation for PoH PFT: get PoH from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(12, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCBoNE <- structure(function( + ##title<< + ## Temporal aggregation for BoNE PFT: get BoNE from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(7, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCBoNS <- structure(function( + ##title<< + ## Temporal aggregation for BoNS PFT: get BoNS from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(9, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCBoBS <- structure(function( + ##title<< + ## Temporal aggregation for BoBS PFT: get BoBS from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(8, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCTeBS <- structure(function( + ##title<< + ## Temporal aggregation for PFTs: get TeBS from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(6, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCTeH <- structure(function( + ##title<< + ## Temporal aggregation for PFTs: get TeH from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(11, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCTeBE <- structure(function( + ##title<< + ## Temporal aggregation for PFTs: get TeBE from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(5, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCTeNE <- structure(function( + ##title<< + ## Temporal aggregation for PFTs: get TeNE from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(4, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCTrBE <- structure(function( + ##title<< + ## Temporal aggregation for PFTs: get TrBE from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(2, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) + + +AggFPCTrBR <- structure(function( + ##title<< + ## Temporal aggregation for PFTs: get TrBR from vector of all PFTs, average over years + ##description<< + ## This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations. + + x, + ### full time series + + agg + ### vector of grouping elements (years) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + mean(x[seq(3, 12*length(agg), by=12)], na.rm=TRUE) + ### The function returns a the aggregated result. +}) diff --git a/LPJmLmdi/R/AggregateNCDF.R b/LPJmLmdi/R/AggregateNCDF.R new file mode 100644 index 0000000..de50771 --- /dev/null +++ b/LPJmLmdi/R/AggregateNCDF.R @@ -0,0 +1,465 @@ +AggregateNCDF <- structure(function( + ##title<< + ## Temporal aggregations and statistics on NetCDF files + ##description<< + ## Compute temporal aggregations and statistics of data in NetCDF files. + + files, + ### (character) file name or vector file names. In case of multiple file names, it is assumed that each file corresponds to a different time period (i.e. all files are a time series) + + fun.agg = sum, + ### function to be used for temporal aggregations + + var.name = NULL, + ### (character) variable name in NetCDF files for which computations should be done. If NULL, all variables will be processed. + + tstep = NULL, + ### (character) time step of input data: "daily", "ndaily" (period of n days), "monthly", "annual". If NULL tstep will be estimated from the files. + + agg.monthly = TRUE, + ### (boolean) aggregate to monthly data? This will be only done if 'tstep' is daily or ndaily. + + agg.annual = TRUE, + ### (boolean) aggregate to annual data? This will be only done if 'tstep' is < annual. + + agg.ndaily = TRUE, + ### (boolean) aggregate to N-daily periods? This will be only done if 'tstep' is < ndays. + + ndays = 7, + ### (integer) length of period [in days] for N-daily aggregations. For example, a aggregation to 7-daily periods will be done if ndays=7. A period starts always at the 1st January. Please note that a 7-daily aggregation does not necessarily correspond to calendar weeks (see \code{\link{GroupDates}} for details). This aggregation will be only done if 'tstep' is < ndays. + + stat.annual = TRUE, + ### (boolean) compute statistics based on annual data? + + stat.monthly = FALSE, + ### (boolean) compute statistics based on monthly data? + + stat.ndaily = FALSE, + ### (boolean) compute statistics based on N-daily data? + + stat.daily = FALSE, + ### (boolean) compute statistics based on daily data? + + msc.monthly = TRUE, + ### (boolean) compute (mean/median) seasonal cycles on monthly data and monthly anomalies? This computation is based on \code{\link{SeasonalCycleNCDF}} and uses CDO modules. + + path.out = NULL, + ### directory for output files. If NULL, directories will be created within the location of the files, otherwise directories will be created under the specified directory. + + path.out.prefix = "img", + ### prefix for output directory names, directory names are created according to the following pattern 'prefix'_'resolution'_'timestep' (e.g. img_0d25_monthly) + + nodes = 1, + ### How many nodes should be used for parallel processing of files? Parallel computing can be only used if length(files) > 1. + + stats = NULL, + ### statistical metrics to compute + + ... + ### further agruments (unused) + + ##details<< + ## + + ##references<< + ## + + ##seealso<< + ## + + ) { + + # get directory and directory for outputs + #---------------------------------------- + + # directory of input data + wd <- getwd() + filestr <- strsplit(files[1], "/")[[1]] + if (length(filestr) > 1) { + path <- paste(filestr[-length(filestr)], collapse = "/") + } else { + path <- getwd() + files <- paste0(path, "/", files) + } + + # basic directory for output data + if (is.null(path.out)) { + pathstr <- strsplit(path, "/")[[1]] + path.out <- paste(pathstr, collapse = "/") + } + message("AggregateNCDF: Directory for results: ", path.out) + + + # get time and space information from files + #------------------------------------------ + + # initalize list for all files that can be produced + files.l <- + list( + daily = NULL, + daily_stat = NULL, + ndaily = NULL, + ndaily_stat = NULL, + monthly = NULL, + monthly_stat = NULL, + annual = NULL, + annual_stat = NULL + ) + + info <- InfoNCDF(files[1]) + files2 <- + unlist(llply(strsplit(files, "/"), function(file) + file[length(file)])) + if (grepl(".", files2[1])) { + data.name <- strsplit(files2[1], ".", fixed = TRUE)[[1]][1] + } else { + data.name <- strsplit(files2[1], "")[[1]] + data.name <- + paste(data.name[1:min(c(length(data.name), 10))], collapse = "") + } + + # identify time step + dt <- mean(diff(info$time)) # difference between time steps + if (is.na(dt) & + length(files) > 1) + dt <- InfoNCDF(files[2])$time - info$time + if (is.na(dt) & + length(files) == 1) + stop("Files have only one time step. Temporal aggregations don't make sense.") + if (is.null(tstep)) { + if (dt == 1) + tstep <- "daily" + if (dt >= 28 & dt <= 31) + tstep <- "monthly" + if (dt >= 365 & dt <= 366) + tstep <- "annual" + if (is.null(tstep)) + tstep <- "ndaily" + message("AggregateNCDF: Identified time step of data is: ", tstep) + } + + if (tstep == "daily") + files.l$daily <- paste(path, files2, sep = "/") + if (tstep == "ndaily") + files.l$ndaily <- paste(path, files2, sep = "/") + if (tstep == "monthly") + files.l$monthly <- paste(path, files2, sep = "/") + if (tstep == "annual") + files.l$annual <- paste(path, files2, sep = "/") + + # identify spatial resolution + res <- mean(diff(info$lon)) + nrow <- length(info$lat) + ncol <- length(info$lon) + + # variable names + if (is.null(var.name)) + var.name <- as.character(info$var$name) + m <- match(var.name, info$var$name) + var.unit <- as.character(info$var$unit[m]) + var.long <- as.character(info$var$longname[m]) + + + # function for temporal aggregation + #---------------------------------- + + DoAgg <- function(file, fun.agg, agg = "annual") { + info <- InfoNCDF(file) + + # time and aggregation groups + ti <- info$time + cdo <- NULL + if (agg == "monthly") { + groups <- format(ti, "%Y-%m") + ti.agg <- as.Date(paste0(unique(groups), "-01")) + cdo <- paste0("cdo mon", fun.agg) + } + if (agg == "annual") { + groups <- format(ti, "%Y") + ti.agg <- as.Date(paste0(unique(groups), "-01-01")) + cdo <- paste0("cdo year", fun.agg) + } + if (agg == "ndaily") { + agg <- gsub("n", ndays, agg) + groups <- GroupDates(ti, freq = ndays) + ti.agg <- unique(groups$group.date) + groups <- groups$group + } + if (grepl("msc", agg)) { + groups <- format(ti, "%m") + ti.agg <- + as.Date(paste0(format(ti, "%Y")[1], unique(groups), "-01")) + cdo <- paste0("cdo ymon", fun.agg) + } + + # output path + un <- unique(groups) + opath <- + paste0(path.out, + "/", + path.out.prefix, + "_", + gsub(".", "d", res, fixed = TRUE), + "_", + agg) + if (!file.exists(opath)) + dir.create(opath) + + # output path + ofile <- + paste0( + opath, + "/", + paste( + data.name, + var.name[1], + nrow, + ncol, + un[1], + un[length(un)], + agg, + fun.agg, + "nc", + sep = "." + ) + ) + if (file.exists(ofile)) + file.remove(ofile) + + if (!is.null(cdo)) { + cdo <- paste(cdo, file, ofile) + system(cdo) + } else { + # do aggregations for each variable + data.l <- + llply(as.list(1:length(var.name)), function(varid) { + data.rb <- brick(file, varname = var.name[varid]) + agg.rb <- AggregateTimeRaster(data.rb, groups, fun.agg) + agg.rb[is.infinite(agg.rb)] <- NA + return(agg.rb) + }) + + # write raster + WriteNCDF4( + data.l, + time = ti.agg, + var.name = var.name, + var.unit = var.unit, + data.name = data.name, + var.description = var.long, + file = ofile, + overwrite = TRUE + ) + return(ofile) + } + return(ofile) + } # end DoAgg + + + #--------------------- + # compute aggregations + #--------------------- + + # setup cluster for parallel processing + parallel <- FALSE + if (nodes > 1 & length(files) > 1) { + message(paste( + "AggregateNCDF: Start cluster nodes for parallel computing.", + Sys.time() + )) + cluster <- makeCluster(nodes) + + # load packages on all nodes + clusterEvalQ(cluster, { + library(raster) + library(ncdf4) + library(plyr) + NULL + }) + + # export required objects to cluster nodes + #clusterExport(cluster, ls(envir=.GlobalEnv), envir=.GlobalEnv) + clusterExport(cluster, ls(), envir = environment()) + } + + # aggregate to monthly time steps + calc.monthly <- + (tstep == "daily" | (tstep == "ndaily" & dt < 30)) + if (agg.monthly & calc.monthly) { + message(paste("AggregateNCDF: Start monthly aggregation.", Sys.time())) + ofiles <- + llply( + as.list(files), + .fun = DoAgg, + fun.agg = fun.agg, + agg = "monthly", + .parallel = parallel + ) + files.l$monthly <- unlist(ofiles) + } + + # aggregate to N-daily time steps + calc.ndaily <- + (tstep == "daily" | (tstep == "monthly" & dt < ndays)) + if (agg.ndaily & calc.ndaily) { + message(paste("AggregateNCDF: Start N-daily aggregation.", Sys.time())) + ofiles <- + llply( + as.list(files), + .fun = DoAgg, + fun.agg = fun.agg, + agg = "ndaily", + .parallel = parallel + ) + files.l$ndaily <- unlist(ofiles) + } + + # aggregate to annual time steps + calc.annual <- + (tstep == "daily" | + (tstep == "ndaily" & dt < 365) | tstep == "monthly") + if (agg.annual & calc.annual) { + message(paste("AggregateNCDF: Start annual aggregation.", Sys.time())) + ofiles <- + llply( + as.list(files), + .fun = DoAgg, + fun.agg = fun.agg, + agg = "annual", + .parallel = parallel + ) + files.l$annual <- unlist(ofiles) + } + + + #--------------------------------- + # compute statistics and anomalies + #--------------------------------- + + if (is.null(stats)) + stats <- + c("mean", + "median", + "max", + "min", + "range", + "sd", + "coefvar", + "sum", + "maxtime", + "mintime") + + if (stat.annual & !is.null(files.l$annual)) { + opath <- + paste0( + path.out, + "/", + path.out.prefix, + "_", + gsub(".", "d", res, fixed = TRUE), + "_annual_stats" + ) + message(paste( + "AggregateNCDF: Start computing annual statistics.", + Sys.time() + )) + files.l$annual_stat <- + StatisticsNCDF( + files.l$annual, + var.name = var.name, + stats = stats, + path.out = opath + ) + } + + if (stat.monthly & !is.null(files.l$monthly)) { + opath <- + paste0( + path.out, + "/", + path.out.prefix, + "_", + gsub(".", "d", res, fixed = TRUE), + "_monthly_stats" + ) + message(paste( + "AggregateNCDF: Start computing monthly statistics.", + Sys.time() + )) + files.l$monthly_stat <- + StatisticsNCDF( + files.l$monthly, + var.name = var.name, + across.files = FALSE, + stats = stats, + path.out = opath + ) + } + + if (stat.ndaily & !is.null(files.l$ndaily)) { + opath <- + paste0( + path.out, + "/", + path.out.prefix, + "_", + gsub(".", "d", res, fixed = TRUE), + "_ndaily_stats" + ) + message(paste( + "AggregateNCDF: Start computing N-daily statistics.", + Sys.time() + )) + files.l$ndaily_stat <- + StatisticsNCDF( + files.l$ndaily, + var.name = var.name, + across.files = FALSE, + stats = stats, + path.out = opath + ) + } + + if (stat.daily & !is.null(files.l$daily)) { + opath <- + paste0( + path.out, + "/", + path.out.prefix, + "_", + gsub(".", "d", res, fixed = TRUE), + "_daily_stats" + ) + message(paste( + "AggregateNCDF: Start computing daily statistics.", + Sys.time() + )) + files.l$daily_stat <- + StatisticsNCDF( + files.l$daily, + var.name = var.name, + across.files = FALSE, + stats = stats, + path.out = opath + ) + } + + # close cluster + if (parallel) { + stopCluster(cluster) + message(paste("AggregateNCDF: Stop cluster nodes.", Sys.time())) + } + + + #----------------------------------------------- + # compute seasonal cycles and seasonal anomalies + #----------------------------------------------- + + if (msc.monthly & !is.null(files.l$monthly)) { + files.l$monthly_stat <- + SeasonalCycleNCDF(files.l$monthly, var.name = var.name) + } + + return(files.l) +}) + \ No newline at end of file diff --git a/LPJmLmdi/R/AllEqual.R b/LPJmLmdi/R/AllEqual.R new file mode 100644 index 0000000..45024d4 --- /dev/null +++ b/LPJmLmdi/R/AllEqual.R @@ -0,0 +1,21 @@ +AllEqual <- structure(function( + ##title<< + ## Check if all values in a vector are the same + ##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. + + x + ### numeric, character vector, or time series of type ts +) { + res <- FALSE + x <- na.omit(as.vector(x)) + if (length(unique(x)) == 1 | length(x) == 0) res <- TRUE + return(res) + ### The function returns TRUE if all values are equal and FALSE if it contains different values. +},ex=function(){ +# check if all values are equal in the following vectors: +AllEqual(1:10) +AllEqual(rep(0, 10)) +AllEqual(letters) +AllEqual(rep(NA, 10)) +}) diff --git a/LPJmLmdi/R/BarplotCost.R b/LPJmLmdi/R/BarplotCost.R new file mode 100644 index 0000000..c777671 --- /dev/null +++ b/LPJmLmdi/R/BarplotCost.R @@ -0,0 +1,176 @@ +BarplotCost <- structure(function( + ##title<< + ## plot a barplot of the cost change from prior to best parameter set + ##description<< + ## The function plots two barplots that are showing the change in the cost per dataset. + + rescue.l, + ### a list of class "rescue", see \code{\link{CombineRescueFiles}} + + type = 1:2, + ### plot type: 1 barplot of total cost from prior and best, 2: change of cost per data set + + ylim = NULL, + ### limits of y-axis (works for type = 2) + + set.par = TRUE, + ### set par() settings from \code{\link{DefaultParL}} + + ... + ### further arguments for \code{\link{plot}} + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CombineRescueFiles}} +) { + + # has KGE metrics? + kge <- !is.null(rescue.l[[1]]$cost$fractional) + if (length(type) > 1) ylim <- NULL + + # get cost and identify prior and best parameter sets + cost <- unlist(llply(rescue.l, function(l) l$cost$total)) # total cost + prior <- (1:length(rescue.l))[unlist(llply(rescue.l, function(l) all(l$dpar == 1)))] + prior <- prior[which.max(cost[prior])] + best <- which.min(cost) + if (is.null(rescue.l[[1]]$cost$use)) { + use <- rep(TRUE, length(rescue.l[[1]]$cost$per.cell.ds)) + } else { + use <- apply(rescue.l[[1]]$cost$use, 1, sum) > 0 + if (kge) use <- rep(use, each=3) + } + + # get cost per data stream + cost.ds <- matrix(laply(rescue.l[c(prior, best)], function(l) { + # if (all(l$dpar == 1)) cost.prior <<- l$cost$total + if (kge) { # KGE cost + if (is.null(l$cost$use)) l$cost$use <- matrix(TRUE, ncol=ncol(l$cost$per.cell.ds), nrow=nrow(l$cost$per.cell.ds)) + m <- l$cost$per.cell.ds * l$cost$use + m <- matrix(t(m), nrow=1) + colnames(m) <- paste(rep(names(l$cost$per.ds), each=3), names(l$cost$per.cell)) + } else { # SSE cost + m <- matrix(l$cost$per.ds, nrow=1) + colnames(m) <- names(l$cost$per.ds) + } + return(m) + }), nrow=2) + cost.ds <- cost.ds[,use] + + # calculate changes in cost + if (kge) { + nms <- paste(rep(names(rescue.l[[1]]$cost$per.ds), each=3), c("Bias", "Var", "Cor"))[use] + #m0 <- cost.ds / sqrt(rowSums(cost.ds)) + m0 <- cost.ds + m <- data.frame(prior=m0[1,], best=m0[2,], nms=nms) + m$diff <- m$best - m$prior + m$perc <- m$diff / m$prior * 100 + m$gr <- unlist(llply(strsplit(nms, " "), function(s) paste0(s[-length(s)], collapse=" "))) + + # aggregate KGE components per data set + m.gr <- aggregate(. ~ gr, m, FUN=sum) + m.gr$min <- aggregate(diff ~ gr, m, FUN=min)[,2] + m.gr$max <- aggregate(diff ~ gr, m, FUN=max)[,2] + m.gr <- m.gr[match(unique(m$gr), m.gr$gr), ] + m.gr$perc <- m.gr$diff / m.gr$prior * 100 + m.gr$txt <- paste(m.gr$gr, "\n", round(m.gr$perc, 0), " %", sep="") + + } else { + nms <- names(rescue.l[[1]]$cost$per.ds)[use] + m <- data.frame(prior=cost.ds[1,], best=cost.ds[2,], nms=nms) + m$diff <- m$best - m$prior + m$perc <- m$diff / m$prior * 100 + m$txt <- paste(m$nms, "\n", round(m$perc, 0), " %", sep="") + + } + + # create colors + nds <- length(names(rescue.l[[1]]$cost$per.ds)) + cols0 <- brewer.pal(nds, "Set1") + if (kge) { + cols <- cols0 + if (length(nms) > 3) { + cols0 <- col2rgb(cols0) + cols <- list() + s <- c(0.7, 0.85, 1) + for (i in 1:ncol(cols0)) cols[[i]] <- rgb(cols0[1,i]*s, cols0[2,i]*s, cols0[3,i]*s, max=255) + cols <- unlist(cols) + } + } else { + cols <- cols0 + } + + # init plot + if (set.par) { + if (length(type) == 2) DefaultParL(mfrow=c(2,1), mar=c(3, 3.5, 0.1, 0.5)) + if (length(type) == 1) DefaultParL(mar=c(2, 3.5, 0.5, 0.5)) + } + + # total cost + if (1 %in% type) { + barplot(as.matrix(m[,1:2]), col=cols, names=c("prior", "best"), ylab="Cost", main="") + ncol <- 1 + if (length(nms) > 9) ncol <- 2 + legend("topright", nms, fill=cols, bty="n", ncol=2) + box() + } + + # change in cost + if (2 %in% type) { + if (is.null(ylim)) { + ylim <- range(m$diff) + if (kge) ylim <- quantile(c(m$diff, m.gr$diff), c(0, 1)) + ylim[1] <- ylim[1] - diff(ylim) * 0.08 + ylim[2] <- ylim[2] + diff(ylim) * 0.08 + if (kge) ylim[1] <- ylim[1] - diff(ylim) * 0.1 + } + + bp <- barplot(m$diff, col=cols, ylab="Change in cost", las=3, main="", names="", ylim=ylim) + abline(h=0) + + # add total cost per datastream + if (kge) { + # plot barplot per data set + xleft <- bp[seq(1, by=3, length=nrow(m.gr))] - diff(bp[1:2]) * 0.47 + xright <- bp[seq(3, by=3, length=nrow(m.gr))] + diff(bp[1:2]) * 0.47 + ybottom <- apply(cbind(0, m.gr$diff), 1, min) + ytop <- apply(cbind(0, m.gr$diff), 1, max) + cols1 <- cols[seq(2, by=3, length=nrow(m.gr))] + rect(xleft, ybottom, xright, ytop, col=cols1) + barplot(m$diff, col=cols, main="", names="", ylim=ylim, axes=FALSE, add=TRUE) + + # add text for percentage change in cost + xpos <- bp[seq(2, by=3, length=nrow(m.gr))] + ypos <- m.gr$diff + ypos[m.gr$diff <= 0] <- apply(cbind(m.gr$min, m.gr$diff), 1, min)[m.gr$diff <= 0] + ypos[ypos < ylim[1]] <- diff(c(0, ylim[1])) * 0.9 + ypos[m.gr$diff > 0] <- apply(cbind(m.gr$max, m.gr$diff), 1, max)[m.gr$diff > 0] + ypos[ypos > ylim[2]] <- diff(c(0, ylim[2])) * 0.9 + pos <- c(1,3)[(m.gr$diff > 0) + 1] + text(xpos, ypos, m.gr$txt, pos=pos) + + # add text for KGE components + ypos <- apply(cbind(m$diff, 0), 1, mean) + text(bp, ypos, c("Bias", "Var", "Cor"), srt=90) + + } else { + pos <- c(3,1)[(m$diff > 0) + 1] + text(x=bp, y=m$diff, m$txt, pos=pos) + } + + x <- bp[length(bp)] + diff(bp[1:2]) * 0.8 + arrows(x, 0, x, ylim[1], col="powderblue", lwd=2) + text(x, mean(c(0, ylim[1])), "improvement", srt=90) + box() + } + + +}, ex=function() { + # files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) + # rescue.l <- CombineRescueFiles(files, remove=FALSE) + # BarplotCost(rescue.l) +}) + diff --git a/LPJmLmdi/R/BreakColours.R b/LPJmLmdi/R/BreakColours.R new file mode 100644 index 0000000..9f4dbdd --- /dev/null +++ b/LPJmLmdi/R/BreakColours.R @@ -0,0 +1,69 @@ +BreakColours <- BreakColors <- structure(function( + ##title<< + ## Colours from class breaks + ##description<< + ## Creates colour palettes from a vector of class breaks + + x, + ### numeric vector of class breaks + + pal = NULL, + ### name of a colour palette from \code{\link{brewer.pal}} + + rev = FALSE, + ### should the colour palette be reversed? + + cols = NULL, + ### alternatively, a colour vector to be interpolated + + ... + ### Further arguments (unused) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{BreakColours}} +){ + if (is.null(pal)) { + if (any(x < 0) & any(x > 0)) { + pal <- "RdBu" + } else { + pal <- "OrRd" + } + } + if (is.null(cols)) { + suppressWarnings(cols <- brewer.pal(11, pal)) + } + if (rev) cols <- rev(cols) + .fun <- colorRampPalette(cols) + cols <- .fun(length(x)-1) + + return(cols) + ### The function returns a vector of colours. +}, ex=function() { + +brks1 <- seq(0, 10, 2) +cols1 <- BreakColours(brks1) + +brks2 <- seq(-100, 100, 25) +cols2 <- BreakColours(brks2) + +brks3 <- seq(-100, 100, 25) +cols3 <- BreakColours(brks3, pal="BrBG") + +brks4 <- seq(0, 10, 1) +cols4 <- BreakColours(brks4, cols=c("red", "green", "blue"), rev=TRUE) + +MapRb() +LegendBarRb(brks=brks1, cols=cols1) +LegendBarRb(brks=brks2, cols=cols2, pos="top", lon = c(-180, 180), lat = c(-20, -15)) +LegendBarRb(brks=brks3, cols=cols3, pos="inside", lon = c(-180, 180), lat = c(15, 20)) +LegendBarRb(brks=brks4, cols=cols4, pos="inside", lon = c(-180, 180), lat = c(30, 35)) + +}) + + + diff --git a/LPJmLmdi/R/Breaks.R b/LPJmLmdi/R/Breaks.R new file mode 100644 index 0000000..c720c8e --- /dev/null +++ b/LPJmLmdi/R/Breaks.R @@ -0,0 +1,61 @@ +Breaks <- structure(function( + ##title<< + ## Class breaks for plotting + ##description<< + ## Calculates class breakpoints based on quantiles. + + x, + ### numeric vector + + n=12, + ### number of breaks + + quantile=c(0.01, 0.99), + ### lower and upper quantiles that should be used to exclude outliers + + zero.min=FALSE, + ### should the minimum break be at 0? + + ... + ### Further arguments (unused) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{BreakColours}} +){ + x <- na.omit(as.vector(x)) + + # are all values the same? + equal <- FALSE + if (length(unique(x)) == 1 | length(x) == 0) equal <- TRUE + + if (equal) { + brks <- c(NA, NA) + } else { + ext <- quantile(x, prob=quantile, na.rm=TRUE) + x[x < ext[1]] <- ext[1] + x[x > ext[2]] <- ext[2] + if (any(ext < 0) & any(ext > 0) & (zero.min == FALSE)) { + ext <- max(abs(ext)) + brks <- c(ext * -1, x, ext) + } else { + brks <- x + } + brks <- pretty(brks, n=n) + } + return(brks) + ### The function returns a vector of values. +}, ex=function() { + +Breaks(rnorm(100, 50, 30)) +Breaks(runif(100, 10, 30)) +Breaks(rlnorm(100)) + +}) + + + diff --git a/LPJmLmdi/R/Cbalance.R b/LPJmLmdi/R/Cbalance.R new file mode 100644 index 0000000..5d9e155 --- /dev/null +++ b/LPJmLmdi/R/Cbalance.R @@ -0,0 +1,385 @@ +Cbalance <- structure(function( + ##title<< + ## Calculate global C balance, C fluxes and stocks + ##description<< + ## The function takes numeric vectors or NetCDF files with values of C fluxes and stocks, and calculates C balances and turnover times [years] (see details). In case of NetCDF files, global total C fluxes and stocks [PgC year-1] are computed from NetCDF files. Thereby the input data unit needs to be [gC m-2] for stocks and [gC m-2 year-1] for fluxes. However, the argument scale is a multiplier that can be used to convert to the original unit to [gC m-2]. The results are returned as a data.frame (table). If some values or files are not provided (i.e. NA), the function will first try to compute these from other metrics (see details). + + gpp=NA, + ### numeric vector or NetCDF file of gross primary production + + npp=NA, + ### numeric vector or NetCDF file of net primary production + + ra=NA, + ### numeric vector or NetCDF file of autotrophic respiration + + rh=NA, + ### numeric vector or NetCDF file of heterotrophic respiration + + reco=NA, + ### numeric vector or NetCDF file of ecosystem respiration + + firec=NA, + ### numeric vector or NetCDF file of fire C emissions + + estab=NA, + ### numeric vector or NetCDF file of establishment C flux (specific to LPJ) + + harvest=NA, + ### numeric vector or NetCDF file of C removal from vegetation through harvest + + vegc=NA, + ### numeric vector or NetCDF file of vegetation C stocks (or biomass) + + soilc=NA, + ### numeric vector or NetCDF file of soil C stocks + + litc=NA, + ### numeric vector or NetCDF file of litter C stocks + + scale=1, + ### multiplier to convert original units to gC m-2 (stocks) or gC m-2 year-1 (fluxes) + + ti=NA, + ### time axis of the data. In case of NetCDF files, time will be extracted from the files. + + mask=NA, + ### A mask in a NetCDF file in order to compute the C fluxes, stocks, balances and turnover times only for specific regions. + + ... + ### further arguments (currently not used) + + ##details<< + ## The function computes (global) terrestrial C balances based on given input data. The used terminology is based on Schulze (2006) and Chapin et al. (2006). The following equations are used: + ## \itemize{ + ## \item{ Net primary production NPP = GPP - Ra } + ## \item{ Ecosystem respiration Reco = Rh + Ra } + ## \item{ Net ecosystem exchange NEE = Reco - GPP = Rh - NPP} + ## \item{ Net biome productivity NBP = (GPP + Estab) - (Reco + FireC + Harvest) } + ## } + ## Vegetation and total ecosystem turnover times are computed based on the formulas in Carvalhais et al. (2014) and Thurner et al. (2016): + ## \item{ Vegetation turnover time: TauVeg_NPP = VegC / NPP } + ## \item{ Vegetation turnover time based on GPP is a approximiation to the real vegetation turnover time (TauVeg_NPP) assuming that NPP is around 50% of GPP: TauVeg_GPP = VegC / ((GPP+Estab) * 0.5) } + ## \item{ Total ecosystem turnover time as in Carvalhais et al. (2014): TauEco_GPP = (VegC + SoilC + LitC) / (GPP+Estab) } + ## \item{ Total ecosystem turnover time based on Reco: TauEco_Reco = (VegC + SoilC + LitC) / Reco } + ## \item{ Total ecosystem turnover time based on Reco and disturbances: TauEco_Dist = (VegC + SoilC + LitC) / (Reco + FireC + Harvest) } + ## } + + ##references<< + ## Carvalhais et al. (2014), Global covariation of carbon turnover times with climate in terrestrial ecosystems, Nature, 514(7521), 213–217, doi:10.1038/nature13731. + ## Chapin et al. (2006), Reconciling Carbon-cycle Concepts, Terminology, and Methods, Ecosystems, 9(7), 1041–1050, doi:10.1007/s10021-005-0105-7. + ## Schulze (2006), Biological control of the terrestrial carbon sink, Biogeosciences, 3(2), 147–166, doi:10.5194/bg-3-147-2006. + ## Thurner, M., C. Beer, N. Carvalhais, M. Forkel, M. Santoro, M. Tum, and C. Schmullius (2016), Large‐scale variation in boreal and temperate forest carbon turnover rate is related to climate, Geophysical Research Letters, doi:10.1002/2016GL068794. + + ##seealso<< + ## \code{\link{Turnover}} +) { + + # read files + #----------- + + if (!is.na(mask) & is.character(mask)) mask.r <- raster(mask) + + # function to read files and to compute global totals [PgC] + .read <- function(metric) { + if (!is.character(metric[1]) | all(is.na(metric))) { + return(metric) + } else { + # read file + if (!file.exists(metric)) stop(paste(metric, "does not exist.")) + message(paste("Cbalance read:", metric)) + i <- InfoNCDF(metric) + if (length(i$time) > 1) x <- brick(metric) + if (length(i$time) == 1) x <- raster(metric) + + # mask file + if (!is.na(mask)) { + ext <- GetCommonExtent(list(x, mask.r)) + x <- crop(x, ext) + mask.r <- crop(mask.r, ext) + x <- raster::mask(x, mask.r) + } + + # apply scalar to convert to [gC m-2] + x <- x * scale + + # multiply with area [gC m-2] -> [gC] + a <- raster::area(x) * 1000000 # km2 -> m2 + x <- x * a + + # [gC] -> [PgC] + x <- x * 1/10^15 + + # spatial aggregation + s <- cellStats(x, "sum") + return(s) + } + } + + # get time information from NetCDF files + if (all(is.na(ti))) { + ti <- llply(list(gpp, npp, ra, rh, reco, firec, estab, harvest, vegc, litc, soilc), function(metric) { + ti <- NA + if (is.character(metric[1])) { + if (file.exists(metric)) ti <- InfoNCDF(metric)$time + } + return(ti) + }) + ti <- ti[[which.max(unlist(llply(ti, length)))]] + } + + # read files and compute global totals + gpp <- .read(gpp) + npp <- .read(npp) + ra <- .read(ra) + rh <- .read(rh) + reco <- .read(reco) + firec <- .read(firec) + estab <- .read(estab) + harvest <- .read(harvest) + vegc <- .read(vegc) + litc <- .read(litc) + soilc <- .read(soilc) + + + # check and compute metrics + #-------------------------- + + # make all vectors the same length + n <- max(length(gpp), length(npp), length(ra), length(rh), length(reco), length(firec), length(estab), length(harvest), length(vegc), length(soilc), length(litc)) + if (length(gpp) < n) gpp <- rep(gpp[1], n) + if (length(npp) < n) npp <- rep(npp[1], n) + if (length(ra) < n) ra <- rep(ra[1], n) + if (length(rh) < n) rh <- rep(rh[1], n) + if (length(reco) < n) reco <- rep(reco[1], n) + if (length(firec) < n) firec <- rep(firec[1], n) + if (length(estab) < n) estab <- rep(estab[1], n) + if (length(harvest) < n) harvest <- rep(harvest[1], n) + + # set time to 1:n if it is still NULL + if (all(is.na(ti))) ti <- 1:n + + # try to compute metrics iteratively + for (i in 1:3) { + gpp[is.na(gpp)] <- npp[is.na(gpp)] + ra[is.na(gpp)] + npp[is.na(npp)] <- gpp[is.na(npp)] - ra[is.na(npp)] + ra[is.na(ra)] <- gpp[is.na(ra)] - npp[is.na(ra)] + ra[is.na(ra)] <- reco[is.na(ra)] - rh[is.na(ra)] + reco[is.na(reco)] <- ra[is.na(reco)] + rh[is.na(reco)] + rh[is.na(rh)] <- reco[is.na(rh)] - ra[is.na(rh)] + } + + # set missing to 0 + gpp[is.na(gpp)] <- 0 + npp[is.na(npp)] <- 0 + ra[is.na(ra)] <- 0 + rh[is.na(rh)] <- 0 + reco[is.na(reco)] <- 0 + firec[is.na(firec)] <- 0 + estab[is.na(estab)] <- 0 + harvest[is.na(harvest)] <- 0 + vegc[is.na(vegc)] <- 0 + litc[is.na(litc)] <- 0 + soilc[is.na(soilc)] <- 0 + + + # calculate fluxes and turnover + #------------------------------ + + # calculate NEE + nee <- reco - gpp + + # calculate NBP + nbp <- (gpp + estab) - (reco + firec + harvest) + + # calculate turnover times + tauveg_gpp <- Turnover(vegc, (gpp+estab) * 0.5) + tauveg_npp <- Turnover(vegc, npp) + taueco_gpp <- Turnover(vegc+litc+soilc, gpp+estab) + taueco_reco <- Turnover(vegc+litc+soilc, reco) + taueco_dist <- Turnover(vegc+litc+soilc, reco+firec+harvest) + + + # prepare data.frame for results + #------------------------------- + + df <- data.frame(time=ti, GPP=gpp, NPP=npp, Ra=ra, Rh=rh, Reco=reco, FireC=firec, Estab=estab, Harvest=harvest, NEE=nee, NBP=nbp, VegC=vegc, LitC=litc, SoilC=soilc, TauVeg_NPP=tauveg_npp, TauVeg_GPP=tauveg_gpp, TauEco_GPP=taueco_gpp, TauEco_Reco=taueco_reco, TauEco_Dist=taueco_dist) + + + # compute temporal mean values + #----------------------------- + + if (n > 1) { + # mean of fluxes and stocks + mean.df <- as.data.frame(t(apply(df[,-1], 2, mean, na.rm=TRUE))) + + # recompute trunover times based on mean values + mean.df <- Cbalance(gpp=mean.df$GPP, npp=mean.df$NPP, ra=mean.df$Ra, rh=mean.df$Rh, firec=mean.df$FireC, estab=mean.df$Estab, harvest=mean.df$Harvest, vegc=mean.df$VegC, litc=mean.df$LitC, soilc=mean.df$SoilC, ti=df$time[1]) + + df2 <- rbind(df, mean.df) + df2$time <- c(as.character(df$time, "%Y"), "mean") + } else { + df2 <- df + } + rownames(df2) <- 1:nrow(df2) + class(df2) <- c("Cbalance", "data.frame") + return(df2) +}, ex=function() { + +# with some typical numbers for the global C budget: +cbal <- Cbalance(gpp=123, npp=61, rh=57, firec=2, vegc=400, soilc=2400) +cbal +plot(cbal) + +## using time series:: +#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) +#cbal +#plot(cbal) + + +}) + + +plot.Cbalance <- structure(function( + ##title<< + ## Plots a C balance + ##description<< + ## The function takes an object of class \code{\link{Cbalance}} and creates time series plots or barplots. + + x, + ### object of class \code{\link{Cbalance}} + + what=NULL, + ### Which variables of C balance to plot? If NULL, sole plots are generated automatically. + + trend=TRUE, + ### Compute trends? + + baseunit="PgC", + ### unit of C stocks + + ylab=NULL, + ### labels for y-axis + + ... + ### further arguments (currently not used) + + ##details<< + + + ##references<< + ## + +) { + + # function to create units + .makeUnits <- function(what, baseunit) { + unit <- rep(baseunit, length(what)) + .unitflux <- function(unit) paste(unit, "yr-1") + unit[what == "GPP"] <- .unitflux(unit[what == "GPP"]) + unit[what == "NPP"] <- .unitflux(unit[what == "NPP"]) + unit[what == "Ra"] <- .unitflux(unit[what == "Ra"]) + unit[what == "Rh"] <- .unitflux(unit[what == "Rh"]) + unit[what == "Reco"] <- .unitflux(unit[what == "Reco"]) + unit[what == "NEE"] <- .unitflux(unit[what == "NEE"]) + unit[what == "NBP"] <- .unitflux(unit[what == "NBP"]) + unit[grepl("Tau", what)] <- "yr" + return(unit) + } + + # function to plot time series + .plotts <- function(x, what, baseunit, ylab=NULL) { + n <- nrow(x) + mean.df <- x[n,] # keep mean + x <- x[-n,] # remove mean + ti <- as.numeric(x$time) + unit <- .makeUnits(what, baseunit=baseunit) + ylim <- range(x[what], na.rm=TRUE) + ylim[2] <- ylim[2] + diff(ylim) * 0.25 + #if (is.null(ylab)) ylab <- paste0(paste(what, collapse=" | "), " (", unit[1], ")") + if (is.null(ylab)) ylab <- unit[1] + cols <- brewer.pal(9, "Set1")[1:length(what)] + plot(ti, rep(1, length(ti)), type="n", ylim=ylim, ylab=ylab, xlab="") + trd.txt <- NULL + for (i in 1:length(what)) { + if (trend & !AllEqual(unlist(x[what[i]]))) { + require(greenbrown) + ts <- ts(unlist(x[what[i]]), start=ti[1], frequency=1) + trd <- Trend(ts, breaks=0) + plot(trd, col=cols[i], add=TRUE) + trd.txt <- c(trd.txt, paste0("d = ", signif(trd$slope, 1) , ", p = ", signif(trd$pval, 1))) + } else { + lines(ti, unlist(x[what[i]]), type="l", col=cols[i]) + } + } + txt <- paste(what, "mean =", round(mean.df[what], 2)) + if (trend) txt <- paste(txt, trd.txt, sep=", ") + legend("top", txt, text.col=cols, bty="n") + } + + # function to plot barplot + .plotbp <- function(x, what, baseunit, ylab=NULL) { + unit <- .makeUnits(what, baseunit=baseunit) + ylim <- range(c(0, x[what]), na.rm=TRUE) + #if (is.null(ylab)) ylab <- paste0(paste(what, collapse=" | "), " (", unit[1], ")") + if (is.null(ylab)) ylab <- unit[1] + cols <- brewer.pal(9, "Set1")[1:length(what)] + bp <- barplot(unlist(x[what]), names=what, ylim=ylim, ylab=ylab, xlab="") + text(bp, x[what], round(x[what], 2), pos=1) + box() + } + + n <- nrow(x) + if (n == 1) { + + # plot barplot + #----------------- + + if (!is.null(what)) { + .plotbp(x, what, baseunit) + } else { + op <- par() + DefaultParL(mfrow=c(3,2)) + .plotbp(x, c("GPP", "Reco"), baseunit) + .plotbp(x, c("NPP", "Ra", "Rh"), baseunit) + .plotbp(x, c("NBP"), baseunit) + .plotbp(x, c("VegC", "SoilC"), baseunit) + .plotbp(x, c("TauVeg_NPP", "TauVeg_GPP"), baseunit) + .plotbp(x, c("TauEco_GPP", "TauEco_Reco", "TauEco_Dist"), baseunit) + par(op) + } + + } else { + + # plot time series + #----------------- + + if (!is.null(what)) { + .plotts(x, what, baseunit) + } else { + op <- par() + DefaultParL(mfrow=c(3,2)) + .plotts(x, c("GPP", "Reco"), baseunit) + .plotts(x, c("NPP", "Ra", "Rh"), baseunit) + .plotts(x, c("NBP"), baseunit) + .plotts(x, c("VegC", "SoilC"), baseunit) + .plotts(x, c("TauVeg_NPP", "TauVeg_GPP"), baseunit) + .plotts(x, c("TauEco_GPP", "TauEco_Reco", "TauEco_Dist"), baseunit) + par(op) + } + } +}, ex=function() { + +# with some typical numbers for the global C budget: +cbal <- Cbalance(gpp=123, npp=61, rh=57, firec=2, vegc=400, soilc=2400) +cbal +plot(cbal) + +## using time series:: +#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) +#cbal +#plot(cbal) + + +}) + diff --git a/LPJmLmdi/R/ChangeParamFile.R b/LPJmLmdi/R/ChangeParamFile.R new file mode 100644 index 0000000..332c907 --- /dev/null +++ b/LPJmLmdi/R/ChangeParamFile.R @@ -0,0 +1,52 @@ +ChangeParamFile <- structure(function( + ##title<< + ## Change parameters in a parameter file + ##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'. + + newpar, + ### a named vector with new parameter values + + file.template, + ### file name of the template parameter with flagged parameters + + file.new, + ### file name of the new parameter file + + wait=FALSE, + ### If TRUE wait 1 second to check if file.template exists in order to relax slow file writting. + + ... + ### further arguments (currently not used) + + ##details<< + ## The function works only on Unix systems because it is based on 'sed' + + ##references<< No reference. + +) { + + if (wait) { + check <- FileExistsWait(file.template, waitmin=0, waitinterval=0.5, waitmax=1) + if (!check) stop(paste(file.template, "does not exist after waiting.", file.new, "is not produced.")) + } + + if (length(newpar) == 1) { + sed <- paste("sed 's;", names(newpar), ";", newpar, ";g' ", file.template, " > ", file.new, + sep="") + } else { + sed <- paste("sed -e", paste(paste("'s;", names(newpar), ";", newpar, ";'", sep=""), collapse=" -e"), "<", file.template, ">", file.new) + } + #sed + system(sed) +}, ex=function() { + +# newpar <- c(ALPHAA_BoNE=0.8) +# LPJChangeParamFile(newpar, file.template="pft_template.par", file.new="pft.par") + +}) + + + + + diff --git a/LPJmLmdi/R/ChangeSoilCodeFile.R b/LPJmLmdi/R/ChangeSoilCodeFile.R new file mode 100644 index 0000000..fa582db --- /dev/null +++ b/LPJmLmdi/R/ChangeSoilCodeFile.R @@ -0,0 +1,57 @@ +ChangeSoilCodeFile <- structure(function( + ##title<< + ## Change soil code in LPJ soil code file + ##description<< + ## The function changes the soil code for the specified grid cells and writes a new LPJ soil code file. + + file.soilcode, + ### original soil code file + + file.soilcode.new, + ### new soil code file + + xy, + ### matrix of grid cells (lon, lat) where the soil code should be changed + + newcode, + ### new soil code at each grid cell (vector with length = nrow(xy)) + + file.grid="cru.grid", + ### grid file for the original soil code file + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadBIN}} +) { + + + # read soilcode file + data.sp <- ReadBIN(file.soilcode, file.grid=file.grid) + grid <- ReadGrid(file.grid) + + # check which grid cells to change + xy.all <- grid + change <- NULL + for (i in 1:nrow(xy)) { + change <- c(change, intersect(which(xy[i,1] == xy.all[,1]), which(xy[i,2] == xy.all[,2]))) + } + + # change soilcode values + if (length(change) > 0) { + data.sp@data[change, ] <- newcode + #plot(data.r) + } + + # write new soilcode file + WriteBIN(data.sp, file.soilcode.new) +}) + + + \ No newline at end of file diff --git a/LPJmLmdi/R/CheckLPJpar.R b/LPJmLmdi/R/CheckLPJpar.R new file mode 100644 index 0000000..3eb39a7 --- /dev/null +++ b/LPJmLmdi/R/CheckLPJpar.R @@ -0,0 +1,92 @@ +CheckLPJpar <- structure(function( + ##title<< + ## Checks LPJ parameters 'LPJpar' + ##description<< + ## The function checks if LPJ parameters are within the lower and upper boundaries or are 0. + + lpjpar, + ### object of class 'LPJpar' + + correct=FALSE + ### correct parameter values (TRUE) or return error message? + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{LPJpar}} +) { + + if (is.null(lpjpar$lower) | is.null(lpjpar$upper) | is.null(lpjpar$prior) | is.null(lpjpar$names)) { + stop("names, prior, lower and upper need to be defined in 'lpjpar'. See LPJpar.") + } + + # lower boundaries > upper boundaries? + bool <- lpjpar$lower > lpjpar$upper + bool2 <- is.na(bool) + if (any(bool2)) { + stop(paste("Parameter boundaries are not defined for", lpjpar$names[bool2])) + } + if (any(bool)) { + if (correct) { + df <- cbind(lpjpar$lower, lpjpar$upper, lpjpar$prior, lpjpar$best) + lpjpar$lower[bool] <- apply(df, 1, min, na.rm=TRUE)[bool] + lpjpar$upper[bool] <- apply(df, 1, max, na.rm=TRUE)[bool] + } else { + stop(paste("Parameter lower boundary > upper boundary:", lpjpar$names[bool])) + } + } + + # which parameter to check? + check <- list(prior=lpjpar$prior, best=lpjpar$best, new=lpjpar$new, best.median=lpjpar$best.median) + + for (i in 1:length(check)) { + par <- check[[i]] + if (!is.null(par)) { + + # NA? + bool <- is.na(par) + par[bool] <- lpjpar$prior[bool] + + # parameter close to 0? + bool <- (par > -0.0000001) & (par < 0.0000001) + if (any(bool)) { + par[bool] <- 0.0000001 + message(paste("Parameter", names(check)[i], "equal 0 can cause division by 0. Parameter changed to 0.0000001:", paste(lpjpar$names[bool], collapse=" "))) + } + + # parameter < lower? + bool <- par < lpjpar$lower + if (any(bool)) { + if (correct) { + par[bool] <- lpjpar$lower[bool] + message(paste("Parameter", names(check)[i], "less than lower boundary. Changed.", paste(lpjpar$names[bool], collapse=" "))) + } else { + stop(paste("Parameter", names(check)[i], "less than lower boundary. ", paste(lpjpar$names[bool], collapse=" "))) + } + } + + # parameter > upper + bool <- par > lpjpar$upper + if (any(bool)) { + if (correct) { + par[bool] <- lpjpar$upper[bool] + message(paste("Parameter", names(check)[i], "higher than upper boundary. Changed.", paste(lpjpar$names[bool], collapse=" "))) + } else { + stop(paste("Parameter", names(check)[i], "higher than upper boundary. ", paste(lpjpar$names[bool], collapse=" "))) + } + } + + # set changed values back to LPJpar + names(par) <- lpjpar$names + g <- grep(names(check)[i], names(lpjpar))[1] + lpjpar[[g]] <- par + } + } # end of loop over check + + class(lpjpar) <- "LPJpar" + return(lpjpar) + ### the function return an object of class 'LPJpar' +}) \ No newline at end of file diff --git a/LPJmLmdi/R/CheckMemoryUsage.R b/LPJmLmdi/R/CheckMemoryUsage.R new file mode 100644 index 0000000..bf4642d --- /dev/null +++ b/LPJmLmdi/R/CheckMemoryUsage.R @@ -0,0 +1,22 @@ +CheckMemoryUsage <- structure(function( + ##title<< + ## Check usage of memory by R objects + ##description<< + ## Prints a message about the used memory and writes a file with the used memory per each R object. + + ... + ### The function has no arguments. + + ##details<< + ## + +) { + obj <- unique(c(ls(), ls(envir=.GlobalEnv))) + siz <- sapply(obj, function(x){object.size(get(x))}) + siz <- sort(siz) + use.df <- data.frame(obj=names(siz), byte=siz, GB=signif(siz*1e-9, 4)) + rownames(use.df) <- 1:nrow(use.df) + write.table(use.df, file="memory_usage.txt") + return(use.df) + ### a data.frame +}) diff --git a/LPJmLmdi/R/CombineLPJpar.R b/LPJmLmdi/R/CombineLPJpar.R new file mode 100644 index 0000000..3573520 --- /dev/null +++ b/LPJmLmdi/R/CombineLPJpar.R @@ -0,0 +1,48 @@ +CombineLPJpar <- structure(function( + ##title<< + ## Combines several 'LPJpar' objects into one + ##description<< + ## The function takes several lpjpar objects and combines them into one LPJpar object + + lpjpar.l + ### a list of \code{\link{LPJpar}} objects + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{LPJpar}} +) { + names <- sort(unique(unlist(llply(lpjpar.l, function(x) x$names)))) + npar <- length(names) + lpjpar2 <- list(names=names) + for (i in 1:length(lpjpar.l)) { + # which parameters were optimized? + is.opt <- !is.na(lpjpar.l[[i]]$uncertainty.iqr) + m1 <- match(lpjpar.l[[i]]$names, names) + m2 <- match(lpjpar.l[[i]]$names[is.opt], names) + for (j in 2:length(lpjpar.l[[i]])) { + colmn <- names(lpjpar.l[[i]])[j] + if (is.null(lpjpar2[[colmn]])) { + vals <- rep(NA, npar) + } else { + vals <- lpjpar2[[colmn]] + } + if (colmn == "prior" | colmn == "upper" | colmn == "lower" | colmn == "pftspecif") { + vals[m1] <- lpjpar.l[[i]][[j]] # take all parameters + if (colmn == "prior" & i == 1) { + lpjpar2$best <- lpjpar2$best.median <- vals + } + } else { + vals[m2] <- lpjpar.l[[i]][[j]][is.opt] # take only optimized parameters + } + names(vals) <- names + lpjpar2[[colmn]] <- vals + } + } + class(lpjpar2) <- "LPJpar" + return(lpjpar2) + ### The function returns a list of class 'LPJparList' +}) \ No newline at end of file diff --git a/LPJmLmdi/R/CombineRescueFiles.R b/LPJmLmdi/R/CombineRescueFiles.R new file mode 100644 index 0000000..c011909 --- /dev/null +++ b/LPJmLmdi/R/CombineRescueFiles.R @@ -0,0 +1,69 @@ +CombineRescueFiles <- structure(function( + ##title<< + ## Combine single rescue files into one rescue file + ##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. + + files.rescue, + ### file names + + remove = TRUE + ### save new rescue file and delete single rescue files? + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CreateRestartFromRescue}}, \code{\link{plot.rescue}} +) { + res <- NULL + + if (length(files.rescue) > 1) { + # read multiple rescue files and combine in one file + for (i in 1:length(files.rescue)) { + load(files.rescue[i]) + if (!exists("rescue.all.l")) rescue.all.l <- rescue.l + if (exists("rescue.all.l")) rescue.all.l <- c(rescue.all.l, rescue.l) + } + rescue.l <- rescue.all.l + rm(rescue.all.l) + + } else if (length(files.rescue) == 1) { + # read single rescue file + load(files.rescue) + } + + # check rescue objects + use.l <- llply(rescue.l, function(rescue.l) { + # use only if cost indicates within boundary parameters + use <- !is.null(rescue.l) + if (use) use <- rescue.l$cost$total != 1e+20 + return(use) + }) + rescue.l <- rescue.l[unlist(use.l)] + + # remove duplicates + txt.l <- llply(rescue.l, function(rescue.l) { + txt <- paste(round(c(rescue.l$cost$total, rescue.l$dpar), 12), collapse="-") + return(txt) + }) + rescue.l <- rescue.l[!duplicated(unlist(txt.l))] + + # remove duplicated priors + r <- laply(rescue.l, function(l) length(l$dpar)) + rescue.l <- rescue.l[r == modal(r)] + + # save new rescue files and delete previous rescue files + if (remove) { + file.rescue <- paste(gsub(":", "-", gsub(" ", "_", as.character(Sys.time()))), "_CmbRscF-", length(rescue.l), "_", sep="") + file.rescue <- tempfile(file.rescue, getwd(), fileext="_rescue.RData") + save(rescue.l, file=file.rescue) + file.remove(files.rescue) + } + + class(rescue.l) <- "rescue" + return(rescue.l) + ### 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). +}) diff --git a/LPJmLmdi/R/CorrelationMatrixS.R b/LPJmLmdi/R/CorrelationMatrixS.R new file mode 100644 index 0000000..5e445d3 --- /dev/null +++ b/LPJmLmdi/R/CorrelationMatrixS.R @@ -0,0 +1,70 @@ +CorrelationMatrixS <- structure(function( + ##title<< + ## plot a correlation matrix + ##description<< + ## + + data, + ### a correlation matrix or a data.frame ( + + method = "spearman", + ### method to compute the correlation + + iscor=NULL, + ### Is 'data' a correlation matrix? + + main="", + ### main title for the plot + + ... + ### further arguments for \code{\link{plot}} + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CombineRescueFiles}} +) { + require(fields) + if (is.null(iscor)) { + iscor <- FALSE + if (colnames(data) == rownames(data)) { + iscor <- TRUE + } + } + if (!iscor) { + m <- as.matrix(data) + m <- apply(m, 2, as.numeric) + r <- cor(m, method=method, use="pairwise.complete.obs") + } else { + r <- data + } + r2 <- r + for (i in 1:nrow(r2)) r2[i, i] <- NA + brks <- pretty(r2, 8) + brks <- pretty(seq(max(abs(brks))*-1, max(abs(brks)), length=10), 8) + .fun <- colorRampPalette(rev(brewer.pal(11, "RdBu"))) + cols <- .fun(length(brks)-1) + + p <- par() + DefaultParL() + par(las=2, oma=c(5,5,1,1), mar=c(5, 5, 1, 1), fig=c(0, 0.85, 0, 1), new=FALSE) + image(r, col=cols, breaks=brks, axes=FALSE, main=main) + abline(0,1) + x <- seq(0, 1, length=nrow(r)) + axis(1, at=x, rownames(r)) + axis(2, at=x, rownames(r)) + if (ncol(r) <= 10) { + xy <- expand.grid(x, x) + r[is.nan(r)] <- NA + text(xy[,1], xy[,2], signif(r, 2)) + } + box() + par(fig=c(0.85, 1, 0, 1), mar=c(0.5, 0.5, 0.5, 3), new=TRUE) + plot.new() + 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)) + par(p) + return(r) +}) \ No newline at end of file diff --git a/LPJmLmdi/R/CostMDS.KGE.R b/LPJmLmdi/R/CostMDS.KGE.R new file mode 100644 index 0000000..487393e --- /dev/null +++ b/LPJmLmdi/R/CostMDS.KGE.R @@ -0,0 +1,112 @@ +CostMDS.KGE <- structure(function( + ##title<< + ## Cost function for multiple data streams based on Kling-Gupta efficiency + ##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. + + integrationdata + ### object of class 'integrationdata', see \code{\link{IntegrationData}} + + ##details<< + ## No details. + + ##references<< No reference. +) { + + # number of data streams and cells + nds <- length(integrationdata) + ds.nms <- unlist(llply(integrationdata, function(ds) ds$name)) + xy <- integrationdata[[1]]$xy + xy <- integrationdata[[1]]$xy + xy.nms <- paste(xy[,1], xy[,2]) + ncell <- nrow(xy) + of.nms <- c("Bias", "Var", "Cor") # 3 KGE components + nof <- length(of.nms) + ds.cost <- (1:nds) + + # which data stream to use in the total cost + use.cost.v <- unlist(llply(integrationdata, function(ds) ds$cost)) # boolean flag: use cost in total cost + use.cost.m <- matrix(use.cost.v, nrow=nds, ncol=nof) + + # area of grid cells + area.v <- integrationdata[[1]]$area.v + area.m <- matrix(1, nrow=nds, ncol=ncell, byrow=TRUE) + area.m <- area.m / rowSums(area.m) + colnames(area.m) <- xy.nms + rownames(area.m) <- ds.nms + + # weighting factor for data stream + weight <- unlist(llply(integrationdata, function(ds) ds$weight)) # weight per data stream + weight.m <- matrix(weight, nrow=nds, ncol=nof) + colnames(weight.m) <- of.nms + rownames(weight.m) <- ds.nms + + # number of observations per data stream and cell + nobs.m <- laply(integrationdata, function(ds) { + nobs <- colSums(!is.na(ds$data.val), na.rm=TRUE) + matrix(nobs, ncol=ncell, nrow=1) + }) + nobs.m <- matrix(nobs.m, nrow=nds, ncol=nof) + colnames(nobs.m) <- of.nms + rownames(nobs.m) <- ds.nms + + # calculate cost per data stream and grid cell + cost.m <- laply(integrationdata, function(ds) { + obs.m <- ds$data.val + unc.m <- ds$data.unc + sim.m <- ds$model.val + var <- r <- 0 + simobs <- na.omit(cbind(as.vector(sim.m), as.vector(obs.m))) + bias <- (mean(simobs[,1], na.rm=TRUE) / mean(simobs[,2], na.rm=TRUE) - 1)^2 + + if (nrow(simobs) > 1) { + # variance component + var <- (sd(simobs[,1], na.rm=TRUE) / sd(simobs[,2], na.rm=TRUE) - 1)^2 + + # if all values are the same, add noise in order to calculate correlation + r <- 1 + if (!AllEqual(simobs[,1]) & !AllEqual(simobs[,2])) { + r <- (cor(simobs[,1], simobs[,2]) - 1)^2 + } + } + + cost.gc <- matrix(c(bias, var, r), nrow=1, ncol=nof) + return(cost.gc) + }) + colnames(cost.m) <- of.nms + rownames(cost.m) <- ds.nms + + # weight cost + costw.m <- cost.m + + # total cost per data stream + cost.ds <- apply(costw.m, 1, function(x) sum(x, na.rm=TRUE)) + names(cost.ds) <- ds.nms + + # total cost per metric + cost.gc <- apply(costw.m, 2, function(x) sum(x, na.rm=TRUE)) + names(cost.gc) <- of.nms + + # fractional cost + cost.frac <- costw.m / sum(costw.m, na.rm=TRUE) + + # total cost - only for data sets that should be used in total cost + cost <- sqrt(sum(costw.m * use.cost.m, na.rm=TRUE)) + if (is.infinite(cost) | is.na(cost)) cost <- 1e+20 + + # result + cost.l <- list( + total = cost, + per.cell = cost.gc, + per.ds = cost.ds, + per.cell.ds = costw.m, + sse = cost.m, + nobs = nobs.m, + weight = weight.m, + use = use.cost.m, + area = area.m, + fractional = cost.frac + ) + return(cost.l) + ### 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). +}) diff --git a/LPJmLmdi/R/CostMDS.KGEw.R b/LPJmLmdi/R/CostMDS.KGEw.R new file mode 100644 index 0000000..09b104c --- /dev/null +++ b/LPJmLmdi/R/CostMDS.KGEw.R @@ -0,0 +1,136 @@ +CostMDS.KGEw <- structure(function( + ##title<< + ## Cost function for multiple data streams based on a weighted Kling-Gupta efficiency + ##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. + + integrationdata + ### object of class 'integrationdata', see \code{\link{IntegrationData}} + + ##details<< + ## No details. + + ##references<< No reference. +) { + + # number of data streams and cells + nds <- length(integrationdata) + ds.nms <- unlist(llply(integrationdata, function(ds) ds$name)) + xy <- integrationdata[[1]]$xy + xy <- integrationdata[[1]]$xy + xy.nms <- paste(xy[,1], xy[,2]) + ncell <- nrow(xy) + of.nms <- c("Bias", "Var", "Cor") # 3 KGE components + nof <- length(of.nms) + ds.cost <- (1:nds) + + # which data stream to use in the total cost + use.cost.v <- unlist(llply(integrationdata, function(ds) ds$cost)) # boolean flag: use cost in total cost + use.cost.m <- matrix(use.cost.v, nrow=nds, ncol=nof) + + # area of grid cells + area.v <- integrationdata[[1]]$area.v + area.m <- matrix(1, nrow=nds, ncol=ncell, byrow=TRUE) + area.m <- area.m / rowSums(area.m) + colnames(area.m) <- xy.nms + rownames(area.m) <- ds.nms + + # weighting factor for data stream + weight <- unlist(llply(integrationdata, function(ds) ds$weight)) # weight per data stream + weight.m <- matrix(weight, nrow=nds, ncol=nof) + colnames(weight.m) <- of.nms + rownames(weight.m) <- ds.nms + + # number of observations per data stream and cell + nobs.m <- laply(integrationdata, function(ds) { + nobs <- colSums(!is.na(ds$data.val), na.rm=TRUE) + matrix(nobs, ncol=ncell, nrow=1) + }) + nobs.m <- matrix(nobs.m, nrow=nds, ncol=nof) + colnames(nobs.m) <- of.nms + rownames(nobs.m) <- ds.nms + + # calculate cost per data stream and grid cell + cost.m <- laply(integrationdata, function(ds) { + obs.m <- ds$data.val + unc.m <- ds$data.unc + sim.m <- ds$model.val + var <- r <- 0 + unc.m[unc.m == 0] <- 0.00000001 + simobs <- na.omit(cbind(as.vector(sim.m), as.vector(obs.m), w=1/as.vector(unc.m))) + simobs[is.infinite(simobs)] <- NA + simobs <- na.omit(simobs) + + # bias component + bias <- (MeanW(simobs[,1], w=1/simobs[,3]) / MeanW(simobs[,2], w=1/simobs[,3]) - 1)^2 + + if (nrow(simobs) > 1) { + # variance component + var <- (SdW(simobs[,1], w=1/simobs[,3]) / SdW(simobs[,2], w=1/simobs[,3]) - 1)^2 + + # if all values are the same, set correlation component to 1 + r <- 1 + if (!AllEqual(simobs[,1]) & !AllEqual(simobs[,2])) { + r <- try((CorW(simobs[,1], simobs[,2], w=1/simobs[,3]) - 1)^2, silent=TRUE) + if (class(r) == "try-error") r <- (cor(simobs[,1], simobs[,2]) - 1)^2 + } + } + + cost.gc <- matrix(c(bias, var, r), nrow=1, ncol=nof) + return(cost.gc) + }) + colnames(cost.m) <- of.nms + rownames(cost.m) <- ds.nms + + # weight cost + costw.m <- cost.m + + # total cost per data stream + cost.ds <- apply(costw.m, 1, function(x) sum(x, na.rm=TRUE)) + names(cost.ds) <- ds.nms + + # total cost per metric + cost.gc <- apply(costw.m, 2, function(x) sum(x, na.rm=TRUE)) + names(cost.gc) <- of.nms + + # fractional cost + cost.frac <- costw.m / sum(costw.m, na.rm=TRUE) + + # total cost - only for data sets that should be used in total cost + cost <- sqrt(sum(costw.m * use.cost.m, na.rm=TRUE)) + if (is.infinite(cost) | is.na(cost)) cost <- 1e+20 + + # result + cost.l <- list( + total = cost, + per.cell = cost.gc, + per.ds = cost.ds, + per.cell.ds = costw.m, + sse = cost.m, + nobs = nobs.m, + weight = weight.m, + use = use.cost.m, + area = area.m, + fractional = cost.frac + ) + return(cost.l) + ### 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). +}, ex=function() { + +# load(paste0(path.me, "/lpj/LPJmL_131016/out_optim/opt_fpc/OFPC_BO-GI-BM_v1_all_0_59_posterior-best.RData")) +# x <- result.post.lpj$integrationdata +# plot(x, 2) + +# cost.see <- CostMDS.SSE(x) +# cost.kge <- CostMDS.KGE(x) +# cost.kgew <- CostMDS.KGEw(x) + +# DefaultParL(mfrow=c(1,3)) +# barplot(cost.see$per.ds) +# barplot(t(cost.kge$per.cell.ds)) +# barplot(t(cost.kgew$per.cell.ds)) + +}) + + + diff --git a/LPJmLmdi/R/CostMDS.SSE.R b/LPJmLmdi/R/CostMDS.SSE.R new file mode 100644 index 0000000..b5a5828 --- /dev/null +++ b/LPJmLmdi/R/CostMDS.SSE.R @@ -0,0 +1,99 @@ +CostMDS.SSE <- structure(function( + ##title<< + ## Cost function for multiple data streams based on SSE + ##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. + + integrationdata + ### object of class 'integrationdata', see \code{\link{IntegrationData}} + + ##details<< + ## No details. + + ##references<< No reference. +) { + + # number of data streams and cells + nds <- length(integrationdata) + ds.nms <- unlist(llply(integrationdata, function(ds) ds$name)) + xy <- integrationdata[[1]]$xy + xy.nms <- paste(xy[,1], xy[,2]) + ncell <- nrow(xy) + ds.cost <- (1:nds) + + # which data stream to use in the total cost + use.cost.v <- unlist(llply(integrationdata, function(ds) ds$cost)) # boolean flag: use cost in total cost + use.cost.m <- matrix(use.cost.v, nrow=nds, ncol=ncell) + + # area-weight of grid cells + area.v <- integrationdata[[1]]$area.v + area.m <- matrix(area.v, nrow=nds, ncol=ncell, byrow=TRUE) + area.m <- area.m / rowSums(area.m) + colnames(area.m) <- xy.nms + rownames(area.m) <- ds.nms + + # weighting factor for data stream + weight <- unlist(llply(integrationdata, function(ds) ds$weight)) # weight per data stream + weight.m <- matrix(weight, nrow=nds, ncol=ncell) + colnames(weight.m) <- xy.nms + rownames(weight.m) <- ds.nms + + # number of observations per data stream and cell + nobs.m <- laply(integrationdata, function(ds) { + #bacds <<- ds + nobs <- colSums(!is.na(ds$data.val), na.rm=TRUE) + matrix(nobs, ncol=ncell, nrow=1) + }) + if (!is.matrix(nobs.m)) nobs.m <- matrix(nobs.m, ncol=ncell, nrow=nds) + colnames(nobs.m) <- xy.nms + rownames(nobs.m) <- ds.nms + + # calculate cost per data stream and grid cell + cost.m <- laply(integrationdata, function(ds) { + ds <<- ds + obs.m <- ds$data.val + unc.m <- ds$data.unc + sim.m <- ds$model.val + CostFunction <- ds$CostFunction + cost.gc <- mapply(function(cell) { + do.call(CostFunction, list(sim.m[,cell], obs.m[,cell], unc.m[,cell])) + }, 1:ncell) + return(cost.gc) + }) + if (!is.matrix(cost.m)) cost.m <- matrix(cost.m, ncol=ncell, nrow=nds) + colnames(cost.m) <- xy.nms + rownames(cost.m) <- ds.nms + + # weight cost + costw.m <- (cost.m / nobs.m * weight.m * area.m) + colnames(costw.m) <- xy.nms + rownames(costw.m) <- ds.nms + + # total cost per data stream + cost.ds <- rowSums(costw.m, na.rm=TRUE) + names(cost.ds) <- ds.nms + + # total cost per grid cell + cost.gc <- colSums(costw.m, na.rm=TRUE) + names(cost.gc) <- xy.nms + + # total cost - only for data sets that should be used in total cost + cost <- sum(costw.m * use.cost.m, na.rm=TRUE) + if (is.infinite(cost) | is.na(cost)) cost <- 1e+20 + + # result + cost.l <- list( + total = cost, + per.cell = cost.gc, + per.ds = cost.ds, + per.cell.ds = costw.m, + costfun = cost.m, + nobs = nobs.m, + weight = weight.m, + use = use.cost.m, + area = area.m + ) + return(cost.l) + ### 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. +}) + diff --git a/LPJmLmdi/R/CreateRestartFromRescue.R b/LPJmLmdi/R/CreateRestartFromRescue.R new file mode 100644 index 0000000..0a06620 --- /dev/null +++ b/LPJmLmdi/R/CreateRestartFromRescue.R @@ -0,0 +1,89 @@ +CreateRestartFromRescue <- structure(function( + ##title<< + ## Create a *.pro file from binary rescue files to restart optimization + ##description<< + ## The function creates a *.pro file friom binary 'rescue' files. The *.pro file can be used to restart OptimizeLPJgenoud. + + path.rescue, + ### directory where the resuce files from each iteration of the optimization are saved. + + pop.size + ### (estimated) population size of the genetic optimization + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{genoudLPJrescue}} +) { + + + # create matrix with cost and parameters from rescue files + #---------------------------------------------------------- + + file.rescue.pro <- paste(path.rescue, "/rescue.pro", sep="") + has.restart.files <- FALSE + ngenerations <- 1 + pop.total <- 0 + optim0.m <- NULL + optim1.m <- NULL + + # load existing rescue file pro files + setwd(path.rescue) + files.pro <- list.files(pattern=".pro") + if (length(files.pro) > 0) { + has.restart.files <- TRUE + optim0.m <- ReadPRO(files.pro)[, -1] + colnames(optim0.m) <- paste("X", 1:ncol(optim0.m)) + file.remove(files.pro) # delete old rescue pro file + } + + # combine rescue RData files + setwd(path.rescue) + files.rescue <- c(list.files(pattern="_rescue0.RData"), list.files(pattern="rescue.RData")) + if (length(files.rescue) > 0) { + has.restart.files <- TRUE + rescue.all.l <- CombineRescueFiles(files.rescue) + n <- laply(rescue.all.l, function(l) length(l$dpar)) + r <- n != modal(n) + rescue.all.l <- rescue.all.l[!r] + optim1.m <- laply(rescue.all.l, function(l) { + cbind(matrix(l$cost$total, 1, 1), matrix(l$dpar, nrow=1, ncol=length(l$dpar))) + }) + colnames(optim1.m) <- paste("X", 1:ncol(optim1.m)) + } + + + # save restart *.pro file + #-------------------------- + + if (has.restart.files) { + if (is.null(optim0.m) & !is.null(optim1.m)) optim.m <- optim1.m + if (!is.null(optim0.m) & is.null(optim1.m)) optim.m <- optim0.m + if (!is.null(optim0.m) & !is.null(optim1.m)) optim.m <- rbind(optim0.m, optim1.m) + optim.m <- optim.m[order(optim.m[,1], decreasing=TRUE), ] + + # check and remove for duplicates + bool <- duplicated(paste(round(optim.m[,1], 6), round(optim.m[,2], 6))) + optim.m <- optim.m[!bool, ] + + # save optim.m as new pro file + pop.total <- nrow(optim.m) + optim.m <- cbind(rep(1:pop.size, length=pop.total), optim.m) + ngenerations <- floor(pop.total / pop.size) + nvar <- ncol(optim.m) - 1 + + # write pro file + con <- file(file.rescue.pro, "w") + writeLines(paste("Generation: 0 ", "\t", " Population Size: ", pop.size, " \t ", "Fit Values: 1 ", "\t", " Variables: ", nvar, sep=""), con) + writeLines("", con) + close(con) + write.table(optim.m, file = file.rescue.pro, append = TRUE, sep=" \t ", row.names=FALSE, col.names=FALSE) + } + result <- list(file=file.rescue.pro, ngenerations=as.integer(ngenerations), pop.total=pop.total) + return(result) + +}) + diff --git a/LPJmLmdi/R/DefaultParL.R b/LPJmLmdi/R/DefaultParL.R new file mode 100644 index 0000000..93eed48 --- /dev/null +++ b/LPJmLmdi/R/DefaultParL.R @@ -0,0 +1,50 @@ +DefaultParL <- structure(function( + ##title<< + ## default 'par' settings for plots + ##description<< + ## The function calls 'par' with some default settings to improve plots. See \code{\link{par}} for details. + + mfrow=c(1,1), + ### number of rows/columns + + mar=c(3.7, 3.5, 2.5, 0.5), + ### margins + + oma=c(0.8, 0.1, 0.1, 0.2), + ### outer margins + + mgp=c(2.4, 1, 0), + ### margin line for axis title, label and lines + + cex=1.3, + ### text and symbol size + + cex.lab=cex*1.1, + ### label size + + cex.axis=cex*1.1, + ### axis anootation size + + cex.main=cex*1.1, + ### title size + + ... + ### further arguments to \code{\link{par}} + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{par}} + +) { + par(mfrow=mfrow, mar=mar, mgp=mgp, cex.lab=cex.lab, cex.axis=cex.axis, cex.main=cex.main, oma=oma, ...) + +}, ex=function() { + +DefaultParL() +plot(1:10) + +}) \ No newline at end of file diff --git a/LPJmLmdi/R/Df2optim.R b/LPJmLmdi/R/Df2optim.R new file mode 100644 index 0000000..fb54a10 --- /dev/null +++ b/LPJmLmdi/R/Df2optim.R @@ -0,0 +1,58 @@ +Df2optim <- structure(function( + ##title<< + ## Convert a data.frame to a \code{\link{optim}} list + ##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. + + optim.df, + ### a 'data.frame' as created by \code{\link{Rescue2DF}} + + pop.size=NA, + ### used population size. If NA, ngen (number of generations) and peak generation cannot be returned correctly. In this case both estimates will be 1. + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CombineRescueFiles}} +) { + # get information about optimization + best <- which.min(optim.df$cost)[1] + rem.ll <- match(c("cost", "ll", "aic", "daic"), colnames(optim.df)) + npar.opt <- ncol(optim.df) - length(rem.ll) + niter <- nrow(optim.df) + if (is.na(pop.size)) { + ngen <- 1 + pop.size <- niter + } else { + ngen <- floor(niter / pop.size) + } + par.best <- as.vector(unlist(optim.df[best, -rem.ll])) + names(par.best) <- colnames(optim.df)[-rem.ll] + + # create opt.genetic object + opt.genetic <- NULL + opt.genetic$value <- optim.df$cost[best] + opt.genetic$par <- par.best + opt.genetic$gradients <- rep(NA, npar.opt) + opt.genetic$generations <- ngen + opt.genetic$peakgeneration <- rep(1:ngen, each=pop.size)[best] + opt.genetic$popsize <- pop.size + opt.genetic$operators <- rep(NA, 9) + + ### The function returns a list + return(opt.genetic) +}, ex=function() { + # files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) + # rescue.l <- CombineRescueFiles(files, remove=FALSE) + # optim.df <- Rescue2Df(rescue.l) + # opt <- Rescue2optim(rescue.l) + # opt +}) + + diff --git a/LPJmLmdi/R/EstOptimUse.R b/LPJmLmdi/R/EstOptimUse.R new file mode 100644 index 0000000..115b64f --- /dev/null +++ b/LPJmLmdi/R/EstOptimUse.R @@ -0,0 +1,24 @@ +EstOptimUse <- structure(function( + ##title<< + ## Estimate optimal number of jobs given a number of cluster nodes + + nodes=16, + ### number of cluster nodes that you want to use + + wish=1000 + ### approx. number of elements + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{WriteCLM}} + +) { + real <- as.integer(ceiling(wish / nodes)) + r <- real * nodes + return(r) + ### an integer value +}) \ No newline at end of file diff --git a/LPJmLmdi/R/FileExistsWait.R b/LPJmLmdi/R/FileExistsWait.R new file mode 100644 index 0000000..d709d75 --- /dev/null +++ b/LPJmLmdi/R/FileExistsWait.R @@ -0,0 +1,53 @@ +FileExistsWait <- structure(function( + ##title<< + ## Iterative checking and waiting for a file. + ##description<< + ## The function repeately checks if a file exists and returns TRUE if the file is existing. + + file, + ### file for which checking and waiting should be applied + + waitmin=0, + ### minimum waiting time (seconds) + + waitinterval=0.5, + ### interval after which the existence of the file should be checked again (seconds) + + waitmax=2, + ### maximum waiting time (seconds) + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. +) { + Sys.sleep(waitmin) # minimum waiting time + if (all(file.exists(file))) { + return(TRUE) + } else { + # repeat checking and waiting for file + n <- as.integer(waitmax / waitinterval) # maximum number of iterations + i <- 1 + while (any(!file.exists(file)) & i <= n) { + Sys.sleep(waitinterval) + if (i == 1) message(paste(paste(file[!file.exists(file)], collapse=", "), "does not exist [waiting ...]", "\n")) + i <- i + 1 + } + if (all(file.exists(file))) { + return(TRUE) + } else { + message(paste(paste(file[!file.exists(file)], collapse=", "), "does not exist after", waitmax+waitmin, "seconds. Waiting stopped.", "\n")) + return(FALSE) + } + } +}, ex=function() { + +FileExistsWait(system.file("external/rlogo.grd", package="raster")) +FileExistsWait("nofile.txt") + +}) + + diff --git a/LPJmLmdi/R/GridProperties.R b/LPJmLmdi/R/GridProperties.R new file mode 100644 index 0000000..109c87a --- /dev/null +++ b/LPJmLmdi/R/GridProperties.R @@ -0,0 +1,48 @@ +GridProperties <- structure(function( + ##title<< + ## Derive grid properties from an object of class 'LPJfiles' + ##description<< + ## The function reads the grid of the input files in 'LPJfiles' and computes the area per grid cell. + + lpjfiles, + ### list of class 'LPJinput' + + res = 0.5, + ### resolution of LPJmL + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{LPJfiles}} +) { + + # is there already grid information + has.grid <- !is.null(lpjfiles$grid) + if (!has.grid) { + grid.pos <- c(grep("grid", lpjfiles$input$name), grep("GRID", lpjfiles$input$name)) + file.grid <- as.character(lpjfiles$input$file[grid.pos]) + grid <- ReadGrid(file.grid) + ll <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0") + ncell <- nrow(grid) + grid.sp <- SpatialPointsDataFrame(grid, data=data.frame(id=1:ncell), proj4string=ll) + ext <- extent(grid.sp) + res2 <- res / 2 + grid.r <- raster(xmn=ext@xmin-res2, xmx=ext@xmax+res2, ymn=ext@ymin-res2, ymx=ext@ymax+res2) + res(grid.r) <- c(res, res) + grid.r[] <- NA + grid.r[cellFromXY(grid.r, grid)] <- 0:(ncell-1) + area.r <- raster::area(grid.r) + area.r <- mask(area.r, grid.r) + grid <- list(grid=grid.r, area=area.r, ncell=nrow(grid)) + } else { + grid <- lpjfiles$grid + } + return(grid) + ### the function returns a list with 'grid' (raster of grid cells), 'area' (vector of grid cell area) and 'ncell' (number of grid cells) +}) \ No newline at end of file diff --git a/LPJmLmdi/R/InfoCLM.R b/LPJmLmdi/R/InfoCLM.R new file mode 100644 index 0000000..4e2707b --- /dev/null +++ b/LPJmLmdi/R/InfoCLM.R @@ -0,0 +1,90 @@ +InfoCLM <- structure(function( + ##title<< + ## Returns information about a CLM file + + file.clm, + ### CLM file name with extension *.clm + + endian="little", + ### endianess of the file + + ... + ### Further arguments (currently not used). + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{WriteLPJinput}} + +) { + + file.size <- file.info(file.clm)$size + + # get filename from first position + file.f <- file(file.clm, "rb") + name <- readBin(file.f, character(), n=1, size=1, endian=endian)[1] + #close(file.f) + + # calculate length of name character string + name <- gsub("\001", "", name) + name <- gsub("\002", "", name) + name <- gsub("\003", "", name) + skip <- length(unlist(strsplit(name, ""))) * 1 + + # initial estimate size of data + size <- 4 + + # read other header information + if (skip == 0) { + # return NA and set headersize to 0 if header does'nt exist + x <- rep(NA, 10) + headersize <- 0 + } else { + # get other header information + x <- readBin(file.f, integer(), n=7, size=size, endian=endian) + # read header again if order value in the header is unrealistic: try natural size + if ((x[2] > 2) | (x[2] < 1)) { + seek(file.f, skip, origin="start", rw="r") + x <- readBin(file.f, integer(), n=7, endian=endian) + } + headersize <- skip + 7 * size + } + close(file.f) + + # check if header information is consistent with file size and return warning + if (headersize == 0) warning("File has no header.") + + # check if header information is valid - if not read file again with endian "big" + if (x[6] > 70000) { + info <- InfoCLM(file.clm, "big") + } else { + + size <- (file.size - headersize) / x[4] / x[7] / x[6] + size2 <- round(size) + suppressWarnings(file.size.fromheader <- (headersize + x[4] * x[7] * x[6] * size2)) + if (is.na(file.size.fromheader)) file.size.fromheader <- file.size + if (file.size.fromheader != file.size) warning("File size does not correspond to header information.") + + # return list with header and file information + info <- list(filename=file.clm, + name=name, + version=x[1], + order=x[2], + firstyear=x[3], + nyear=x[4], + firstcell=x[5], + ncell=x[6], + nbands=x[7], + size=round(size), + headersize=headersize, + file.size.real=file.size, + file.size.fromheader=file.size.fromheader, + endian=endian + ) + } + + return(info) +}) \ No newline at end of file diff --git a/LPJmLmdi/R/InfoLPJ.R b/LPJmLmdi/R/InfoLPJ.R new file mode 100644 index 0000000..566dc6d --- /dev/null +++ b/LPJmLmdi/R/InfoLPJ.R @@ -0,0 +1,70 @@ +InfoLPJ <- structure(function( + ##title<< + ## Information about a LPJmL binary file + ##description<< + ## The function reads information about a LPJ binary output file. + + file.bin="fpc.bin", + ### binary LPJ output file + + file.grid="grid.bin", + ### binary LPJ grid file + + file.annual=c("vegc.bin", "litc.bin", "soilc.bin"), + ### one of the binary LPJ output files with annual data + + size=4, + ### the number of bytes per element in the byte stream. + + data.type=numeric(), + ### data type of the file (default=numeric()) + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadLPJ}} + +) { + + check <- FileExistsWait(c(file.bin, file.grid), waitmin=0, waitinterval=0.5, waitmax=1) + if (any(!check)) return(NULL) + + # get number of pixels from grid file + npixel <- file.info(file.grid)$size / size + + # read grid - get coordinates + grid.fn <- file(file.grid, "rb") + grid.data <- matrix(readBin(grid.fn, integer(), n=npixel*2, size=2), ncol=2, byrow=TRUE) / 100 + close(grid.fn) + ext <- extent(min(grid.data[,1]), max(grid.data[,1]), min(grid.data[,2]), max(grid.data[,2])) + + # get number of years from vegc file + file.annual.exists <- file.exists(file.annual) + if (all(!file.annual.exists)) stop("One of the files lic.bin, soilc.bin or vegc.bin should exists.") + file.annual <- file.annual[file.annual.exists][1] + nyear <- file.info(file.annual)$size / size / npixel + + # get number of bands from file + nbands <- file.info(file.bin)$size / size / npixel / nyear + + info <- list( + grid = grid.data, + filename=file.bin, + npixel=npixel, + nyear=nyear, + nbands=nbands, + extent=ext + ) + return(info) + ### The function returns a list with information about the LPJ binary file (number of grid cells, number of years, number of bands, spatial extent). +}, ex=function() { + +# InfoLPJ("vegc.bin") + +}) diff --git a/LPJmLmdi/R/InfoNCDF.R b/LPJmLmdi/R/InfoNCDF.R new file mode 100644 index 0000000..7495da4 --- /dev/null +++ b/LPJmLmdi/R/InfoNCDF.R @@ -0,0 +1,54 @@ +InfoNCDF <- structure(function( + ##title<< + ## Get information about variables in a NetCDF + + file + ### file name + + ##details<< + ## + + ##references<< + ## + + ##seealso<< + ## \code{\link{WriteNCDF4}} + +) { + nc <- nc_open(file) + + # get variables + nms <- unlist(llply(nc$var, function(v) v$name)) + units <- unlist(llply(nc$var, function(v) v$units)) + nms2 <- unlist(llply(nc$var, function(v) v$longname)) + + # get dimensions + lon <- nc$dim$lon$vals + lat <- nc$dim$lat$vals + ti <- try(as.Date(gsub("days since ", "", nc$dim$time$units)) + nc$dim$time$vals, silent=TRUE) + if (class(ti) == "try-error") { + ti <- nc$dim$time$vals + } + + # all dimensions + dim <- llply(nc$dim, function(dim) { + return(list(name=dim$name, length=length(dim$vals))) + }) + + + # get global attributes + glob <- ncatt_get(nc, 0) + + nc_close(nc) + info.l <- list( + file = file, + lat = lat, + lon = lon, + time = ti, + dim = dim, + global = glob, + var = data.frame(name=nms, unit=units, longname=nms2) + ) + return(info.l) + ### The function returns a list with information about the dimensions and variables in the NetCDF file. +}) diff --git a/LPJmLmdi/R/IntegrationData.R b/LPJmLmdi/R/IntegrationData.R new file mode 100644 index 0000000..0e34e16 --- /dev/null +++ b/LPJmLmdi/R/IntegrationData.R @@ -0,0 +1,59 @@ +IntegrationData <- structure(function( + ##title<< + ## Create an object of class 'IntegrationData' + ##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}}. + + ... + ### one or several objects of class 'IntegrationDataset' + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationDataset}} +) { + integrationdata <- list(...) + llply(integrationdata, function(ds) { + if (class(ds) != "IntegrationDataset") stop(paste(ds$name, "is not of class 'IntegrationDataset'")) + }) + class(integrationdata) <- "IntegrationData" + return(integrationdata) + ### The function returns a list of class 'IntegrationData' +}, ex=function() { + +# # grid cells for which LPJmL should be run and for which the integration data should be extracted +# xy <- cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75)) + +# # use monthly FAPAR in model-data integration +# fapar <- IntegrationDataset(name="FAPAR", unit="", + # data.val.file="GIMMS.FAPAR.1982.2011.nc", + # data.unc.file=0.12, + # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + # model.val.file="mfapar.bin", + # model.agg=NULL, + # xy=xy, + # data.factor=NULL, + # cost=TRUE, + # CostFunction=SSE, + # weight=1) + +# # use mean annual GPP in model-data integration +# gpp <- IntegrationDataset(name="GPP", unit="gC m-2 yr-1", + # data.val.file="MTE.GPP.1982.2011.meanannual.nc", + # data.unc.file="MTE.GPPunc.1982.2011.meanannual.nc", + # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + # model.val.file="mgpp.bin", + # model.agg=AggSumMean, # sum of each year, mean over all years -> mean annual GPP + # xy=xy, + # data.factor=NULL, + # cost=TRUE, + # CostFunction=SSE, + # weight=1) + +# integrationdata <- IntegrationData(fapar, gpp) + +}) + diff --git a/LPJmLmdi/R/IntegrationData2Df.R b/LPJmLmdi/R/IntegrationData2Df.R new file mode 100644 index 0000000..53258ee --- /dev/null +++ b/LPJmLmdi/R/IntegrationData2Df.R @@ -0,0 +1,57 @@ +IntegrationData2Df <- structure(function( + ##title<< + ## Converts IntegrationData to a data.frame + ##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. + + x, + ### object of class \code{\link{IntegrationData}} + + sim.name = "sim", + ### 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') + + ... + ### further arguments (not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationData}} +) { + + # has simulations? + has.sim <- is.matrix(x[[1]]$model.val) + + # iterate over all datasets: create data.frame + data.l <- llply(x, function(ds) { + .create.df <- function(data, name) { + data.df <- cbind(time=as.Date(ds$data.time), as.data.frame(data)) + colnames(data.df) <- c("time", paste(ds$xy$lon, ds$xy$lat)) + data.df <- gather(data.df, key=xy, value=Y, -time) %>% + separate(xy, c("lon", "lat"), sep=" ", convert=TRUE) %>% + unite(lon, lat, time, col="id", remove=FALSE) + colnames(data.df) <- c("id", "time", "lon", "lat", name) + return(data.df) + } + data.df <- .create.df(ds$data.val, paste0(ds$name, ".obs")) + if (has.sim) { + sim.df <- .create.df(ds$model.val, paste(ds$name, sim.name, sep=".")) + data.df <- merge(data.df, sim.df) + } + return(data.df) + }) + + # merge all data.frames + ids <- unique(unlist(llply(data.l, function(df) df$id))) + all.df <- data.frame(id=ids) %>% + separate(id, c("lon", "lat", "time"), sep="_", convert=TRUE, remove=FALSE) + all.df$time <- as.Date(all.df$time) + for (i in 1:length(data.l)) all.df <- merge(all.df, data.l[[i]], all=TRUE) + + return(all.df) + ### a data.frame +}) + diff --git a/LPJmLmdi/R/IntegrationDataset.R b/LPJmLmdi/R/IntegrationDataset.R new file mode 100644 index 0000000..a7bd010 --- /dev/null +++ b/LPJmLmdi/R/IntegrationDataset.R @@ -0,0 +1,145 @@ +IntegrationDataset <- structure(function( + ##title<< + ## Create an object of class 'IntegrationDataset' + ##description<< + ## The function sets up an object of class 'IntegrationDataset' to define a dataset that should be used in model optimization, including dataset properties and the corresponding model output files. The function also reads the data input files as defined in 'data.val.file' and subsets the input data for the grid cells in 'xy'. One or several 'IntegrationDataset's need to be collected in an object of class \code{\link{IntegrationData}} which is used in the \code{\link{RunLPJ}} and \code{\link{OptimizeLPJgenoud}} functions. + + name, + ### name of the dataset or variable + + unit="", + ### unit of the variable (same unit as in LPJmL model output file 'model.val.file') + + data.val.file, + ### name of file with the observation values, should be a file that can be read with \code{\link{brick}} + + data.unc.file, + ### name of file with the data uncertainties or a numeric value if the same uncertainty value should be used for all observations + + data.time, + ### a vector of class 'Date' with the time steps of the observations. + + model.time = data.time, + ### a vector of class 'Date' with the time steps for which model results should be read. For example, if data.val.file represents just one value (e.g. long-term mean), the full time period for which the model results should be averaged needs to be defined here. + + model.val.file, + ### file name of the corresponding model result [e.g. model.val.file="mnpp.bin"] or function without arguments [e.g. model.val.file=function() { ReadLPJ("mnpp.bin", start=1901, end=2009, ...) }]. The option to pass a function allows to perform any calculations on LPJ model results or to combine several LPJ model outputs in order to be comparable with observations. + + xy, + ### a matrix of grid cells that is used in \code{\link{RunLPJ}} and \code{\link{OptimizeLPJgenoud}}. The data in 'data.val.file' and 'data.unc.file' is extracted for these grid cells. + + AggFun=NULL, + ### aggregation function to aggregate model results to the temporal resolution of the observations, for example \code{\link{AggSumMean}} for annual sums and mean over annual sums. If NULL no temporal aggregation is done. + + data.factor=1, + ### scaling factor to be applied to the observation data, e.g. for unit conversions + + model.factor=1, + ### scaling factor to be applied to model outputs, e.g. for unit conversions or scaling + + cost=TRUE, + ### Should the data stream be included in the computation of the total cost (TRUE) or not (FALSE). In case of FALSE, evaluation plots are produced for this dataset but the dataset is not considered in the compuation of the total cost and therfore not in optimization. + + CostFunction=SSE, + ### cost function that should be used for this dataset, default \code{\link{SSE}} + + weight=1 + ### weighting factor for the dataset in the cost function, cost = CostFunction / number of observations * weight + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationData}} +) { + + # read data files and extract for grid cells + #------------------------------------------- + + ncell <- nrow(xy) + + # read observations + data.val.r <- brick(data.val.file) + if (nlayers(data.val.r) == 1) data.val.r <- raster(data.val.file) + data.val <- matrix(t(data.val.r[cellFromXY(data.val.r, xy)]), ncol=ncell) + + # read values of the uncertainty + if (is.character(data.unc.file)) { + # read values of a data stream from file + data.unc.r <- brick(data.unc.file) + if (nlayers(data.unc.r) == 1) data.unc.r <- raster(data.unc.file) + data.unc <- matrix(t(data.unc.r[cellFromXY(data.unc.r, xy)]), ncol=ncell) + } else { + # create raster with constant uncertainty + data.unc <- data.val + data.unc[] <- data.unc.file + } + + # grid cell area + area.r <- raster::area(data.val.r) + area.v <- extract(area.r, xy) + + + # create IntegrationDataset object + #--------------------------------- + + if (is.null(data.factor)) data.factor <- 1 + + ds <- list( + name=name, + unit=unit, + data.val.file=data.val.file, + data.unc.file=data.unc.file, + data.time=data.time, + model.time=model.time, + model.val.file=model.val.file, + model.factor=model.factor, + AggFun=AggFun, + data.factor=data.factor, + cost=cost, + CostFunction=CostFunction, + weight=weight, + data.val=data.val*data.factor, + data.unc=data.unc*data.factor, + xy=xy, + area.v=area.v + ) + class(ds) <- "IntegrationDataset" + return(ds) + ### The function returns a list of class 'IntegrationDataset' +}, ex=function() { + +# # grid cells for which LPJmL should be run and for which the integration data should be extracted +# xy <- cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75)) + +# # use monthly FAPAR in model-data integration +# fapar <- IntegrationDataset(name="FAPAR", unit="", + # data.val.file="GIMMS.FAPAR.1982.2011.nc", + # data.unc.file=0.12, + # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + # model.val.file="mfapar.bin", + # model.agg=NULL, + # xy=xy, + # data.factor=NULL, + # cost=TRUE, + # CostFunction=SSE, + # weight=1) + +# # use mean annual GPP in model-data integration +# gpp <- IntegrationDataset(name="GPP", unit="gC m-2 yr-1", + # data.val.file="MTE.GPP.1982.2011.meanannual.nc", + # data.unc.file="MTE.GPPunc.1982.2011.meanannual.nc", + # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + # model.val.file="mgpp.bin", + # model.agg=AggSumMean, # sum of each year, mean over all years -> mean annual GPP + # xy=xy, + # data.factor=NULL, + # cost=TRUE, + # CostFunction=SSE, + # weight=1) + + +}) + diff --git a/LPJmLmdi/R/LE2ET.R b/LPJmLmdi/R/LE2ET.R new file mode 100644 index 0000000..1798127 --- /dev/null +++ b/LPJmLmdi/R/LE2ET.R @@ -0,0 +1,45 @@ +LE2ET <- structure(function( + ##title<< + ## Compute evapotranspiration (ET) from latent heat (LE). + + le, + ### latent heat (W m-2) + + temp = 20, + ### temperature (degC, default 20 degC) + + rho_w = 1000 + # density of water (kg m-3) + + ##details<< + ## + + ##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 + + ##seealso<< + ## \code{\link{WriteLPJinput}} + +) { + # latent heat of vaporization + lambda_v <- (5.147 * exp(-0.0004643 * temp) - 2.6466) # MJ/kg + lambda_v <- lambda_v * 1E6 # (J/kg) + + # evapotranspiration (m s-1) + et <- le / (rho_w * lambda_v) + + # evapotranspiration (m s-1) -> (mm day-1) + et <- et * 1000 * 86400 + return(et) + ### The function returns evapotranspiration (mm day-1) +}, ex=function() { + # Example from FAO (1998) + le <- 12 # latent heat that is used to vapourize water (MJ m-2 day-1) + le <- le / 86400 # MJ m-2 day-1 -> MJ m-2 sec-1 + le <- le * 1E6 # MJ m-2 sec-1 -> W m-2 + LE2ET(le=le) + + temp <- -30:40 + et <- LE2ET(le=le, temp=temp) + plot(temp, et) +}) diff --git a/LPJmLmdi/R/LPJ2NCDF.R b/LPJmLmdi/R/LPJ2NCDF.R new file mode 100644 index 0000000..460f8c5 --- /dev/null +++ b/LPJmLmdi/R/LPJ2NCDF.R @@ -0,0 +1,133 @@ +LPJ2NCDF <- structure(function( + ##title<< + ## Convert binary LPJmL model output files to NetCDF + ##description<< + ## The function converts a binary LPJmL output file to NetCDF + + file, + ### file name of LPJmL model output, e.g. "mgpp.bin" + + var.name, + ### variable name, e.g. "GPP" + + var.unit, + ### variable unit, e.g. "gC m-2 mon-1" + + start=1982, + ### first year for which the data should be converted to NetCDF + + end=2011, + ### last year for which the data should be converted to NetCDF + + sim.start.year=1901, + ### first year of the simulation + + var.longname = var.name, + ### long variable name, e.g. "gross primary production" + + run.name="LPJmL", + ### name of the LPJmL run (will be part of the file names) + + run.description="LPJmL run", + ### description of the LPJmL run + + provider="M. Forkel, matthias.forkel@geo.tuwien.ac.at", + ### name of the provider + + creator=provider, + ### name of the creator + + 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", + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. +) { + + # get filename and information for actual variable + info <- InfoLPJ(file) + files.nc <- NA + files.new <- NA + + # define function to read a band for several years for the variable v + .ReadWrite <- function(band) { + if (((end - start) + 1) < 5) { # read all at once if only few years + start.read <- start + end.read <- end + } else { + # read data sequentiell: create start years to read the data + start.read <- seq(start, end-4, 5) + end.read <- start.read + 4 + } + + # loop over datasets: read bin, convert to brick and write as NetCDF + for (y in 1:length(start.read)) { + # get start and end year to read + start.y <- start.read[y] + end.y <- end.read[y] + if (y == length(start.read)) end.y <- end + + # create time vector + if ((info$nbands == 12) & (file != "fpc.bin")) { + time <- seq(as.Date(paste(start.y, "-01-01", sep="")), as.Date(paste(end.y, "-12-01", sep="")), by="month") + } + if ((info$nbands == 1) | (file == "fpc.bin")) { + time <- seq(as.Date(paste(start.y, "-01-01", sep="")), as.Date(paste(end.y, "-01-01", sep="")), by="year") + } + + if (file == "mburnt_area.bin" | file == "mburntarea.bin") { + file <- list.files(pattern="mburnt") + if (length(file) == 0) return("NoFire") + } + + # read LPJ file + data.sp <- ReadLPJ(file, start=start.y, end=end.y, sim.start.year=sim.start.year) + + # subset bands to read + if (band == "ALL") { + which.bands <- 1:ncol(data.sp@data) + var.name0 <- var.name + } else { + nyear <- ncol(data.sp@data) / info$nbands + which.bands <- seq(band, by=info$nbands, length=nyear) + var.name0 <- paste(var.name, band, sep="_") + } + data.sp@data <- data.sp@data[,which.bands] + + # convert to RasterBrick + data.rb <- brick(as(data.sp, "SpatialPixelsDataFrame")) + + # write as NetCDF + nc <- WriteNCDF4(data=list(data.rb), var.name=var.name0, var.unit=var.unit, var.description=var.longname, time=time, data.name=run.name, file.description=run.description, + reference=reference, provider=provider, creator=creator, overwrite=TRUE) + files.nc[y] <- nc + } + + # combine files for time slices in one file + ofile <- unlist(strsplit(files.nc[1], ".", fixed=TRUE)) + ofile[6] <- end + ofile <- paste(ofile, collapse=".") + cdo <- paste("cdo mergetime", paste0(files.nc, collapse=" "), ofile) + system(cdo) + + # delete temporary files + file.remove(files.nc) + return(ofile) + } # end function .ReadWrite + + # read files + if (file == "fpc.bin") { # read for fpc.bin all bands individually + for (band in 1:info$nbands) files.new <- c(files.new, .ReadWrite(band)) + } else { # for other variables read all bands at once + files.new <- c(files.new, .ReadWrite("ALL")) + } + + # return file names + return(na.omit(files.new)) +}) + + diff --git a/LPJmLmdi/R/LPJfiles.R b/LPJmLmdi/R/LPJfiles.R new file mode 100644 index 0000000..8466956 --- /dev/null +++ b/LPJmLmdi/R/LPJfiles.R @@ -0,0 +1,73 @@ +LPJfiles <- structure(function( + ##title<< + ## Create an object of class 'LPJfiles' + ##description<< + ## The function creates a list of class 'LPJfiles' that defines all paths, input files, and configurations files for a LPJ run. + + path.lpj, + ### path where LPJ is installed + + path.tmp, + ### path for temporary outputs + + path.out, + ### path for results + + sim.start.year, + ### start year of the LPJ simulation as defined in lpjml.conf + + sim.end.year=NA, + ### last year of the LPJ simulation as defined in lpjml.conf + + lpj.conf, + ### template for LPJ configuration file (create a template from lpjml.conf) + + param.conf, + ### template for parameter configuration file (create a template from param.conf) + + pft.par, + ### template file for PFT-specific parameters (create a template from pft.par) + + param.par, + ### template file for global parameters (create a template from param.par) + + input.conf, + ### template file for input data (create a template from input.conf) + + 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")) + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. +) { + + # make list of class LPJfiles + lpjfiles <- list( + path.lpj = path.lpj, + path.tmp = path.tmp, + path.out = path.out, + sim.start.year = sim.start.year, + sim.end.year = sim.end.year, + lpj.conf = lpj.conf, + param.conf = param.conf, + pft.par = pft.par, + param.par = param.par, + input.conf = input.conf, + input = input) + class(lpjfiles) <- "LPJfiles" + + # check if file exists + files <- unlist(llply(lpjfiles, function(l) { + if (is.character(l)) return(l) + if (is.data.frame(l)) return(as.character(l$file)) + })) + bool <- file.exists(files) + if (any(!bool)) stop(paste(files[!bool], "does not exist.")) + + return(lpjfiles) +}) diff --git a/LPJmLmdi/R/LPJpar.R b/LPJmLmdi/R/LPJpar.R new file mode 100644 index 0000000..003560e --- /dev/null +++ b/LPJmLmdi/R/LPJpar.R @@ -0,0 +1,46 @@ +LPJpar <- structure(function( + ##title<< + ## Create an object of class 'LPJpar' + ##description<< + ## The function creates a data.frame of class 'LPJpar' that defines the parameters for LPJ runs. + + par.prior, + ### parameter vector (prior) + + par.lower, + ### lower boundaries for parameters + + par.upper, + ### upper boundaries for parameters + + par.pftspecif, + ### Which parameter is PFT specific (TRUE) or global (FALSE)? + + par.names, + ### parameter name + + is.int = rep(FALSE, length(par.prior)), + ### is parameter a integer? + + ... + ### further arguments for CheckLPJpar + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CheckLPJpar}} +) { + + names(par.prior) <- par.names + names(par.lower) <- par.names + names(par.upper) <- par.names + names(par.pftspecif) <- par.names + lpjpar <- data.frame(names=par.names, prior=par.prior, lower=par.lower, upper=par.upper, pftspecif=par.pftspecif, is.int=is.int) + class(lpjpar) <- "LPJpar" + lpjpar <- CheckLPJpar(lpjpar, ...) + return(lpjpar) + ### The function returns a list of class 'LPJpar' +}) \ No newline at end of file diff --git a/LPJmLmdi/R/LPJparList.R b/LPJmLmdi/R/LPJparList.R new file mode 100644 index 0000000..3b28318 --- /dev/null +++ b/LPJmLmdi/R/LPJparList.R @@ -0,0 +1,99 @@ +LPJparList <- structure(function( + ##title<< + ## Create a list of 'LPJpar' objects + ##description<< + ## The function creates a list of \code{\link{LPJpar}} objects that can be used to compare parameters from different optimization experiments + + ... + ### objects of class \code{\link{LPJpar}} + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{LPJpar}} +) { + + lpjpar <- list(...) + class(lpjpar) <- "LPJparList" + return(lpjpar) + ### The function returns a list of class 'LPJparList' +}) + + +plot.LPJparList <- structure(function( + ##title<< + ## Plots to compare LPJpar objects + ##description<< + ## The function takes a \code{\link{LPJparList}} object and creates a plot to compare optimized parameters + + x, + ### object of class 'LPJparList' + + par.name = NULL, + ### name(s) of the parameters that should be plotted + + ... + ### further arguments to \code{\link{plot.LPJpar}} + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{LPJpar}}, \code{\link{plot.LPJpar}} + +) { + + err <- "Select a valid parameter name." + if (is.null(par.name)) { + txt.l <- strsplit(as.character(x$names), "_") + txt.l <- llply(txt.l, function(txt) paste(txt[-length(txt)], collapse="_")) + par.name <- unique(unlist(txt.l)) + par.name <- par.name[par.name != ""] + } else { + if (any(is.na(par.name))) stop(err) + } + + # check lower/upper parameter ranges + + + # where to place the arrows and points relative to PFT? + nexp <- length(x) + xoff <- seq(-0.23, 0.23, length=nexp) + + # colors and names for the experiments + cols <- brewer.pal(max(3, nexp), "Set1") + + exp.name <- unlist(llply(x, function(lpjpar) lpjpar$exp.name)) + if (is.null(exp.name)) exp.name <- paste("Exp", 1:nexp) + + # loop over parameter names + for (i in 1:length(par.name)) { + noplot <- all(is.na(x[[1]]$best.median[grep(par.name[i], x[[1]]$names)])) + if (!noplot) { + ylim <- range(unlist(llply(x, function(lpjpar) { + g <- grep(par.name[i], lpjpar$names) + c(lpjpar$lower[g], lpjpar$upper[g]) + })), na.rm=TRUE) + if (ylim[1] == ylim[2]) ylim[2] <- ylim[2] + 0.1 + ylim[1] <- ylim[1] - (ylim[2] - ylim[1]) * 0.01 + ylim[2] <- ylim[2] + (ylim[2] - ylim[1]) * 0.01 + if (nexp > 3) ylim[2] <- ylim[2] + (ylim[2] - ylim[1]) * 0.12 + + plot(x[[1]], par.name[i], xoff=xoff[1], col=cols[1], ylim=ylim, ...) + if (nexp > 1) { + for (j in 2:length(x)) { + plot(x[[j]], par.name[i], add=TRUE, xoff=xoff[j], col=cols[j], ...) + } + ncol <- min(nexp, 2) + legend("top", exp.name, text.col=cols, bty="n", ncol=ncol) + } + } + } # end loop over par.name +}) + + diff --git a/LPJmLmdi/R/LPJpp.R b/LPJmLmdi/R/LPJpp.R new file mode 100644 index 0000000..96b282c --- /dev/null +++ b/LPJmLmdi/R/LPJpp.R @@ -0,0 +1,364 @@ +LPJpp <- structure(function( + ##title<< + ## Post-process LPJmL model output + ##description<< + ## The function converts binary LPJmL output files to NetCDF and calculates summary statistics. Please note, climate data operators (CDO) is required. + + path, + ### directory with LPJmL outputs in *.bin format + + start=1982, + ### first year for which the data should be converted to NetCDF + + end=2011, + ### last year for which the data should be converted to NetCDF + + sim.start.year=1901, + ### first year of the simulation + + run.name="LPJ", + ### name of the LPJmL run (will be part of the file names) + + run.description="LPJ run", + ### description of the LPJmL run + + provider="M. Forkel, matthias.forkel@geo.tuwien.ac.at", + ### name of the provider + + creator=provider, + ### name of the creator + + 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", + + lpj.df = NULL, + ### A data.frame with information about LPJmL outputs that should be post-processed. If NULL, a set of default outputs will post-processed. See details for the required structure of this data.frame. + + convert = TRUE, + ### Convert files in lpj.df to NetCDF? + + calc.nbp = FALSE, + ### Calculate net biome productivity? NBP = Rh + FireC + HarvestC - (NPP + Estab) + + calc.cbalance = FALSE, + ### Calculate global total C stocks, fluxes, balances, and turnover times? + + calc.tau = FALSE, + ### Calculate spatial fields of turnover times? + + calc.et = FALSE, + ### Calculate evapotranspiration? ET = transp + evap + interc + + calc.tree = FALSE, + ### Calculate total tree cover? See also the argument pft.istree + + pft.istree = 2:9, + ### Which bands in fpc.bin represents tree? + + mask = NA, + ### A mask in a NetCDF file in order to compute the C fluxes, stocks, balances and turnover times only for specific regions. + + ... + ### further arguments (currently not used) + + ##details<< + ## The data.frame 'lpj.df' should have the following columns + ## \itemize{ + ## \item{ \code{file} name of binary LPJmL output file (e.g. mgpp.bin)} + ## \item{ \code{var.name} short name of the variable (e.g. GPP)} + ## \item{ \code{var.unit} units of the variables in the input file (e.g. "gC m-2")} + ## \item{ \code{var.longname} (optional) long name of the variable (e.g. "Gross primary production"). If this column is not provided 'var.name' will be used instead.} + ## \item{ \code{var.agg.fun} (optional) name of a function to aggregate the varibale to annual values (e.g "sum", "mean", "min", "max", or NA (no aggregation)). If this column is not provided, aggregations will be not computed.} + ## \item{ \code{subset.start} (optional) This can be used to additionally subset the NetCDF files to a shorter time period. Set to a year (e.g. 2000) or NA.} + ## \item{ \code{subset.end} (optional) This can be used to additionally subset the NetCDF files to a shorter time period. Set to a year (e.g. 2001) or NA. } + ## \item{ \code{stat.annual} (optional) Set to TRUE to compute statistical values based on annual aggregated data. If this is not provided, statistical values will be not computed} + ## \item{ \code{stat.monthly} (optional) Set to TRUE to compute statistical values based on monthly data. If this is not provided, statistical values will be not computed} + ## } + + ##references<< No reference. +) { + + wd <- getwd() + + # default lpj.df + lpj0.df <- data.frame( + file=c("mgpp.bin", "mnpp.bin", "mrh.bin", "mfirec.bin", "vegc.bin", "soilc.bin", "litc.bin", "mfapar.bin", "malbedo.bin", "fpc.bin", "mswc1.bin", "mswc2.bin", "mevap.bin", "mtransp.bin", "minterc.bin", "flux_estab.bin", "flux_harvest.bin"), + var.name=c("GPP", "NPP", "Rh", "FireC", "VegC", "SoilC", "LitC", "FAPAR", "Albedo", "FPC", "SWC1", "SWC2", "Evap", "Transp", "Interc", "Estab", "Harvest"), + var.unit=c("gC m-2", "gC m-2", "gC m-2", "gC m-2", "gC m-2", "gC m-2", "gC m-2", "", "", "", "", "", "mm", "mm", "mm", "gC m-2", "gC m-2"), + var.longname=c("Gross Primary Production", "Net Primary Production", "Heterotrophic respiration", "Fire C emissions", "Biomass", "Soil organic C", "Litter C", "Fraction of absorbed photosynthetic active radition", "Albedo", "Foliar projective cover", "Soil water content in first layer", "Soil water content in second layer", "Soil evaporation", "Transpiration", "Interception", "Estab", "Harvest"), + var.agg.fun=c("sum", "sum", "sum", "sum", NA, NA, NA, "max", "min", NA, "mean", "mean", "sum", "sum", "sum", NA, NA) + ) + + # check or create lpj.df + if (!is.null(lpj.df)) { + bool <- "file" %in% colnames(lpj.df) & "var.name" %in% colnames(lpj.df) & "var.unit" %in% colnames(lpj.df) & "var.longname" %in% colnames(lpj.df) & "var.agg.fun" %in% colnames(lpj.df) + if (!bool) stop("Columns are missing or wrongly named in 'lpj.df'.'") + } else { + lpj.df <- lpj0.df + } + + # process Transp, Interc, and Evap to calculate ET + if (calc.et) { # required variables to compute ET + if (!("Transp" %in% lpj.df$var.name)) lpj.df <- rbind(lpj.df, lpj0.df[grep("Transp", lpj0.df$var.name), ]) + if (!("Interc" %in% lpj.df$var.name)) lpj.df <- rbind(lpj.df, lpj0.df[grep("Interc", lpj0.df$var.name), ]) + if (!("Evap" %in% lpj.df$var.name)) lpj.df <- rbind(lpj.df, lpj0.df[grep("Evap", lpj0.df$var.name), ]) + } + + + # add information to lpj.df + if (is.null(lpj.df$subset.start)) lpj.df$subset.start <- NA + if (is.null(lpj.df$subsetend)) lpj.df$subset.end <- NA + if (is.null(lpj.df$longname)) lpj.df$longname <- lpj.df$name + if (is.null(lpj.df$var.agg.fun)) lpj.df$var.agg.fun <- NA + if (is.null(lpj.df$stat.annual)) lpj.df$stat.annual <- FALSE + if (is.null(lpj.df$stat.monthly)) lpj.df$stat.monthly <- FALSE + + + #------------------------------------------------ + # convert for each variable *.bin files to NetCDF + #------------------------------------------------ + + message(paste("LPJ post-processing:", path)) + + # internal function to subset and to compute statistics on subset + .subset <- function(files.nc, subset.start, subset.end, var.agg.fun, stat.annual, stat.monthly) { + for (i in 1:length(files.nc)) { + info <- InfoNCDF(files.nc[i]) + g1 <- grep(subset.start, format(info$time, "%Y"))[1] + g2 <- grep(subset.end, format(info$time, "%Y")) + g2 <- g2[length(g2)] + ofile <- unlist(strsplit(files.nc[i], ".", fixed=TRUE)) + ofile[5] <- subset.start + ofile[6] <- subset.end + ofile <- paste(ofile, collapse=".") + file.remove(ofile) + cdo <- paste0("cdo seltimestep,", paste(g1:g2, collapse=","), " ", files.nc[i], " ", ofile) + system(cdo) + + # aggregation and statistics on subset + AggregateNCDF(ofile, fun.agg = var.agg.fun, stat.annual = stat.annual, stat.monthly=stat.monthly, msc.monthly=stat.monthly, path.out = path, stats="mean") + } # end for + } + + if (convert) { + # get the file names of LPJ outputs + setwd(path) + files.lpj <- list.files(pattern=".bin") + files.lpj <- files.lpj[-grep("grid", files.lpj)] + + # check if for lpj files meta-information exists: process only files with meta data + run.vars <- na.omit(match(files.lpj, lpj.df$file)) + run.vars <- sort(run.vars) + + # apply for all variables: convert to NetCDF + l <- llply(as.list(run.vars), .fun=function(v) { + message(paste("LPJ post-processing:", as.character(lpj.df$var.name[v]))) + + # convert to NetCDF + files.nc <- LPJ2NCDF(file=as.character(lpj.df$file[v]), var.name=as.character(lpj.df$var.name[v]), var.unit=as.character(lpj.df$var.unit[v]), var.longname=as.character(lpj.df$var.longname[v]), start=start, end=end, sim.start.year=sim.start.year, run.name=run.name, run.description=run.description, provider=provider, creator=creator, reference=reference) + + # aggregation and statistics + #if (!is.na(lpj.df$var.agg.fun[v]) | lpj.df$stat.annual[v] | lpj.df$stat.monthly[v]) { + for (i in 1:length(files.nc)) { + AggregateNCDF(files.nc[i], fun.agg = as.character(lpj.df$var.agg.fun[v]), + stat.annual = lpj.df$stat.annual[v], + stat.monthly = lpj.df$stat.monthly[v], + msc.monthly = lpj.df$stat.annual[v], + path.out = path, stats="mean") + } + #} + + # subset and statistics on subset? + subset.start <- max(c(start, as.character(lpj.df$subset.start[v])), na.rm=TRUE) + subset.end <- min(c(end, as.character(lpj.df$subset.end[v])), na.rm=TRUE) + if (subset.start > start | subset.end < end) { + .subset(files.nc, subset.start, subset.end, var.agg.fun=lpj.df$var.agg.fun[v], stat.annual=lpj.df$stat.annual[v], stat.monthly=lpj.df$stat.monthly[v]) + } # end if subset + + return(na.omit(files.nc)) + }, .parallel=FALSE) + } # end if convert + + + #--------------------------------------------------- + # global total C fluxes, stocks, balances and stocks + #--------------------------------------------------- + + if (calc.cbalance) { + message("LPJ post-processing: calculate global C balance, stocks and fluxes") + + # function to get NetCDF files of a specific variabe + .getFile <- function(var) { + files <- c(list.files(pattern=".annual.sum.nc", recursive=TRUE), list.files(pattern=".365days.nc", recursive=TRUE)) + files <- files[grep(var, files)] + files <- files[grep(paste(start, end, sep="."), files)] + if (length(files) == 0) files <- NA + return(files) + } + + # calculate global C balance + setwd(path) + cbal <- Cbalance(gpp=.getFile("GPP"), npp=.getFile("NPP"), rh=.getFile("Rh"), firec=.getFile("FireC"), estab=.getFile("Estab"), harvest=.getFile("Harvest"), vegc=.getFile("VegC"), litc=.getFile("LitC"), soilc=.getFile("SoilC")) + + setwd(path) + write.table(cbal, paste0(run.name, ".Cbalance.global.", start, ".", end, ".table.txt")) + + pdf(paste0(run.name, ".Cbalance.global.", start, ".", end, ".ts.pdf"), width=7, height=7) + plot(cbal) + dev.off() + + # calculate C balance for masked regions + if (!is.na(mask)) { + cbal <- Cbalance(gpp=.getFile("GPP"), npp=.getFile("NPP"), rh=.getFile("Rh"), firec=.getFile("FireC"), estab=.getFile("Estab"), harvest=.getFile("Harvest"), vegc=.getFile("VegC"), litc=.getFile("LitC"), soilc=.getFile("SoilC"), mask=mask) + + setwd(path) + write.table(cbal, paste0(run.name, ".Cbalance.masked.", start, ".", end, ".table.txt")) + + pdf(paste0(run.name, ".Cbalance.masked.", start, ".", end, ".ts.pdf"), width=7, height=7) + plot(cbal) + dev.off() + + } + } + + + #------------------------ + # calculate NetCDF of NBP + #------------------------ + + if (calc.nbp) { + message("LPJ post-processing: calculate NBP") + LPJppNBP(path, start=start, end=end, sim.start.year=sim.start.year) + setwd(path) + file.nbp <- list.files(pattern="NBP") + AggregateNCDF(file.nbp, fun.agg = "sum", stat.annual=TRUE, stat.monthly=FALSE, msc.monthly=TRUE, path.out = path, stats="mean") + } + + + #----------------------------- + # calculate evapotranspiration = Transp + Evap + Interc + #----------------------------- + + if (calc.et) { + message("LPJ post-processing: calculate ET") + # calc ET + setwd(path) + file.transp <- list.files(pattern="Transp") + file.transp <- file.transp[grep(paste(start, end, "30days.nc", sep="."), file.transp)] + file.evap <- list.files(pattern="Evap") + file.evap <- file.evap[grep(paste(start, end, "30days.nc", sep="."), file.evap)] + file.interc <- list.files(pattern="Interc") + file.interc <- file.interc[grep(paste(start, end, "30days.nc", sep="."), file.interc)] + file.et <- gsub("Transp", "ET", file.transp) + cdo <- paste("cdo enssum", paste(c(file.transp, file.evap, file.interc), collapse=" "), file.et) + system(cdo) + + # compute statistics + setwd(path) + v <- grep("Transp", lpj.df$var.name) + if (!is.na(lpj.df$var.agg.fun[v]) | lpj.df$stat.annual[v] | lpj.df$stat.monthly[v]) { + AggregateNCDF(file.et, fun.agg = as.character(lpj.df$var.agg.fun[v]), + stat.annual = lpj.df$stat.annual[v], + stat.monthly = lpj.df$stat.monthly[v], + msc.monthly = lpj.df$stat.monthly[v], + path.out = path, stats="mean") + } + + # subset and statistics on subset? + subset.start <- max(c(start, lpj.df$subset.start[v]), na.rm=TRUE) + subset.end <- min(c(end, lpj.df$subset.end[v]), na.rm=TRUE) + if (subset.start > start | subset.end < end) { + .subset(file.et, subset.start, subset.end, var.agg.fun=lpj.df$var.agg.fun[v], stat.annual=lpj.df$stat.annual[v], stat.monthly=lpj.df$stat.monthly[v]) + } + } + + + #------------------------- + # calculate turnover times + #------------------------- + + if (calc.tau) { + message("LPJ post-processing: turnover times") + + # function to get NetCDF files of a specific variabe + .getFile <- function(var) { + files <- list.files(pattern=".mean.nc", recursive=TRUE) + files <- files[grep(var, files)] + if (length(files) == 0) files <- NA + return(files) + } + + # add soil and litter C + file.soilc <- .getFile("SoilC") + file.litc <- .getFile("LitC") + cdo <- paste("cdo add", file.soc, file.litc, gsub("SoilC", "SoilLitC", file.soilc)) + system(cdo) + + file.vegc <- .getFile("VegC") + file.npp <- .getFile("NPP") + file.gpp <- .getFile("GPP") + file.soc <- .getFile("SoilLitC") + + # combinations of fluxes and stocks + combn.m <- rbind( + expand.grid(file.vegc, file.gpp), + expand.grid(file.vegc, file.npp), + expand.grid(file.soc, file.gpp) + ) + + # calculate tau for each combination + for (i in 1:nrow(combn.m)) { + stock.r <- raster(as.character(combn.m[i,1])) + flux.r <- raster(as.character(combn.m[i,2])) + flux.r[flux.r < 5] <- NA # ignore small fluxes + tau.r <- stock.r / flux.r + istock <- InfoNCDF(as.character(combn.m[i,1])) + iflux <- InfoNCDF(as.character(combn.m[i,2])) + var.name <- paste("Tau_", istock$var$name[1], format(istock$time, "%Y"), "_", iflux$var$name[1], format(iflux$time, "%Y"), sep="") + WriteNCDF4(list(tau.r), var.name=var.name, var.unit="years", time=istock$time, data.name=run.name, overwrite=TRUE) + } # end if for + } # end if calc tau + + + #--------------------- + # calculate tree cover + #--------------------- + + if (calc.tree) { + message("LPJ post-processing: calculate tree cover") + setwd(path) + # get all FPC files for tree PFTs + files.fpc <- list.files(pattern="FPC") + files.fpc <- files.fpc[grepl(paste(start, end, "365days.nc", sep="."), files.fpc)] + file.lu <- files.fpc[grep("FPC_1.", files.fpc, fixed=TRUE)[1]] + + # select only tree PFTs + b <- NULL + for (i in 1:length(pft.istree)) b <- c(b, grep(paste("FPC_", pft.istree[i], sep=""), files.fpc)) + files.fpc <- files.fpc[b] + files.fpc <- unique(files.fpc) + + # total tree FPC + file.fpctree <- gsub("FPC_1", "FPCTree", file.lu) + cdo <- paste("cdo enssum", paste(files.fpc, collapse=" "), file.fpctree) + system(cdo) + file.fpctree2 <- gsub("FPC_1", "FPCTree2", file.lu) + cdo <- paste("cdo setname,Tree", file.fpctree, file.fpctree2) + system(cdo) + + # correct tree cover by landuse fraction + file.tree <- gsub("FPC_1", "Tree", file.lu) + cdo <- paste("cdo mul", file.fpctree2, file.lu, file.tree) + system(cdo) + file.remove(c(file.fpctree, file.fpctree2)) + + # compute statistics + setwd(path) + v <- grep("FPC", lpj.df$var.name) + paste("cdo setname,Tree", file.tree) + + } + + setwd(wd) +}) + + diff --git a/LPJmLmdi/R/LPJppNBP.R b/LPJmLmdi/R/LPJppNBP.R new file mode 100644 index 0000000..98d9639 --- /dev/null +++ b/LPJmLmdi/R/LPJppNBP.R @@ -0,0 +1,99 @@ +LPJppNBP <- structure(function( + ##title<< + ## Post-process LPJmL model output: calculate NEE + ##description<< + ## The function calculates NEE from LPJmL model output + + path, + ### directory with LPJmL outputs in *.bin format + + start=1982, + ### first year for which the data should be converted to NetCDF + + end=2011, + ### last year for which the data should be converted to NetCDF + + sim.start.year=1901, + ### first year of the simulation + + ... + ### further arguments (currently not used) + + ##details<< + ## + + ##references<< No reference. +) { + + # input files + file.rh <- "mrh.bin" + file.fire <- "mfirec.bin" + file.npp <- "mnpp.bin" + file.estab <- "flux_estab.bin" + file.harvest <- "flux_harvest.bin" + file.gpp <- "mgpp.bin" + + + # read data + #---------- + + time <- seq(as.Date(paste(start, "-01-01", sep="")), as.Date(paste(end, "-12-01", sep="")), by="month") + + # read NPP, Rh and establishment flux + setwd(path) + rh.sp <- ReadLPJ(file.rh, sim.start.year=sim.start.year, start=start, end=end) + npp.sp <- ReadLPJ(file.npp, sim.start.year=sim.start.year, start=start, end=end) + gpp.sp <- ReadLPJ(file.gpp, sim.start.year=sim.start.year, start=start, end=end) + estab.sp <- ReadLPJ(file.estab, sim.start.year=sim.start.year, start=start, end=end) + + # read or creaty empty fire flux in case of simulation without fire + if (file.exists(file.fire)) { + fire.sp <- ReadLPJ(file.fire, sim.start.year=sim.start.year, start=start, end=end) + } else { + fire.sp <- npp.sp + fire.sp@data <- as.data.frame(matrix(0, ncol=ncol(fire.sp@data), nrow=nrow(fire.sp@data))) + } + + # read harvest flux or create empty harvest flux in case of simulation without land use + if (file.exists(file.harvest)) { + harvest.sp <- ReadLPJ(file.harvest, sim.start.year=sim.start.year, start=start, end=end) + } else { + harvest.sp <- estab.sp + harvest.sp@data <- as.data.frame(matrix(0, ncol=ncol(harvest.sp@data), nrow=nrow(harvest.sp@data))) + } + + + # interpolate estab and harvest to monthly data + #---------------------------------------------- + + InterpolateMonthly <- function(sp) { + m <- sp@data + mnew <- matrix(NA, ncol=1, nrow=nrow(m)) + for (i in 1:ncol(m)) { + mnew <- cbind(mnew, matrix(rep(m[,i], each=12), ncol=12, nrow=nrow(m), byrow=TRUE)) + } + mnew <- mnew[, -1] + mnew <- mnew / 12 # distribute among months + sp2 <- sp + sp2@data <- as.data.frame(mnew) + colnames(sp2@data) <- colnames(npp.sp@data) + return(sp2) + } + + estab.m.sp <- InterpolateMonthly(estab.sp) + harvest.m.sp <- InterpolateMonthly(harvest.sp) + + + # calculate NBP and NEE + #---------------------- + + # calculate NBP + nbp.sp <- rh.sp + nbp.sp@data <- rh.sp@data + fire.sp@data + harvest.m.sp@data - (npp.sp@data + estab.m.sp@data) + nbp.rb <- brick(as(nbp.sp, "SpatialPixelsDataFrame")) + WriteNCDF4(list(nbp.rb), "NBP", "gC m-2", "Net biome productivity", time=time, data.name="LPJmL", overwrite=TRUE) + + +}) + + diff --git a/LPJmLmdi/R/LWin2LWnet.R b/LPJmLmdi/R/LWin2LWnet.R new file mode 100644 index 0000000..c9bd145 --- /dev/null +++ b/LPJmLmdi/R/LWin2LWnet.R @@ -0,0 +1,36 @@ +LWin2LWnet <- structure(function( + ##title<< + ## Compute long-wave net radiation from long-wave incoming radiation and temperature. + + lwin, + ### long-wave incoming radiation (Wm-2) + + temp, + ### temperature (degC, conversion to K is done within the function) + + emissivity = 0.97 + ### 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). + + ##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). + + ##references<< Campbell GS, Norman JM (1998) An Introduction to Environmental Biophysics. Springer New York, New York, NY. + + ##seealso<< + ## \code{\link{WriteLPJinput}} + +) { + sigma <- 5.67037 * 10^(-8) # Stefan-Boltzmann constant + temp <- temp + 273.15 # degC -> K + lwout <- sigma * emissivity * (temp^4) + lwnet <- lwin - lwout + return(lwnet) + ### The function returns long-wave net radiation (Wm-2) +}, ex=function() { + lwin <- 200:380 # long-wave incoming radiation (Wm-2) + temp <- 0.14 * lwin - 32 + rnorm(length(lwin), 0, 5) # temperature (degC) + plot(lwin, temp) + lwnet <- LWin2LWnet(lwin, temp) + plot(temp, lwnet) + plot(lwin, lwnet) +}) \ No newline at end of file diff --git a/LPJmLmdi/R/LegendBar.R b/LPJmLmdi/R/LegendBar.R new file mode 100644 index 0000000..dbeb887 --- /dev/null +++ b/LPJmLmdi/R/LegendBar.R @@ -0,0 +1,80 @@ +LegendBar <- structure(function( + ##title<< + ## Add a colour legend bar to a plot + ##description<< + ## Adds a colour legend bar to a plot + + x, + ### x coordinates for the legend bar + + y, + ### y coordinates for the legend bar + + brks = seq(0, 1, by=0.2), + ### class breaks for the legend bar + + cols = NULL, + ### colours for each class. If NULL grey scales are used. + + brks.txt = NULL, + ### text labels for the class breaks. If NULL, 'brks' are used + + title = "", + ### title for the legend bar + + srt = NULL, + ### rotation of breaks text labels + + col.txt = "black", + ### colour for text labels + + cex.txt = 1, + ### size of the text labels + + ... + ### arguments (unused) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CRSll}} +) { + xy <- cbind(x, y) + + # breaks + if (is.null(cols)) cols <- BreakColours(brks) + if (is.null(brks.txt)) { + brks.txt <- as.character(brks) + slen <- sapply(strsplit(brks.txt, ""), FUN=length) + if (length(brks) > 6 | any(slen > 3)) { + brks.txt[seq(2, length(brks)-1, by=2)] <- "" + brks.txt[brks == 0] <- "0" + } + } else { + brks.txt <- as.character(brks.txt) + } + slen <- sapply(strsplit(brks.txt, ""), FUN=length) + if (any(slen > 3) & length(brks.txt) > 8 & is.null(srt)) srt <- 20 + if (is.null(srt)) srt <- 0 + + # text and colour bar + text(seq(xy[1,1], xy[2,1], length=length(brks)), min(xy[,2]), labels=brks.txt, pos=1, srt=srt, col=col.txt, cex=cex.txt) + text(mean(xy[,1]), max(xy[,2]), labels=title, pos=3, col=col.txt, cex=cex.txt) + color.legend(xy[1,1], xy[1,2], xy[2,1], xy[2,2], legend="", rect.col=cols, align="rb") + par(xpd=FALSE) +}, ex=function() { + + plot.new() + LegendBar(x=c(0.1, 0.9), y=c(0.4, 0.6)) + LegendBar(x=c(0.1, 0.5), y=c(0.7, 0.8)) + + brks <- seq(-1, 1, 0.2) + cols <- BreakColors(brks) + LegendBar(x=c(0.6, 1), y=c(0.7, 0.8), brks=brks, cols=cols, title="My title") + + LegendBar(x=c(0.2, 0.8), y=c(0.1, 0.2), brks=brks, cols=cols, col.txt="purple", title="purple", srt=90) + +}) diff --git a/LPJmLmdi/R/MeanW.R b/LPJmLmdi/R/MeanW.R new file mode 100644 index 0000000..0210fc9 --- /dev/null +++ b/LPJmLmdi/R/MeanW.R @@ -0,0 +1,125 @@ +MeanW <- structure(function( + ##title<< + ## Weighted mean + ##description<< + ## Compute the weighted mean. + + x, + ### a vector + + w = rep(1, length(x)) + ### vector of weights + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ObjFct}} +) { + sum((w * x), na.rm=TRUE) / sum(w, na.rm=TRUE) +}, ex=function() { + +x <- 1:5 +mean(x) +MeanW(x, w=c(1, 1, 1, 2, 2)) +}) + + +VarW <- structure(function( + ##title<< + ## Weighted variance + ##description<< + ## Compute the weighted variance. + + x, + ### a vector + + w = rep(1, length(x)) + ### vector of weights + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ObjFct}} +) { + xm <- MeanW(x, w) + sum((x - xm)^2 * w, na.rm=TRUE) * (1 / (sum(w, na.rm=TRUE) - 1)) +}, ex=function() { + +x <- 1:5 +var(x) +VarW(x, w=c(1, 1, 1, 2, 2)) +}) + + +SdW <- structure(function( + ##title<< + ## Weighted standard deviation + ##description<< + ## Compute the standard deviation. + + x, + ### a vector + + w = rep(1, length(x)) + ### vector of weights + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ObjFct}} +) { + sqrt(VarW(x, w)) +}, ex=function() { + +x <- 1:5 +sd(x) +SdW(x, w=c(1, 1, 1, 2, 2)) +}) + + +CorW <- structure(function( + ##title<< + ## Weighted correlation + ##description<< + ## Compute the correlation. + + x, + ### a vector of x values + + y, + ### a vector of y values + + w = rep(1, length(x)) + ### vector of weights + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ObjFct}} +) { + d <- na.omit(cbind(as.vector(x), as.vector(y), as.vector(w))) + if (nrow(d) == 0) return(as.numeric(NA)) + x <- cbind(d[,1], d[,2]) + wt <- d[,3] + if (nrow(x) == 0) return(NA) + cov.wt(x, wt, cor=TRUE)$cor[2,1] +}, ex=function() { + +x <- 1:5 +y <- x * -1 + rnorm(5) +cor(x, y) +CorW(x, y, w=c(1, 1, 1, 2, 2)) +}) + diff --git a/LPJmLmdi/R/OptimizeLPJgenoud.R b/LPJmLmdi/R/OptimizeLPJgenoud.R new file mode 100644 index 0000000..8ab4e63 --- /dev/null +++ b/LPJmLmdi/R/OptimizeLPJgenoud.R @@ -0,0 +1,757 @@ +OptimizeLPJgenoud <- structure(function( + ##title<< + ## Optimize LPJ using the GENOUD optimizer (genetic optimization using derivatives) + ##description<< + ## This function performs an optimization of LPJmL model parameters for the specified grid cells unsing the GENOUD genetic optimization algorithm. + + xy, + ### matrix of grid cell coordinates to run LPJ + + name, + ### name of the experiment (basic file name for all outputs) + + lpjpar, + ### data.frame of class \code{\link{LPJpar}} that define all LPJ parameter values, ranges, and names + + par.optim, + ### names of the parameters that should be optimized + + lpjfiles, + ### list of class \code{\link{LPJfiles}} that define all LPJ directories, input files, configuration template files + + lpjcmd = "srun ./bin/lpjml", + ### How you usually run the LPJ model at the console: 'srun ./bin/lpjml' or './bin/lpjml' + + copy.input = TRUE, + ### Should LPJ input data be copied to the directory for temporary output? This might speed up computations if the directory is on the same machine where the program runs. + + integrationdata, + ### list of integration data and information + + plot=TRUE, + ### plot diagnostic graphics of optimization results? + + pop.size=1000, + ### population size, see \code{\link{genoud}} + + max.generations=20, + ### max number of generations, see \code{\link{genoud}} + + wait.generations=19, + ### How many generations should genoud wait before returning an optimum, see \code{\link{genoud}} + + BFGSburnin=18, + ### The number of generations before the L-BFGS-B algorithm is first used, see \code{\link{genoud}} + + calc.jacob=FALSE, + ### Should the Hessian and Jacobian matrix be computed (yes = TRUE, no = FALSE)? + + restart=0, + ### Where to re-start the optimization? 0 = start at the beginning, 1 = continue with existing genoud optimization, 2 = start after genoud and post-process results. + + path.rescue=NULL, + ### directory where the resuce files from each iteration of a previous optimization are saved. This is needed if restart > 0. + + restart.jacob=FALSE, + ### Should the Hessian and Jacobian matrix be recomputed if restart > 0 (yes = TRUE, no = FALSE)? Works only if calc.jacob is TRUE. + + nodes=1, + ### use parallel computing? How many nodes to use? + + maxAutoRestart=5, + ### maximum number of automatic restarts of the optimization if an error occurs within genoud() + + runonly=FALSE, + ### run only the model with prior parameters set but don't perform optimization. Produces only results of prior model run. + + warnings = TRUE, + ### print all LPJmL warning messages during optimization? + + new.spinup4post=TRUE, + ### What spinup conditions should be used for the posterior ('posterior-best' and 'posterior-median') model runs? If TRUE, a new spinup is computed based on the optimized parameters. If FALSE, the posterior model runs are started from the spinup conditions of the prior model run (like the runs during optimization). + + CostMDS = CostMDS.SSE + ### cost function for multiple data streams to calculate total cost, cost per data stream, and eventually cost per grid cell. See \code{\link{CostMDS.SSE}} (default) or \code{\link{CostMDS.KGE}} + +) { + + + #-------------------------------- + # prepare optimization experiment + #-------------------------------- + + # select parameters to be optimized + lpjpar <- CheckLPJpar(lpjpar, correct=FALSE) + par.optim <- unique(par.optim) + par.optim <- sort(par.optim) # order alphabetically + which.par.opt <- match(par.optim, lpjpar$names) + bool <- is.na(which.par.opt) + if (any(bool)) stop(paste0("Parameter '", par.optim[bool], "' does not exist in lpjpar. Check 'par.optim'.")) + + # get LPJ cell number from coordinates + xy <- cbind(as.numeric(xy[,1]), as.numeric(xy[,2])) + grid.l <- GridProperties(lpjfiles) + lpjfiles$grid <- grid.l + cell <- extract(grid.l$grid, xy) - 1 + ncell <- length(cell) + cell.startend <- c(cell[1], cell[ncell]) + + # directory for optimization results + # path.optresult <- paste(lpjfiles$path.out, "/", name, "_", cell.startend[1], "_", cell.startend[2], sep="") + path.optresult <- paste(lpjfiles$path.out, "/", name, sep="") + path.optresult <- gsub("//", "/", path.optresult) + dir.create(path.optresult) + + # file for optimization results + # file.optresult <- paste(path.optresult, "/", name, "_", cell.startend[1], "_", cell.startend[2], ".pro", sep="") + file.optresult <- paste(path.optresult, "/", name, ".pro", sep="") + file.optresult <- gsub("//", "/", file.optresult) + file.optsetup <- gsub(".pro", "_optsetup.RData", file.optresult, fixed=TRUE) + + # prepare restart + if (restart > 0 & !is.null(path.rescue) & !runonly) { + # check if file opt result exists if optimization should be restarted + if (!file.exists(path.rescue)) { + restart <- 0 + message(paste("OptimizeLPJgenoud: restart changed to 0 because", file.optresult, "does not exist.", Sys.time())) + } else { + # prepare rescue files + message(paste("OptimizeLPJgenoud: Read rescue files from previous optimization for restart.", Sys.time())) + file.restart <- CreateRestartFromRescue(path.rescue, pop.size)$file + system(paste("cp", file.restart, file.optresult)) + } + } + + # save optimization setup file + setwd(lpjfiles$path.out) + save(xy, name, pop.size, max.generations, wait.generations, BFGSburnin, cell, file.optresult, lpjpar, par.optim, lpjfiles, integrationdata, which.par.opt, CostMDS, file=file.optsetup) + file.copy(file.optsetup, gsub(".RData", "_backup.RData", file.optsetup, fixed=TRUE)) + + + # print information about optimization experiment + if (runonly) { + message(paste( + " ", + "------------------------------------------------------------------", + "-- OptimizeLPJgenoud ---------------------------------------------", + paste("-- start at ", Sys.time()), + "-- Run LPJmL with prior parameters", + paste("name :", name), + paste("number grid cells :", nrow(xy)), + paste("first grid cell : ", paste(xy[1,], collapse=" E, "), " N", sep=""), + paste("last grid cell : ", paste(xy[nrow(xy),], collapse=" E, "), " N", sep=""), + paste("opt. setup file :", file.optsetup), + paste("population file :", file.optresult)[!runonly], + "------------------------------------------------------------------", + "\n", + sep="\n")) + + } else { + message(paste( + " ", + "------------------------------------------------------------------", + "-- OptimizeLPJgenoud ---------------------------------------------", + paste("-- start at ", Sys.time()), + "-- Information about optimization experiment", + paste("name :", name), + paste("number grid cells :", nrow(xy)), + paste("first grid cell : ", paste(xy[1,], collapse=" E, "), " N", sep=""), + paste("last grid cell : ", paste(xy[nrow(xy),], collapse=" E, "), " N", sep=""), + paste("pop.size :", pop.size)[restart<2], + paste("max.generations :", max.generations)[restart<2], + paste("wait.generations :", wait.generations)[restart<2], + paste("BFGSburnin :", BFGSburnin)[restart<2], + paste("restart :", c("start new optimization", "continue with previous GENOUD optimization", "continue after GENOUD")[restart+1]), + paste("opt. setup file :", file.optsetup), + paste("population file :", file.optresult), + paste("parameters :", paste(lpjpar$names[which.par.opt], collapse=", ")), + "------------------------------------------------------------------", + "\n", + sep="\n")) + } + + + #----------------- + # check parameters + #----------------- + + # prior and best guess initial parameters + npar <- length(lpjpar$prior) + + # create scaled parameters + dlpjpar <- LPJpar(par.prior=rep(1, npar), par.lower=(lpjpar$lower / lpjpar$prior), par.upper=(lpjpar$upper / lpjpar$prior), par.pftspecif=lpjpar$pftspecif, par.names=lpjpar$names, correct=TRUE) + + # write parameter files with prior parameters + setwd(path.optresult) + WriteLPJpar(lpjpar, file=gsub(".pro", "", file.optresult, fixed=TRUE), pft.par=lpjfiles$pft.par, param.par=lpjfiles$param.par) + + + #---------------------- + # check integrationdata + #---------------------- + + # subset integrationdata for time period of model run + integrationdata <- llply(integrationdata, function(ds) { + years.ds <- format(ds$data.time, "%Y") + + # cut data if it starts before first year of model run + if (!is.na(lpjfiles$sim.start.year)) { + bool <- years.ds < lpjfiles$sim.start.year + if (any(bool)) { + ds$data.time <- ds$data.time[!bool] + ds$data.val <- matrix(ds$data.val[!bool, ], ncol=ncell, nrow=length(ds$data.time)) + ds$data.unc <- matrix(ds$data.unc[!bool, ], ncol=ncell, nrow=length(ds$data.time)) + } + } + + # cut data if it ends after last year of model run + if (!is.na(lpjfiles$sim.end.year)) { + bool <- years.ds > lpjfiles$sim.end.year + if (any(bool)) { + ds$data.time <- ds$data.time[!bool] + ds$data.val <- matrix(ds$data.val[!bool, ], ncol=ncell, nrow=length(ds$data.time)) + ds$data.unc <- matrix(ds$data.unc[!bool, ], ncol=ncell, nrow=length(ds$data.time)) + } + } + return(ds) + }) + + + #--------------------------------------------------------------- + # define directory for temporary outputs and copy LPJ input data + #--------------------------------------------------------------- + + # path for temporary output + path.tmp.out.act <- tempfile(system("whoami", intern=TRUE), tmpdir=lpjfiles$path.tmp) + path.tmp.out.act <- gsub("//", "/", path.tmp.out.act) + dir.create(path.tmp.out.act) + # file.optresult.tmp <- paste(path.tmp.out.act, "/", name, "_", cell.startend[1], "_", cell.startend[2], ".pro", sep="") + file.optresult.tmp <- paste(path.tmp.out.act, "/", name, ".pro", sep="") + + # path for rescue files in case of optimization + lpjfiles$path.rescue <- gsub(".pro", "_rescue", file.optresult, fixed=TRUE) + dir.create(lpjfiles$path.rescue) + + # copy input files to temporary directory + if (copy.input) { + files <- as.character(unlist(lpjfiles$input$file)) + files.tmp <- llply(strsplit(files, "/"), function(x) paste(path.tmp.out.act, x[length(x)], sep="/") ) + bool <- file.copy(files, unlist(files.tmp)) + + # modify lpjfiles list + lpjfiles$input$file <- files.tmp + } + + + #--------------------------- + # spinup model and run prior + #--------------------------- + + # path for results of actual grid cell + # path <- paste(path.tmp.out.act, "/", name, "_OPTFILE_", cell.startend[1], "_", cell.startend[2], sep="") + path <- paste(path.tmp.out.act, "/", name, "_OPTFILE", sep="") + path <- gsub("//", "/", path) + dir.create(path) + if (!file.exists(path)) stop(paste("OptimizeLPJgenoud: Cannot create and access temporary working directory ", path.tmp.out.act, ". Check permissions.", sep="")) + + # run spinup for new grid cells and return result of prior model + message(paste("OptimizeLPJgenoud: Starting LPJ spinup.", Sys.time())) + if (plot) pdf(gsub(".pro", "_prior.pdf", file.optresult, fixed=TRUE), width=9.75, height=10) + result.prior.lpj <- RunLPJ(dpar=dlpjpar$prior, lpjpar=lpjpar, which.par.opt=1:npar, lpjfiles=lpjfiles, path=path, integrationdata=integrationdata, xy, name=name, lpjcmd=lpjcmd, newcell=TRUE, plot=plot, getresult=TRUE, warnings=warnings, clean=1, clean.path=TRUE, CostMDS=CostMDS) + if (plot) dummy <- plot(result.prior.lpj, what="annual") + if (plot) dummy <- plot(result.prior.lpj, what="monthly") + if (plot) dummy <- plot(result.prior.lpj, what="grid") + if (plot) dev.off() + cost.prior <- result.prior.lpj$cost + + # save outputs from prior model run + setwd(lpjfiles$path.out) + save(result.prior.lpj, file=gsub(".pro", "_prior.RData", file.optresult, fixed=TRUE)) + + # number of observations + nobs.ds <- llply(integrationdata, function(ds) sum(!is.na(ds$data.val))) + nobs.ds <- nobs.ds[unlist(llply(integrationdata, function(ds) ds$cost))] + nobs <- sum(unlist(nobs.ds)) + + # initialize empty result objects + hessian <- matrix(NA, length(which.par.opt), length(which.par.opt)) + jacobian <- matrix(NA, 1, length(which.par.opt)) + + if (!runonly) { # do optimization and uncertainty calculation only if runonly == FALSE + + #--------------------------------------------- + # prepare cluster nodes for parallel computing + #--------------------------------------------- + + # check if parallel computing should be done based on required nodes + parallel <- TRUE + if (nodes <= 1 | restart == 2) parallel <- FALSE + + # export all objects to cluster nodes + if (parallel) { + balance <- FALSE + message(paste("OptimizeLPJgenoud: Start preparing cluster nodes for parallel computing.", Sys.time())) + require(parallel) + # require(doSnow) + + # check memory use + setwd(lpjfiles$path.out) + use.df <- CheckMemoryUsage() + message(paste(" Actual memory usage per node:", signif(sum(use.df$GB), 4), "GB, see file 'memory_usage.txt' for details.")) + rm(use.df) + + # initialize cluster + cluster <- makeCluster(nodes) + + # load packages on all nodes + clusterEvalQ(cluster, { + library(raster) + library(ncdf) + library(plyr) + NULL + }) + + # export required objects to cluster nodes + clusterExport(cluster, ls(envir=.GlobalEnv), envir=.GlobalEnv) + clusterExport(cluster, ls(), envir=environment()) + + message(paste("OptimizeLPJgenoud: Finished preparing cluster nodes for parallel computing.", Sys.time())) + + } else { + cluster <- FALSE + balance <- FALSE + } + + + #----------------------------- + # perform genetic optimization + #----------------------------- + + # start new genoud optimization or restart? Create starting values + niter.todo <- wait.generations * pop.size # number of iterations to to + nkeep <- niter.todo * 0.01 # keep best 10% of result files + if (restart == 0) { + share.type <- 0 + starting.values <- dlpjpar$prior[which.par.opt] # prior as only starting value + niter.init <- 0 # how many iterations are already done? + } else if (restart == 1) { + share.type <- 1 + setwd(lpjfiles$path.out) + starting.values <- StartingValues(file.optresult, pop.size) # prior, best, other best + niter.init <- starting.values$niter # how many iterations are already done? + starting.values <- starting.values$start + } + + + # do genoud optimization - and try to automatically restart if an error occurs + #----------------------------------------------------------------------------- + + if (restart < 2) { # only if restart is 0 or 1 + message(paste("OptimizeLPJgenoud: Start GENOUD optimization.", Sys.time())) + + # try to restart optimization in case of an error, + restart.optim <- TRUE + file.pro <- file.optresult + i <- 1 + while (restart.optim & i <= maxAutoRestart) { + i <- i + 1 + + + # genetic optimization + #--------------------- + + opt.genetic <- try(genoud(fn=RunLPJ, nvars=length(which.par.opt), pop.size=pop.size, max.generations=max.generations, wait.generations=wait.generations, hard.generation.limit=TRUE, Domains=cbind(dlpjpar$lower[which.par.opt], dlpjpar$upper[which.par.opt]), boundary.enforcement=2, starting.values=starting.values, gradient.check=FALSE, BFGS=TRUE, BFGSburnin=BFGSburnin, optim.method="L-BFGS-B", hessian=FALSE, share.type=share.type, project.path=file.pro, control=list(reltol=1e-7, maxit=100), P9=0, cluster=cluster, lpjpar=lpjpar, which.par.opt=which.par.opt, lpjfiles=lpjfiles, path=path, integrationdata=integrationdata, xy=xy, name=name, lpjcmd=lpjcmd, newcell=FALSE, plot=FALSE, clean.path=TRUE, warnings=warnings, CostMDS=CostMDS, nkeep=nkeep)) + + + # combine all restart and pro files in one pro file + #-------------------------------------------------- + + # create restart file from rescue files + Sys.sleep(5) + restart.l <- CreateRestartFromRescue(as.character(lpjfiles$path.rescue), pop.size) + system(paste("cp", restart.l$file, file.optresult)) + + + # automatically restart optimization if an error occured + #------------------------------------------------------- + + if (class(opt.genetic) == "try-error") { + + # new pro file in case of restart + file.pro <- gsub(".pro", paste0("_restart_", i-1, ".pro"), file.optresult, fixed=TRUE) + system(paste("cp", restart.l$file, file.pro)) + + # set new values for genoud for restart + share.type <- 1 + niter.done <- restart.l$pop.total - niter.init # number of done iterations + niter.miss <- niter.todo - niter.done # number of missing iterations + niter.miss <- max(c(0, niter.miss)) + + # finish optimization if enough iterations were done or above maxAutoRestart + if (i > (maxAutoRestart + 1) | niter.miss == 0) { + message(paste("OptimizeLPJgenoud: Error occured during GENOUD optimization. Start post-processing.", Sys.time())) + restart <- 2 + restart.optim <- FALSE + + } else { + # else restart optimization + dBFGSburnin <- BFGSburnin - max.generations + max.generations <- ceiling(niter.miss / pop.size) # new number of max generations + max.generations <- max(c(2, max.generations)) + wait.generations <- max.generations - 1 + BFGSburnin <- max.generations + dBFGSburnin + BFGSburnin[BFGSburnin < 1] <- 1 + + # get starting values (prior, best from previous optimization, median from previous optimization) + setwd(lpjfiles$path.out) + starting.values <- StartingValues(file.optresult, pop.size)$start + + message(paste( + "-----------------------------------------------------------------------", + "OptimizeLPJgenoud: Error occured. Restart the optimization :", + paste(" number of done iterations :", niter.done), + paste(" number of missing iterations :", niter.miss), + " Settings for restart :", + paste(" pop.size :", pop.size), + paste(" max.generations :", max.generations), + paste(" wait.generations :", wait.generations), + paste(" BFGSburnin :", BFGSburnin), + paste(" new population file :", file.pro), + Sys.time(), + "-----------------------------------------------------------------------", + "\n", + sep="\n")) + } # end if else + + } else { # in case of no try-error, save optimization result + restart.optim <- FALSE + save(opt.genetic, file=gsub(".pro", "_opt.genetic.RData", file.optresult, fixed=TRUE)) + message(paste("OptimizeLPJgenoud: GENOUD optimization finished.", Sys.time())) + + } # end if else try-error + } # end while over restart + } # end restart + + + # stop cluster + #------------- + + if (parallel) { + stopCluster(cluster) + message(paste("OptimizeLPJgenoud: Cluster nodes were stopped after all optimizations.", Sys.time())) + } + + + #--------------------------------------------- + # post-processing: start analysis + #--------------------------------------------- + + message(paste("OptimizeLPJgenoud: Start analysis of optimization results.", Sys.time())) + + + # read results from all iterations of optimization + #------------------------------------------------- + + setwd(lpjfiles$path.rescue) + files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) + rescue.l <- CombineRescueFiles(files, remove=FALSE) + + + # plot cost per data stream ~ indviduals + #--------------------------------------- + + pdf(gsub(".pro", "_cost-vs-individuals.pdf", file.optresult, fixed=TRUE), width=8, height=5.5) + DefaultParL() + plot(rescue.l, ylim=NULL, only.cost=TRUE) + plot(rescue.l, ylim=c(0, 10), only.cost=TRUE) + dev.off() + + + # plot barplot of cost + #--------------------- + + pdf(gsub(".pro", "_cost-per-datastream.pdf", file.optresult, fixed=TRUE), width=6, height=6) + BarplotCost(rescue.l, 1) + BarplotCost(rescue.l, 2) + dev.off() + + + # plot PCA of parameters + #----------------------- + + pdf(gsub(".pro", "_parameter-PCA.pdf", file.optresult, fixed=TRUE), width=9, height=7) + PlotParPCA(rescue.l) + dev.off() + + + # prepare opt.genetic object in case of restart + #---------------------------------------------- + + optim.df <- Rescue2Df(rescue.l, lpjpar) + rm(rescue.l) + + if (restart == 2) { + opt.genetic <- Df2optim(optim.df, pop.size) + save(opt.genetic, file=gsub(".pro", "_opt.genetic.RData", file.optresult, fixed=TRUE)) + } # end restart + + + # extract best parameters and parameter uncertainties + #---------------------------------------------------- + + lpjpar <- Rescue2LPJpar(optim.df, lpjpar) + dlpjpar$best <- lpjpar$best / lpjpar$prior + dlpjpar$best.median <- lpjpar$best.median / lpjpar$prior + + dlpjpar <- CheckLPJpar(dlpjpar, correct=TRUE) + lpjpar <- CheckLPJpar(lpjpar, correct=TRUE) + + + #-------------------------------------------------------------------- + # compute Jacbian, Hessian and parameter uncertainty based on Hessian + #-------------------------------------------------------------------- + + # calculate Jacobian and Hessian? + costmin <- opt.genetic$value + if (calc.jacob) { + # compute Jacobian at optimized parameters + if (restart.jacob | restart == 0 | !file.exists(gsub(".pro", "_jacobian.RData", file.optresult, fixed=TRUE))) { + message(paste("OptimizeLPJgenoud: Compute Jacobian.", Sys.time())) + jacobian <- jacobian(RunLPJ, opt.genetic$par, + # further parameters for RunLPJ ... + lpjpar, which.par.opt=which.par.opt, lpjfiles=lpjfiles, path=path, integrationdata=integrationdata, xy=xy, name=name, lpjcmd=lpjcmd, newcell=FALSE, plot=FALSE, getresult=FALSE, clean=1, clean.path=TRUE, CostMDS=CostMDS, nkeep=nkeep, warnings=warnings) + save(jacobian, file=gsub(".pro", "_jacobian.RData", file.optresult, fixed=TRUE)) + } else { + load(gsub(".pro", "_jacobian.RData", file.optresult, fixed=TRUE)) + } + + if (restart.jacob | restart == 0 | !file.exists(gsub(".pro", "_hessian.RData", file.optresult, fixed=TRUE))) { + message(paste("OptimizeLPJgenoud: Compute Hessian.", Sys.time())) + opt.bfgs <- optim(opt.genetic$par, RunLPJ, method="BFGS", hessian=TRUE, + # further parameters for RunLPJ ... + lpjpar, which.par.opt=which.par.opt, lpjfiles=lpjfiles, path=path, integrationdata=integrationdata, xy=xy, name=name, lpjcmd=lpjcmd, newcell=FALSE, plot=FALSE, getresult=FALSE, clean=1, clean.path=TRUE, CostMDS=CostMDS, nkeep=nkeep, warnings=warnings) + hessian <- opt.bfgs$hessian + costmin <- opt.bfgs$value + save(hessian, opt.bfgs, costmin, file=gsub(".pro", "_hessian.RData", file.optresult, fixed=TRUE)) + + # select best parameters: best from BFGS optimization + dlpjpar$best <- rep(NA, npar) + dlpjpar$best[which.par.opt] <- opt.bfgs$par + lpjpar$best <- dlpjpar$best * lpjpar$prior + names(lpjpar$best) <- lpjpar$names + } else { + load(gsub(".pro", "_hessian.RData", file.optresult, fixed=TRUE)) + } + } + + # paramter uncertainty from Hessian + lpjpar$uncertainty.hessian <- rep(NA, npar) + keep <- diag(hessian) != 0 + + # compute covariance matrix from Hessian + cov.m <- VarCovMatrix(hessian, par.optim) + + # compute alternative covariance matrix + rem.ll <- match(c("cost", "ll", "aic", "daic"), colnames(optim.df)) + if (all(is.na(cov.m))) { + message(paste("OptimizeLPJgenoud: WARNING! Covariance matrix, uncertainty.hessian and parameter correlation are computed from sampled parameters because Hessian was not or not correctly estimated.", Sys.time())) + best <- (1:nrow(optim.df))[optim.df$daic <= 2] + if (all(is.na(best))) best <- (1:nrow(optim.df))[optim.df$cost <= quantile(optim.df$cost, 0.05)] + optim.best.df <- optim.df[best, ] + w <- 1 - (optim.best.df$cost - min(optim.best.df$cost)) / (max(optim.best.df$cost) - min(optim.best.df$cost)) + m <- optim.best.df[, -rem.ll] + cov.m <- try(cov.wt(m, w)$cov, silent=TRUE) + if (class(cov.m) == "try-error") cov.m <- matrix(NA, ncol=ncol(hessian), nrow=ncol(hessian)) + } + + # compute standard errors + if (all(is.na(cov.m))) { + se <- rep(-98, npar) # flag indicates cannot compute standard error because of numerical reasons + cor.m <- matrix(NA, npar, npar) + } else { + se <- StandardError(as.matrix(cov.m), nobs, costmin) * lpjpar$prior[which.par.opt] + cor.m <- cov2cor(as.matrix(cov.m)) + } + lpjpar$uncertainty.hessian[match(names(se), lpjpar$names)] <- se + lpjpar$uncertainty.hessian[which.par.opt[!keep]] <- -99 # flag indicates parameter has no gradient + names(lpjpar$uncertainty.hessian) <- lpjpar$names + + + #-------------------------------------------------------------------- + # plot parameter distributions, evolution, sensitiviy and correlation + #-------------------------------------------------------------------- + + message(paste("OptimizeLPJgenoud: Plot parameters.", Sys.time())) + + # write parameter files with prior and posterior parameters + setwd(path.optresult) + WriteLPJpar(lpjpar, file=gsub(".pro", "", file.optresult, fixed=TRUE), pft.par=lpjfiles$pft.par, param.par=lpjfiles$param.par) + + if (plot) { + # plot parameter distributions, evolution, sensitiviy + pdf(gsub(".pro", "_parameter-dist-unc.pdf", file.optresult, fixed=TRUE), width=9, height=7) + PlotPar(optim.df, lpjpar) + dev.off() + + # plot parameter correlation + if (any(!is.na(cor.m))) { + pdf(gsub(".pro", "_parameter-cor.pdf", file.optresult, fixed=TRUE), width=15, height=15) + CorrelationMatrixS(cor.m) + dev.off() + } + } + + + #------------------------------------------------------- + # run and plot posterior model with optimized parameters + #------------------------------------------------------- + + message(paste("OptimizeLPJgenoud: Run LPJ with optimized parameters and remove temporary files.", Sys.time())) + + # calculate posterior model with best parameter set + if (plot) pdf(gsub(".pro", "_posterior-best.pdf", file.optresult, fixed=TRUE), width=9.75, height=10) + result.post.lpj <- RunLPJ(dlpjpar$best, lpjpar=lpjpar, which.par.opt=1:npar, lpjfiles=lpjfiles, path=path, integrationdata=integrationdata, xy, name=name, lpjcmd=lpjcmd, newcell=new.spinup4post, plot=plot, getresult=TRUE, clean=1, clean.path=TRUE, warnings=warnings, CostMDS=CostMDS) + if (plot) dummy <- plot(result.post.lpj, what="annual") + if (plot) dummy <- plot(result.post.lpj, what="monthly") + if (plot) dummy <- plot(result.post.lpj, what="grid") + if (plot) dev.off() + cost.post.best <- result.post.lpj$cost + setwd(lpjfiles$path.out) + save(result.post.lpj, file=gsub(".pro", "_posterior-best.RData", file.optresult, fixed=TRUE)) + + + # calculate posterior model with median best parameter set + if (plot) pdf(gsub(".pro", "_posterior-median.pdf", file.optresult, fixed=TRUE), width=9.75, height=10) + result.post.lpj <- RunLPJ(dlpjpar$best.median, lpjpar=lpjpar, which.par.opt=1:npar, lpjfiles=lpjfiles, path=path, integrationdata=integrationdata, xy, name=name, lpjcmd=lpjcmd, newcell=new.spinup4post, plot=plot, getresult=TRUE, clean=1, clean.path=TRUE, warnings=warnings, CostMDS=CostMDS) + if (plot) dummy <- plot(result.post.lpj, what="annual") + if (plot) dummy <- plot(result.post.lpj, what="monthly") + if (plot) dummy <- plot(result.post.lpj, what="grid") + if (plot) dev.off() + cost.post.med <- result.post.lpj$cost + setwd(lpjfiles$path.out) + save(result.post.lpj, file=gsub(".pro", "_posterior-median.RData", file.optresult, fixed=TRUE)) + + + } else { # if else runonly + + #------------------------------------------------------------ + # create default/empty result objects in case runonly == TRUE + #------------------------------------------------------------ + + result.post.lpj <- result.prior.lpj + max.generations <- pop.size <- wait.generations <- BFGSburnin <- NA + cost.post.med <- cost.post.best <- cost.prior + lpjpar$dummy <- rep(NA, npar) + names(lpjpar$dummy) <- lpjpar$names + lpjpar$best <- lpjpar$best.median <- lpjpar$uncertainty.hessian <- lpjpar$uncertainty.iqr <- lpjpar$uncertainty.iqr95 <- lpjpar$uncertainty.005.min <- lpjpar$uncertainty.005.max <- lpjpar$dummy + cor.m <- cov.m <- matrix(NA, npar, npar) + } # end if else runonly + + # delete temporary folder + system(paste("rm -rf", path.tmp.out.act)) + + + #-------------------------------------------------- + # plot cost surface between each pair of parameters + #-------------------------------------------------- + + if (plot & !runonly) { + require(fields) + pdf(gsub(".pro", "_cost-surface.pdf", file.optresult, fixed=TRUE), width=6.5, height=6.5) + comb <- combn(as.character(lpjpar$names[which.par.opt]), 2) + for (i in 1:ncol(comb)) { + par.a <- comb[1, i] + par.b <- comb[2, i] + post <- unlist(c(lpjpar$best[grep(par.a, lpjpar$names)[1]], lpjpar$best[grep(par.b, lpjpar$names)[1]])) + prior <- c(lpjpar$prior[grep(par.a, lpjpar$names)[1]], lpjpar$prior[grep(par.b, lpjpar$names)[1]]) + x <- unlist(optim.df[ , grep(par.a, colnames(optim.df))[1]]) + y <- unlist(optim.df[ , grep(par.b, colnames(optim.df))[1]]) + + if (!AllEqual(x) & !AllEqual(y)) { + # convert parameter combinations to raster + combn.par <- data.frame(x=x, y=y) + sp <- SpatialPointsDataFrame(combn.par, data.frame(cost=optim.df$cost)) + ext <- extent(lpjpar$lower[grep(par.a, lpjpar$names)], lpjpar$upper[grep(par.a, lpjpar$names)], lpjpar$lower[grep(par.b, lpjpar$names)], lpjpar$upper[grep(par.b, lpjpar$names)]) + r <- raster(ext, ncols=25, nrows=25) + r <- rasterize(sp, r, "cost", fun=quantile, prob=0.01, na.rm=TRUE) + + # plot cost ~ parameter + brks.q <- c(0, 0.01, 0.05, seq(0.1, 1, 0.1)) + brks <- quantile(c(0, values(r)), brks.q, na.rm=TRUE) + .fun <- colorRampPalette(rev(brewer.pal(11, "RdYlBu"))) + cols <- .fun(length(brks)-1) + DefaultParL(mar=c(3.7, 3.5, 2.5, 6)) + image(r, xlab=par.a, ylab=par.b, main=paste("Cost", par.a, "vs.", par.b), breaks=brks, col=cols) + points(combn.par[optim.df$cost < quantile(optim.df$cost, 0.05), ], pch=16, cex=0.5) # parameter with 95% confidence + arrows(prior[1], prior[2], post[1], post[2], length=0.1, lwd=2, col="yellow") # change from prior -> posterior + box() + lab.breaks <- c("", paste0("Q", brks.q[-1])) + image.plot(r, zlim=range(brks.q, na.rm=TRUE), legend.only=TRUE, breaks=brks.q, col=cols, legend.shrink=0.9, lab.breaks=lab.breaks, legend.width=1.2) + } + } + dev.off() + } + + + #-------------------------------- + # prepare, save and return result + #-------------------------------- + + # list with all results + results.l <- list( + # coordinates and result file + xy = xy, + file.opt = file.optresult, + file.optsetup = file.optsetup, + + # optimization information + max.generations = max.generations, + pop.size = pop.size, + wait.generations = wait.generations, + BFGSburnin = BFGSburnin, + + # cost + cost.prior = cost.prior, + cost.post.best = cost.post.best, + cost.post.med = cost.post.med, + + # return parameters + lpjpar = lpjpar, + + # Hessian and Jacobian + hessian = hessian, + jacobian = jacobian, + + # correlation matrix + cor.m = cor.m, + + # covariance matrix + cov.m <- cov.m + ) + save(results.l, file=gsub(".pro", "_results.RData", file.optresult, fixed=TRUE)) + + message(paste( + " ", + "------------------------------------------------------------------", + "-- OptimizeLPJgenoud successfully finished. ----------------------", + paste("-- finished at ", Sys.time()), + "-- Files with optimization results:", + paste("path :", path.optresult), + paste("opt. setup file :", file.optsetup), + paste("all results :", gsub(".pro", "_results.RData", file.optresult, fixed=TRUE)), + paste("prior PFT param. :", paste0(gsub(".pro", "", file.optresult, fixed=TRUE), "_prior_pft.par")), + paste("prior global param. :", paste0(gsub(".pro", "", file.optresult, fixed=TRUE), "_prior_param.par")), + paste("results of prior run :", gsub(".pro", "_prior.RData", file.optresult, fixed=TRUE)), + paste("population file :", file.optresult)[!runonly], + paste("best PFT param. :", paste0(gsub(".pro", "", file.optresult, fixed=TRUE), "_best_pft.par"))[!runonly], + paste("best global param. :", paste0(gsub(".pro", "", file.optresult, fixed=TRUE), "_best_param.par"))[!runonly], + paste("results of best run :", gsub(".pro", "_posterior-best.RData", file.optresult, fixed=TRUE))[!runonly], + paste("Jacobian matrix :", gsub(".pro", "_jacobian.RData", file.optresult, fixed=TRUE))[!runonly & calc.jacob], + paste("Hessian matrix :", gsub(".pro", "_hessian.RData", file.optresult, fixed=TRUE))[!runonly & calc.jacob], + "------------------------------------------------------------------", + "\n", + sep="\n")) + + return(paste("Results in list 'result.l' in", gsub(".pro", "_results.RData", file.optresult, fixed=TRUE))) +}) + diff --git a/LPJmLmdi/R/PlotPar.R b/LPJmLmdi/R/PlotPar.R new file mode 100644 index 0000000..f159c0f --- /dev/null +++ b/LPJmLmdi/R/PlotPar.R @@ -0,0 +1,141 @@ +PlotPar <- structure(function( + ##title<< + ## Plot parameter vs. cost + ##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. + + rescue.l, + ### a list of class "rescue" (\code{\link{CombineRescueFiles}}) or alternatively a data.frame as created with \code{\link{Rescue2Df}}. + + lpjpar, + ### a list of class "LPJpar" (see \code{\link{LPJpar}}) + + par.name = NULL, + ### name(s) of the parameters that should be plotted + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CombineRescueFiles}} +) { + if (class(rescue.l) == "rescue") { + par.optim <- names(rescue.l[[1]]$dpar) + optim.df <- Rescue2Df(rescue.l, lpjpar) + } else if (class(rescue.l) == "data.frame") { + optim.df <- rescue.l + } else { + stop("rescue.l should be of class 'rescue' or a 'data.frame'") + } + + # remove columns from parameter table + rem.ll <- match(c("cost", "ll", "aic", "daic"), colnames(optim.df)) + par.optim <- colnames(optim.df)[-rem.ll] + if (is.null(par.name)) par.name <- par.optim + best <- which.min(optim.df$cost) + + # normalized likelihood + nll <- optim.df$ll / max(optim.df$ll, na.rm=TRUE) + if (all(is.na(nll))) nll <- optim.df$cost / max(optim.df$cost, na.rm=TRUE) + + # loop over parameter names: make plots + for (i in 1:length(par.name)) { + nme <- par.name[i] + g1 <- grep(nme, lpjpar$names) + g2 <- grep(nme, colnames(optim.df)) + if (length(g1) == 1 & length(g2) == 1) { + niter <- nrow(optim.df) + par.all <- optim.df[, g2] + if (all(is.na(optim.df$daic))) { + par.sel <- optim.df[optim.df$cost <= quantile(optim.df$cost, 0.05, na.rm=TRUE), g2] + } else { + par.sel <- optim.df[optim.df$daic <= 2, g2] + } + par.prior <- lpjpar$prior[g1] + par.best <- lpjpar$best[g1] + par.med <- lpjpar$best.median[g1] + par.unc.min <- lpjpar$uncertainty.005.min[g1] + par.unc.max <- lpjpar$uncertainty.005.max[g1] + par.prior.ll <- optim.df$ll[par.prior == par.all] + nll.prior <- max(par.prior.ll, na.rm=TRUE) / max(optim.df$ll, na.rm=TRUE) + + # initalize plot + DefaultParL(new=FALSE, mar=c(3.7, 3.5, 0.2, 0.5), oma=c(0, 0.1, 2, 0.2)) + par(fig=c(0,0.5,0.5,1)) + + # plot 1: histogram + brks <- hist(par.all, xlab=nme, ylab="Frequency", main="", breaks=20, col="darkgrey") + hist(par.sel, breaks=brks$breaks, col="orange", add=TRUE, main="") + box() + abline(v=par.med, col="darkorange3", lwd=2) + abline(v=par.best, col="red", lwd=2) + abline(v=par.prior, col="blue", lwd=2) + y0 <- max(brks$counts) * 0.97 + arrows(x0=par.unc.min, y0=y0, x1=par.unc.max, y1=y0, col="red", code=3, angle=90, lwd=2, length=0.05) + pos <- "topright" + if (par.best > par.prior) pos <- "topleft" + legend(pos, c("all", "best (dAIC < 2)"), fill=c("grey", "orange"), bty="n", title="individuals", cex=0.8) + text(x=c(par.med, par.best, par.prior), y=max(brks$counts)*c(0.5, 0.8, 0.2), c("median", "best", "prior"), col=c("darkorange3", "red", "blue"), srt=90, pos=2) + mtext(nme, 3, 0.4, font=2, cex=1.4, outer=TRUE) + + # plot 2: evolution of parameter + par(fig=c(0.5,1,0.5,1), new=TRUE) + o <- order(optim.df$cost, decreasing=TRUE) + brks <- hist(1:niter, plot=FALSE)$mids + nclass <- length(brks) + agg <- cut(1:niter, breaks=seq(1, niter, length=nclass)) + levels(agg) <- brks + bxp <- boxplot(par.all ~ agg, ylab=nme, xlab="Iterations of genetic optimization", cex=0.5) + points(x=ncol(bxp$stats), y=par.best, col="red", lwd=2, pch=4, cex=1.5) + points(x=ncol(bxp$stats), y=par.med, col="darkorange3", lwd=2, pch=4, cex=1.5) + points(x=1, y=par.prior, col="blue", lwd=2, pch=4, cex=1.5) + arrows(x0=ncol(bxp$stats), y0=par.unc.min, x1=ncol(bxp$stats), y1=par.unc.max, col="red", code=3, angle=90, lwd=2, length=0.05) + text(y=c(par.med, par.best, par.prior), x=c(ncol(bxp$stats), ncol(bxp$stats), 1), c("median", "best", "prior"), col=c("darkorange3", "red", "blue"), pos=c(3, 1, 3)) + + # plot 3: scatter plot par ~ normalized likelihood + par(fig=c(0,0.5,0,0.5), new=TRUE) + xlim1 <- min(c(quantile(par.all, 0.4, na.rm=TRUE), quantile(par.sel, 0.005, na.rm=TRUE), par.best, par.med), na.rm=TRUE) + xlim2 <- max(c(quantile(par.all, 0.6, na.rm=TRUE), quantile(par.sel, 0.995, na.rm=TRUE), par.best, par.med), na.rm=TRUE) + xlim <- c(xlim1, xlim2) + pos <- "topright" + if (par.best > (xlim[1] + ((xlim[2]-xlim[1])*0.5))) pos <- "topleft" + plot(1, 1, xlab=nme, ylab="Normalized likelihood", xlim=xlim, ylim=c(min(nll), 1), type="n") + box() + b1 <- par.all >= xlim[1] & par.all <= xlim[2] + points(par.all[b1], nll[b1], cex=0.7, col=c("darkgrey", "orange")[(optim.df$daic[b1] <= 2)+1], pch=20) + abline(v=par.med, col="darkorange3", lwd=2) + points(x=par.best, y=1, col="red", lwd=2, pch=4, cex=1.5) + points(x=par.prior, y=nll.prior, col="blue", lwd=2, pch=4, cex=1.5) + arrows(x0=par.unc.min, y0=1, x1=par.unc.max, y1=1, col="red", code=3, angle=90, lwd=2, length=0.05) + box() + legend(pos, c("all", "best (dAIC < 2)"), col=c("grey", "orange"), title="individuals", cex=0.8, pch=20, bg="white") + text(x=c(par.med, par.best, par.prior), y=c(0.5, 1, nll.prior), c("median", "best", "prior"), col=c("darkorange3", "red", "blue"), pos=c(1, 1, 3)) + + # plot 4: plot.LPJpar + par(fig=c(0.5,0.65,0,0.5), new=TRUE) + plot(lpjpar, nme, xaxt="n") + + # plot 5: legend + par(fig=c(0.65,1,0,0.5), new=TRUE, mar=c(3.7, 0, 2.5, 0.1)) + plot.new() + hess <- lpjpar$uncertainty.hessian[g1] + if (is.null(hess)) hess <- NA + txt <- paste(c("prior", "best", "median", "Hessian", "IQR(dAIC)", "Range_95%(dAIC)", "Range( 10000) { + optim.df <- optim.df[order(optim.df$cost), ] + optim.df <- optim.df[1:10000, ] + } + + # do PCA + pc <- princomp(optim.df[,-1], scale=TRUE) + ld <- loadings(pc) + + # plot PCA + DefaultParL(mfrow=c(2,3)) + explvar <- cumsum((pc$sdev^2) / sum(pc$sdev^2)) * 100 + barplot(explvar[1:min(c(length(explvar), 9))], ylab="Cumulative explained variance (%)", ylim=c(0, 100)) + box() + biplot(pc, c(1,2), xlabs=rep(".", nrow(optim.df))) + biplot(pc, c(1,3), xlabs=rep(".", nrow(optim.df))) + biplot(pc, c(2,3), xlabs=rep(".", nrow(optim.df))) + biplot(pc, c(1,4), xlabs=rep(".", nrow(optim.df))) + biplot(pc, c(2,4), xlabs=rep(".", nrow(optim.df))) + + par(op) + return(pc) + ### The function returns an object of class 'princomp'. +}) diff --git a/LPJmLmdi/R/PlotParUnc.R b/LPJmLmdi/R/PlotParUnc.R new file mode 100644 index 0000000..19e26f6 --- /dev/null +++ b/LPJmLmdi/R/PlotParUnc.R @@ -0,0 +1,164 @@ +PlotParUnc <- structure(function( + ##title<< + ## Plot the psoterior parameter uncertainty + ##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 + + lpjpar, + ### a list of class "LPJpar" (see \code{\link{LPJpar}}) + + uncertainty = "uncertainty.005", + ### name of the uncertainty estimate in LPJpar that should be used to compute posterior uncertainties + + ylab = "Relative parameter uncertainty", + ### label of y-axis + + main = NULL, + ### title of plot + + par.name = NULL, + ### name(s) of the parameters that should be plotted + + use.par = TRUE, + ### use default settings for the graphic window? If FALSE, the internal settings for par() are not used. + + legend = TRUE, + ### plot a legend for PFTs? + + srt = 40, + ### string rotation of parameter names at the x-axis + + cex = 1, + ### size of point symbols + + ... + ### further arguments for plot + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CombineRescueFiles}} +) { + if (class(lpjpar) != "LPJpar") { + stop("lpjpar should be of class LPJpar") + } + + # colours and symbols for PFTs + cols <- c("#E41A1C", "#4DAF4A", "#377EB8", "darkgrey") + cols <- c(global=cols[4], TrBE=cols[1], TrBR=cols[1], TrH=cols[1], + TeNE=cols[2], TeBE=cols[2], TeBS=cols[2], TeH=cols[2], + BoNE=cols[3], BoNS=cols[3], BoBS=cols[3], PoH=cols[3]) + pchs <- c(global=16, TrBE=19, TrBR=21, TrH=15, + TeNE=17, TeBE=19, TeBS=21, TeH=15, + BoNE=17, BoNS=24, BoBS=21, PoH=15) + + # get uncertainty estimate + # uncertainty estimate + unc <- grep(uncertainty, names(lpjpar)) + if (uncertainty != "uncertainty.005") unc <- unc[1] + has.unc <- !all(is.na(unc)) + if (has.unc) { + if (length(unc) == 1) { # uncertainty range + unc <- lpjpar[[unc]] + unclow <- lpjpar$best - 0.5 * unc + uncup <- lpjpar$best + 0.5 * unc + + bool <- unclow < lpjpar$lower + bool[is.na(bool)] <- FALSE + unclow[bool] <- lpjpar$lower[bool] + uncup[bool] <- unclow[bool] + unc[bool] + + bool <- uncup > lpjpar$upper + bool[is.na(bool)] <- FALSE + uncup[bool] <- lpjpar$upper[bool] + unclow[bool] <- uncup[bool] - unc[bool] + } else if (length(unc) == 2) { # uncertainty lower and upper + low <- (lpjpar[[unc[1]]]) + up <- (lpjpar[[unc[2]]]) + if (any(na.omit(low > up))) { + up <- (lpjpar[[unc[1]]]) + low <- (lpjpar[[unc[2]]]) + } + unclow <- low + uncup <- up + } else { + warning("Check the selected uncertainty estimate") + has.unc <- FALSE + } + } + + # + if (is.null(main)) main <- uncertainty + + # compute relative uncertainty + dpar <- abs(lpjpar$best / lpjpar$prior) + dunc <- abs(uncup - unclow) / abs(lpjpar$upper - lpjpar$lower) + names(dunc) <- names(dpar) + bool <- !is.na(dunc) + dunc <- dunc[bool] + dpar <- dpar[bool] + + # get names and PFT names + nms <- strsplit(names(dunc), "_") + pfts <- laply(nms, function(nme) { + pft <- nme[length(nme)] + if (!any(grepl(pft, names(cols)))) pft <- "global" + return(pft) + }) + nms <- laply(nms, function(nme) { + pft <- nme[length(nme)] + if (any(grepl(pft, names(cols)))) { + nme <- paste(nme[-length(nme)], collapse="_") + } else { + nme <- paste(nme, collapse="_") + } + return(nme) + }) + + # select only parameters that should be plotted + if (!is.null(par.name)) { + m <- NULL + for (i in 1:length(par.name)) m <- c(m, grep(par.name[i], nms)) + pfts <- pfts[m] + nms <- nms[m] + dunc <- dunc[m] + } + nms <- as.factor(nms) + nms2 <- as.integer(nms) + + # aggregate uncertainty for each parameter across PFTs + dunc.agg <- aggregate(dunc ~ nms2, FUN=mean) + dunc.agg[,3] <- nms[match(dunc.agg[,1], nms2)] + dunc.agg <- dunc.agg[order(dunc.agg[,2]), ] + + col <- cols[match(pfts, names(cols))] + pch <- pchs[match(pfts, names(cols))] + + if (use.par) DefaultParL(las=0, mar=c(8, 3.8, 2, 0.5), xpd=FALSE) + + # plot(1:nrow(dunc.agg), ylim=c(0, 2), xaxt="n", type="n", xlab="", ylab="Parameter best / prior") + # abline(h=1) + # points(match(nms2, dunc.agg[,1]), dpar, col=col, pch=pch) + + plot(1:nrow(dunc.agg), dunc.agg[,2], xaxt="n", xlab="", type="l", ylim=c(0,1), lwd=2, ylab=ylab, main=main, ...) + axis(1, 1:nrow(dunc.agg), rep("", nrow(dunc.agg))) + points(match(nms2, dunc.agg[,1]), dunc, col=col, pch=pch, cex=cex) + par(xpd=TRUE) + txt <- as.character(dunc.agg[,3]) + txt <- ifelse(nchar(txt) > 14, paste0(substring(txt, 1, 13), "..."), txt) + text(1:nrow(dunc.agg), -0.08, txt, srt=srt, adj=c(1,1)) + #par(xpd=FALSE) + + m <- match(unique(pfts), names(cols)) + ncol <- 3 + if (length(m) <= 8) ncol <- 2 + if (legend) legend("topleft", names(cols)[m], col=cols[m], pch=pchs[m], ncol=ncol, bty="n", title="PFT", cex=cex) + +}, ex=function() { + # PlotParUnc(lpjpar) +}) + + diff --git a/LPJmLmdi/R/PlotWorld110.R b/LPJmLmdi/R/PlotWorld110.R new file mode 100644 index 0000000..a083e84 --- /dev/null +++ b/LPJmLmdi/R/PlotWorld110.R @@ -0,0 +1,35 @@ +PlotWorld110 <- structure(function( + ##title<< + ## Plot a world map based on 1:110Mio data + + admin=FALSE, + ### Plot administrative boundaries? + + lakes=TRUE, + ### Plot lakes? + + rivers=TRUE, + ### Plot rivers? + + col=c("black", "blue", "red"), + ### Colors for (1) coastlines, (2) rivers and (3) administrative boundaries + + bg=NA, + ### background color, default: NA (no background) + + ... + ### additional arguments to plot +) { + data(data110) # loads coast110, land110, admin110, rivers110, lakes110 + + plot(coast110, col=col[1], ...) + if (!is.na(bg)) plot(land110, add=TRUE, col=bg) + if (admin == TRUE) plot(admin110, border=col[3], add=TRUE) + plot(coast110, col=col[1], add=TRUE) + if (rivers == TRUE) plot(rivers110, col=col[2], add=TRUE) + if (lakes == TRUE) plot(lakes110, border=col[2], col="powderblue", add=TRUE) +}, ex=function(){ + +PlotWorld110() + +}) \ No newline at end of file diff --git a/LPJmLmdi/R/PrepareRestartFiles.R b/LPJmLmdi/R/PrepareRestartFiles.R new file mode 100644 index 0000000..d934ab1 --- /dev/null +++ b/LPJmLmdi/R/PrepareRestartFiles.R @@ -0,0 +1,64 @@ +PrepareRestartFiles <- structure(function( + ##title<< + ## Prepare restart files to restart OptimizeLPJgenoud + ##description<< + ## The function prepares all files that are needed to restart OptimizeLPJgenoud + + file.optsetup, + ### OptimizeLPJgenoud setup file, ends with "_optsetup.RData" + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{LPJfiles}} +) { + + # create file names + file.optresult <- gsub("_optsetup.RData", ".pro", file.optsetup) + path.tmp <- unlist(strsplit(file.optresult, "/")) + path.tmp <- paste(path.tmp[-length(path.tmp)], collapse="/") + file.optresult <- gsub(path.tmp, "", file.optresult) + file.optresult <- gsub("/", "", file.optresult) + + wd <- getwd() + setwd(path.tmp) + + # check if opt.genetic initial file exists else create opt.genetic list and save file + if (!file.exists(gsub(".pro", "_initial_opt.genetic.RData", file.optresult))) { + # read population file + optim.df <- read.table(gsub(".pro", "_initial.pro", file.optresult), comment.char='G') + pop.size <- max(optim.df[,1]) + best <- which.min(optim.df[,2])[1] + npar <- length(3:ncol(optim.df)) + ngen <- nrow(optim.df) / pop.size + + # create opt.genetic object + opt.genetic <- NULL + opt.genetic$value <- as.vector(unlist(optim.df[best, 2])) + opt.genetic$par <- as.vector(unlist(optim.df[best, 3:ncol(optim.df)])) + opt.genetic$gradients <- rep(NA, npar) + opt.genetic$generations <- ngen + opt.genetic$peakgeneration <- rep(1:ngen, each=pop.size)[best] + opt.genetic$popsize <- pop.size + opt.genetic$operators <- rep(NA, 9) + + save(opt.genetic, file=gsub(".pro", "_initial_opt.genetic.RData", file.optresult)) + } + + # check if opt.genetic file exists else create it + if (!file.exists(gsub(".pro", "_opt.genetic.RData", file.optresult))) { + file.copy(gsub(".pro", "_initial_opt.genetic.RData", file.optresult), gsub(".pro", "_opt.genetic.RData", file.optresult)) + } +}) + + + + + + \ No newline at end of file diff --git a/LPJmLmdi/R/ReadBIN.R b/LPJmLmdi/R/ReadBIN.R new file mode 100644 index 0000000..3fa1ed1 --- /dev/null +++ b/LPJmLmdi/R/ReadBIN.R @@ -0,0 +1,79 @@ +ReadBIN <- structure(function( + ##title<< + ## Read simple binary files without header + ##description<< + ## The function is used to read for example the soil*.bin and drainclass.bin files + ##title<< + ## Read a CLM file to a SpatialPixelsDataFrame + + file.bin, + ### binary file name with extension *.bin + + nbands=1, + ### number of bands per year + + size=1, + ### The number of bytes per element in the byte stream. + + file.grid=NA, + ### file name of the corresponding grid file + + endian.data="little", + ### endinaess of the data file + + endian.grid="little", + ### endianess of the grid file + + data.type=integer(), + ### type of the data + + ... + ### Further arguments (currently not used). + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{WriteCLM}} + +) { + + # get path and file name + wd <- getwd() + file.bin <- unlist(strsplit(file.bin, "/")) + if (length(file.bin) > 1) { + path.bin <- paste(file.bin[-length(file.bin)], collapse="/") + file.bin <- file.bin[length(file.bin)] + setwd(path.bin) + } + + # read CRU grid + if (is.na(file.grid)) { + file.grid <- c(gsub(".bin", ".grid", file.bin), "cru.grid", "grid.bin") + file.grid <- file.grid[file.exists(file.grid)][1] + if (is.na(file.grid)) stop("Cannot find a grid file. Please provide a file name 'file.grid'.") + } + grid.data <- ReadGrid(file.grid, endian.grid) + npixel <- nrow(grid.data) + + # read soilcode file + con <- file(file.bin, "rb") + x <- readBin(con, data.type, n=(npixel * 1 * nbands), size=size, endian=endian.data) + close(con) + + # data.sp <- try(SpatialPixelsDataFrame(grid.data, data=data.frame(x), proj4string=CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"), tolerance=0.5), silent=TRUE) + # if (class(data.sp) == "try-error") data.sp <- SpatialPointsDataFrame(grid.data, data=data.frame(x), proj4string=CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")) + data.sp <- SpatialPointsDataFrame(grid.data, data=data.frame(x), proj4string=CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")) + + setwd(wd) + return(data.sp) +}, ex=function() { + +# ReadBIN("soil_new_67420.bin") + +}) + + + \ No newline at end of file diff --git a/LPJmLmdi/R/ReadCLM.R b/LPJmLmdi/R/ReadCLM.R new file mode 100644 index 0000000..e888358 --- /dev/null +++ b/LPJmLmdi/R/ReadCLM.R @@ -0,0 +1,205 @@ +ReadCLM <- structure(function( + ##title<< + ## Read a CLM file to a SpatialPixelsDataFrame + + file.clm, + ### CLM file name with extension *.clm + + start=NA, + ### first year to be read + + end=NA, + ### last year to be read, reads until last year in case of NA + + start.year=NA, + ### first year in the dataset, read from header information in case NA + + grid=NULL, + ### 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 + + nbands=NA, + ### number of bands per year, read from header information in case NA + + size=NA, + ### The number of bytes per element in the byte stream. + + file.grid=NA, + ### file name of the corresponding grid file + + endian.data=NA, + ### endinaess of the data file + + endian.grid="big", + ### endianess of the grid file + + data.type=integer(), + ### type of the data + + ... + ### Further arguments (currently not used). + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{WriteCLM}} + +) { + + # get path and file name + wd <- getwd() + file.clm <- unlist(strsplit(file.clm, "/")) + if (length(file.clm) > 1) { + path.clm <- paste(file.clm[-length(file.clm)], collapse="/") + file.clm <- file.clm[length(file.clm)] + } else { + path.clm <- getwd() + } + + + # read grid + #---------- + + setwd(path.clm) + if (is.na(file.grid)) { + file.grid <- c(paste0(file.clm, ".grid"), "cru.grid", "grid.bin") + file.grid <- file.grid[file.exists(file.grid)][1] + if (is.na(file.grid)) stop("Cannot find a grid file. Pleaseprovide a file name 'file.grid'.") + } + grid.data <- ReadGrid(file.grid, endian.grid) + npixel <- nrow(grid.data) + + + # get file information from header + #--------------------------------- + + info <- InfoCLM(file.clm) + offset <- info$headersize + file.size <- info$file.size.real + size.header.diff <- file.size - info$file.size.fromheader + if (is.na(endian.data)) endian.data <- info$endian + + # return error if grid and data has a different number of pixels + w1 <- FALSE + if (npixel != info$ncell) { + w1 <- TRUE + warning(paste("Number of pixel in grid (n = ", npixel, ") is not equal to the number of pixel in the dataset (n = ", info$ncell, ").", sep="")) + npixel <- info$ncell + } + + # check header: return error if header does not agree with file size and start.year, sizeof.data or nbands are not defined + err1 <- "File has no or incorrect header. Please specifiy the number of bands (nbands), the first year in the data set (start.year) and size." + # if ((abs(size.header.diff) > 1) & (is.na(nbands) | is.na(start.year) | is.na(size))) stop(err1) + if ((offset == 0) & (is.na(nbands) | is.na(start.year) | is.na(size))) { + stop(err1) + } else { + start.year <- info$firstyear + nyear <- info$nyear + nbands <- info$nbands + size <- info$size + } + + + # calculate start and end years to read the data + #----------------------------------------------- + + if (is.na(start)) start <- start.year + if (start < start.year) start <- start.year + + # read all years if grid cells area specified + start0 <- start + end0 <- end + if (!is.null(grid)) { + start <- start.year + end <- start.year + nyear - 1 + } + + # calculate first year to return based on start and end + if (nyear > 1) { + if (is.na(end)) end <- start.year + nyear - 1 + if (is.na(end0)) end0 <- start.year + nyear - 1 + nyear_first <- start - start.year + nyear_plot <- end - start + 1 + # create colnames (style: dYEAR-band, e.g. d2000-1) + names <- NULL + for (i in start:end) names <- c(names, paste("d", rep(i, nbands), "-", 1:nbands, sep="")) + names0 <- NULL + for (i in start0:end0) names0 <- c(names0, paste("d", rep(i, nbands), "-", 1:nbands, sep="")) + } else { + nyear_plot <- 1 + nyear_first <- start - start.year + names <- 1:nbands + } + + + # read data for specific grid cells + #---------------------------------- + + if (!is.null(grid)) { + + # function to read data for specific grid cell + .ReadXY <- function(xy) { + # get position of cell in global grid + cell.pos <- match(paste(xy[1], xy[2]), paste(grid.data[,1], grid.data[,2])) + + # calculate first position of cell in file + skip <- offset + size.header.diff + (cell.pos - 1) * nbands * size + + # read cell values for each year + x.all <- NA + for (i in 1:nyear_plot) { + if (i > 1) skip <- skip + (npixel * nbands * size) + + con <- file(file.clm, "rb") + seek(con, where=skip, origin="start", rw = "read") + x <- readBin(con, data.type, n=(1 * 1 * nbands), size=size, endian=endian.data) + close(con) + x.all <- c(x.all, x) + } + x.all <- x.all[-1] + return(x.all) + } + + # read data + data.sp <- as.data.frame(t(apply(grid, 1, .ReadXY))) + data.sp <- data.sp[ ,match(names0, names)] + colnames(data.sp) <- names0 + grid.data <- grid + + } else { + + # OR: read data for all grid cells + #--------------------------------- + + # read data + con <- file(file.clm, "rb") + skip <- nyear_first * nbands * npixel * size + offset + size.header.diff + + seek(con, where=skip, origin="start", rw = "read") + # seek(con) + + # read desired data between start and end + data <- 1:npixel + for (i in 1:nyear_plot) { # loop over single years + x <- data.frame(matrix( + readBin(con, data.type, n=(npixel * 1 * nbands), size=size, endian=endian.data), + nrow=npixel, ncol=(1 * nbands), byrow=TRUE)) + # summary(x) + data <- cbind(data, x) + } + data.sp <- as.data.frame(data[,-1]) + close(con) + colnames(data.sp) <- names + } + + # return data as SpatialPixelsDataFrame + if (w1 == FALSE) { + ll <- CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0") + data.sp <- SpatialPointsDataFrame(grid.data, data.sp, proj4string=ll) + } + # plot(raster(data.sp,1)) + setwd(wd) + return(data.sp) +}) \ No newline at end of file diff --git a/LPJmLmdi/R/ReadGrid.R b/LPJmLmdi/R/ReadGrid.R new file mode 100644 index 0000000..e87f04e --- /dev/null +++ b/LPJmLmdi/R/ReadGrid.R @@ -0,0 +1,68 @@ +ReadGrid <- structure(function( + ##title<< + ## Reads a binary input data grid file. + + file.grid="cru.grid", + ### CLM file name with extension *.clm + + endian="little", + ### endianess of the file + + ... + ### Further arguments (currently not used). + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadCLM}} + +) { + is.ok <- FALSE # flag to check if grid is OK (no lat > 90 | < 90) + iter <- 1 + while (!is.ok & iter <= 2) { + + # open file + con <- file(file.grid, "rb") + + # get filetype name + name <- readBin(con, character(), n=1, size=1, endian=endian) + + # skip/read header information - depending on file type version + if (name == "LPJGRID") { # old LPJGRID files + close(con) + con <- file(file.grid, "rb") + seek(con, where=15, origin = "start", rw = "read") + } else if (name == "LPJGRID\001") { # new LPJGRID files V1 + x <- readBin(con, integer(), n=15, size=2, endian=endian) + } else if (name == "LPJGRID\002") { # new LPJGRID files V2 + x <- readBin(con, integer(), n=17, size=2, endian=endian) + } else if (name == "LPJGRID\003") { # new LPJGRID files V3 + x <- readBin(con, integer(), n=21, size=2, endian=endian) + } else { + stop(paste(file.grid, "is no valid LPJGRID file.")) + } + + # read data + grid <- readBin(con, integer(), n=(300000*2), size=2, endian=endian) + grid <- data.frame(matrix(grid/100, ncol=2, byrow=TRUE)) + close(con) + + # check grid - and swap endianness + if (max(grid[,2]) > 90 | min(grid[,2]) < -90) { + is.ok <- FALSE + if (endian == "little") { + endian <- "big" + } else { + endian <- "little" + } + iter <- iter + 1 + } else { + is.ok <- TRUE + } + if (iter > 2) warning(paste("Coordinates in", file.grid, "might be wrong. Please check.")) + } + return(grid) +}) \ No newline at end of file diff --git a/LPJmLmdi/R/ReadLPJ.R b/LPJmLmdi/R/ReadLPJ.R new file mode 100644 index 0000000..0bf4248 --- /dev/null +++ b/LPJmLmdi/R/ReadLPJ.R @@ -0,0 +1,94 @@ +ReadLPJ <- structure(function( + ##title<< + ## Read a LPJ binary file + ##description<< + ## The function reads a binary LPJ output file and returns a SpatialPointsDataFrame + + file.bin, + ### binary LPJ output file + + file.grid="grid.bin", + ### binary LPJ grid file + + sim.start.year=1901, + ### first year of the simulation + + start=sim.start.year, + ### first year to read + + end=NA, + ### last year to read, reads until last year if NA + + file.annual=c("vegc.bin", "litc.bin", "soilc.bin"), + ### one of the binary LPJ output files with annual data + + size=4, + ### the number of bytes per element in the byte stream. + + data.type=numeric(), + ### data type of the file (default=numeric()) + + endian="little", + ### endianess of the binary file + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadLPJsim}} + +) { + # get information about file + info <- InfoLPJ(file.bin=file.bin, file.grid=file.grid, file.annual=file.annual, size=size, data.type=data.type) + if (is.null(info)) return(NULL) + npixel <- info$npixel # number of pixels from grid file + nyear <- info$nyear # number of years from vegc file + nbands <- info$nbands # number of bands + + # get end year if it is NA and get number of years + if (is.na(end)) end <- sim.start.year + nyear - 1 + nyear_first <- start - sim.start.year # number of years between simulation start and desired end + nyear_plot <- end - start + 1 # number of years to return (between start and end) + + # terminate function if resulting object will be too large + #if (npixel * nbands * nyear_plot > 23679600) return(stop("Object will be to large! Select a shorter time span.")) + + # open data file connection + con <- file(file.bin, "rb") + + # skip first years (sim.start.year to start) + skip <- nyear_first * nbands * npixel * size + seek(con, where = skip, origin = "start", rw = "read") + + # read desired data between start and end + data <- data.frame(matrix( + x <- readBin(con, data.type, n=(npixel * nyear_plot * nbands), size=size, endian=endian), + nrow=npixel, ncol=(nyear_plot * nbands), byrow=FALSE)) + close(con) + + # create colnames (style: dYEAR-band, e.g. d2000-1) + names <- NULL + for (i in start:end) names <- c(names, paste("d", rep(i, nbands), "-", 1:nbands, sep="")) + colnames(data) <- names + + # convert data to SpatialPixelsDataFrame and return + proj <- CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0") + data.sp <- SpatialPointsDataFrame(info$grid, data, proj4string=proj) + return(data.sp) + ### The function returns a SpatialPointsDataFrame. +}, ex=function() { + +# ReadLPJ("mgpp.bin", start=1982, end=2011) + +}) + + + + + + diff --git a/LPJmLmdi/R/ReadLPJ2IntegrationData.R b/LPJmLmdi/R/ReadLPJ2IntegrationData.R new file mode 100644 index 0000000..4d077ad --- /dev/null +++ b/LPJmLmdi/R/ReadLPJ2IntegrationData.R @@ -0,0 +1,99 @@ +ReadLPJ2IntegrationData <- structure(function( + ##title<< + ## Read LPJ model results into an of class IntegrationData + ##description<< + ## The function reads for each dataset in \code{\link{IntegrationData}} the corresponding model output and performs temporal aggregation. + + integrationdata, + ### object of class \code{\link{IntegrationData}} + + xy, + ### matrix of grid cell coordinates to run LPJ + + lpjfiles, + ### list of class \code{\link{LPJfiles}} that define all LPJ directories, input files, configuration template files + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationData}} + +) { + integrationdata <- llply(integrationdata, function(ds) { + + # ds <<- ds + + # get time info + model.time <- ds$model.time + data.time <- as.Date(ds$data.time) + years.mod <- format(model.time, "%Y") + years.dat <- format(data.time, "%Y") + start <- min(as.numeric(years.mod)) + end <- max(as.numeric(years.mod)) + + # read model simulation of data stream + if (is.function(ds$model.val.file)) { + model.sp <- do.call(ds$model.val.file, args=list()) + } else { + model.sp <- ReadLPJ(ds$model.val.file, start=start, end=end, sim.start.year=lpjfiles$sim.start.year) + } + ncell <- nrow(xy) + + # apply scaling factor + if (!is.null(ds$model.factor)) model.sp@data <- model.sp@data * ds$model.factor + + # change order of grid cells in simulation according to order of observations + o <- 1 + if (ncell > 1) { + coord.order.obs <- apply(xy, 1, paste, collapse="_") + coord.order.sim <- apply(coordinates(model.sp), 1, paste, collapse="_") + o <- match(coord.order.obs, coord.order.sim) + } + model.m <- as.matrix(t(model.sp@data[o,])) + + # aggregate model result? + if (!is.null(ds$AggFun)) { + agg <- years.mod + years.mod <- unique(years.mod) + model.m <- matrix(apply(model.m, 2, FUN=ds$AggFun, agg=agg), ncol=ncell) + if (nrow(model.m) == 1) { + model.time <- data.time # one value + } else if (nrow(model.m) == 12 & nrow(model.m) != length(years.mod)) { + model.time <- data.time # mean seasonal cycle + } else { + model.time <- as.Date(paste0(years.mod, "-01-01")) # annual time series + } + } + + # match data time and model time + b <- length(data.time) != length(model.time) + if (!b) b <- any(data.time != model.time) + if (b) { + m <- match(data.time, model.time) + if (all(is.na(m))) stop(paste0("ReadLPJ2IntegrationData: IntegrationDataset = ", ds$name, ": time steps of data and model do not match.")) + if (length(m) > 1) { + model.m <- model.m[m, ] + } else { + model.m <- matrix(model.m[m, ], nrow=1, ncol=ncell) + } + } + ds$model.val <- model.m + + # error check + if (any(dim(ds$model.val) != dim(ds$data.val))) { + stop(paste0("ReadLPJ2IntegrationData: IntegrationDataset = ", ds$name, ": dimensions of data and model results don't match.")) + } + + return(ds) + }) + class(integrationdata) <- "IntegrationData" + return(integrationdata) + ### The function returns the same list oc class 'IntegrationData' but with added model outputs. +}) + diff --git a/LPJmLmdi/R/ReadLPJ2ts.R b/LPJmLmdi/R/ReadLPJ2ts.R new file mode 100644 index 0000000..eb1ac5b --- /dev/null +++ b/LPJmLmdi/R/ReadLPJ2ts.R @@ -0,0 +1,81 @@ +ReadLPJ2ts <- structure(function( + ##title<< + ## Read a LPJ binary file and returns a spatial averaged time series + ##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 + + file.bin, + ### binary LPJ output file + + sim.start.year=1901, + ### first year of the simulation + + start=sim.start.year, + ### first year to read + + end=NA, + ### last year to read, reads until last year if NA + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadLPJsim}} + +) { + info <- InfoLPJ(file.bin) + var <- ReadLPJ(file.bin, sim.start.year=sim.start.year, start=start, end=end)@data + + monthly <- annual <- daily <- FALSE + if (info$nbands == 365) { + daily <- TRUE + freq <- 365 + } else if (info$nbands == 12) { + monthly <- TRUE + freq <- 12 + } else if (info$nbands == 1) { + annual <- TRUE + freq <- 1 + } + + if (file.bin == "fpc.bin" | file.bin == "waterstress.bin" | file.bin == "soilc_layer.bin" | file.bin == "cftfrac.bin" | file.bin == "pft_harvest.pft.bin") { + freq <- 1 + npft <- info$nbands + pft.names <- 1:npft + if (file.bin == "fpc.bin" | file.bin == "cftfrac.bin") { + if (npft == 10) pft.names <- c("TrBE", "TrBR", "TeNE", "TeBE", "TeBS", "BoNE", "BoBS", "BoNS", "TeH", "TrH") + if (npft == 11) pft.names <- c("NatStand", "TrBE", "TrBR", "TeNE", "TeBE", "TeBS", "BoNE", "BoBS", "BoNS", "TeH", "TrH") + if (npft == 12) pft.names <- c("NatStand", "TrBE", "TrBR", "TeNE", "TeBE", "TeBS", "BoNE", "BoBS", "BoNS", "TrH", "TeH", "PoH") + if (npft == 13) pft.names <- c("TrBE", "TrBR", "TeNE", "TeBE", "TeBS", "BoNE", "BoBS", "BoNS", "TrH", "TrArH", "TeArH", "TeH", "PoH") + if (npft == 14) pft.names <- c("NatStand", "TrBE", "TrBR", "TeNE", "TeBE", "TeBS", "BoNE", "BoBS", "BoNS", "TrH", "TrArH", "TeArH", "TeH", "PoH") + if (npft != length(pft.names)) pft.names <- paste("PFT", 1:npft, sep="") + } + if (file.bin == "soilc_layer.bin") { + pft.names <- 1:npft + } + fpc.ts <- unlist(colMeans(var, na.rm=TRUE)) + var.ts <- ts(fpc.ts[seq(1, length(fpc.ts), by=npft)], start=c(start)) + for (p in 2:npft) var.ts <- cbind(var.ts, ts(fpc.ts[seq(p, length(fpc.ts), by=npft)], start=c(start))) + + # calculate PFTs per grid cell + if (file.bin == "fpc.bin" & any(grepl("NatStand", pft.names))) { + var.ts[,2:ncol(var.ts)] <- var.ts[,2:ncol(var.ts)] * var.ts[,1] + var.ts[var.ts < 0] <- 0 + } + + colnames(var.ts) <- pft.names + } else { + var.ts <- ts(colMeans(var, na.rm=TRUE), start=c(start, 1), freq=freq) + } + return(var.ts) + ### The function returns a time series of class 'ts'. +}, ex=function() { + +# gpp <- ReadLPJ2ts("mgpp.bin") + +}) diff --git a/LPJmLmdi/R/ReadLPJinput.R b/LPJmLmdi/R/ReadLPJinput.R new file mode 100644 index 0000000..9cfb69c --- /dev/null +++ b/LPJmLmdi/R/ReadLPJinput.R @@ -0,0 +1,109 @@ +ReadLPJinput <- structure(function( + ##title<< + ## Read and subset CLM files to LPJinput objects + ##description<< + ## The functions reads a CLM file, selects the data according to the provided grid and returns an object of class LPJinput. + + files, + ### character vector of CLM or binary file names + + grid=NULL, + ### 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. + + start=NA, + ### first year to read + + ... + ### Further arguments to ReadCLM or ReadBIN + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{WriteLPJinput}} + +) { + + # loop over files + lpjinput <- NULL + for (i in 1:length(files)) { + file.clm <- files[i] + if (!file.exists(file.clm)) stop(paste(file.clm, "does not exists.")) + + + # read CLM or BIN data + #--------------------- + + fmt <- unlist(strsplit(file.clm, ".", fixed=TRUE)) + fmt <- fmt[length(fmt)] + + pyear <- start + + if (fmt == "bin") { + data.sp <- ReadBIN(file.clm, ...) + info <- list(filename=file.clm, firstyear=NA, nyear=NA, nbands=1) + } else if (fmt == "clm") { + info <- InfoCLM(file.clm) + data.sp <- ReadCLM(file.clm, grid=grid, start=start, ...) + if (is.na(start)) { + pyear <- info$firstyear + } else { + pyear <- start + } + } else { + stop(paste(fmt, "is not implemented in ReadLPJinput as format for LPJ input data.")) + } + grid0 <- coordinates(data.sp) + + + # select grid cells from data + #---------------------------- + + if (!is.null(grid)) { + # grid as text + grid1.txt <- paste(grid[,1], grid[,2]) + grid0.txt <- paste(grid0[,1], grid0[,2]) + m <- match(grid1.txt, grid0.txt) + data.m <- as.matrix(data.sp@data[m, ]) + } else { + data.m <- as.matrix(data.sp@data) + grid <- coordinates(data.sp) + } + + + # create object of class lpjinput + #-------------------------------- + + # new data set + data.l <- list( + file.orig = info$filename, + file.new = NA, + firstyear = pyear, + nyear = info$nyear, + nbands = info$nbands, + fmt = fmt, + data = data.m + ) + + # create new or add to existing lpjinput + if (is.null(lpjinput)) { # make new lpjinput + lpjinput <- list( + grid = grid, + data = list(data.l) + ) + class(lpjinput) <- "LPJinput" + } else { + ndata <- length(lpjinput$data) + lpjinput$data[[ndata+1]] <- data.l + } + } + return(lpjinput) + ### The function returns a list of class "LPJinput". +}, ex=function(){ + +# 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))) +# str(lpjinput) + +}) \ No newline at end of file diff --git a/LPJmLmdi/R/ReadLPJsim.R b/LPJmLmdi/R/ReadLPJsim.R new file mode 100644 index 0000000..e8460bb --- /dev/null +++ b/LPJmLmdi/R/ReadLPJsim.R @@ -0,0 +1,110 @@ +ReadLPJsim <- structure(function( + ##title<< + ## Read a LPJ simulation results + ##description<< + ## The function reads all binary output files from a LPJ simulation and returns regional aggregated time series. + + sim.start.year=1901, + ### first year of the simulation + + start=sim.start.year, + ### first year to read + + end=NA, + ### last year to read. If NA, reads until last year + + files=NA, + ### Which LPJ binary output files should be read? If NA, all *.bin files in the current directory are read. + + outputvars.par=NULL, + ### 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. + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadLPJ2ts}} + +) { + + # list all LPJmL output files + if (is.na(files)) { + files <- list.files(pattern=".bin") + files <- files[-grep("grid.bin", files)] + } + files <- files[!grepl("seasonality.bin", files)] + files <- files[file.exists(files)] + + # remove older files from reading - likely from different model run + filei <- file.info(files) + ti <- filei$mtime[grep("vegc.bin", files)] + bool <- abs(filei$mtime - ti) > 60*3 + if (any(bool)) { + warnings(paste0("These files are older and might be not from the same model run: ", " \n ", paste(files[bool], collapse=", "), " \n ", "Files are excluded from reading.")) + files <- files[!bool] + } + names <- gsub(".bin", "", files) + + # get grid + info <- InfoLPJ(files[1]) + npixel <- info$npixel + grid.data <- info$grid + + # read time series + data.l <- llply(as.list(files), .fun=function(file) { + # bac <<- file + ReadLPJ2ts(file, sim.start.year=sim.start.year, start=start, end=end) + }) + names(data.l) <- names + + # get information for output files/variables + if (is.null(outputvars.par)) outputvars.par <- list.files("../..", "outputvars.par", recursive=TRUE, full.names=TRUE) + if (length(outputvars.par) == 0) outputvars.par <- NULL + if (!is.null(outputvars.par)) { + if (!file.exists(outputvars.par)) outputvars.par <- NULL + } + if (length(outputvars.par) == 0) outputvars.par <- NULL + if (!is.null(outputvars.par)) { + # read "outputvars.par" to get meta-information + output.df <- ReadOutputvars(outputvars.par=outputvars.par) + info.df <- ldply(as.list(files), .fun=function(file) { + g <- grep(gsub(".bin", "", file), output.df$id) + if (length(g) == 0) g <- grep(toupper(gsub(".bin", "", file)), output.df$id) + if (length(g) == 0) g <- grep(gsub(".bin", "", file), output.df$name) + if (length(g) == 0) g <- grep(toupper(gsub(".bin", "", file)), output.df$name) + if (length(g) == 0) g <- grep(gsub("d", "d_", (gsub(".bin", "", file))), output.df$name) + if (length(g) == 0) { + df <- data.frame(id=file, name=gsub(".bin", "", file), name2="", description="", unit="", scale=1, file=file) + } else { + df <- output.df[g[1],] + df$file <- file + } + return(df) + }) + + # apply scaling factor + data.l <- llply(as.list(1:length(data.l)), function(id) { + data.l[[id]] * 1/info.df$scale[id] + }) + names(data.l) <- names + } else { + message("File 'outputvars.par' not found. Read LPJ output without meta-information.") + info.df <- data.frame(id=files, name=gsub(".bin", "", files), name2="", description="", unit="", scale=1) + } + + lpj.l <- list(data=data.l, grid=grid.data, info=info.df) + class(lpj.l) <- "LPJsim" + return(lpj.l) + ### The function returns a list of class 'LPJsim' +}, ex=function() { + + # setwd(path.mylpjresult) + # sim <- ReadLPJsim(start=1982, end=2011) + +}) + diff --git a/LPJmLmdi/R/ReadOutputvars.R b/LPJmLmdi/R/ReadOutputvars.R new file mode 100644 index 0000000..e17b901 --- /dev/null +++ b/LPJmLmdi/R/ReadOutputvars.R @@ -0,0 +1,55 @@ +ReadOutputvars <- structure(function( + ##title<< + ## Read 'outputvars.par' to get information about LPJmL output + ##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}}. + + outputvars.par=NULL, + ### 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. + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadLPJsim}} +) { + # search for file 'outputvars.par' + wd <- getwd() + if (is.null(outputvars.par)) { + outputvars.par <- list.files(pattern="outputvars.par", recursive=TRUE) + if (length(outputvars.par) == 0) { + setwd("..") + outputvars.par <- list.files(pattern="outputvars.par", recursive=TRUE) + } + if (length(outputvars.par) == 0) stop(paste0("File 'outputvars.par' does not exist within ", getwd(), ". Please provide the correct file name.")) + } + + # read file and skip first lines + suppressWarnings(txt <- readLines(outputvars.par)) + txt <- txt[-c(1:(grep("GRID", txt)-1))] + s <- strsplit(txt, "\"")[[1]] + + # convert to data.frame + varinfo.df <- ldply(strsplit(txt, "\""), function(s) { + if (length(s)==1) { + df <- data.frame(id="COMMENT", name="", name2="", description="", unit="", scale=NA) + } else { + df <- data.frame(id=gsub(" ", "", s[1]), name=s[2], name2=s[4], description=s[6], unit=s[8], scale=as.numeric(s[9])) + } + return(df) + }) + varinfo.df <- varinfo.df[-grep("COMMENT", varinfo.df$id),] + + setwd(wd) + return(varinfo.df) + ### The function returns a time series of class 'ts'. +}, ex=function() { + +# ReadOutputvars() + +}) diff --git a/LPJmLmdi/R/ReadPRO.R b/LPJmLmdi/R/ReadPRO.R new file mode 100644 index 0000000..da90599 --- /dev/null +++ b/LPJmLmdi/R/ReadPRO.R @@ -0,0 +1,43 @@ +ReadPRO <- structure(function( + ##title<< + ## Read *.pro files as produced from GENOUD + ##description<< + ## The function is used within OptimizeLPJgenoud + + files.pro + ### file names (*.pro) of genoud optimization results. + + ##details<< + ## No details. + + ##references<< No reference. +) { + + # read all pro population files + optim.df <- ldply(as.list(files.pro), function(file.pro) { + if (file.info(file.pro)$size > 0) { + m <- read.table(file.pro, comment.char='G') + colnames(m) <- paste("X", 1:ncol(m)) + return(m) + } else { + return(NULL) + } + }) + + # remove duplicates + txt <- apply(optim.df, 1, function(x) { + txt <- round(x[2:length(x)], 8) + paste(x, collapse="-") + }) + optim.df <- optim.df[!duplicated(txt), ] + + # remove out-of-range individuals + use <- optim.df[,2] != 1e+20 + optim.df <- optim.df[use, ] + + return(optim.df) + ### The function returns a data.frame with number of individual, cost and parameer values +}) + + + \ No newline at end of file diff --git a/LPJmLmdi/R/RegridLPJinput.R b/LPJmLmdi/R/RegridLPJinput.R new file mode 100644 index 0000000..774847b --- /dev/null +++ b/LPJmLmdi/R/RegridLPJinput.R @@ -0,0 +1,72 @@ +RegridLPJinput <- structure(function( + ##title<< + ## Regrid or subset LPJmL input + ##description<< + ## Subsets grid cells or regrids LPJmL input files. + + files, + ### character vector of CLM or binary file names + + grid.clm, + ### old grid *.clm file + + 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. + + path.out, + ### directory where the new files should be saved + + overwrite = TRUE, + ### overwrite existing files? + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{WriteLPJinput}} + +) { + dir.create(path.out, recursive=TRUE) + + # new file names + files2 <- laply(strsplit(files, "/"), function(f) paste(path.out, f[length(f)], sep="/")) + + # write grid + grid.txt <- paste0(path.out, "/grid.txt") + grid.new.clm <- paste0(path.out, "/grid.clm") + if (ncol(grid) > 2) stop("grid needs only 2 columns: 'lon' and 'lat'") + write.table(grid, file=grid.txt, sep=",", row.names=FALSE, col.names=FALSE) + + bool <- all(file.exists(c(grid.new.clm, files2))) + if (overwrite | !bool) { + + # write new grid clm file + cmd <- paste("txt2grid -skip 0 -fmt \"%g,%g\"", grid.txt, grid.new.clm) + system(cmd) + + # regrid input files + for (i in 1:length(files)) { + if (names(files)[i] == "SOILCODE_FILE") { + cmd <- paste("regridsoil", grid.clm, grid.new.clm, files[i], files2[i]) + } else { + cmd <- paste("regridclm", grid.clm, grid.new.clm, files[i], files2[i]) + } + system(cmd) + } + } + bool <- file.exists(files2) + if (any(!bool)) stop("File does not exist.") + files.df <- data.frame( + name = c("GRID_FILE", names(files)), + file = c(grid.new.clm, files2) + ) + return(files.df) + ### The function returns TRUE if the CLM file was created. +}, ex=function() { + # no example +}) diff --git a/LPJmLmdi/R/Rescue2Df.R b/LPJmLmdi/R/Rescue2Df.R new file mode 100644 index 0000000..3b3dcf3 --- /dev/null +++ b/LPJmLmdi/R/Rescue2Df.R @@ -0,0 +1,57 @@ +Rescue2Df <- structure(function( + ##title<< + ## Convert a 'rescue' list to a data.frame + ##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). + + rescue.l, + ### a list of class "rescue", see \code{\link{CombineRescueFiles}} + + lpjpar=NULL, + ### a list of class "LPJpar" (see \code{\link{LPJpar}}) to convert the scaled parameters in rescue.l back to the original units (optional) + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CombineRescueFiles}} +) { + + # remove duplicated priors + r <- laply(rescue.l, function(l) length(l$dpar)) + rescue.l <- rescue.l[r == modal(r)] + + # create data.frame + cost <- unlist(llply(rescue.l, function(x) x$cost$total)) + dpar <- ldply(rescue.l, function(x) x$dpar) + optim.df <- data.frame(cost, dpar) + par.optim <- names(rescue.l[[1]]$dpar) + colnames(optim.df) <- c("cost", par.optim) + + # scale parameters to original units + if (!is.null(lpjpar)) { + which.par.opt <- match(par.optim, lpjpar$names) + scale.m <- matrix(c(1, lpjpar$prior[which.par.opt]), ncol=ncol(optim.df), nrow=nrow(optim.df), byrow=TRUE) + optim.df <- optim.df * scale.m + } + + # compute likelihood and AIC + optim.df$ll <- exp(-optim.df$cost) # likelihood + optim.df$aic <- 2 * length(par.optim) - 2 * log(optim.df$ll) # Akaike Information Criterion + aic.min <- min(optim.df$aic) # AIC of best model + optim.df$daic <- optim.df$aic - aic.min # AIC differences + return(optim.df) + ### The function returns a data.frame. +}, ex=function() { + # files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) + # rescue.l <- CombineRescueFiles(files, remove=FALSE) + # optim.df <- Rescue2Df(rescue.l) + # summary(optim.df) +}) + + diff --git a/LPJmLmdi/R/Rescue2LPJpar.R b/LPJmLmdi/R/Rescue2LPJpar.R new file mode 100644 index 0000000..0846f2f --- /dev/null +++ b/LPJmLmdi/R/Rescue2LPJpar.R @@ -0,0 +1,93 @@ +Rescue2LPJpar <- structure(function( + ##title<< + ## Add information from a 'rescue' list to an 'LPJpar' object + ##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' (see \code{\link{LPJpar}}) object. Then it extracts the best parameter set, the median of the best parameter sets (defined based on dAIC <= 2), and various uncertainty measures and adds them to the 'LPJpar' object. + + rescue.l, + ### a list of class "rescue" (\code{\link{CombineRescueFiles}}) or alternatively a data.frame as created with \code{\link{Rescue2Df}}. + + lpjpar, + ### a list of class "LPJpar" (\code{\link{LPJpar}}) + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CombineRescueFiles}} +) { + if (class(rescue.l) == "rescue") { + par.optim <- names(rescue.l[[1]]$dpar) + optim.df <- Rescue2Df(rescue.l, lpjpar) + } else if (class(rescue.l) == "data.frame") { + optim.df <- rescue.l + } else { + stop("rescue.l should be of class 'rescue' or a 'data.frame'") + } + rem.ll <- match(c("cost", "ll", "aic", "daic"), colnames(optim.df)) + par.optim <- colnames(optim.df)[-rem.ll] + + # select best models according to maximum AIC difference of 2 (Bunham & Anderson 70) + if (all(is.na(optim.df$daic))) { + best <- (1:nrow(optim.df))[optim.df$cost <= quantile(optim.df$cost, 0.05, na.rm=TRUE)] + } else { + best <- (1:nrow(optim.df))[optim.df$daic <= 2] + } + optim.best.df <- optim.df[best, ] + + # select best parameters: best from optimization + which.par.opt <- match(par.optim, lpjpar$names) + lpjpar$best <- lpjpar$prior + lpjpar$best[which.par.opt] <- unlist(optim.df[which.min(optim.df$cost), -rem.ll]) + names(lpjpar$best) <- as.character(lpjpar$names) + + # select best parameters: median from best genes + lpjpar$best.median <- lpjpar$prior + lpjpar$best.median[which.par.opt] <- apply(optim.best.df, 2, median, na.rm=TRUE)[-rem.ll] + names(lpjpar$best.median) <- lpjpar$names + + # uncertainty as inter-quartile range from best individuals + lpjpar$uncertainty.iqr <- rep(NA, length(lpjpar$prior)) + lpjpar$uncertainty.iqr[which.par.opt] <- apply(optim.best.df, 2, IQR, na.rm=TRUE)[-rem.ll] + names(lpjpar$uncertainty.iqr) <- lpjpar$names + + # uncertainty as inter-quantile range 0.025-0.975 (central 95 %) from best individuals + lpjpar$uncertainty.iqr95 <- rep(NA, length(lpjpar$prior)) + lpjpar$uncertainty.iqr95[which.par.opt] <- apply(optim.best.df, 2, FUN=function(x) { diff(quantile(x, c(0.025, 0.975), na.rm=TRUE)) })[-rem.ll] + names(lpjpar$uncertainty.iqr95) <- lpjpar$names + + # uncertainty as range of parameters with cost < quantile 0.05 + cost.trs <- quantile(optim.df$cost, 0.05) + optim.q005.df <- subset(optim.df, cost <= cost.trs) + lpjpar$uncertainty.005.min <- lpjpar$uncertainty.005.max <- rep(NA, length(lpjpar$prior)) + lpjpar$uncertainty.005.min[which.par.opt] <- apply(optim.q005.df[,-rem.ll], 2, FUN=min, na.rm=TRUE) + lpjpar$uncertainty.005.max[which.par.opt] <- apply(optim.q005.df[,-rem.ll], 2, FUN=max, na.rm=TRUE) + + return(lpjpar) + ### The function returns the provided 'LPJpar' object with the following additional slots: + ### \itemize{ + ### \item{ \code{best} Best parameter set } + ### \item{ \code{best.median} median of best parameter sets (based on all parameter sets with dAIC <= 2) } + ### \item{ \code{uncertainty.iqr} uncertainty of parameters as the inter-quartile range of the best parameter sets } + ### \item{ \code{uncertainty.iqr95} uncertainty of parameters as the central 95% inter-quantile range (0.975-0.025) of the best parameter sets } + ### \item{ \code{uncertainty.005.min} lower parameter uncertainty estimate based on the minimum parameter value from all parameter sets for which the cost <= quantile(cost, 0.05) } + ### \item{ \code{uncertainty.005.max} upper parameter uncertainty estimate based on the maximum parameter value from all parameter sets for which the cost <= quantile(cost, 0.05) } + ### } +}, ex=function() { + # files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) + # rescue.l <- CombineRescueFiles(files, remove=FALSE) + # lpjpar2 <- Rescue2LPJpar(rescue.l, lpjpar) + # str(lpjpar2) + # plot(lpjpar2, "ALPHAA", "uncertainty.iqr95") + # plot(lpjpar2, "TMIN_BASE", "uncertainty.iqr95") +}) + + + + + diff --git a/LPJmLmdi/R/RunLPJ.R b/LPJmLmdi/R/RunLPJ.R new file mode 100644 index 0000000..bc0a127 --- /dev/null +++ b/LPJmLmdi/R/RunLPJ.R @@ -0,0 +1,370 @@ +RunLPJ <- structure(function( + ##title<< + ## Run LPJmL from R and get results + ##description<< + ## This function calls LPJmL, reads the results of the model run, computes the cost based on the data sets in \code{\link{IntegrationData}} and the defined cost function (in CostMDS), and returns the simulation results. + + dpar, + ### vector of scaling factors for each parameter in 'which.par.opt': parameter = dpar * prior (e.g. if dpar is 1, prior parameters are used in the model run). Optimization is performed on these scaling factors + + lpjpar, + ### data.frame of class \code{\link{LPJpar}} that define LPJ parameter values, ranges, and names + + which.par.opt, + ### integer vector that indicates which parameters in lpjpar should be optimized + + lpjfiles, + ### list of class \code{\link{LPJfiles}} that define all LPJ directories, input files, configuration template files + + path=NULL, + ### path for output files of actual model run + + integrationdata, + ### list of of class \code{\link{IntegrationData}} + + xy, + ### matrix of grid cell coordinates to run LPJ + + newcell=FALSE, + ### calculate new cell and new spinup? + + name="LPJmL", + ### name of the LPJ run, basic name for all outputs + + lpjcmd = "srun ./bin/lpjml", + ### How you usually run the LPJ model at the console: 'srun ./bin/lpjml' or './bin/lpjml' + + plot=FALSE, + ### plot results? see \code{\link{plot.IntegrationData}} + + getresult=FALSE, + ### If TRUE, all model results are returned in a LPJsim object and model results are saved. If FALSE, only the cost function value is returned. + + clean=1, + ### clean results and temporay configuration and parameter files? 0 = keep everthing; 1 = delete parameter files, conf files and outputs; 2 = clean additionally input files, soil code files and restart + + clean.path=FALSE, + ### Delete output directory 'path' in case it already exists before the model run? + + CostMDS = CostMDS.SSE, + ### cost function for multiple data streams + + nkeep = 400, + ### number of result files to keep. If more are existing, the ones with highest costs will be deleted + + warnings = TRUE + ### print all LPJmL warning messages during optimization? +) { + + # get LPJ cell number from coordinates + xy <- cbind(as.numeric(xy[,1]), as.numeric(xy[,2])) + grid.l <- GridProperties(lpjfiles) + cell <- extract(grid.l$grid, xy) - 1 + ncell <- length(cell) + cell.startend <- c(cell[1], cell[ncell]) + + + # check and scale parameters + #--------------------------- + + # scale parameters + lpjpar$new <- lpjpar$prior + lpjpar$new[which.par.opt] <- dpar * lpjpar$prior[which.par.opt] + lpjpar$new[lpjpar$is.int] <- round(lpjpar$new[lpjpar$is.int], 0) + names(lpjpar$new) <- lpjpar$names + + # proposed parameters outside allowed range? - return high cost + cost.l <- list(total=1e+20) + out.of.range <- ((lpjpar$new < lpjpar$lower) | (lpjpar$new > lpjpar$upper)) + bool <- is.na(out.of.range) + if (any(bool)) lpjpar$new[bool] <- lpjpar$prior[bool] + out.of.range <- ((lpjpar$new < lpjpar$lower) | (lpjpar$new > lpjpar$upper)) + + if (any(out.of.range)) { + message(paste("Parameter out of range:", lpjpar$names[out.of.range], "new =", signif(lpjpar$new[out.of.range], 5), "lower =", lpjpar$lower[out.of.range], "upper =", lpjpar$upper[out.of.range], "\n")) + } + + # check parameters - avoid parameter with 0 + lpjpar <- CheckLPJpar(lpjpar, correct=TRUE) + + + # prepare path and files + #----------------------- + + # create main output directory for grid cell and output directory for actual run + if (is.null(path)) { + path <- paste(getwd(), "/", name, "_OPTFILE_", cell.startend[1], "_", cell.startend[2], sep="") + } + path <- gsub("//", "/", path) + if (file.exists(path) & newcell & clean.path) system(paste("rm -rf", path)) + if (!file.exists(path)) dir.create(path) + + # create name for files and folders + idname <- unlist(strsplit(name, "")) + if (length(idname) > 10) idname <- idname[1:10] + idname <- paste(idname, collapse="") + # id <- paste(idname, "_OPTFILE_", cell.startend[1], "_", cell.startend[2], sep="") + id <- paste(idname, "_OPTFILE", sep="") + tmp <- paste(gsub(":", "-", gsub(" ", "_", as.character(Sys.time()))), "_", sep="") + tmp <- gsub("/", "", tempfile(tmp, tmpdir="")) + outpath.cell <- paste(path, tmp, sep="/") + outpath.cell <- gsub("//", "/", outpath.cell) + dir.create(outpath.cell) + + # create temporary file names for actual run + lpj.conf.file.cell <- paste(lpjfiles$path.lpj, "lpj_OPTFILE_", tmp, ".js", sep="") + lpj.parconf.file.cell <- paste(lpjfiles$path.lpj, "param_OPTFILE_", tmp, ".js", sep="") + lpj.par.pft.file.cell <- paste(lpjfiles$path.lpj, "par/pft_OPTFILE_", tmp, ".js", sep="") + lpj.par.file.cell <- paste(lpjfiles$path.lpj, "par/param_OPTFILE_", tmp, ".js", sep="") + + # create file names for run of same grid cell + restart.file.cell <- paste(path, "/restart_", id, ".bin", sep="") + lpj.soilcode.file.cell <- paste(path, "/soil_OPTFILE.bin", sep="") + lpj.input.file.cell <- paste(lpjfiles$path.lpj, "input_", id, ".conf", sep="") + + # set grid cell number in LPJ configuration file + names(cell.startend) <- c("CELL_START", "CELL_END") + setwd(lpjfiles$path.lpj) + file.tmp <- paste(outpath.cell, "temp.js", sep="/") + ChangeParamFile(cell.startend, lpjfiles$lpj.conf, file.tmp) + + # set file names in conf file + newfiles <- c(lpj.parconf.file.cell, outpath.cell, restart.file.cell, lpj.input.file.cell, lpjfiles$sim.start.year, lpjfiles$sim.end.year) + names(newfiles) <- c("CELL_PARCONF_FILE", "CELL_OUTPATH", "CELL_RESTART_FILE", "CELL_INPUT_FILE", "YEAR_START", "YEAR_END") + setwd(lpjfiles$path.lpj) + ChangeParamFile(newfiles, file.tmp, lpj.conf.file.cell, wait=TRUE) + file.remove(file.tmp) + + # write new parameters to LPJ parameter file: PFT-specific parameters + setwd(lpjfiles$path.lpj) + ChangeParamFile(lpjpar$new[lpjpar$pftspecif], lpjfiles$pft.par, lpj.par.pft.file.cell) + + # write new parameters to LPJ parameter file: global parameters + ChangeParamFile(lpjpar$new[!lpjpar$pftspecif], lpjfiles$param.par, lpj.par.file.cell) + + # set parameter file names in param.conf file + newfiles <- c("PAR_PFT_FILE_CELL"=lpj.par.pft.file.cell, "PAR_FILE_CELL"=lpj.par.file.cell) + ChangeParamFile(newfiles, lpjfiles$param.conf, lpj.parconf.file.cell) + + # in case of new grid cell: update LPJ conf file + if (newcell) { + # change soil code file: set cells that are not computed to 0 + file.soilcode <- as.character(unlist(lpjfiles$input$file[grep("SOILCODE_FILE", lpjfiles$input$name)])) + file.grid <- as.character(unlist(lpjfiles$input$file[grep("GRID_FILE", lpjfiles$input$name)])) + #ChangeSoilCodeFile(file.soilcode=file.soilcode, file.soilcode.new=lpj.soilcode.file.cell, xy, newcode=0, file.grid=file.grid) + file.copy(file.soilcode, lpj.soilcode.file.cell) + + # create input file + setwd(lpjfiles$path.lpj) + lpj.input.files.cell <- as.character(lpjfiles$input$file) + names(lpj.input.files.cell) <- as.character(lpjfiles$input$name) + ChangeParamFile(lpj.input.files.cell, lpjfiles$input.conf, lpj.input.file.cell) + } + system("sync") # force file writing + + # check if all LPJ configuration and parameter files are exiting + check <- FileExistsWait(c(lpj.input.file.cell, lpj.conf.file.cell, lpj.par.pft.file.cell, lpj.par.file.cell, lpj.parconf.file.cell, lpj.soilcode.file.cell), waitmin=0, waitmax=1) + if (any(!check)) { + message(paste("FILEWARNING: LPJ configuration files were not written for cell", cell.startend[1], "-", cell.startend[2]), "Return cost=NA") + return(NA) + } + + + # make model runs + #---------------- + + if (!any(out.of.range)) { + + + # spinup model run + #----------------- + + lpjroot <- paste("export LPJROOT=", lpjfiles$path.lpj, sep="") + system(lpjroot) + + check <- file.exists(restart.file.cell) + if (newcell) { + system("sync") + i <- 1 + while (any(!check) & i <= 2) { # try to repeat spinup model run (maximum 2 times) if restart file was not written + lpj1 <- paste("./bin/lpjcheck >", paste0(id, "_lpjcheck.txt"), "-param", lpj.conf.file.cell) + lpj2 <- paste(lpjcmd, ">", paste0(id, "_lpjspinup.txt"), lpj.conf.file.cell) + setwd(as.character(lpjfiles$path.lpj)) + system(lpj1, intern=!warnings, ignore.stdout=!warnings) + lpj.spinup <- system(lpj2, intern=!warnings, ignore.stdout=!warnings) + check <- FileExistsWait(restart.file.cell, waitmin=0, waitmax=2) + i <- i + 1 + } + if (any(!check)) { + message(paste("FILEWARNING: LPJ restart file was not written after 2 spinup model runs for cell ", cell.startend[1], "-", cell.startend[2]), ". Return cost=NA", sep="") + return(NA) + } + } + + + # transient model run + #-------------------- + + check <- FALSE + i <- 1 + while (any(!check) & i <= 2) { # try to repeat transient model run (maximum 2 times) if output files were not written + lpj <- paste(lpjcmd, ">", paste0(id, "_lpjrun.txt"), "-DFROM_RESTART", lpj.conf.file.cell) + setwd(as.character(lpjfiles$path.lpj)) + lpj.trans <- system(lpj, intern=!warnings, ignore.stdout=!warnings) + system("sync") + setwd(outpath.cell) + files.out <- llply(integrationdata, function(ds) { + if (!is.function(ds$model.val.file)) return(ds$model.val.file) + return(NA) + }) + check <- FileExistsWait(c(na.omit(unlist(files.out)), "grid.bin"), waitmin=0, waitmax=2) + i <- i + 1 + } + + + # read model results, plot model vs. data and compute cost + #--------------------------------------------------------- + + # return warnings or error message if LPJ output files don't exist + if (any(!check)) { + # # remove results for actual run + # setwd(as.character(lpjfiles$path.lpj)) + # file.remove(lpj.conf.file.cell, lpj.parconf.file.cell, lpj.par.pft.file.cell, lpj.par.file.cell) + # system(paste("rm -r", outpath.cell)) + + # save parameters + setwd(as.character(lpjfiles$path.lpj)) + save(lpjpar, file=paste(id, "_lpjpar_with-error.RData", sep="")) + message(paste("You might check this file: ", paste(id, "_lpjpar_with-error.RData", sep=""), sep="")) + + # return high cost in case files don't exist + if (!getresult) { + message(paste("LPJ output files don't exists. Return cost =", unlist(cost.l$total), sep="")) + return(unlist(cost.l$total)) + } else { + stop("RunLPJ: LPJ output files don't exists.") + } + } + + # add model outputs to 'IntegrationData' + setwd(outpath.cell) + integrationdata <- ReadLPJ2IntegrationData(integrationdata, xy, lpjfiles) + + # calculate cost + cost.l <- CostMDS(integrationdata) + + # plot comparison model-data + if (plot) plot(integrationdata, CostMDS=CostMDS) + + # make list if model results should be returned + if (getresult) { + # save all outputs + path.save <- NULL + if (!is.null(lpjfiles$path.rescue)) { + setwd(outpath.cell) + files.out <- list.files() + # path.save <- tempfile("output_", tmpdir=lpjfiles$path.rescue) + path.save <- paste(lpjfiles$path.rescue, paste0("output_", round(cost.l$total, 12)), sep="/") + dir.create(path.save) + system(paste("cp", paste(files.out, collapse=" "), path.save)) + } + + # get model results for observation period + setwd(outpath.cell) + years <- unique(unlist(llply(integrationdata, function(ds) format(ds$data.time, "%Y")))) + + start <- max(c(min(as.numeric(years)), lpjfiles$sim.start.year), na.rm=TRUE) + end <- min(c(max(as.numeric(years)), lpjfiles$sim.end.year), na.rm=TRUE) + result.lpj <- ReadLPJsim(start=start, end=end, sim.start.year=lpjfiles$sim.start.year) + result.lpj$cost <- cost.l + result.lpj$integrationdata <- integrationdata + result.lpj$dpar <- dpar + result.lpj$output <- path.save + + setwd(path.save) + save(result.lpj, file="result.lpj.RData") + } + + + # save rescue and result files for cost and parameter values + #----------------------------------------------------------- + + path.rescue <- unlist(lpjfiles$path.rescue) + if (!is.null(path.rescue)) { + if (!file.exists(path.rescue)) dir.create(path.rescue) + + + # save and clean rescue files + #---------------------------- + + # save rescue file + setwd(path.rescue) + file.rescue <- paste(gsub(":", "-", gsub(" ", "_", as.character(Sys.time()))), "_", sep="") + file.rescue <- gsub("//", "/", tempfile(file.rescue, tmpdir=path.rescue, "_rescue0.RData")) + names(dpar) <- as.character(lpjpar$names[which.par.opt]) + rescue.l <- list(list(cost=cost.l, dpar=dpar)) + save(rescue.l, file=file.rescue) + + # combine rescue files if already many are exisiting and delete single files + files.rescue <- list.files(pattern="_rescue0.RData") + if (length(files.rescue) > 100) { + rescue.l <- CombineRescueFiles(files.rescue) + } + + + # save and clean result files + #---------------------------- + + # save result of iteration + setwd(path.rescue) + file.new <- paste0("cost_", round(cost.l$total, 12), "_result.RData") # new result file with cost in file name + + files.result <- list.files(pattern="_result.RData") # existing result files + files.cost <- as.numeric(unlist(llply(strsplit(files.result, "_"), function(s) s[length(s)-1]))) # get cost + files.result <- files.result[order(files.cost)] # existing result files, sort from lowest to highest cost + files.cost <- files.cost[order(files.cost)] + nfiles <- length(files.result) + save.result <- TRUE + + # check if result files should be cleaned-up + if (nfiles > nkeep) { # keep only N best + file.remove(files.result[(nkeep+1):nfiles]) + if (cost.l$total > files.cost[1]) save.result <- FALSE # don't save if actual cost is larger than best + } + + # save result + if (save.result) { + result.l <- list(cost=cost.l, dpar=dpar, integrationdata=integrationdata) + save(result.l, file=file.new) + } + } # end if path.rescue + + } # end if out.of.range + + + # clean temporary files and folders + #---------------------------------- + + # delete all files and results? + if (clean == 1) { # remove temporary files and folders for actual run + setwd(as.character(lpjfiles$path.lpj)) + file.remove(lpj.conf.file.cell, lpj.parconf.file.cell, lpj.par.pft.file.cell, lpj.par.file.cell) + system(paste("rm -r", outpath.cell)) + } + if (clean == 2) { # remove everthing + setwd(as.character(lpjfiles$path.lpj)) + file.remove(lpj.conf.file.cell, lpj.parconf.file.cell, lpj.par.pft.file.cell, restart.file.cell, lpj.input.file.cell,lpj.soilcode.file.cell) + system(paste("rm -r", path)) + } + + + # return results or total cost + #----------------------------- + + # return model results + if (getresult) return(result.lpj) + + # return total cost + cost <- unlist(cost.l$total) + return(cost) +}) diff --git a/LPJmLmdi/R/SSE.R b/LPJmLmdi/R/SSE.R new file mode 100644 index 0000000..5fd70e0 --- /dev/null +++ b/LPJmLmdi/R/SSE.R @@ -0,0 +1,33 @@ +SSE <- structure(function( + ##title<< + ## Sum-of-squared residuals error + ##description<< + ## The function implements the sum-of-squared residuals error as cost function + + sim, + ### vector of simulations + + obs, + ### vector of observations + + unc + ### vector of observation uncertainties + + ##details<< + ## No details. + + ##references<< No reference. +) { + b <- is.na(obs) | is.na(unc) + sim[b] <- NA + unc[unc == 0] <- NA + sum( (sim - obs)^2 / (unc^2), na.rm=TRUE) + +}, ex=function() { + +obs <- rnorm(10, 0, 2) +sim <- obs + rnorm(10, 0.05, 0.01) +unc <- 0.01 +SSE(sim, obs, unc) + +}) \ No newline at end of file diff --git a/LPJmLmdi/R/StandardError.R b/LPJmLmdi/R/StandardError.R new file mode 100644 index 0000000..d81488c --- /dev/null +++ b/LPJmLmdi/R/StandardError.R @@ -0,0 +1,24 @@ +StandardError <- structure(function( + ##title<< + ## Compute standard errors from a variance-covariance matrix + ##description<< + ## SE = sqrt(diag(vc) * cost^2 / (nobs - npar)) + + vc, + ### variance-covariance matrix + + nobs, + ### number of observations + + cost + ### cost function value + + ##details<< + ## No details. + + ##references<< No reference. +) { + npar <- nrow(vc) + s2 <- cost^2 / (nobs - npar) + sqrt(diag(vc) * s2) # standard errors +}) \ No newline at end of file diff --git a/LPJmLmdi/R/StartingValues.R b/LPJmLmdi/R/StartingValues.R new file mode 100644 index 0000000..b9bf397 --- /dev/null +++ b/LPJmLmdi/R/StartingValues.R @@ -0,0 +1,52 @@ +StartingValues <- structure(function( + ##title<< + ## Get starting values for genoud from *.pro file + ##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. + + file.optresult, + ### genoud *.pro file with optimization results + + pop.size=NULL, + ### population size + + ... + ### further arguments (not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{OptimizeLPJgenoud}} +) { + + # read previous optimization results + optim.df <- ReadPRO(file.optresult) + niter <- nrow(optim.df) + + # pop.size + if (is.null(pop.size)) { + pop.size <- min(c(20, nrow(optim.df))) + } + + # best individual from previous optimization + cost <- optim.df[,2] + best <- which.min(cost)[1] + dpar.best <- as.vector(unlist(optim.df[best, 3:ncol(optim.df)])) + + # sample from best individuals + cost.trs <- quantile(cost, 0.1) # threshold of best + optim.best.df <- optim.df[cost <= cost.trs, ] + size <- min(c(20, pop.size, nrow(optim.best.df))) + dpar.other <- optim.best.df[sample(1:nrow(optim.best.df), size), 3:ncol(optim.best.df)] + + # median of best individuals + dpar.med <- apply(optim.best.df[,3:ncol(optim.best.df)], 2, median) + + # parameter vectors to be introduced to genoud: best, some other best, median of best + starting.values <- list(start=as.matrix(rbind(dpar.best, dpar.other, dpar.med)), niter=niter) + return(starting.values) +}) + diff --git a/LPJmLmdi/R/Texture2Soilcode.R b/LPJmLmdi/R/Texture2Soilcode.R new file mode 100644 index 0000000..f8c392f --- /dev/null +++ b/LPJmLmdi/R/Texture2Soilcode.R @@ -0,0 +1,53 @@ +Texture2Soilcode <- structure(function( + ##title<< + ## Convert soil texture to a LPJ soilcode + ##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". + + sand, + ### percentage of sand + + silt, + ### percentage of silt + + clay, + ### percentage of clay + + lpj.soilcodes = c("Cl", "SiCl", "SaCl", "ClLo", "SiClLo", "SaClLo", "Lo", "SiLo", "SaLo", "Si", "LoSa", "Sa"), + ### LPJ soil codes + + plot=TRUE, + ### plot soil triangle? + + ... + ### Further arguments (currently not used). + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadBIN}} + +) { + # soil type + require(soiltexture) + texture <- data.frame(CLAY=clay, SILT=silt, SAND=sand) + texture <- texture / rowSums(texture) * 100 + + # get soil type of the side + if (plot) TT.plot(class.sys = "USDA.TT", tri.data=texture, col="red") + soil.type <- TT.points.in.classes(texture, class.sys = "USDA.TT") + soil.type + + # LPJ soil code + soilcode <- match(colnames(soil.type)[apply(soil.type, 1, which.max)], lpj.soilcodes) + return(soilcode) + ### The function returns the LPJ soilcode +}, ex=function(){ + +# data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) +# WriteBIN(data.sp, file="data.bin") + +}) diff --git a/LPJmLmdi/R/Turnover.R b/LPJmLmdi/R/Turnover.R new file mode 100644 index 0000000..455903f --- /dev/null +++ b/LPJmLmdi/R/Turnover.R @@ -0,0 +1,28 @@ +Turnover <- structure(function( + ##title<< + ## Calculate turnover time from stock and flux + ##description<< + ## Calculates turnover times. + + stock, + ### stock, e.g. biomass + + flux, + ### flux, e.g. NPP + + ... + ### further arguments (currently not used) + + ##details<< + ## turnover = stock / flux + + ##references<< No reference. +) { + if (length(stock) == 1) { + tau <- stock / flux + } else { + dstock <- c(NA, diff(stock)) + tau <- - stock / (dstock - flux) + } + return(tau) +}) diff --git a/LPJmLmdi/R/VarCovMatrix.R b/LPJmLmdi/R/VarCovMatrix.R new file mode 100644 index 0000000..a119715 --- /dev/null +++ b/LPJmLmdi/R/VarCovMatrix.R @@ -0,0 +1,67 @@ +VarCovMatrix <- structure(function( + ##title<< + ## Compute variance-covariance matrix + ##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. + + hessian, + ### Hessian matrix + + nms=paste("P", 1:n, sep="") + ### names of the parameters (rows and columns in the matrix + + ##details<< + ## No details. + + ##references<< No reference. +) { + + n <- ncol(hessian) + result <- matrix(NA, ncol=n, nrow=n) + colnames(result) <- nms + rownames(result) <- nms + dimnames(hessian) <- list(nms, nms) + + if (any(is.na(hessian))) return(result) + + # compute uncertainty if matrix is invertable + rem <- NULL + issingular <- FALSE + if (det(hessian) == 0) { # check if determinant is 0 + issingular <- TRUE # matrix is singular + + # check if any diagonal element is 0 / remove these rows and columns + isnull <- (diag(hessian) == 0) + if (any(isnull)) { + rem <- (1:ncol(hessian))[isnull] + hessian <- hessian[-rem, -rem] + if (!is.matrix(hessian)) hessian <- matrix(hessian) + if (det(hessian) != 0) issingular <- FALSE + } + } + + # invert matrix and compute standard error + if (!issingular) { + # function to invert hessian and compute standard errors + f <- function(hessian) { + vc <- qr.solve(hessian) # variance-covariance matrix + colnames(vc) <- colnames(hessian) + rownames(vc) <- colnames(hessian) + return(vc) + } + + vc <- tryCatch({ + f(hessian) + }, warning = function(w) { + f(hessian) + }, error = function(e) { + warning("Hessian cannot be inverted.") + return(result) + }, finally = function(x) { + return(result) + }) + pos <- match(colnames(vc), colnames(result)) + result[pos, pos] <- vc + } + return(result) +}) \ No newline at end of file diff --git a/LPJmLmdi/R/WriteBIN.R b/LPJmLmdi/R/WriteBIN.R new file mode 100644 index 0000000..091c959 --- /dev/null +++ b/LPJmLmdi/R/WriteBIN.R @@ -0,0 +1,44 @@ +WriteBIN <- structure(function( + ##title<< + ## Write a BIN file from SpatialPointsDataFrame + ##description<< + ## The function writes BIN files from a SpatialPointsDataFrame or SpatialPixelsDataFrame. + + data.sp, + ### SpatialPointsDataFrame or SpatialPixelsDataFrame with data + + file.bin, + ### binary file name with extension *.bin + + size=1, + ### The number of bytes per element in the byte stream. + + ... + ### Further arguments (currently not used). + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadBIN}} + +) { + # write binary file + con <- file(file.bin, "wb") + writeBin(as.integer(unlist(data.sp@data)), file.bin, size=size) + close(con) + + # write grid + file.grid <- gsub(".bin", ".grid", file.bin) + WriteGrid(coordinates(data.sp), file.grid=file.grid) + + return(file.exists(file.bin)) + ### The function returns TRUE if the CLM file was created. +}, ex=function(){ + +# data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) +# WriteBIN(data.sp, file="data.bin") + +}) diff --git a/LPJmLmdi/R/WriteCLM.R b/LPJmLmdi/R/WriteCLM.R new file mode 100644 index 0000000..31ec6c5 --- /dev/null +++ b/LPJmLmdi/R/WriteCLM.R @@ -0,0 +1,130 @@ +WriteCLM <- structure(function( + ##title<< + ## Write a CLM file from SpatialPointsDataFrame + ##description<< + ## The function writes CLM files from a SpatialPointsDataFrame or SpatialPixelsDataFrame. The LPJmL program cru2clm needs to be installed. + + data.sp, + ### SpatialPointsDataFrame or SpatialPixelsDataFrame with data + + file.clm, + ### CLM file name with extension *.clm + + start, + ### integer. First year in data. + + nbands, + ### Number of bands per year. + + size=2, + ### The number of bytes per element in the byte stream. + + scale=1, + ### Scaling factor to be written to the header of the CLM file. The factor will be not applied to the data. + + na.replace=-9999, + ### integer to replace NA values. + + path.lpj=NULL, + ### path to LPJ installation + + res=0.5, + ### spatial resolution of the grid cells + + ... + ### Further arguments (currently not used). + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{WriteLPJinput}} + +) { + + # check spatial temporal resolution + coord <- coordinates(data.sp) + ncell <- nrow(coord) + data <- data.sp@data + if (res != 0.5 & res != 0.25) stop(paste("res =", res, "is not supported from WriteCLM.R and lpj/src/utils/cru2clm*")) + if (nbands != 12 & nbands != 365 & nbands != 1) stop(paste("nbands =", nbands, "is not supported from WriteCLM.R and lpj/src/utils/cru2clm*")) + + # create directory + wd0 <- getwd() + s <- unlist(strsplit(file.clm, "/")) + if (length(s) > 1) { + path <- paste(s[-length(s)], collapse="/") + if (!file.exists(path)) dir.create(path, recursive=TRUE) + setwd(path) + file.clm <- s[length(s)] + } + file.cru <- gsub(".clm", ".cru", file.clm) + + # if pixel px to write is NA, write all pixels + px <- 1:ncell + + # create vectors of years and of bands in years + nyear <- ncol(data) / nbands + + # write binary *.cru file + con <- file(file.cru, "wb") + data.y <- as.matrix(data.sp@data) + data.y <- as.vector(t(data.y)) + data.y[is.na(data.y)] <- na.replace + if (size == 2) data.y[data.y > 32767] <- 32766 # set to maximum possible value if size==2 + data.y <- as.integer(round(data.y, 0)) + writeBin(data.y, con, size=size) + close(con) + + # convert binary file to clm file + cmd0 <- "" + if (!is.null(path.lpj)) cmd0 <- paste0(path.lpj, "/bin/") + cmd1 <- paste0(cmd0, "cru2clm") + #if (res == 0.5 & nbands == 365) cmd1 <- paste0(cmd0, "cru2clm_0d50_daily") + #if (res == 0.25 & nbands == 12) cmd1 <- paste0(cmd0, "cru2clm_0d25_monthly") + #if (res == 0.25 & nbands == 365) cmd1 <- paste0(cmd0, "cru2clm_0d25_daily") + + cmd1 <- paste(cmd1, paste("-firstyear", start, "-nyear", nyear, "-nbands", nbands, "-ncell", ncell, "-scale", scale, file.cru, file.clm)) + cmd1 <- gsub("//", "/", cmd1) + system(cmd1) # runs only on unix system with compiled LPJ code + + cmd1 <- paste0(cmd0, paste("setclm order 1", file.clm)) + cmd1 <- gsub("//", "/", cmd1) + system(cmd1) # runs only on unix system with compiled LPJ code + + cmd1 <- paste0(cmd0, paste("setclm ncell", ncell, file.clm)) + cmd1 <- gsub("//", "/", cmd1) + system(cmd1) # runs only on unix system with compiled LPJ code + + # check CLM file + cmd1 <- paste0(cmd0, paste("printclm -data", file.clm, ">", gsub(".clm", ".check.txt", file.clm))) + cmd1 <- gsub("//", "/", cmd1) + system(cmd1) + + # delete cru file + file.remove(file.cru) + + # write grid + WriteGrid(coord, file.grid=paste0(file.clm, ".grid")) + + # x <- ReadCLM(file.clm) + # plot(raster(x, 1)) + + return(file.exists(file.clm)) + ### The function returns TRUE if the CLM file was created. +}, ex=function(){ + +# data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) +# WriteCLM(data.sp, file="data.clm", start=1901, nbands=12, size=2) + +}) + + + + + + + + diff --git a/LPJmLmdi/R/WriteGrid.R b/LPJmLmdi/R/WriteGrid.R new file mode 100644 index 0000000..41b344e --- /dev/null +++ b/LPJmLmdi/R/WriteGrid.R @@ -0,0 +1,53 @@ +WriteGrid <- structure(function( + ##title<< + ## Write a *.grid file from a matrix of coordiantes or a SpatialPointsDataFrame + ##description<< + ## Writes a grid file for LPJ input data. The functions needs the LPJmL module txt2grid to be installed. + + grid, + ### SpatialPointsDataFrame; SpatialPixelsDataFrame, matrix or data.frame with coordinates + + file.grid, + ### Grid file name + + ... + ### Further arguments (currently not used). + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{WriteLPJinput}} + +) { + + if (!is.matrix(grid) | !is.data.frame(grid)) grid <- coordinates(grid) + file.grid.txt <- paste0(file.grid, ".txt") + + # write grid as txt file + grid.df <- data.frame(Id=1:nrow(grid), Lon=grid[,1], Lat=grid[,2]) + write.table(grid.df, file=file.grid.txt, sep=",", row.names=FALSE) + + # write grid as binary file + cmd <- paste("txt2grid", file.grid.txt, file.grid) + system(cmd) + file.remove(file.grid.txt) + return(file.exists(file.grid)) + ### The function returns TRUE if the grid file was created. +}, ex=function(){ + +lon <- c(59.75, 68.25) +lat <- c(61.25, 65.75) +WriteGrid(cbind(lon, lat), "test.grid") + +}) + + + + + + + + diff --git a/LPJmLmdi/R/WriteLPJinput.R b/LPJmLmdi/R/WriteLPJinput.R new file mode 100644 index 0000000..7ddd0de --- /dev/null +++ b/LPJmLmdi/R/WriteLPJinput.R @@ -0,0 +1,63 @@ +WriteLPJinput <- structure(function( + ##title<< + ## Write an object of class 'LPJinput' to CLM files + ##description<< + ## The function writes CLM input files for LPJ. + + lpjinput, + ### Object of class 'LPJinput' to be written. + + files=NULL, + ### names of the output CLM or binary files. + + path.lpj=NULL, + ### path to LPJ installation + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{WriteLPJinput}} + +) { + + # loop over datasets + ndata <- length(lpjinput$data) + res <- rep(FALSE, ndata) + for (i in 1:ndata) { + + # get data information + data.m <- lpjinput$data[[i]]$data + nbands <- lpjinput$data[[i]]$nbands + firstyear <- lpjinput$data[[i]]$firstyear + fmt <- lpjinput$data[[i]]$fmt + file.clm <- NULL + if (is.null(file.clm)) file.clm <- files[i] + if (is.null(file.clm)) file.clm <- lpjinput$data[[i]]$file.new + if (is.null(file.clm)) stop("Provide file name for the output files.") + + # convert data to SpatialPointsDataFrame + data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) + + # write CLM file and grid file + if (fmt == "clm") { + res[i] <- WriteCLM(data.sp, file.clm=file.clm, start=firstyear, nbands=nbands, size=2, path.lpj=path.lpj) + } else if (fmt == "bin") { + res[i] <- WriteBIN(data.sp, file.bin=file.clm, nbands=nbands, size=1, path.lpj=path.lpj) + } + } + + return(res) + ### The function returns TRUE if the CLM file was created. +}, ex=function() { + +# 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))) +# str(lpjinput) +# WriteLPJinput(lpjinput) + +}) diff --git a/LPJmLmdi/R/WriteLPJpar.R b/LPJmLmdi/R/WriteLPJpar.R new file mode 100644 index 0000000..514efea --- /dev/null +++ b/LPJmLmdi/R/WriteLPJpar.R @@ -0,0 +1,147 @@ +WriteLPJpar <- structure(function( + ##title<< + ## Writes an object of class 'LPJpar' as parameter file or table. + ##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. + + x, + ### object of class 'LPJpar' + + file = "LPJpar", + ### basic file name for all output files, e.g. name of the optimization experiment + + pft.par=NULL, + ### template file for PFT-specific parameters (create a template from pft.par). If NULL, parameter files will be not written but only parameter tables. + + param.par=NULL, + ### template file for global parameters (create a template from param.par). If NULL, parameter files will be not written but only parameter tables. + + param.only=TRUE, + ### write only parameters to table (TRUE) or also parameter prior ranges (FALSE)? + + ... + ### further arguments for CheckLPJpar + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{LPJpar}}, \code{\link{CheckLPJpar}} +) { + + file.pftpar.prior <- file.pftpar.best <- file.pftpar.median <- file.parampar.prior <- file.parampar.best <- file.parampar.median <- file.tab.prior <- file.tab.best <- file.tab.median <- NA + has.best <- !is.null(x$best) + has.median <- !is.null(x$best.median) + + + # write PFT-specific parameter files + #----------------------------------- + + if (!is.null(pft.par)) { + + # prior parameter + file.pftpar.prior <- paste0(file, "_prior_pft.js") + ChangeParamFile(x$prior, pft.par, file.pftpar.prior) + + # posterior best + if (has.best) { + file.pftpar.best <- paste0(file, "_best_pft.js") + ChangeParamFile(x$best, pft.par, file.pftpar.best) + } + + # posterior best median + if (has.median) { + file.pftpar.median <- paste0(file, "_median_pft.js") + ChangeParamFile(x$best.median, pft.par, file.pftpar.median) + } + } + + + # write global parameter files + #----------------------------- + + if (!is.null(param.par)) { + + # prior parameter + file.parampar.prior <- paste0(file, "_prior_param.js") + ChangeParamFile(x$prior[!x$pftspecif], param.par, file.parampar.prior) + + # posterior best + if (has.best) { + file.parampar.best <- paste0(file, "_best_param.js") + ChangeParamFile(x$best[!x$pftspecif], param.par, file.parampar.best) + } + + # posterior best median + if (has.median) { + file.parampar.median <- paste0(file, "_median_param.js") + ChangeParamFile(x$best.median[!x$pftspecif], param.par, file.parampar.median) + } + } + + + # write parameter tables + #----------------------- + + # get unique PFT names + txt.l <- strsplit(as.character(x$names[x$pftspecif]), "_") + pfts <- c(unique(unlist(llply(txt.l, function(txt) txt[length(txt)]))), "global") + + # get unique parameter names + params <- unique(x$names) + for (i in 1:length(pfts)) params <- gsub(paste("_", pfts[i], sep=""), "", params) + params <- unique(params) + + # initialize table + table.prior.df <- table.best.df <- table.median.df <- data.frame(parameter=params, matrix(NA, ncol=length(pfts), nrow=length(params))) + colnames(table.prior.df) <- colnames(table.best.df) <- colnames(table.median.df) <- c("parameter", as.character(pfts)) + + # fill table with parameter values + for (i in 1:length(x$names)) { + # get parameter and name of the PFT + param <- as.character(x$names[i]) + param <- unlist(strsplit(param, "_")) + if (length(param) > 1) { + pft <- param[length(param)] + param <- param[-length(param)] + param <- paste(param, collapse="_") + prior <- x$prior[i] + if (has.best) best <- x$best[i] + if (has.median) med <- x$best.median[i] + prior.rge <- paste("(", paste(signif(c(x$lower[i], x$upper[i]), 3), collapse="-"), ")", sep="") + if (!param.only) { + prior <- paste(as.character(signif(prior, 3)), prior.rge) + # best <- paste(as.character(signif(best, 3)), rge) + } + } else { + pft <- "global" + } + + # copy parameter value into table + table.prior.df[grep(param, table.prior.df$parameter), grep(pft, colnames(table.prior.df))] <- round(prior, 3) + if (has.best) table.best.df[grep(param, table.best.df$parameter), grep(pft, colnames(table.best.df))] <- round(best, 3) + if (has.median) table.median.df[grep(param, table.median.df$parameter), grep(pft, colnames(table.median.df))] <- round(med, 3) + } + + file.tab.prior <- paste0(file, "_table_prior.txt") + write.table(table.prior.df, file=file.tab.prior, row.names=FALSE) + if (has.best) { + file.tab.best <- paste0(file, "_table_best.txt") + write.table(table.best.df, file=file.tab.best, row.names=FALSE) + } + if (has.median) { + file.tab.median <- paste0(file, "_table_median.txt") + write.table(table.median.df, file=file.tab.median, row.names=FALSE) + } + + result <- data.frame( + file = c(file.pftpar.prior, file.pftpar.best, file.pftpar.median, file.parampar.prior, file.parampar.best, file.parampar.median, file.tab.prior, file.tab.best, file.tab.median), + description = c("LPJmL PFT prior parameter file", "LPJmL PFT best posterior parameter file", "LPJmL PFT median of best posterior parameter file", "LPJmL global prior parameter file", "LPJmL global best posterior parameter file", "LPJmL global median of best posterior parameter file", "Prior parameter table", "Best posterior parameter table", "Median of best posterior parameter table")) + result <- na.omit(result) + return(result) + ### The function returns a data.frame with an overview of the written files +}) + + diff --git a/LPJmLmdi/R/WriteNCDF4.R b/LPJmLmdi/R/WriteNCDF4.R new file mode 100644 index 0000000..40ef4f5 --- /dev/null +++ b/LPJmLmdi/R/WriteNCDF4.R @@ -0,0 +1,178 @@ +WriteNCDF4 <- structure(function( + ##title<< + ## Write NetCDF files + + ##description<< + ## Writes NetCDF files from rasters and makes sure that meta-information is properly defined. + + data.l, + ### a single Raster* object or a list of Raster* objects + + var.name, + ### vector of variable names + + var.unit, + ### vector of variable units + + time=as.Date("2000-01-01"), + ### vector of time steps for each layer. + + var.description=var.name, + ### vector of variable descriptions + + file=NULL, + ### file name. If NULL the file name will be created from the variable name and the dimensions of the data. + + data.name=NA, + ### name of the dataset + + region.name=NA, + ### name of the region + + file.title=var.name, + ### title of the file + + file.description=var.name, + ### description of the file + + reference="", + ### reference for the dataset + + provider="", + ### dataset provider + + creator="", + ### dataset creator + + missval=-9999, + ### flag for missing/NA values + + scale=1, + ### scaling values for the data + + offset=0, + ### offset value + + compression=9, + ### 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. + + overwrite=FALSE + ### overwrite existing file? + + ##details<< + ## + + ##references<< + ## + + ##seealso<< + ## +) { + + # check parameters + if (is.null(data.l)) stop("Provide a list of Raster* object") + if (is.null(var.name)) stop("Define 'var.name'") + if (is.null(var.unit)) stop("Define 'var.unit'") + + # conver raster brick + rb2l <- function(rb) { + l <- vector("list") + for (i in 1:nlayers(rb)) l[[i]] <- raster(rb, i) + return(l) + } + if (length(var.name) > 1 & class(data.l) == "RasterBrick") { + data.l <- rb2l(data.l) + } + + if (class(data.l) != "list") data.l <- list(data.l) + + # check time + if (!is.null(time)) { + if ((class(time) == "Date") | (class(time) == "POSIXct") | (class(time) == "POSIXlt") ) { + start <- try(format(time[1], "%Y"), TRUE) + if (class(start) == "try-error") start <- time[1] + end <- try(format(time[length(time)], "%Y"), TRUE) + if (class(end) == "try-error") end <- time[length(time)] + timestep <- diff(time) + if (length(timestep) == 0) { + timestep <- 0 + time2 <- time + } else { + timestep <- gsub(" ", "", format(mean(timestep), digits=1)) + time2 <- try(difftime(time, as.POSIXct(ISOdatetime(1582,10,14,0,0,0)), units="days"), TRUE) + } + if (class(time2) == "try-error") time2 <- time + } else { + stop("time should be of class Date, POSIXct or POSIXlt.") + } + } else { + stop("Define time axis 'time'.") + } + + # define dimensions for NetCDF + xy <- xyFromCell(data.l[[1]], 1:ncell(data.l[[1]])) + dlon <- ncdim_def("longitude", "degrees_east", unique(xy[, 1])) + dlat <- ncdim_def("latitude", "degrees_north", unique(xy[, 2])) + rdate <- as.numeric(time - as.Date("1582-10-14")) + dtime <- ncdim_def("time", "days since 1582-10-14 00:00:00", rdate, unlim = TRUE) + + if (length(missval) < length(data.l)) missval <- rep(missval, length(data.l)) + + # define variables + ncvars.l <- llply(as.list(1:length(data.l)), function(i) { + ncvar_def(name=var.name[i], units=var.unit[i], dim=list(dlon, dlat, dtime), missval=missval[i], longname=var.description[i], compression=compression) + }) + + # create file name and check if file exists + if (is.null(file)) { + nme <- var.name + if (length(var.name) > 1) nme <- nme[1] + file <- paste(data.name, nme, nrow(data.l[[1]]), ncol(data.l[[1]]), region.name, start, end, timestep, "nc", sep=".") + file <- gsub("NA.", "", file, fixed=TRUE) + } + if (file.exists(file) & (overwrite == FALSE)) stop("File 'file' already exists. Use overwrite=TRUE to overwrite it.") + + # create NetCDF + nc <- nc_create(file, ncvars.l) + + # write data and set attributes + if (length(scale) < length(data.l)) scale <- rep(scale[1], length(data.l)) + if (length(offset) < length(data.l)) offset <- rep(offset[1], length(data.l)) + llply(as.list(1:length(data.l)), function(id) { + file.tmp <- paste(tempfile(tmpdir=getwd()), ".grd", sep="") + + # add scale and offset to data + data <- data.l[[id]] + data[is.na(data)] <- missval[id] + if (scale[id] != 1 | offset[id] != 0) { + if (nlayers(data) > 5) { + data <- calc(data, function(x) { + x <- x * scale[id] + offset[id] + return(x) + }, file=file.tmp) + } else { + data <- data * scale[id] + offset[id] + } + } + ncvar_put(nc, var.name[id], values(data)) + suppressWarnings(file.remove(file.tmp)) + + # write variable-specific attributes to NetCDF file + ncatt_put(nc, var.name[id], "scale_factor", scale[id], "double") + ncatt_put(nc, var.name[id], "add_offset", offset[id], "double") + }) + + # set global attributes + ncatt_put(nc, 0, "title", as.character(file.title), "text") + ncatt_put(nc, 0, "description", as.character(file.description), "text") + history <- paste(Sys.time(), creator, ": file created from R function WriteNCDF4") + ncatt_put(nc, 0, "history", as.character(history), "text") + ncatt_put(nc, 0, "provided_by", as.character(provider), "text") + ncatt_put(nc, 0, "created_by", as.character(creator), "text") + ncatt_put(nc, 0, "reference", as.character(reference), "text") + + nc_close(nc) + return(file) +}) + + diff --git a/LPJmLmdi/R/plot.IntegrationData.R b/LPJmLmdi/R/plot.IntegrationData.R new file mode 100644 index 0000000..6bce542 --- /dev/null +++ b/LPJmLmdi/R/plot.IntegrationData.R @@ -0,0 +1,322 @@ +plot.IntegrationData <- structure(function( + ##title<< + ## Plot an object of class IntegrationData + ##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}}. + + x, + ### object of class \code{\link{IntegrationData}} + + ds=1:length(x), + ### Which data sets in x should be plotted (integer) + + CostMDS = CostMDS.SSE, + ### cost function for multiple data streams + + fits = "poly3", + ### Fitting methods that should be used for scatter plots, see \code{\link{MultiFit}} + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{IntegrationData}} + +) { + + + # internal function to plot maps + #------------------------------- + + .map <- function(val, title="") { + brks <- Breaks(val, n=7) + cols <- BreakColors(brks) + cols2 <- cols[findInterval(val, brks, all.inside=TRUE)] + .lim <- function(x, lon=TRUE) { + lim <- range(x) + d <- diff(lim) + lim[1] <- lim[1] - d * 0.3 + lim[2] <- lim[2] + d * 0.3 + if (lon & lim[1] < -180) lim[1] <- -180 + if (lon & lim[2] > 180) lim[2] <- 180 + if (!lon & lim[2] > 90) lim[2] <- 90 + if (!lon) lim[1] <- lim[1] - diff(lim) * 0.2 + lim + } + ylim.map <- .lim(xy[,2], lon=FALSE) + xlim.map <- .lim(xy[,1], lon=TRUE) + + # init map + plot(0, 1, type="n", xlab="Longitude (E)", ylab="Latitude (N)", ylim=ylim.map, xlim=xlim.map) + PlotWorld110(rivers=FALSE, lakes=FALSE, bg="grey", col=rep("darkgrey", 3), add=TRUE) + # mtext(title, 3, 0.2, font=2, cex=1.2) + + # add legend + x <- xlim.map + x[2] <- x[1] + diff(x) * 0.5 + y <- ylim.map + y[1] <- y[1] + diff(ylim.map) * 0.1 + y[2] <- y[1] + diff(ylim.map) * 0.12 + LegendBar(x, y, brks, cols, bg="white", col.txt="purple", cex.txt=0.8, title=title) + + # add values + points(xy, bg=cols2, pch=21) + box() + + } + + + # loop over data + #--------------- + + integrationdata <- x + par0 <- par() + has.sim <- is.matrix(integrationdata[[1]]$model.val) + if (has.sim) cost.l <- CostMDS(integrationdata) + for (d in ds) { + obs <- integrationdata[[d]]$data.val + has.cycle <- FALSE + if (!all(is.na(obs))) { + if (has.sim) { + sim <- integrationdata[[d]]$model.val + res <- sim - obs + } else { + sim <- res <- obs + sim[] <- NA + res[] <- NA + } + unc <- integrationdata[[d]]$data.unc + time.ds <- integrationdata[[d]]$data.time + name.ds <- integrationdata[[d]]$name + unit.ds <- integrationdata[[d]]$unit + xy <- integrationdata[[d]]$xy + + # limits for y-axis + ylim <- range(c(obs, sim), na.rm=TRUE) + d2 <- (ylim[2] - ylim[1]) * 0.2 + ylim[2] <- ylim[2] + d2 + ylim[1] <- ylim[1] - d2 + mn <- min(c(obs, sim), na.rm=TRUE) + if (mn >= 0 & ylim[1] < 0) ylim[1] <- 0 + + # is data stream a time series? + is.ts <- nrow(obs) > 1 + # if (nrow(obs) != length(time.ds)) is.ts <- FALSE + + # is a mean seasonal cycle? + tstep <- diff(time.ds)[1] + is.msc <- ((nrow(obs) == 12) & (tstep > 27 & tstep < 32)) | ((nrow(obs) == 365) & (tstep > 0.9 & tstep < 1.1)) + if (is.msc) is.ts <- TRUE + + # extract time series properties + if (is.ts) { + nyears <- as.numeric((max(time.ds) - min(time.ds))/365) + + if (is.msc) { + is.ts <- TRUE + time.txt <- time.ds <- time.pr <- cycl <- 1:12 + freq <- 12 + freq2 <- "month" + start <- c(1900, 1) + has.cycl <- TRUE + } else { + start <- as.numeric(c(format(time.ds[1], "%Y"), format(time.ds[1], "%j"))) + freq <- 1 + has.cycl <- FALSE + col.cycl <- "darkgray" + if (tstep > 27 & tstep < 32) { + freq <- 12 + has.cycl <- TRUE + } + if (tstep == 1) { + freq <- 365 + has.cycl <- TRUE + } + if (has.cycl) cycl <- as.integer(format(time.ds, "%m")) + } + if (has.cycl) { + col.cycl <- colorRampPalette(c("dodgerblue4", "green", "yellow", "darkorange3", "dodgerblue2")) + col.cycl <- col.cycl(12)[cycl] + } + + if (length(time.ds) != nrow(obs)) time.ds <- seq(min(time.ds), max(time.ds), length=nrow(obs)) + + # x-axis labels (time) + time.pr <- pretty(time.ds) + if (is.msc) time.pr <- 1:12 + if (!is.msc) { + if (nyears > 4) time.txt <- format(time.pr, "%Y") + if (nyears > 1.2 & nyears <= 4) time.txt <- format(time.pr, "%Y-%m") + if (nyears <= 1.2) time.txt <- format(time.pr, "%Y-%m-%d") + } + + } else { + col.cycl <- "darkgray" + } + + # has data multiple locations? + has.space <- ncol(obs) > 1 + + + # plot time series or map + #------------------------ + + DefaultParL(fig=c(0, 0.66, 0.66, 1), mar=c(2.5, 3.5, 1, 0.5), oma=c(0.5, 0.5, 1, 0.5), new=FALSE) + if (is.ts) { # plot time series + obs.med <- apply(obs, 1, median, na.rm=TRUE) + unc.med <- apply(unc, 1, median, na.rm=TRUE) + sim.med <- apply(sim, 1, median, na.rm=TRUE) + + type <- "l" + if (length(time.ds) < 15 & any(is.na(obs))) type <- "p" + + # plot all cells + matplot(time.ds, obs, col="lightblue", type=type, xaxt="n", lty=1, pch=16, ylim=ylim, xlab="", ylab=paste(name.ds, " (", unit.ds, ")", sep="")) + if (has.sim) matplot(time.ds, sim, col="orange", add=TRUE, lty=1, type="l") + + # add uncertainty only if !has.space + if (!has.space) { + matplot(time.ds, obs+unc, col="lightblue", add=TRUE, lty=1, type=type, pch=16) + matplot(time.ds, obs-unc, col="lightblue", add=TRUE, lty=1, type=type, pch=16) + } + + # add median + if (type == "l") lines(time.ds, obs.med, col="blue", lwd=2) + if (type == "p") points(time.ds, obs.med, col="blue", pch=16) + if (has.sim) lines(time.ds, sim.med, col="red", lwd=2) + axis(1, time.pr, time.txt) + legend("topleft", paste0(name.ds, c(".obs", ".sim")[c(TRUE, has.sim)]), lty=1, lwd=2, col=c("blue", "red"), bty="n") + } else { + if (has.space) { # plot map + par(c(3.8, 3.5, 0.5, 0.5), mar=c(3.8, 3.5, 0.5, 0.5)) + if (has.sim) { + .map(sim, paste(name.ds, ".sim (", unit.ds, ")", sep="")) + } else { + .map(obs, paste(name.ds, ".obs (", unit.ds, ")", sep="")) + } + } else { # plot nothing + plot.new() + } + } + mtext(name.ds, 3, line=-0.2, outer=TRUE, font=2, cex=1.5) + + + # plot boxplot + #------------- + + sim[is.na(obs)] <- NA + par(new=TRUE, fig=c(0.66, 1, 0.66, 1)) + boxplot(list(obs, sim), ylab=paste(name.ds, " (", unit.ds, ")", sep=""), ylim=ylim, names=c("Obs", "Sim"), col=c("blue", "red")) + boxplot(c(obs-unc, obs+unc), add=TRUE, border="lightblue", xaxt="n", yaxt="n", boxwex=0.6) + + + if (has.sim) { + + # plot residuals as time series or map + #------------------------------------- + + par(new=TRUE, fig=c(0, 0.66, 0.33, 0.66), mar=c(3.8, 3.5, 0.5, 0.5)) + if (is.ts) { # plot time series + res.med <- apply(sim, 1, mean, na.rm=TRUE) - apply(obs, 1, mean, na.rm=TRUE) + matplot(time.ds, res, col="darkgrey", type=type, pch=16, xaxt="n", lty=1, xlab="", ylab=paste(name.ds, ".res (", unit.ds, ")", sep="")) + abline(h=0) + lines(time.ds, res.med, col="black", lwd=2) + axis(1, time.pr, time.txt) + } else { + if (has.space) { # plot map + .map(res, paste(name.ds, ".res (", unit.ds, ")", sep="")) + } else { + barplot(res, xlab="", ylab=paste(name.ds, ".res (", unit.ds, ")", sep="")) + box() + } + } + + + # plot scatterplot + #----------------- + + par(new=TRUE, fig=c(0.66, 1, 0.33, 0.66)) + if (is.ts | has.space) { + ScatterPlot(as.vector(obs), as.vector(sim), xlim=ylim, ylim=ylim, xlab=paste(name.ds, ".obs (", unit.ds, ")", sep=""), ylab=paste(name.ds, ".sim (", unit.ds, ")", sep=""), col.global="black", col.points="grey", fits=fits, nrpoints=0) + abline(0,1) + } else { + plot.new() + } + obj <- ObjFct(as.vector(sim), as.vector(obs)) + if (is.ts | has.space) { + txt <- c(ObjFct2Text(obj, "Cor"), ObjFct2Text(obj, "MEF"), ObjFct2Text(obj, "RMSE"), paste("Cost =", signif(cost.l$per.ds[d]))) + } else { + txt <- c(ObjFct2Text(obj, "Pbias"), paste("Cost =", signif(cost.l$per.ds[d]))) + } + legend("topleft", txt, bty="n", cex=1, text.col="red") + + + # plot map of residuals + #---------------------- + + if (is.ts) { + obs.sp <- apply(obs, 2, mean, na.rm=TRUE) + sim.sp <- apply(sim, 2, mean, na.rm=TRUE) + res.sp <- sim.sp - obs.sp + par(new=TRUE, fig=c(0, 0.66, 0, 0.33)) + .map(res.sp, paste(name.ds, ".mean.res (", unit.ds, ")", sep="")) + + } # end is.ts + + + # plot residuals vs. latitude + #---------------------------- + + if (!is.ts & has.space) { + # vs. latitude + par(new=TRUE, fig=c(0, 0.33, 0, 0.33)) + ScatterPlot(xy[,2], as.vector(res), xlab="Latitude (N)", ylab=paste(name.ds, ".res (", unit.ds, ")", sep=""), col.global="black", col.points="grey", fits=fits, nrpoints=0) + abline(h=0) + if (!AllEqual(as.vector(xy[,2])) & !AllEqual(as.vector(res))) { + obj <- ObjFct(as.vector(res), as.vector(xy[,2]))$Cor + legend("topleft", paste("Cor =", signif(obj, 3)), bty="n", cex=1, text.col="red") + } + + # vs. longitude + par(new=TRUE, fig=c(0.33, 0.66, 0, 0.33)) + ScatterPlot(xy[,1], as.vector(res), xlab="Longitude (E)", ylab=paste(name.ds, ".res (", unit.ds, ")", sep=""), col.global="black", col.points="grey", fits=fits, nrpoints=0) + abline(h=0) + if (!AllEqual(as.vector(xy[,1])) & !AllEqual(as.vector(res))) { + obj <- ObjFct(as.vector(res), as.vector(xy[,1]))$Cor[1] + legend("topleft", paste("Cor =", signif(obj, 3)), bty="n", cex=1, text.col="red") + } + } + + + # plot residuals ~ fitted + #------------------------ + + par(new=TRUE, fig=c(0.66, 1, 0, 0.33)) + ScatterPlot(as.vector(sim), as.vector(res), xlab=paste(name.ds, ".sim (", unit.ds, ")", sep=""), ylab=paste(name.ds, ".res (", unit.ds, ")", sep=""), col.global="black", col.points="grey", fits=fits, nrpoints=0) + abline(h=0) + if (!AllEqual(as.vector(sim)) & !AllEqual(as.vector(res))) { + obj <- ObjFct(as.vector(res), as.vector(sim))$Cor[1] + legend("topleft", paste("Cor =", signif(obj, 3)), bty="n", cex=1, text.col="red") + } + + } else { # end if (has.sim) + + # map of observations + #-------------------- + + if (has.space & is.ts) { + obs.sp <- apply(obs, 2, mean, na.rm=TRUE) + par(new=TRUE, fig=c(0, 0.66, 0.33, 0.66)) + .map(obs.sp, paste(name.ds, ".mean.obs (", unit.ds, ")", sep="")) + } + + } + } # end if is.na + } # end loop over data streams + suppressWarnings(par(par0)) +}) diff --git a/LPJmLmdi/R/plot.LPJpar.R b/LPJmLmdi/R/plot.LPJpar.R new file mode 100644 index 0000000..1f851ff --- /dev/null +++ b/LPJmLmdi/R/plot.LPJpar.R @@ -0,0 +1,266 @@ +plot.LPJpar <- structure(function( + ##title<< + ## Plot parameters in 'LPJpar' object. + ##description<< + ## + + x, + ### object of class 'LPJpar' + + par.name = NULL, + ### name(s) of the parameters that should be plotted + + uncertainty="uncertainty.005", + ### name of the uncertainty estimate in LPJpar that should be used to plot posterior uncertainties + + unc.change = FALSE, + ### 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) + + col = NULL, + ### vector of colours for PFT-specific parameters + + ylim = NULL, + ### limits of the y-axis + + xlim = NULL, + ### limits of the x-axis + + which.pft = NULL, + ### character vector of PFT names that should be plotted. If NULL all + + if.opt = FALSE, + ### plot parameters only if optimized (i.e. best) parameters are in LPJpar + + names = FALSE, + ### plot PFT names within the plot? + + opt.val = TRUE, + ### plot value of optimized parameter? + + xaxt = "s", + ### x axis type. "n" suppresses the x axis. + + add = FALSE, + ### add to existing plot? + + xoff = 0 + ### offset for adjusting in x-direction + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{LPJpar}}, \code{\link{CheckLPJpar}} + +) { + + pft.names <- c("TrBE", "TrBR", "TeNE", "TeBE", "TeBS", "BoNE", "BoBS", "BoNS", "TrH", "TeH", "PoH") + + err <- "Select a valid parameter name." + if (is.null(par.name)) { + txt.l <- strsplit(as.character(x$names), "_") + txt.l <- llply(txt.l, function(txt) { + if (txt[length(txt)] %in% pft.names) { + txt <- txt[-length(txt)] + } + paste(txt, collapse="_") + }) + par.name <- unique(unlist(txt.l)) + par.name <- par.name[par.name != ""] + par.name <- sort(par.name) + } else { + if (any(is.na(par.name))) stop(err) + } + + # loop over parameter names + for (i in 1:length(par.name)) { + i <<- i + pos <- grep(par.name[i], x$names) + if (length(pos) == 0) stop(err) + + # has parameter PFT-specific values? + txt.l <- strsplit(as.character(x$names[pos]), "_") + txt.df <- ldply(txt.l, function(txt) data.frame(matrix(as.character(txt), nrow=1))) + + if (!AllEqual(txt.df[, ncol(txt.df)])) { + has.pfts <- TRUE + pfts <- txt.df[, ncol(txt.df)] + npft <- length(pfts) + nme <- par.name[i] + + if (is.null(col)) { + col <- c(TrBE="#961a1d", TrBR="#facbcd", TeNE="#173218", TeBE="#69bd45", TeBS="#1b5127", BoNE="#a74198", BoBS="#622163", BoNS="#865aa6", TrH="#fecd08", TeH="#f6f068", PoH="#8ad4e2") + if (length(col) < npft) col <- rainbow(npft) + if (any(is.na(col))) col <- rainbow(npft) + } + col1 <- col[match(pfts, names(col))] + } else { + has.pfts <- FALSE + pfts <- "global" + npft <- 1 + if (is.null(col)) col1 <- "black" + nme <- x$names[pos] + } + + # priors + par.df <- data.frame( + par = nme, + pft = 1:npft, + pft.name = pfts, + col = col1, + prior = x$prior[pos], + lower = x$lower[pos], + upper = x$upper[pos]) + + # best from optimization + has.best <- !is.null(x$best) + if (has.best) par.df$best <- x$best[pos] + + # uncertainty estimate + unc <- grep(uncertainty, names(x)) + if (uncertainty != "uncertainty.005") unc <- unc[1] + has.unc <- !all(is.na(unc)) + if (has.unc) { + if (length(unc) == 1) { # uncertainty range + par.df$unc = x[[unc]][pos] + par.df$unclow <- par.df$best - 0.5 * par.df$unc + par.df$uncup <- par.df$best + 0.5 * par.df$unc + + bool <- par.df$unclow < par.df$lower + bool[is.na(bool)] <- FALSE + par.df$unclow[bool] <- par.df$lower[bool] + par.df$uncup[bool] <- par.df$unclow[bool] + par.df$unc[bool] + + bool <- par.df$uncup > par.df$upper + bool[is.na(bool)] <- FALSE + par.df$uncup[bool] <- par.df$upper[bool] + par.df$unclow[bool] <- par.df$uncup[bool] - par.df$unc[bool] + } else if (length(unc) == 2) { # uncertainty lower and upper + low <- (x[[unc[1]]])[pos] + up <- (x[[unc[2]]])[pos] + if (any(na.omit(low > up))) { + up <- (x[[unc[1]]])[pos] + low <- (x[[unc[2]]])[pos] + } + par.df$unclow <- low + par.df$uncup <- up + } else { + warning("Check the selected uncertainty estimate") + has.unc <- FALSE + } + if (unc.change) par.df$change <- abs(par.df$uncup - par.df$unclow) / abs(par.df$upper - par.df$lower) + } + + # subset only selected PFTs + if (has.pfts & !is.null(which.pft)) { + m <- match(which.pft, par.df$pft.name) + if (length(m) > 0) { + par.df <- par.df[m,] + par.df$col <- as.character(par.df$col) + par.df$col[is.na(par.df$col)] <- "black" + pfts <- par.df$pft.name <- which.pft + npft <- length(which.pft) + par.df$pft <- 1:npft + } + } + + # plot only optimized parameters? + par.nd <- rep(FALSE, nrow(par.df)) + par.nd[par.df$prior == 999 | par.df$prior == -999] <- TRUE + if (has.best & if.opt) par.nd[is.na(par.df$best.median)] <- TRUE + par.df$prior[par.nd] <- NA + par.df$lower[par.nd] <- NA + par.df$upper[par.nd] <- NA + + # axis ranges for plot + if (is.null(ylim)) { + ylim <- range(c(par.df$lower, par.df$upper), na.rm=TRUE) + if (unc.change) ylim <- c(0,1) + if (ylim[1] == ylim[2]) ylim[2] <- ylim[2] + 0.1 + ylim[1] <- ylim[1] - (ylim[2] - ylim[1]) * 0.01 + ylim[2] <- ylim[2] + (ylim[2] - ylim[1]) * 0.01 + } + if (is.null(xlim)) xlim <- c(min(par.df$pft)-0.3, max(par.df$pft)+0.3) + + # init plot + if (!add) { + if (unc.change) { + plot(change ~ pft, par.df, ylim=ylim, xlim=xlim, type="n", xaxt="n", yaxt="n", ylab=paste("dUncertainty", nme), xlab="") + } else { + plot(prior ~ pft, par.df, ylim=ylim, xlim=xlim, type="n", xaxt="n", yaxt="n", ylab=nme, xlab="") + rect(par.df$pft-0.25, par.df$lower, par.df$pft+0.25, par.df$upper, col="lightgray", border="lightgray") + } + + yaxt <- pretty(ylim, 3) + axis(2, yaxt, yaxt) + if (xaxt != "n") axis(1, at=par.df$pft, par.df$pft.name, las=2) + + } else { + rect(par.df$pft+xoff-0.05, par.df$lower, par.df$pft+xoff+0.05, par.df$upper, col="lightgray", border="lightgray") + } + + # change prior -> best + is.best <- rep(FALSE, npft) + if (has.best & !unc.change) { + is.best <- par.df$prior != par.df$best + suppressWarnings(arrows(x0=par.df$pft[is.best]+xoff, y0=par.df$prior[is.best], x1=par.df$pft[is.best]+xoff, y1=par.df$best[is.best], code=2, length=0.1, lwd=2, col=as.character(par.df$col[is.best]))) # change from prior to best + } + + # prior + d <- par.df[!is.best,] + if (!unc.change) points(d$pft+xoff, d$prior, col=as.character(d$col), pch=18) + + # posterior uncertainty + if (has.unc & !unc.change) { + suppressWarnings(arrows(x0=par.df$pft+xoff, y0=par.df$unclow, x1=par.df$pft+xoff, y1=par.df$uncup, code=3, angle=90, length=0.1, lty=1, col=as.character(par.df$col))) + } + + # posterior uncertainty + if (has.unc & unc.change) { + points(d$pft+xoff, d$change, col=as.character(d$col), pch=18, cex=2) + } + + # best individual + if (has.best & !unc.change) { + d <- par.df[is.best,] + points(d$pft+xoff, d$best, col=as.character(d$col), pch=16) + + # plot value of optimized parameter + if (opt.val) { + txt <- round(d$best, 2) + pos <- rep(1, length(d$best)) + pos[d$best < mean(ylim)] <- 3 + text(d$pft+xoff, d$best, txt, pos=pos, srt=20) + } + } + + # add names + if (names & (npft > 1) & !add) { + text(par.df$pft, y=ylim[1]+diff(ylim)*0.1, par.df$pft.name, col=as.character(par.df$col), srt=45, cex=1.2) + } + + #if (any(par.nd)) text((1:npft)[par.nd], ylim[1], "nd", cex=1.4) + + if (length(par.name) > 1) ylim <- xlim <- NULL + + } # end loop over par.name +}, ex=function() { + # plot(lpjpar, par.name="ALBEDO_LEAF_TeBS", uncertainty="uncertainty.iqr95") + # plot(lpjpar, par.name="ALBEDO_LEAF", uncertainty="uncertainty.iqr") + # plot(lpjpar, par.name="LIGHTEXTCOEFF", uncertainty="uncertainty.iqr") + # par(mfrow=c(2,2)) + # plot(lpjpar, par.name=c("ALPHAA", "LIGHTEXTCOEFF", "ALBEDO_LEAF", "ALBEDO_STEM")) +}) + + + + + + + + + + + diff --git a/LPJmLmdi/R/plot.LPJsim.R b/LPJmLmdi/R/plot.LPJsim.R new file mode 100644 index 0000000..e96c7dd --- /dev/null +++ b/LPJmLmdi/R/plot.LPJsim.R @@ -0,0 +1,173 @@ +plot.LPJsim <- structure(function( + ##title<< + ## Plots a LPJsim object + ##description<< + ## The function plots a LPJsim object: monthly, annual time series or map of grid cells + + x, + ### an object of class 'LPJsim' + + what="annual", + ### 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 + + start=NA, + ### first year for time series plot + + end=NA, + ### last year for time series plot + + omit0=TRUE, + ### omit variables from plotting that are only 0? + + AggFun = AggMeanNULL, + ### 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. + + ... + ### further arguments (currently not used) + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{ReadLPJ2ts}}, \code{\link{ReadLPJsim}} + +) { + + # plot map if what == 'grid' + if (what == "grid") { + PlotWorld110() + points(x$grid, col="red", pch="+", xlab="", ylab="") + if (nrow(x$grid) == 1) text(x$grid[1,1], x$grid[1,2], paste(x$grid, collapse=", "), col="red", pos=3) + return(x$grid) + } + + # check frequency daily(365), monthly(12) or annual(1) + data.l <- x$data + info.df <- x$info + freq <- llply(data.l, .fun=frequency) + + # scale with factor + nms <- names(data.l) + data.l <- llply(as.list(1:length(data.l)), function(id) data.l[[id]] * info.df$scale[id]) + + # aggregate time series to common resolution + freq.plot <- 1 # annual + freq.plot[what == "monthly"] <- 12 + freq.plot[what == "daily"] <- 365 + + if (!freq.plot %in% unlist(freq)) { + warning(paste("Frequency", freq.plot, "not included in x. Plot what='annual' instead.")) + freq.plot <- 1 + what <- "annual" + } + + # aggregate data to common resolution + data.agg.l <- llply(as.list(1:length(data.l)), .fun=function(id) { + Yt <- data.l[[id]] + if (freq[[id]] == freq.plot) { + return(Yt) + } else if (freq[[id]] > 1 & freq.plot == 1) { # monthly or daily to annual + agg <- rep(start(Yt)[1]:end(Yt)[1], each=freq[[id]]) + Yt2 <- AggFun(as.vector(Yt), agg) + return(Yt2) + } else if (freq[[id]] == 365 & freq.plot == 12) { # daily to monthly + ndaymonth <- c(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) + agg <- paste(rep(start(Yt)[1]:end(Yt)[1], each=365), rep(1:12, ndaymonth)) + Yt2 <- AggFun(as.vector(Yt), agg) + return(Yt2) + } else { # would require interpolation + return(0) + } + }) + names(data.agg.l) <- nms + varnames <- NULL + for (i in 1:length(data.agg.l)) { + varnames <- c(varnames, paste(names(data.agg.l)[i], colnames(data.agg.l[[i]]))) + } + data.ts <- data.agg.l[[1]] + for (i in 2:length(data.agg.l)) data.ts <- cbind(data.ts, data.agg.l[[i]]) + colnames(data.ts) <- varnames + + + # plot time series + #----------------- + + if (what != "grid") { + + # omit variables with only 0 values + if (omit0) { + o <- apply(data.ts, 2, mean, na.rm=TRUE) + ti <- tsp(data.ts) + data.ts <- data.ts[,(1:ncol(data.ts))[o != 0]] + data.ts <- ts(data.ts) + tsp(data.ts) <- ti + } + + if (is.na(start)) start <- start(data.ts) + if (is.na(end)) end <- end(data.ts) + + # calculate optimal number of rows and columns for the plot + row <- nds <- ncol(data.ts) + if (is.null(row)) { + row <- nds <- 1 + } + if (row == 0) { + warning("nothing to plot") + return(NA) + } + col <- 1 + if (row > 10) { + col <- 4 + row <- ceiling( ncol(data.ts) / 4 ) + } + + # plot the graphic + par <- par() + if (nds == 1) { + plot(window(data.ts, start=start, end=end), ylab="") + return(data.ts) + } + if (col > 1) DefaultParL(mfrow=c(row, col), mar=c(0.8,4,0,1), oma=c(4,0,2,0.2)) + if (col == 1) DefaultParL(mfrow=c(row, col), mar=c(0.8,4,0,4), oma=c(4,0,2,0)) + i <- 1 + for (r in 1:row) { + for (c in 1:col) { + if (i <= nds) { + plot(window(data.ts[,i], start=start, end=end), ylab="", xaxt="n", yaxt="n") + grid() + # plot x axis + if (r == row) axis(1, pretty(window(time(data.ts), start=start, end=end)), pretty(window(time(data.ts), start=start, end=end))) + + # plot y axis + yax <- pretty(data.ts[,i]) + if (col == 1) { + if (i %% 2 == 1) { + axis(2, yax, yax) + mtext(colnames(data.ts)[i], 2, 2.7) + } + if (i %% 2 == 0) { + axis(4, yax, yax) + mtext(colnames(data.ts)[i], 4, 2.7) + } + } else { + axis(2, yax, yax) + mtext(colnames(data.ts)[i], 2, 2.7) + } + box() + i <- i + 1 + } + } + } + par(par) + + return(data.ts) + } +}, ex=function() { + +# setwd(path.mylpjresult) +# sim <- ReadLPJ2ts(start=1982, end=2011) +# plot(sim, what="annual") + +}) diff --git a/LPJmLmdi/R/plot.rescue.R b/LPJmLmdi/R/plot.rescue.R new file mode 100644 index 0000000..db9725c --- /dev/null +++ b/LPJmLmdi/R/plot.rescue.R @@ -0,0 +1,138 @@ +plot.rescue <- structure(function( + ##title<< + ## plot an object of class "rescue" / monitor OptimizeLPJgenoud + ##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)". + + x, + ### a list of class "rescue", see \code{\link{CombineRescueFiles}} + + ylim=NULL, + ### limits of the y-axis of the plot + + xlim=NULL, + ### limits of the x-axis of the plot + + ylab="Cost", + ### label for the y axis + + xlab="Individuals of genetic optimization", + ### label for the x axis + + only.cost=FALSE, + ### plot all integration datasets (TRUE) or only these ones with cost=TRUE + + ... + ### further arguments for \code{\link{plot}} + + ##details<< + ## No details. + + ##references<< No reference. + + ##seealso<< + ## \code{\link{CombineRescueFiles}} +) { + + rescue.l <- x + + # has KGE metrics? + kge <- !is.null(rescue.l[[1]]$cost$fractional) + if (kge) nms <- paste(rep(names(rescue.l[[1]]$cost$per.ds), each=3), names(rescue.l[[1]]$cost$per.cell)) + if (!kge) nms <- names(rescue.l[[1]]$cost$per.ds) + + # get cost per data stream + cost.ds <- laply(rescue.l, function(l) { + # if (all(l$dpar == 1)) cost.prior <<- l$cost$total + if (kge) { # KGE cost + m <- t(l$cost$fractional * l$cost$total) + #m <- t(l$cost$per.cell.ds) + m <- matrix(m, nrow=1) + } else { # SSE cost + m <- matrix(l$cost$per.ds, nrow=1) + } + return(m) + }) + + # select only data streams that are included in cost function or all + if (only.cost) { + if (is.null(rescue.l[[1]]$cost$use)) { + use <- rep(TRUE, length(rescue.l[[1]]$cost$per.cell.ds)) + } else { + use <- apply(rescue.l[[1]]$cost$use, 1, sum) > 0 + } + + cost <- unlist(llply(rescue.l, function(l) l$cost$total)) # total cost + cost.ds <- matrix(cost.ds[,use], nrow=length(cost)) + if (kge) nms <- paste(rep(names(rescue.l[[1]]$cost$per.ds), each=3)[rep(use, each=3)], names(rescue.l[[1]]$cost$per.cell)) + if (!kge) nms <- names(rescue.l[[1]]$cost$per.ds)[use] + } else { + if (!kge) cost <- rowSums(cost.ds) + if (kge) cost <- sqrt(rowSums(cost.ds)) + } + + # get prior parameter set + isprior <- unlist(llply(rescue.l, function(l) all(l$dpar == 1))) + + # prepare matrix for plotting + o <- order(cost, decreasing=TRUE) + cost <- cost[o] + isprior <- isprior[o] + cost.ds <- matrix(cost.ds[o, ], nrow=length(cost)) + cost.ds <- (cost.ds * cost) / rowSums(cost.ds) + nds <- length(nms) + + # rescue.l[[isprior]] cost.ds[isprior,] cost.ds[nrow(cost.ds),] + + # create colors + cols0 <- brewer.pal(nds, "Set1") + if (kge) { + cols0 <- col2rgb(cols0) + cols <- list() + s <- c(0.7, 0.85, 1) + for (i in 1:ncol(cols0)) cols[[i]] <- rgb(cols0[1,i]*s, cols0[2,i]*s, cols0[3,i]*s, max=255) + cols <- unlist(cols) + } else { + cols <- cols0 + } + + # prepare data for plot + cost.plot <- cost.ds + cost.plot <- matrix(apply(cost.plot, 1, cumsum), ncol=length(cost)) + cost.plot <- t(cost.plot) + if (is.null(ylim)) ylim <- c(0, quantile(cost.plot, 0.95, na.rm=TRUE)) + if (is.null(xlim)) xlim <- c(0, nrow(cost.plot)) + + # init plot + plot(cost, xlim=xlim, ylim=ylim, pch=16, ylab=ylab, xlab=xlab) #, ...) # + for (i in ncol(cost.plot):1) { + if (nrow(cost.plot) < 15000) { # plot as polygon + x <- c(1:nrow(cost.plot), nrow(cost.plot):1) + y <- c(cost.plot[,i], rep(0, nrow(cost.plot))) + polygon(x, y, col=cols[i], border=NA) + } else { # plot as lines -> faster + x <- 1:nrow(cost.plot) + y <- cost.plot[,i] + points(x, y, col=cols[i], type="h", lwd=0.5) + } + } + + # add prior + prior.cost <- max(cost[which(isprior)]) + prior <- which(cost == prior.cost) + best <- nrow(cost.plot) + for (i in ncol(cost.plot):1) { + points(x=prior, y=cost.plot[prior,i], pch=21, lwd=2, col=cols[i], type="h") + } + abline(v=prior, h=prior.cost, lty=2) + text(x=prior, y=0, "prior", pos=3) + text(x=best, y=0, "best", pos=3) + points(x=rep(prior, nds), y=cost.plot[prior,], pch=21, cex=1.5, bg=cols, col="black") + points(x=rep(best, nds), y=cost.plot[best,], pch=21, cex=1.5, bg=cols, col="black") + + text(2, ylim[2], paste("max =", "\n", round(max(cost), 2)), pos=1) + legend("topright", nms, fill=cols, ncol=min(c(nds, 4)), bg="white", title="Component of cost") + box() + +}) + diff --git a/LPJmLmdi/data/data110.RData b/LPJmLmdi/data/data110.RData new file mode 100644 index 0000000..f9513c1 Binary files /dev/null and b/LPJmLmdi/data/data110.RData differ diff --git a/LPJmLmdi/html/00Index.html b/LPJmLmdi/html/00Index.html new file mode 100644 index 0000000..81c7d4c --- /dev/null +++ b/LPJmLmdi/html/00Index.html @@ -0,0 +1,186 @@ + + +R: Model-Data Integration for the LPJmL Dynamic Global Vegetation +Model + + + +

Model-Data Integration for the LPJmL Dynamic Global Vegetation +Model + +

+
+
+[Up] +[Top] +

Documentation for package ‘LPJmLmdi’ version 1.0

+ + + +

Help Pages

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LPJmLmdi-packageModel-Data Integration for the LPJmL Dynamic Global Vegetation Model
AggFPCBoBSTemporal aggregation for BoBS PFT: get BoBS from vector of all PFTs, average over years
AggFPCBoNETemporal aggregation for BoNE PFT: get BoNE from vector of all PFTs, average over years
AggFPCBoNSTemporal aggregation for BoNS PFT: get BoNS from vector of all PFTs, average over years
AggFPCPoHTemporal aggregation for PoH PFT: get PoH from vector of all PFTs, average over years
AggFPCTeBETemporal aggregation for PFTs: get TeBE from vector of all PFTs, average over years
AggFPCTeBSTemporal aggregation for PFTs: get TeBS from vector of all PFTs, average over years
AggFPCTeHTemporal aggregation for PFTs: get TeH from vector of all PFTs, average over years
AggFPCTeNETemporal aggregation for PFTs: get TeNE from vector of all PFTs, average over years
AggFPCTrBETemporal aggregation for PFTs: get TrBE from vector of all PFTs, average over years
AggFPCTrBRTemporal aggregation for PFTs: get TrBR from vector of all PFTs, average over years
AggMaxNULLTemporal aggregation: aggregate by using annual maximum
AggMeanMeanTemporal aggregation: first mean, then mean = mean over all values
AggMeanNULLTemporal aggregation: first mean, then nothing = mean per group
AggMSCTemporal aggregation: mean seasonal cycle
AggNULLMeanTemporal aggregation: mean over all values
AggQ09NULLTemporal aggregation: aggregate by using quantile with prob=0.9
AggSumMeanTemporal aggregation: first sum, then mean
AggSumNULLTemporal aggregation: first sum, then nothing = sum per group
AllEqualCheck if all values in a vector are the same
BarplotCostplot a barplot of the cost change from prior to best parameter set
ChangeParamFileChange parameters in a parameter file
ChangeSoilCodeFileChange soil code in LPJ soil code file
CheckLPJparChecks LPJ parameters 'LPJpar'
CheckMemoryUsageCheck usage of memory by R objects
CombineRescueFilesCombine single rescue files into one rescue file
CorrelationMatrixSplot a correlation matrix
CostMDS.KGECost function for multiple data streams based on Kling-Gupta efficiency
CostMDS.KGEwCost function for multiple data streams based on a weighted Kling-Gupta efficiency
CostMDS.SSECost function for multiple data streams based on SSE
CreateRestartFromRescueCreate a *.pro file from binary rescue files to restart optimization
DefaultParLdefault 'par' settings for plots
Df2optimConvert a data.frame to a 'optim' list
EstOptimUseEstimate optimal number of jobs given a number of cluster nodes
FileExistsWaitIterative checking and waiting for a file.
GridPropertiesDerive grid properties from an object of class 'LPJfiles'
InfoCLMReturns information about a CLM file
InfoLPJInformation about a LPJmL binary file
IntegrationDataCreate an object of class 'IntegrationData'
IntegrationDatasetCreate an object of class 'IntegrationDataset'
LE2ETCompute evapotranspiration (ET) from latent heat (LE).
LPJfilesCreate an object of class 'LPJfiles'
LPJmLmdiModel-Data Integration for the LPJmL Dynamic Global Vegetation Model
LPJparCreate an object of class 'LPJpar'
LWin2LWnetCompute long-wave net radiation from long-wave incoming radiation and temperature.
ObjFctObjective functions
OptimizeLPJgenoudOptimize LPJ using the GENOUD optimizer (genetic optimization using derivatives)
plot.IntegrationDataPlot an object of class IntegrationData
plot.LPJparPlot parameters in 'LPJpar' object.
plot.LPJsimPlots a LPJsim object
plot.rescueplot an object of class "rescue" / monitor OptimizeLPJgenoud
PlotParPlot parameter vs. cost
PlotParPCAplot a PCA of optimized parameters
PlotWorld110Plot a world map based on 1:110Mio data
PrepareRestartFilesPrepare restart files to restart OptimizeLPJgenoud
print.ObjFctprint objective functions
ReadBINRead simple binary files without header Read a CLM file to a SpatialPixelsDataFrame
ReadCLMRead a CLM file to a SpatialPixelsDataFrame
ReadGridReads a binary input data grid file.
ReadLPJRead a LPJ binary file
ReadLPJ2IntegrationDataRead LPJ model results into an of class IntegrationData
ReadLPJ2tsRead a LPJ binary file and returns a spatial averaged time series
ReadLPJinputRead and subset CLM files to LPJinput objects
ReadLPJsimRead a LPJ simulation results
ReadOutputvarsRead 'outputvars.par' to get information about LPJmL output
ReadPRORead *.pro files as produced from GENOUD
Rescue2DfConvert a 'rescue' list to a data.frame
Rescue2LPJparAdd information from a 'rescue' list to an 'LPJpar' object
RunLPJRun LPJmL from R and get results
SSESum-of-squared residuals error
StandardErrorCompute standard errors from a variance-covariance matrix
StartingValuesGet starting values for genoud from *.pro file
text.ObjFctconvert objective functions to text
Texture2SoilcodeConvert soil texture to a LPJ soilcode
VarCovMatrixCompute variance-covariance matrix
WriteBINWrite a BIN file from SpatialPointsDataFrame
WriteCLMWrite a CLM file from SpatialPointsDataFrame
WriteGridWrite a *.grid file from a matrix of coordiantes or a SpatialPointsDataFrame
WriteLPJinputWrite an object of class 'LPJinput' to CLM files
WriteLPJparWrites an object of class 'LPJpar' as parameter file or table.
+ diff --git a/LPJmLmdi/html/AggFPCBoBS.html b/LPJmLmdi/html/AggFPCBoBS.html new file mode 100644 index 0000000..3304c4b --- /dev/null +++ b/LPJmLmdi/html/AggFPCBoBS.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for BoBS PFT: get BoBS from vector of... + + + + +
AggFPCBoBS {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCBoBS(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggFPCBoNE.html b/LPJmLmdi/html/AggFPCBoNE.html new file mode 100644 index 0000000..058a750 --- /dev/null +++ b/LPJmLmdi/html/AggFPCBoNE.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for BoNE PFT: get BoNE from vector of... + + + + +
AggFPCBoNE {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCBoNE(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggFPCBoNS.html b/LPJmLmdi/html/AggFPCBoNS.html new file mode 100644 index 0000000..462c9c3 --- /dev/null +++ b/LPJmLmdi/html/AggFPCBoNS.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for BoNS PFT: get BoNS from vector of... + + + + +
AggFPCBoNS {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCBoNS(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggFPCPoH.html b/LPJmLmdi/html/AggFPCPoH.html new file mode 100644 index 0000000..67ccbfa --- /dev/null +++ b/LPJmLmdi/html/AggFPCPoH.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for PoH PFT: get PoH from vector of all... + + + + +
AggFPCPoH {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCPoH(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggFPCTeBE.html b/LPJmLmdi/html/AggFPCTeBE.html new file mode 100644 index 0000000..1b81f0c --- /dev/null +++ b/LPJmLmdi/html/AggFPCTeBE.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for PFTs: get TeBE from vector of all... + + + + +
AggFPCTeBE {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCTeBE(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggFPCTeBS.html b/LPJmLmdi/html/AggFPCTeBS.html new file mode 100644 index 0000000..979dcc7 --- /dev/null +++ b/LPJmLmdi/html/AggFPCTeBS.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for PFTs: get TeBS from vector of all... + + + + +
AggFPCTeBS {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCTeBS(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggFPCTeH.html b/LPJmLmdi/html/AggFPCTeH.html new file mode 100644 index 0000000..20aa020 --- /dev/null +++ b/LPJmLmdi/html/AggFPCTeH.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for PFTs: get TeH from vector of all... + + + + +
AggFPCTeH {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCTeH(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggFPCTeNE.html b/LPJmLmdi/html/AggFPCTeNE.html new file mode 100644 index 0000000..89ff4fb --- /dev/null +++ b/LPJmLmdi/html/AggFPCTeNE.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for PFTs: get TeNE from vector of all... + + + + +
AggFPCTeNE {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCTeNE(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggFPCTrBE.html b/LPJmLmdi/html/AggFPCTrBE.html new file mode 100644 index 0000000..f504457 --- /dev/null +++ b/LPJmLmdi/html/AggFPCTrBE.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for PFTs: get TrBE from vector of all... + + + + +
AggFPCTrBE {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCTrBE(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggFPCTrBR.html b/LPJmLmdi/html/AggFPCTrBR.html new file mode 100644 index 0000000..9f76643 --- /dev/null +++ b/LPJmLmdi/html/AggFPCTrBR.html @@ -0,0 +1,59 @@ +R: Temporal aggregation for PFTs: get TrBR from vector of all... + + + + +
AggFPCTrBR {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggFPCTrBR(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggMSC.html b/LPJmLmdi/html/AggMSC.html new file mode 100644 index 0000000..d435f66 --- /dev/null +++ b/LPJmLmdi/html/AggMSC.html @@ -0,0 +1,59 @@ +R: Temporal aggregation: mean seasonal cycle + + + + +
AggMSC {LPJmLmdi}R Documentation
+ +

Temporal aggregation: mean seasonal cycle

+ +

Description

+ +

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

+ + +

Usage

+ +
AggMSC(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns the mean seasonal cycle

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggMaxNULL.html b/LPJmLmdi/html/AggMaxNULL.html new file mode 100644 index 0000000..e9b47f8 --- /dev/null +++ b/LPJmLmdi/html/AggMaxNULL.html @@ -0,0 +1,59 @@ +R: Temporal aggregation: aggregate by using annual maximum + + + + +
AggMaxNULL {LPJmLmdi}R Documentation
+ +

Temporal aggregation: aggregate by using annual maximum

+ +

Description

+ +

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

+ + +

Usage

+ +
AggMaxNULL(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggMeanMean.html b/LPJmLmdi/html/AggMeanMean.html new file mode 100644 index 0000000..c171465 --- /dev/null +++ b/LPJmLmdi/html/AggMeanMean.html @@ -0,0 +1,59 @@ +R: Temporal aggregation: first mean, then mean = mean over all... + + + + +
AggMeanMean {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggMeanMean(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggMeanNULL.html b/LPJmLmdi/html/AggMeanNULL.html new file mode 100644 index 0000000..d76db4e --- /dev/null +++ b/LPJmLmdi/html/AggMeanNULL.html @@ -0,0 +1,59 @@ +R: Temporal aggregation: first mean, then nothing = mean per... + + + + +
AggMeanNULL {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggMeanNULL(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggNULLMean.html b/LPJmLmdi/html/AggNULLMean.html new file mode 100644 index 0000000..76e0caa --- /dev/null +++ b/LPJmLmdi/html/AggNULLMean.html @@ -0,0 +1,59 @@ +R: Temporal aggregation: mean over all values + + + + +
AggNULLMean {LPJmLmdi}R Documentation
+ +

Temporal aggregation: mean over all values

+ +

Description

+ +

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

+ + +

Usage

+ +
AggNULLMean(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggQ09NULL.html b/LPJmLmdi/html/AggQ09NULL.html new file mode 100644 index 0000000..18402a8 --- /dev/null +++ b/LPJmLmdi/html/AggQ09NULL.html @@ -0,0 +1,59 @@ +R: Temporal aggregation: aggregate by using quantile with... + + + + +
AggQ09NULL {LPJmLmdi}R Documentation
+ +

Temporal aggregation: aggregate by using quantile with prob=0.9

+ +

Description

+ +

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

+ + +

Usage

+ +
AggQ09NULL(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggSumMean.html b/LPJmLmdi/html/AggSumMean.html new file mode 100644 index 0000000..ef28165 --- /dev/null +++ b/LPJmLmdi/html/AggSumMean.html @@ -0,0 +1,59 @@ +R: Temporal aggregation: first sum, then mean + + + + +
AggSumMean {LPJmLmdi}R Documentation
+ +

Temporal aggregation: first sum, then mean

+ +

Description

+ +

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

+ + +

Usage

+ +
AggSumMean(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AggSumNULL.html b/LPJmLmdi/html/AggSumNULL.html new file mode 100644 index 0000000..ccbe3ea --- /dev/null +++ b/LPJmLmdi/html/AggSumNULL.html @@ -0,0 +1,59 @@ +R: Temporal aggregation: first sum, then nothing = sum per group + + + + +
AggSumNULL {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
AggSumNULL(x, agg)
+ + +

Arguments

+ + + + + + +
x +

full time series

+
agg +

vector of grouping elements (years)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a the aggregated result.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/AllEqual.html b/LPJmLmdi/html/AllEqual.html new file mode 100644 index 0000000..7573d89 --- /dev/null +++ b/LPJmLmdi/html/AllEqual.html @@ -0,0 +1,51 @@ +R: Check if all values in a vector are the same + + + + +
AllEqual {LPJmLmdi}R Documentation
+ +

Check if all values in a vector are the same

+ +

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.

+ + +

Usage

+ +
AllEqual(x)
+ + +

Arguments

+ + + + +
x +

numeric, character vector, or time series of type ts

+
+ + +

Value

+ +

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

+ + +

Author(s)

+ +

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

+ + +

Examples

+ +
+# check if all values are equal in the following vectors:
+AllEqual(1:10)
+AllEqual(rep(0, 10))
+AllEqual(letters)
+AllEqual(rep(NA, 10))
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/BarplotCost.html b/LPJmLmdi/html/BarplotCost.html new file mode 100644 index 0000000..4aa074b --- /dev/null +++ b/LPJmLmdi/html/BarplotCost.html @@ -0,0 +1,63 @@ +R: plot a barplot of the cost change from prior to best... + + + + +
BarplotCost {LPJmLmdi}R Documentation
+ +

plot a barplot of the cost change from prior to best parameter set

+ +

Description

+ +

The function plots two barplots that are showing the change in the cost per dataset.

+ + +

Usage

+ +
BarplotCost(rescue.l, ...)
+ + +

Arguments

+ + + + + + +
rescue.l +

a list of class "rescue", see CombineRescueFiles

+
... +

further arguments for plot

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CombineRescueFiles

+ + +

Examples

+ +
+# files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE))
+# rescue.l <- CombineRescueFiles(files, remove=FALSE)
+# BarplotCost(rescue.l)
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ChangeParamFile.html b/LPJmLmdi/html/ChangeParamFile.html new file mode 100644 index 0000000..f7f5ae0 --- /dev/null +++ b/LPJmLmdi/html/ChangeParamFile.html @@ -0,0 +1,72 @@ +R: Change parameters in a parameter file + + + + +
ChangeParamFile {LPJmLmdi}R Documentation
+ +

Change parameters in a parameter file

+ +

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'.

+ + +

Usage

+ +
ChangeParamFile(newpar, file.template, file.new, wait = FALSE, 
+    ...)
+ + +

Arguments

+ + + + + + + + + + + + +
newpar +

a named vector with new parameter values

+
file.template +

file name of the template parameter with flagged parameters

+
file.new +

file name of the new parameter file

+
wait +

If TRUE wait 1 second to check if file.template exists in order to relax slow file writting.

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

The function works only on Unix systems because it is based on 'sed'

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

Examples

+ +
+
+# newpar <- c(ALPHAA_BoNE=0.8)
+# LPJChangeParamFile(newpar, file.template="pft_template.par", file.new="pft.par")
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ChangeSoilCodeFile.html b/LPJmLmdi/html/ChangeSoilCodeFile.html new file mode 100644 index 0000000..57008b6 --- /dev/null +++ b/LPJmLmdi/html/ChangeSoilCodeFile.html @@ -0,0 +1,71 @@ +R: Change soil code in LPJ soil code file + + + + +
ChangeSoilCodeFile {LPJmLmdi}R Documentation
+ +

Change soil code in LPJ soil code file

+ +

Description

+ +

The function changes the soil code for the specified grid cells and writes a new LPJ soil code file.

+ + +

Usage

+ +
ChangeSoilCodeFile(file.soilcode, file.soilcode.new, xy, newcode, 
+    file.grid = "cru.grid", ...)
+ + +

Arguments

+ + + + + + + + + + + + + + +
file.soilcode +

original soil code file

+
file.soilcode.new +

new soil code file

+
xy +

matrix of grid cells (lon, lat) where the soil code should be changed

+
newcode +

new soil code at each grid cell (vector with length = nrow(xy))

+
file.grid +

grid file for the original soil code file

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadBIN

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/CheckLPJpar.html b/LPJmLmdi/html/CheckLPJpar.html new file mode 100644 index 0000000..dddfe9c --- /dev/null +++ b/LPJmLmdi/html/CheckLPJpar.html @@ -0,0 +1,59 @@ +R: Checks LPJ parameters 'LPJpar' + + + + +
CheckLPJpar {LPJmLmdi}R Documentation
+ +

Checks LPJ parameters 'LPJpar'

+ +

Description

+ +

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

+ + +

Usage

+ +
CheckLPJpar(lpjpar, correct = FALSE)
+ + +

Arguments

+ + + + + + +
lpjpar +

object of class 'LPJpar'

+
correct +

correct parameter values (TRUE) or return error message?

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

the function return an object of class 'LPJpar'

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

LPJpar

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/CheckMemoryUsage.html b/LPJmLmdi/html/CheckMemoryUsage.html new file mode 100644 index 0000000..39cafd6 --- /dev/null +++ b/LPJmLmdi/html/CheckMemoryUsage.html @@ -0,0 +1,37 @@ +R: Check usage of memory by R objects + + + + +
CheckMemoryUsage {LPJmLmdi}R Documentation
+ +

Check usage of memory by R objects

+ +

Description

+ +

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

+ + +

Usage

+ +
CheckMemoryUsage()
+ + +

Value

+ +

a data.frame

+ + +

Author(s)

+ +

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

+ + +

Examples

+ +
+CheckMemoryUsage()
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/CombineRescueFiles.html b/LPJmLmdi/html/CombineRescueFiles.html new file mode 100644 index 0000000..e81d31b --- /dev/null +++ b/LPJmLmdi/html/CombineRescueFiles.html @@ -0,0 +1,59 @@ +R: Combine single rescue files into one rescue file + + + + +
CombineRescueFiles {LPJmLmdi}R Documentation
+ +

Combine single rescue files into one rescue file

+ +

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 (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.

+ + +

Usage

+ +
CombineRescueFiles(files.rescue, remove = TRUE)
+ + +

Arguments

+ + + + + + +
files.rescue +

file names

+
remove +

save new rescue file and delete single rescue files?

+
+ + +

Details

+ +

No details.

+ + +

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).

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CreateRestartFromRescue, plot.rescue

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/CorrelationMatrixS.html b/LPJmLmdi/html/CorrelationMatrixS.html new file mode 100644 index 0000000..e2b8e99 --- /dev/null +++ b/LPJmLmdi/html/CorrelationMatrixS.html @@ -0,0 +1,62 @@ +R: plot a correlation matrix + + + + +
CorrelationMatrixS {LPJmLmdi}R Documentation
+ +

plot a correlation matrix

+ +

Usage

+ +
CorrelationMatrixS(data, method = "spearman", iscor = NULL, main = "", 
+    ...)
+ + +

Arguments

+ + + + + + + + + + + + +
data +

a correlation matrix or a data.frame (

+
method +

method to compute the correlation

+
iscor +

Is 'data' a correlation matrix?

+
main +

main title for the plot

+
... +

further arguments for plot

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CombineRescueFiles

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/CostMDS.KGE.html b/LPJmLmdi/html/CostMDS.KGE.html new file mode 100644 index 0000000..611e0c7 --- /dev/null +++ b/LPJmLmdi/html/CostMDS.KGE.html @@ -0,0 +1,50 @@ +R: Cost function for multiple data streams based on Kling-Gupta... + + + + +
CostMDS.KGE {LPJmLmdi}R Documentation
+ +

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

+ +

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.

+ + +

Usage

+ +
CostMDS.KGE(integrationdata)
+ + +

Arguments

+ + + + +
integrationdata +

object of class 'integrationdata', see IntegrationData

+
+ + +

Details

+ +

No details.

+ + +

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).

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/CostMDS.KGEw.html b/LPJmLmdi/html/CostMDS.KGEw.html new file mode 100644 index 0000000..ae97d1c --- /dev/null +++ b/LPJmLmdi/html/CostMDS.KGEw.html @@ -0,0 +1,70 @@ +R: Cost function for multiple data streams based on a weighted... + + + + +
CostMDS.KGEw {LPJmLmdi}R Documentation
+ +

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

+ +

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.

+ + +

Usage

+ +
CostMDS.KGEw(integrationdata)
+ + +

Arguments

+ + + + +
integrationdata +

object of class 'integrationdata', see IntegrationData

+
+ + +

Details

+ +

No details.

+ + +

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).

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

Examples

+ +
+
+# load(paste0(path.me, "/lpj/LPJmL_131016/out_optim/opt_fpc/OFPC_BO-GI-BM_v1_all_0_59_posterior-best.RData"))
+# x <- result.post.lpj$integrationdata
+# plot(x, 2)
+
+# cost.see <- CostMDS.SSE(x)
+# cost.kge <- CostMDS.KGE(x)
+# cost.kgew <- CostMDS.KGEw(x)
+
+# DefaultParL(mfrow=c(1,3))
+# barplot(cost.see$per.ds)
+# barplot(t(cost.kge$per.cell.ds))
+# barplot(t(cost.kgew$per.cell.ds))
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/CostMDS.SSE.html b/LPJmLmdi/html/CostMDS.SSE.html new file mode 100644 index 0000000..215fe04 --- /dev/null +++ b/LPJmLmdi/html/CostMDS.SSE.html @@ -0,0 +1,50 @@ +R: Cost function for multiple data streams based on SSE + + + + +
CostMDS.SSE {LPJmLmdi}R Documentation
+ +

Cost function for multiple data streams based on SSE

+ +

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 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.

+ + +

Usage

+ +
CostMDS.SSE(integrationdata)
+ + +

Arguments

+ + + + +
integrationdata +

object of class 'integrationdata', see IntegrationData

+
+ + +

Details

+ +

No details.

+ + +

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.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/CreateRestartFromRescue.html b/LPJmLmdi/html/CreateRestartFromRescue.html new file mode 100644 index 0000000..4faf7e5 --- /dev/null +++ b/LPJmLmdi/html/CreateRestartFromRescue.html @@ -0,0 +1,54 @@ +R: Create a *.pro file from binary rescue files to restart... + + + + +
CreateRestartFromRescue {LPJmLmdi}R Documentation
+ +

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

+ +

Description

+ +

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

+ + +

Usage

+ +
CreateRestartFromRescue(path.rescue, pop.size)
+ + +

Arguments

+ + + + + + +
path.rescue +

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

+
pop.size +

(estimated) population size of the genetic optimization

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

genoudLPJrescue

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/DefaultParL.html b/LPJmLmdi/html/DefaultParL.html new file mode 100644 index 0000000..38e1e4b --- /dev/null +++ b/LPJmLmdi/html/DefaultParL.html @@ -0,0 +1,94 @@ +R: default 'par' settings for plots + + + + +
DefaultParL {LPJmLmdi}R Documentation
+ +

default 'par' settings for plots

+ +

Description

+ +

The function calls 'par' with some default settings to improve plots. See par for details.

+ + +

Usage

+ +
DefaultParL(mfrow = c(1, 1), mar = c(3.7, 3.5, 2.5, 0.5), oma = c(0.8, 
+    0.1, 0.1, 0.2), mgp = c(2.4, 1, 0), cex = 1.3, cex.lab = cex * 
+    1.1, cex.axis = cex * 1.1, cex.main = cex * 1.1, ...)
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + + + +
mfrow +

number of rows/columns

+
mar +

margins

+
oma +

outer margins

+
mgp +

margin line for axis title, label and lines

+
cex +

text and symbol size

+
cex.lab +

label size

+
cex.axis +

axis anootation size

+
cex.main +

title size

+
... +

further arguments to par

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

par

+ + +

Examples

+ +
+
+DefaultParL()
+plot(1:10)
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/Df2optim.html b/LPJmLmdi/html/Df2optim.html new file mode 100644 index 0000000..878cf97 --- /dev/null +++ b/LPJmLmdi/html/Df2optim.html @@ -0,0 +1,69 @@ +R: Convert a data.frame to a 'optim' list + + + + +
Df2optim {LPJmLmdi}R Documentation
+ +

Convert a data.frame to a optim list

+ +

Description

+ +

The function takes a 'data.frame' as created by Rescue2DF and converts it to a list with the same structure like the results of the optim and genoud functions.

+ + +

Usage

+ +
Df2optim(optim.df, pop.size = NA, ...)
+ + +

Arguments

+ + + + + + + + +
optim.df +

a 'data.frame' as created by Rescue2DF

+
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.

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CombineRescueFiles

+ + +

Examples

+ +
+# files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE))
+# rescue.l <- CombineRescueFiles(files, remove=FALSE)
+# optim.df <- Rescue2Df(rescue.l)
+# opt <- Rescue2optim(rescue.l)
+# opt
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/EstOptimUse.html b/LPJmLmdi/html/EstOptimUse.html new file mode 100644 index 0000000..8b9ff47 --- /dev/null +++ b/LPJmLmdi/html/EstOptimUse.html @@ -0,0 +1,54 @@ +R: Estimate optimal number of jobs given a number of cluster... + + + + +
EstOptimUse {LPJmLmdi}R Documentation
+ +

Estimate optimal number of jobs given a number of cluster nodes

+ +

Usage

+ +
EstOptimUse(nodes = 16, wish = 1000)
+ + +

Arguments

+ + + + + + +
nodes +

number of cluster nodes that you want to use

+
wish +

approx. number of elements

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

an integer value

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

WriteCLM

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/FileExistsWait.html b/LPJmLmdi/html/FileExistsWait.html new file mode 100644 index 0000000..3bf1da6 --- /dev/null +++ b/LPJmLmdi/html/FileExistsWait.html @@ -0,0 +1,72 @@ +R: Iterative checking and waiting for a file. + + + + +
FileExistsWait {LPJmLmdi}R Documentation
+ +

Iterative checking and waiting for a file.

+ +

Description

+ +

The function repeately checks if a file exists and returns TRUE if the file is existing.

+ + +

Usage

+ +
FileExistsWait(file, waitmin = 0, waitinterval = 0.5, waitmax = 2, 
+    ...)
+ + +

Arguments

+ + + + + + + + + + + + +
file +

file for which checking and waiting should be applied

+
waitmin +

minimum waiting time (seconds)

+
waitinterval +

interval after which the existence of the file should be checked again (seconds)

+
waitmax +

maximum waiting time (seconds)

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

Examples

+ +
+
+FileExistsWait(system.file("external/rlogo.grd", package="raster"))
+FileExistsWait("nofile.txt")
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/GridProperties.html b/LPJmLmdi/html/GridProperties.html new file mode 100644 index 0000000..83b9dec --- /dev/null +++ b/LPJmLmdi/html/GridProperties.html @@ -0,0 +1,59 @@ +R: Derive grid properties from an object of class 'LPJfiles' + + + + +
GridProperties {LPJmLmdi}R Documentation
+ +

Derive grid properties from an object of class 'LPJfiles'

+ +

Description

+ +

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

+ + +

Usage

+ +
GridProperties(lpjfiles, ...)
+ + +

Arguments

+ + + + + + +
lpjfiles +

list of class 'LPJinput'

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

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

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

LPJfiles

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/InfoCLM.html b/LPJmLmdi/html/InfoCLM.html new file mode 100644 index 0000000..e471f5b --- /dev/null +++ b/LPJmLmdi/html/InfoCLM.html @@ -0,0 +1,53 @@ +R: Returns information about a CLM file + + + + +
InfoCLM {LPJmLmdi}R Documentation
+ +

Returns information about a CLM file

+ +

Usage

+ +
InfoCLM(file.clm, endian = "little", ...)
+ + +

Arguments

+ + + + + + + + +
file.clm +

CLM file name with extension *.clm

+
endian +

endianess of the file

+
... +

Further arguments (currently not used).

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

WriteLPJinput

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/InfoLPJ.html b/LPJmLmdi/html/InfoLPJ.html new file mode 100644 index 0000000..9e8b046 --- /dev/null +++ b/LPJmLmdi/html/InfoLPJ.html @@ -0,0 +1,86 @@ +R: Information about a LPJmL binary file + + + + +
InfoLPJ {LPJmLmdi}R Documentation
+ +

Information about a LPJmL binary file

+ +

Description

+ +

The function reads information about a LPJ binary output file.

+ + +

Usage

+ +
InfoLPJ(file.bin = "fpc.bin", file.grid = "grid.bin", file.annual = c("vegc.bin", 
+    "litc.bin", "soilc.bin"), size = 4, data.type = numeric(), 
+    ...)
+ + +

Arguments

+ + + + + + + + + + + + + + +
file.bin +

binary LPJ output file

+
file.grid +

binary LPJ grid file

+
file.annual +

one of the binary LPJ output files with annual data

+
size +

the number of bytes per element in the byte stream.

+
data.type +

data type of the file (default=numeric())

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

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).

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadLPJ

+ + +

Examples

+ +
+
+# InfoLPJ("vegc.bin")
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/IntegrationData.html b/LPJmLmdi/html/IntegrationData.html new file mode 100644 index 0000000..134ed1d --- /dev/null +++ b/LPJmLmdi/html/IntegrationData.html @@ -0,0 +1,93 @@ +R: Create an object of class 'IntegrationData' + + + + +
IntegrationData {LPJmLmdi}R Documentation
+ +

Create an object of class 'IntegrationData'

+ +

Description

+ +

The function takes several objects of class IntegrationDataset and converts them to an object 'IntegrationData' that is used in RunLPJ and OptimizeLPJgenoud.

+ + +

Usage

+ +
IntegrationData(...)
+ + +

Arguments

+ + + + +
... +

one or several objects of class 'IntegrationDataset'

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a list of class 'IntegrationData'

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationDataset

+ + +

Examples

+ +
+
+# # grid cells for which LPJmL should be run and for which the integration data should be extracted
+# xy <- cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75))
+
+# # use monthly FAPAR in model-data integration
+# fapar <- IntegrationDataset(name="FAPAR", unit="", 
+	# data.val.file="GIMMS.FAPAR.1982.2011.nc", 
+	# data.unc.file=0.12, 
+	# data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"),
+	# model.val.file="mfapar.bin",
+	# model.agg=NULL,
+	# xy=xy,
+	# data.factor=NULL,
+	# cost=TRUE,
+	# CostFunction=SSE,
+	# weight=1)
+	
+# # use mean annual GPP in model-data integration
+# gpp <- IntegrationDataset(name="GPP", unit="gC m-2 yr-1", 
+	# data.val.file="MTE.GPP.1982.2011.meanannual.nc", 
+	# data.unc.file="MTE.GPPunc.1982.2011.meanannual.nc", 
+	# data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"),
+	# model.val.file="mgpp.bin",
+	# model.agg=AggSumMean, # sum of each year, mean over all years -> mean annual GPP
+	# xy=xy,
+	# data.factor=NULL,
+	# cost=TRUE,
+	# CostFunction=SSE,
+	# weight=1)	
+	
+# integrationdata <- IntegrationData(fapar, gpp)
+	
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/IntegrationDataset.html b/LPJmLmdi/html/IntegrationDataset.html new file mode 100644 index 0000000..61a6a41 --- /dev/null +++ b/LPJmLmdi/html/IntegrationDataset.html @@ -0,0 +1,142 @@ +R: Create an object of class 'IntegrationDataset' + + + + +
IntegrationDataset {LPJmLmdi}R Documentation
+ +

Create an object of class 'IntegrationDataset'

+ +

Description

+ +

The function sets up an object of class 'IntegrationDataset' to define a dataset that should be used in model optimization, including dataset properties and the corresponding model output files. The function also reads the data input files as defined in 'data.val.file' and subsets the input data for the grid cells in 'xy'. One or several 'IntegrationDataset's need to be collected in an object of class IntegrationData which is used in the RunLPJ and OptimizeLPJgenoud functions.

+ + +

Usage

+ +
IntegrationDataset(name, unit = "", data.val.file, data.unc.file, 
+    data.time, model.val.file, xy, AggFun = NULL, data.factor = 1, 
+    model.factor = 1, cost = TRUE, CostFunction = SSE, weight = 1)
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
name +

name of the dataset or variable

+
unit +

unit of the variable (same unit as in LPJmL model output file 'model.val.file')

+
data.val.file +

name of file with the observation values, should be a file that can be read with brick

+
data.unc.file +

name of file with the data uncertainties or a numeric value if the same uncertainty value should be used for all observations

+
data.time +

a vector of class 'Date' with the time period for which the observations are representative. This vector defines also for which time period model results are read to be compared with the data. For example, if data.val.file represents just one value (e.g. long-term mean), the full time period for which this long-term mean is representative needs still to be defined here.

+
model.val.file +

file name of the corresponding model result [e.g. model.val.file="mnpp.bin"] or function without arguments [e.g. model.val.file=function() ReadLPJ("mnpp.bin", start=1901, end=2009, ...) ]. The option to pass a function allows to perform any calculations on LPJ model results or to combine several LPJ model outputs in order to be comparable with observations.

+
xy +

a matrix of grid cells that is used in RunLPJ and OptimizeLPJgenoud. The data in 'data.val.file' and 'data.unc.file' is extracted for these grid cells.

+
AggFun +

aggregation function to aggregate model results to the temporal resolution of the observations, for example AggSumMean for annual sums and mean over annual sums. If NULL no temporal aggregation is done.

+
data.factor +

scaling factor to be applied to the observation data, e.g. for unit conversions

+
model.factor +

scaling factor to be applied to model outputs, e.g. for unit conversions or scaling

+
cost +

Should the data stream be included in the computation of the total cost (TRUE) or not (FALSE). In case of FALSE, evaluation plots are produced for this dataset but the dataset is not considered in the compuation of the total cost and therfore not in optimization.

+
CostFunction +

cost function that should be used for this dataset, default SSE

+
weight +

weighting factor for the dataset in the cost function, cost = CostFunction / number of observations * weight

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a list of class 'IntegrationDataset'

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationData

+ + +

Examples

+ +
+
+# # grid cells for which LPJmL should be run and for which the integration data should be extracted
+# xy <- cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75))
+
+# # use monthly FAPAR in model-data integration
+# fapar <- IntegrationDataset(name="FAPAR", unit="", 
+	# data.val.file="GIMMS.FAPAR.1982.2011.nc", 
+	# data.unc.file=0.12, 
+	# data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"),
+	# model.val.file="mfapar.bin",
+	# model.agg=NULL,
+	# xy=xy,
+	# data.factor=NULL,
+	# cost=TRUE,
+	# CostFunction=SSE,
+	# weight=1)
+	
+# # use mean annual GPP in model-data integration
+# gpp <- IntegrationDataset(name="GPP", unit="gC m-2 yr-1", 
+	# data.val.file="MTE.GPP.1982.2011.meanannual.nc", 
+	# data.unc.file="MTE.GPPunc.1982.2011.meanannual.nc", 
+	# data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"),
+	# model.val.file="mgpp.bin",
+	# model.agg=AggSumMean, # sum of each year, mean over all years -> mean annual GPP
+	# xy=xy,
+	# data.factor=NULL,
+	# cost=TRUE,
+	# CostFunction=SSE,
+	# weight=1)	
+	
+	
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/LE2ET.html b/LPJmLmdi/html/LE2ET.html new file mode 100644 index 0000000..9bbfe07 --- /dev/null +++ b/LPJmLmdi/html/LE2ET.html @@ -0,0 +1,55 @@ +R: Compute evapotranspiration (ET) from latent heat (LE). + + + + +
LE2ET {LPJmLmdi}R Documentation
+ +

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

+ +

Usage

+ +
LE2ET(le, temp = NULL)
+ + +

Arguments

+ + + + + + +
le +

latent heat (W m-2)

+
temp +

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

+
+ + +

Value

+ +

The function returns evapotranspiration (mm day-1)

+ + +

Author(s)

+ +

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

+ + +

See Also

+ +

WriteLPJinput

+ + +

Examples

+ +
+le <- 0:200 # long-wave incoming radiation (W m-2)
+temp <- 0.14 * lwin - 32 + rnorm(length(lwin), 0, 5) # temperature (degC)
+
+et <- LE2ET(le)
+plot(le, et)
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/LPJfiles.html b/LPJmLmdi/html/LPJfiles.html new file mode 100644 index 0000000..4caf48a --- /dev/null +++ b/LPJmLmdi/html/LPJfiles.html @@ -0,0 +1,91 @@ +R: Create an object of class 'LPJfiles' + + + + +
LPJfiles {LPJmLmdi}R Documentation
+ +

Create an object of class 'LPJfiles'

+ +

Description

+ +

The function creates a list of class 'LPJfiles' that defines all paths, input files, and configurations files for a LPJ run.

+ + +

Usage

+ +
LPJfiles(path.lpj, path.tmp, path.out, sim.start.year, sim.end.year = NA, 
+    lpj.conf, param.conf, pft.par, param.par, input.conf, input, 
+    ...)
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
path.lpj +

path where LPJ is installed

+
path.tmp +

path for temporary outputs

+
path.out +

path for results

+
sim.start.year +

start year of the LPJ simulation as defined in lpjml.conf

+
sim.end.year +

last year of the LPJ simulation as defined in lpjml.conf

+
lpj.conf +

template for LPJ configuration file (create a template from lpjml.conf)

+
param.conf +

template for parameter configuration file (create a template from param.conf)

+
pft.par +

template file for PFT-specific parameters (create a template from pft.par)

+
param.par +

template file for global parameters (create a template from param.par)

+
input.conf +

template file for input data (create a template from input.conf)

+
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"))

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/LPJmLmdi-package.html b/LPJmLmdi/html/LPJmLmdi-package.html new file mode 100644 index 0000000..feafdec --- /dev/null +++ b/LPJmLmdi/html/LPJmLmdi-package.html @@ -0,0 +1,29 @@ +R: Model-Data Integration for the LPJmL Dynamic Global... + + + + +
LPJmLmdi-package {LPJmLmdi}R Documentation
+ +

Model-Data Integration for the LPJmL Dynamic Global Vegetation Model

+ +

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.

+ + +

Details

+ +

The DESCRIPTION file: +This package was not yet installed at build time.
+

+

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

+ + +

Author(s)

+ +

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

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/LPJpar.html b/LPJmLmdi/html/LPJpar.html new file mode 100644 index 0000000..d568000 --- /dev/null +++ b/LPJmLmdi/html/LPJpar.html @@ -0,0 +1,80 @@ +R: Create an object of class 'LPJpar' + + + + +
LPJpar {LPJmLmdi}R Documentation
+ +

Create an object of class 'LPJpar'

+ +

Description

+ +

The function creates a data.frame of class 'LPJpar' that defines the parameters for LPJ runs.

+ + +

Usage

+ +
LPJpar(par.prior, par.lower, par.upper, par.pftspecif, par.names, 
+    is.int = rep(FALSE, length(par.prior)), ...)
+ + +

Arguments

+ + + + + + + + + + + + + + + + +
par.prior +

parameter vector (prior)

+
par.lower +

lower boundaries for parameters

+
par.upper +

upper boundaries for parameters

+
par.pftspecif +

Which parameter is PFT specific (TRUE) or global (FALSE)?

+
par.names +

parameter name

+
is.int +

is parameter a integer?

+
... +

further arguments for CheckLPJpar

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a list of class 'LPJpar'

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CheckLPJpar

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/LWin2LWnet.html b/LPJmLmdi/html/LWin2LWnet.html new file mode 100644 index 0000000..33cd2c1 --- /dev/null +++ b/LPJmLmdi/html/LWin2LWnet.html @@ -0,0 +1,70 @@ +R: Compute long-wave net radiation from long-wave incoming... + + + + +
LWin2LWnet {LPJmLmdi}R Documentation
+ +

Compute long-wave net radiation from long-wave incoming radiation and temperature.

+ +

Usage

+ +
LWin2LWnet(lwin, temp, emissivity = 0.97)
+ + +

Arguments

+ + + + + + + + +
lwin +

long-wave incoming radiation (Wm-2)

+
temp +

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

+
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).

+
+ + +

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).

+ + +

Value

+ +

The function returns long-wave net radiation (Wm-2)

+ + +

Author(s)

+ +

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

+ + +

References

+ +

Campbell GS, Norman JM (1998) An Introduction to Environmental Biophysics. Springer New York, New York, NY.

+ + +

See Also

+ +

WriteLPJinput

+ + +

Examples

+ +
+lwin <- 200:380 # long-wave incoming radiation (Wm-2)
+temp <- 0.14 * lwin - 32 + rnorm(length(lwin), 0, 5) # temperature (degC)
+plot(lwin, temp)
+lwnet <- LWin2LWnet(lwin, temp)
+plot(temp, lwnet)
+plot(lwin, lwnet)
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/OptimizeLPJgenoud.html b/LPJmLmdi/html/OptimizeLPJgenoud.html new file mode 100644 index 0000000..86afdf4 --- /dev/null +++ b/LPJmLmdi/html/OptimizeLPJgenoud.html @@ -0,0 +1,120 @@ +R: Optimize LPJ using the GENOUD optimizer (genetic optimization... + + + + +
OptimizeLPJgenoud {LPJmLmdi}R Documentation
+ +

Optimize LPJ using the GENOUD optimizer (genetic optimization using derivatives)

+ +

Description

+ +

This function performs an optimization of LPJmL model parameters for the specified grid cells unsing the GENOUD genetic optimization algorithm.

+ + +

Usage

+ +
OptimizeLPJgenoud(xy, name, lpjpar, par.optim, lpjfiles, copy.input = TRUE, 
+    integrationdata, plot = TRUE, pop.size = 1000, max.generations = 20, 
+    wait.generations = 19, BFGSburnin = 18, calc.jacob = FALSE, 
+    restart = 0, path.rescue = NULL, restart.jacob = FALSE, nodes = 1, 
+    maxAutoRestart = 5, runonly = FALSE, new.spinup4post = TRUE, 
+    CostMDS = CostMDS.SSE)
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
xy +

matrix of grid cell coordinates to run LPJ

+
name +

name of the experiment (basic file name for all outputs)

+
lpjpar +

data.frame of class LPJpar that define all LPJ parameter values, ranges, and names

+
par.optim +

names of the parameters that should be optimized

+
lpjfiles +

list of class LPJfiles that define all LPJ directories, input files, configuration template files

+
copy.input +

Should LPJ input data be copied to the directory for temporary output? This might speed up computations if the directory is on the same machine where the program runs.

+
integrationdata +

list of integration data and information

+
plot +

plot diagnostic graphics of optimization results?

+
pop.size +

population size, see genoud

+
max.generations +

max number of generations, see genoud

+
wait.generations +

How many generations should genoud wait before returning an optimum, see genoud

+
BFGSburnin +

The number of generations before the L-BFGS-B algorithm is first used, see genoud

+
calc.jacob +

Should the Hessian and Jacobian matrix be computed (yes = TRUE, no = FALSE)?

+
restart +

Where to re-start the optimization? 0 = start at the beginning, 1 = continue with existing genoud optimization, 2 = start after genoud and post-process results.

+
path.rescue +

directory where the resuce files from each iteration of a previous optimization are saved. This is needed if restart > 0.

+
restart.jacob +

Should the Hessian and Jacobian matrix be recomputed if restart > 0 (yes = TRUE, no = FALSE)? Works only if calc.jacob is TRUE.

+
nodes +

use parallel computing? How many nodes to use?

+
maxAutoRestart +

maximum number of automatic restarts of the optimization if an error occurs within genoud()

+
runonly +

run only the model with prior parameters set but don't perform optimization. Produces only results of prior model run.

+
new.spinup4post +

What spinup conditions should be used for the posterior ('posterior-best' and 'posterior-median') model runs? If TRUE, a new spinup is computed based on the optimized parameters. If FALSE, the posterior model runs are started from the spinup conditions of the prior model run (like the runs during optimization).

+
CostMDS +

cost function for multiple data streams to calculate total cost, cost per data stream, and eventually cost per grid cell. See CostMDS.SSE (default) or CostMDS.KGE

+
+ + +

Author(s)

+ +

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

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/PlotPar.html b/LPJmLmdi/html/PlotPar.html new file mode 100644 index 0000000..8bdc333 --- /dev/null +++ b/LPJmLmdi/html/PlotPar.html @@ -0,0 +1,71 @@ +R: Plot parameter vs. cost + + + + +
PlotPar {LPJmLmdi}R Documentation
+ +

Plot parameter vs. cost

+ +

Description

+ +

The function takes an object of class 'rescue' (see CombineRescueFiles) (alternatively a 'data.frame' as created with Rescue2Df) and a 'LPJpar' object and plots different plots of cost vs. parameter value and parameter uncertainties.

+ + +

Usage

+ +
PlotPar(rescue.l, lpjpar, par.name = NULL, ...)
+ + +

Arguments

+ + + + + + + + + + +
rescue.l +

a list of class "rescue" (CombineRescueFiles) or alternatively a data.frame as created with Rescue2Df.

+
lpjpar +

a list of class "LPJpar" (see LPJpar)

+
par.name +

name(s) of the parameters that should be plotted

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CombineRescueFiles

+ + +

Examples

+ +
+# files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE))
+# rescue.l <- CombineRescueFiles(files, remove=FALSE)
+# PlotCostPar(rescue.l, lpjpar)
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/PlotParPCA.html b/LPJmLmdi/html/PlotParPCA.html new file mode 100644 index 0000000..6ea6351 --- /dev/null +++ b/LPJmLmdi/html/PlotParPCA.html @@ -0,0 +1,59 @@ +R: plot a PCA of optimized parameters + + + + +
PlotParPCA {LPJmLmdi}R Documentation
+ +

plot a PCA of optimized parameters

+ +

Description

+ +

The function takes an object of class 'rescue' (see 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.

+ + +

Usage

+ +
PlotParPCA(rescue.l, ...)
+ + +

Arguments

+ + + + + + +
rescue.l +

a list of class "rescue", see CombineRescueFiles

+
... +

further arguments for plot

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns an object of class 'princomp'.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CombineRescueFiles, princomp

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/PlotWorld110.html b/LPJmLmdi/html/PlotWorld110.html new file mode 100644 index 0000000..19ce567 --- /dev/null +++ b/LPJmLmdi/html/PlotWorld110.html @@ -0,0 +1,60 @@ +R: Plot a world map based on 1:110Mio data + + + + +
PlotWorld110 {LPJmLmdi}R Documentation
+ +

Plot a world map based on 1:110Mio data

+ +

Usage

+ +
PlotWorld110(admin = FALSE, lakes = TRUE, rivers = TRUE, col = c("black", 
+    "blue", "red"), bg = NA, ...)
+ + +

Arguments

+ + + + + + + + + + + + + + +
admin +

Plot administrative boundaries?

+
lakes +

Plot lakes?

+
rivers +

Plot rivers?

+
col +

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

+
bg +

background color, default: NA (no background)

+
... +

additional arguments to plot

+
+ + +

Author(s)

+ +

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

+ + +

Examples

+ +
+
+PlotWorld110()
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/PrepareRestartFiles.html b/LPJmLmdi/html/PrepareRestartFiles.html new file mode 100644 index 0000000..a458689 --- /dev/null +++ b/LPJmLmdi/html/PrepareRestartFiles.html @@ -0,0 +1,54 @@ +R: Prepare restart files to restart OptimizeLPJgenoud + + + + +
PrepareRestartFiles {LPJmLmdi}R Documentation
+ +

Prepare restart files to restart OptimizeLPJgenoud

+ +

Description

+ +

The function prepares all files that are needed to restart OptimizeLPJgenoud

+ + +

Usage

+ +
PrepareRestartFiles(file.optsetup, ...)
+ + +

Arguments

+ + + + + + +
file.optsetup +

OptimizeLPJgenoud setup file, ends with "_optsetup.RData"

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

LPJfiles

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/R.css b/LPJmLmdi/html/R.css new file mode 100644 index 0000000..6fb3c36 --- /dev/null +++ b/LPJmLmdi/html/R.css @@ -0,0 +1,96 @@ +body { + background: white; + color: black; +} + +a:link { + background: white; + color: blue; +} + +a:visited { + background: white; + color: rgb(50%, 0%, 50%); +} + +h1 { + background: white; + color: rgb(55%, 55%, 55%); + font-family: monospace; + font-size: x-large; + text-align: center; +} + +h2 { + background: white; + color: rgb(40%, 40%, 40%); + font-family: monospace; + font-size: large; + text-align: center; +} + +h3 { + background: white; + color: rgb(40%, 40%, 40%); + font-family: monospace; + font-size: large; +} + +h4 { + background: white; + color: rgb(40%, 40%, 40%); + font-family: monospace; + font-style: italic; + font-size: large; +} + +h5 { + background: white; + color: rgb(40%, 40%, 40%); + font-family: monospace; +} + +h6 { + background: white; + color: rgb(40%, 40%, 40%); + font-family: monospace; + font-style: italic; +} + +img.toplogo { + vertical-align: middle; +} + +img.arrow { + width: 30px; + height: 30px; + border: 0; +} + +span.acronym { + font-size: small; +} + +span.env { + font-family: monospace; +} + +span.file { + font-family: monospace; +} + +span.option{ + font-family: monospace; +} + +span.pkg { + font-weight: bold; +} + +span.samp{ + font-family: monospace; +} + +div.vignettes a:hover { + background: rgb(85%, 85%, 85%); +} diff --git a/LPJmLmdi/html/ReadBIN.html b/LPJmLmdi/html/ReadBIN.html new file mode 100644 index 0000000..7f846d8 --- /dev/null +++ b/LPJmLmdi/html/ReadBIN.html @@ -0,0 +1,88 @@ +R: Read simple binary files without header Read a CLM file to a... + + + + +
ReadBIN {LPJmLmdi}R Documentation
+ +

Read simple binary files without header Read a CLM file to a SpatialPixelsDataFrame

+ +

Description

+ +

The function is used to read for example the soil*.bin and drainclass.bin files

+ + +

Usage

+ +
ReadBIN(file.bin, nbands = 1, size = 1, file.grid = NA, endian.data = "little", 
+    endian.grid = "little", data.type = integer(), ...)
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + +
file.bin +

binary file name with extension *.bin

+
nbands +

number of bands per year

+
size +

The number of bytes per element in the byte stream.

+
file.grid +

file name of the corresponding grid file

+
endian.data +

endinaess of the data file

+
endian.grid +

endianess of the grid file

+
data.type +

type of the data

+
... +

Further arguments (currently not used).

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

WriteCLM

+ + +

Examples

+ +
+
+# ReadBIN("soil_new_67420.bin")
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ReadCLM.html b/LPJmLmdi/html/ReadCLM.html new file mode 100644 index 0000000..26dc8c7 --- /dev/null +++ b/LPJmLmdi/html/ReadCLM.html @@ -0,0 +1,91 @@ +R: Read a CLM file to a SpatialPixelsDataFrame + + + + +
ReadCLM {LPJmLmdi}R Documentation
+ +

Read a CLM file to a SpatialPixelsDataFrame

+ +

Usage

+ +
ReadCLM(file.clm, start = NA, end = NA, start.year = NA, grid = NULL, 
+    nbands = NA, size = NA, file.grid = NA, endian.data = NA, 
+    endian.grid = "big", data.type = integer(), ...)
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
file.clm +

CLM file name with extension *.clm

+
start +

first year to be read

+
end +

last year to be read, reads until last year in case of NA

+
start.year +

first year in the dataset, read from header information in case NA

+
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

+
nbands +

number of bands per year, read from header information in case NA

+
size +

The number of bytes per element in the byte stream.

+
file.grid +

file name of the corresponding grid file

+
endian.data +

endinaess of the data file

+
endian.grid +

endianess of the grid file

+
data.type +

type of the data

+
... +

Further arguments (currently not used).

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

WriteCLM

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ReadGrid.html b/LPJmLmdi/html/ReadGrid.html new file mode 100644 index 0000000..8f0ce7e --- /dev/null +++ b/LPJmLmdi/html/ReadGrid.html @@ -0,0 +1,53 @@ +R: Reads a binary input data grid file. + + + + +
ReadGrid {LPJmLmdi}R Documentation
+ +

Reads a binary input data grid file.

+ +

Usage

+ +
ReadGrid(file.grid = "cru.grid", endian = "little", ...)
+ + +

Arguments

+ + + + + + + + +
file.grid +

CLM file name with extension *.clm

+
endian +

endianess of the file

+
... +

Further arguments (currently not used).

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadCLM

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ReadLPJ.html b/LPJmLmdi/html/ReadLPJ.html new file mode 100644 index 0000000..eb39ce1 --- /dev/null +++ b/LPJmLmdi/html/ReadLPJ.html @@ -0,0 +1,103 @@ +R: Read a LPJ binary file + + + + +
ReadLPJ {LPJmLmdi}R Documentation
+ +

Read a LPJ binary file

+ +

Description

+ +

The function reads a binary LPJ output file and returns a SpatialPointsDataFrame

+ + +

Usage

+ +
ReadLPJ(file.bin, file.grid = "grid.bin", sim.start.year = 1901, 
+    start = sim.start.year, end = NA, file.annual = c("vegc.bin", 
+        "litc.bin", "soilc.bin"), size = 4, data.type = numeric(), 
+    endian = "little", ...)
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
file.bin +

binary LPJ output file

+
file.grid +

binary LPJ grid file

+
sim.start.year +

first year of the simulation

+
start +

first year to read

+
end +

last year to read, reads until last year if NA

+
file.annual +

one of the binary LPJ output files with annual data

+
size +

the number of bytes per element in the byte stream.

+
data.type +

data type of the file (default=numeric())

+
endian +

endianess of the binary file

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a SpatialPointsDataFrame.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadLPJsim

+ + +

Examples

+ +
+
+# ReadLPJ("mgpp.bin", start=1982, end=2011)
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ReadLPJ2IntegrationData.html b/LPJmLmdi/html/ReadLPJ2IntegrationData.html new file mode 100644 index 0000000..5d4c2bf --- /dev/null +++ b/LPJmLmdi/html/ReadLPJ2IntegrationData.html @@ -0,0 +1,67 @@ +R: Read LPJ model results into an of class IntegrationData + + + + +
ReadLPJ2IntegrationData {LPJmLmdi}R Documentation
+ +

Read LPJ model results into an of class IntegrationData

+ +

Description

+ +

The function reads for each dataset in IntegrationData the corresponding model output and performs temporal aggregation.

+ + +

Usage

+ +
ReadLPJ2IntegrationData(integrationdata, xy, lpjfiles, ...)
+ + +

Arguments

+ + + + + + + + + + +
integrationdata +

object of class IntegrationData

+
xy +

matrix of grid cell coordinates to run LPJ

+
lpjfiles +

list of class LPJfiles that define all LPJ directories, input files, configuration template files

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns the same list oc class 'IntegrationData' but with added model outputs.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationData

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ReadLPJ2ts.html b/LPJmLmdi/html/ReadLPJ2ts.html new file mode 100644 index 0000000..3d6603d --- /dev/null +++ b/LPJmLmdi/html/ReadLPJ2ts.html @@ -0,0 +1,81 @@ +R: Read a LPJ binary file and returns a spatial averaged time... + + + + +
ReadLPJ2ts {LPJmLmdi}R Documentation
+ +

Read a LPJ binary file and returns a spatial averaged time series

+ +

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

+ + +

Usage

+ +
ReadLPJ2ts(file.bin, sim.start.year = 1901, start = sim.start.year, 
+    end = NA, ...)
+ + +

Arguments

+ + + + + + + + + + + + +
file.bin +

binary LPJ output file

+
sim.start.year +

first year of the simulation

+
start +

first year to read

+
end +

last year to read, reads until last year if NA

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a time series of class 'ts'.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadLPJsim

+ + +

Examples

+ +
+
+# gpp <- ReadLPJ2ts("mgpp.bin")
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ReadLPJinput.html b/LPJmLmdi/html/ReadLPJinput.html new file mode 100644 index 0000000..0943e29 --- /dev/null +++ b/LPJmLmdi/html/ReadLPJinput.html @@ -0,0 +1,77 @@ +R: Read and subset CLM files to LPJinput objects + + + + +
ReadLPJinput {LPJmLmdi}R Documentation
+ +

Read and subset CLM files to LPJinput objects

+ +

Description

+ +

The functions reads a CLM file, selects the data according to the provided grid and returns an object of class LPJinput.

+ + +

Usage

+ +
ReadLPJinput(files, grid = NULL, start = NA, ...)
+ + +

Arguments

+ + + + + + + + + + +
files +

character vector of CLM or binary file names

+
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.

+
start +

first year to read

+
... +

Further arguments to ReadCLM or ReadBIN

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a list of class "LPJinput".

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

WriteLPJinput

+ + +

Examples

+ +
+
+# 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)))
+# str(lpjinput)
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ReadLPJsim.html b/LPJmLmdi/html/ReadLPJsim.html new file mode 100644 index 0000000..1765c1a --- /dev/null +++ b/LPJmLmdi/html/ReadLPJsim.html @@ -0,0 +1,86 @@ +R: Read a LPJ simulation results + + + + +
ReadLPJsim {LPJmLmdi}R Documentation
+ +

Read a LPJ simulation results

+ +

Description

+ +

The function reads all binary output files from a LPJ simulation and returns regional aggregated time series.

+ + +

Usage

+ +
ReadLPJsim(sim.start.year = 1901, start = sim.start.year, end = NA, 
+    files = NA, outputvars.par = NULL, ...)
+ + +

Arguments

+ + + + + + + + + + + + + + +
sim.start.year +

first year of the simulation

+
start +

first year to read

+
end +

last year to read. If NA, reads until last year

+
files +

Which LPJ binary output files should be read? If NA, all *.bin files in the current directory are read.

+
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.

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a list of class 'LPJsim'

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadLPJ2ts

+ + +

Examples

+ +
+
+# setwd(path.mylpjresult)
+# sim <- ReadLPJsim(start=1982, end=2011)
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ReadOutputvars.html b/LPJmLmdi/html/ReadOutputvars.html new file mode 100644 index 0000000..d50f41e --- /dev/null +++ b/LPJmLmdi/html/ReadOutputvars.html @@ -0,0 +1,68 @@ +R: Read 'outputvars.par' to get information about LPJmL output + + + + +
ReadOutputvars {LPJmLmdi}R Documentation
+ +

Read 'outputvars.par' to get information about LPJmL output

+ +

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 ReadLPJsim.

+ + +

Usage

+ +
ReadOutputvars(outputvars.par = NULL, ...)
+ + +

Arguments

+ + + + + + +
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.

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a time series of class 'ts'.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadLPJsim

+ + +

Examples

+ +
+
+# ReadOutputvars()
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/ReadPRO.html b/LPJmLmdi/html/ReadPRO.html new file mode 100644 index 0000000..0d17310 --- /dev/null +++ b/LPJmLmdi/html/ReadPRO.html @@ -0,0 +1,50 @@ +R: Read *.pro files as produced from GENOUD + + + + +
ReadPRO {LPJmLmdi}R Documentation
+ +

Read *.pro files as produced from GENOUD

+ +

Description

+ +

The function is used within OptimizeLPJgenoud

+ + +

Usage

+ +
ReadPRO(files.pro)
+ + +

Arguments

+ + + + +
files.pro +

file names (*.pro) of genoud optimization results

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

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

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/Rescue2Df.html b/LPJmLmdi/html/Rescue2Df.html new file mode 100644 index 0000000..3ca81a6 --- /dev/null +++ b/LPJmLmdi/html/Rescue2Df.html @@ -0,0 +1,73 @@ +R: Convert a 'rescue' list to a data.frame + + + + +
Rescue2Df {LPJmLmdi}R Documentation
+ +

Convert a 'rescue' list to a data.frame

+ +

Description

+ +

The function takes an object of class 'rescue' (see 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).

+ + +

Usage

+ +
Rescue2Df(rescue.l, lpjpar = NULL, ...)
+ + +

Arguments

+ + + + + + + + +
rescue.l +

a list of class "rescue", see CombineRescueFiles

+
lpjpar +

a list of class "LPJpar" (see LPJpar) to convert the scaled parameters in rescue.l back to the original units (optional)

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a data.frame.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CombineRescueFiles

+ + +

Examples

+ +
+# files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE))
+# rescue.l <- CombineRescueFiles(files, remove=FALSE)
+# optim.df <- Rescue2Df(rescue.l)
+# summary(optim.df)
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/Rescue2LPJpar.html b/LPJmLmdi/html/Rescue2LPJpar.html new file mode 100644 index 0000000..430da66 --- /dev/null +++ b/LPJmLmdi/html/Rescue2LPJpar.html @@ -0,0 +1,96 @@ +R: Add information from a 'rescue' list to an 'LPJpar' object + + + + +
Rescue2LPJpar {LPJmLmdi}R Documentation
+ +

Add information from a 'rescue' list to an 'LPJpar' object

+ +

Description

+ +

The function takes an object of class 'rescue' (see CombineRescueFiles) (alternatively a 'data.frame' as created with Rescue2Df) and a 'LPJpar' (see LPJpar) object. Then it extracts the best parameter set, the median of the best parameter sets (defined based on dAIC <= 2), and various uncertainty measures and adds them to the 'LPJpar' object.

+ + +

Usage

+ +
Rescue2LPJpar(rescue.l, lpjpar, ...)
+ + +

Arguments

+ + + + + + + + +
rescue.l +

a list of class "rescue" (CombineRescueFiles) or alternatively a data.frame as created with Rescue2Df.

+
lpjpar +

a list of class "LPJpar" (LPJpar)

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns the provided 'LPJpar' object with the following additional slots: +

+ +
    +
  • best Best parameter set +

    +
  • +
  • best.median median of best parameter sets (based on all parameter sets with dAIC <= 2) +

    +
  • +
  • uncertainty.iqr uncertainty of parameters as the inter-quartile range of the best parameter sets +

    +
  • +
  • uncertainty.iqr95 uncertainty of parameters as the central 95% inter-quantile range (0.975-0.025) of the best parameter sets +

    +
  • +
  • uncertainty.005.min lower parameter uncertainty estimate based on the minimum parameter value from all parameter sets for which the cost <= quantile(cost, 0.05) +

    +
  • +
  • uncertainty.005.max upper parameter uncertainty estimate based on the maximum parameter value from all parameter sets for which the cost <= quantile(cost, 0.05) +

    +
+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CombineRescueFiles

+ + +

Examples

+ +
+files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE))
+rescue.l <- CombineRescueFiles(files, remove=FALSE)
+lpjpar2 <- Rescue2LPJpar(rescue.l, lpjpar)
+str(lpjpar2)
+plot(lpjpar2, "ALPHAA", "uncertainty.iqr95")
+plot(lpjpar2, "TMIN_BASE", "uncertainty.iqr95")
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/RunLPJ.html b/LPJmLmdi/html/RunLPJ.html new file mode 100644 index 0000000..c3b1196 --- /dev/null +++ b/LPJmLmdi/html/RunLPJ.html @@ -0,0 +1,93 @@ +R: Run LPJmL from R and get results + + + + +
RunLPJ {LPJmLmdi}R Documentation
+ +

Run LPJmL from R and get results

+ +

Description

+ +

This function calls LPJmL, reads the results of the model run, computes the cost based on the data sets in IntegrationData and the defined cost function (in CostMDS), and returns the simulation results.

+ + +

Usage

+ +
RunLPJ(dpar, lpjpar, which.par.opt, lpjfiles, path = NULL, integrationdata, 
+    xy, newcell = FALSE, name = "LPJmL", plot = FALSE, getresult = FALSE, 
+    clean = 1, clean.path = FALSE, CostMDS = CostMDS.SSE, nkeep = 400)
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
dpar +

vector of scaling factors for each parameter in 'which.par.opt': parameter = dpar * prior (e.g. if dpar is 1, prior parameters are used in the model run). Optimization is performed on these scaling factors

+
lpjpar +

data.frame of class LPJpar that define LPJ parameter values, ranges, and names

+
which.par.opt +

integer vector that indicates which parameters in lpjpar should be optimized

+
lpjfiles +

list of class LPJfiles that define all LPJ directories, input files, configuration template files

+
path +

path for output files of actual model run

+
integrationdata +

list of of class IntegrationData

+
xy +

matrix of grid cell coordinates to run LPJ

+
newcell +

calculate new cell and new spinup?

+
name +

name of the LPJ run, basic name for all outputs

+
plot +

plot results? see plot.IntegrationData

+
getresult +

If TRUE, all model results are returned in a LPJsim object and model results are saved. If FALSE, only the cost function value is returned.

+
clean +

clean results and temporay configuration and parameter files? 0 = keep everthing; 1 = delete parameter files, conf files and outputs; 2 = clean additionally input files, soil code files and restart

+
clean.path +

Delete output directory 'path' in case it already exists before the model run?

+
CostMDS +

cost function for multiple data streams

+
nkeep +

number of result files to keep. If more are existing, the ones with highest costs will be deleted

+
+ + +

Author(s)

+ +

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

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/SSE.html b/LPJmLmdi/html/SSE.html new file mode 100644 index 0000000..4257752 --- /dev/null +++ b/LPJmLmdi/html/SSE.html @@ -0,0 +1,65 @@ +R: Sum-of-squared residuals error + + + + +
SSE {LPJmLmdi}R Documentation
+ +

Sum-of-squared residuals error

+ +

Description

+ +

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

+ + +

Usage

+ +
SSE(sim, obs, unc)
+ + +

Arguments

+ + + + + + + + +
sim +

vector of simulations

+
obs +

vector of observations

+
unc +

vector of observation uncertainties

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

Examples

+ +
+
+obs <- rnorm(10, 0, 2)
+sim <- obs + rnorm(10, 0.05, 0.01)
+unc <- 0.01
+SSE(sim, obs, unc)
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/StandardError.html b/LPJmLmdi/html/StandardError.html new file mode 100644 index 0000000..52167a4 --- /dev/null +++ b/LPJmLmdi/html/StandardError.html @@ -0,0 +1,53 @@ +R: Compute standard errors from a variance-covariance matrix + + + + +
StandardError {LPJmLmdi}R Documentation
+ +

Compute standard errors from a variance-covariance matrix

+ +

Description

+ +

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

+ + +

Usage

+ +
StandardError(vc, nobs, cost)
+ + +

Arguments

+ + + + + + + + +
vc +

variance-covarianc ematrix

+
nobs +

number of observations

+
cost +

cost function value

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/StartingValues.html b/LPJmLmdi/html/StartingValues.html new file mode 100644 index 0000000..0ab57c7 --- /dev/null +++ b/LPJmLmdi/html/StartingValues.html @@ -0,0 +1,58 @@ +R: Get starting values for genoud from *.pro file + + + + +
StartingValues {LPJmLmdi}R Documentation
+ +

Get starting values for genoud from *.pro file

+ +

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 OptimizeLPJgenoud is a restart is performed.

+ + +

Usage

+ +
StartingValues(file.optresult, pop.size = NULL, ...)
+ + +

Arguments

+ + + + + + + + +
file.optresult +

genoud *.pro file with optimization results

+
pop.size +

population size

+
... +

further arguments (not used)

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

OptimizeLPJgenoud

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/Texture2Soilcode.html b/LPJmLmdi/html/Texture2Soilcode.html new file mode 100644 index 0000000..3faf11f --- /dev/null +++ b/LPJmLmdi/html/Texture2Soilcode.html @@ -0,0 +1,87 @@ +R: Convert soil texture to a LPJ soilcode + + + + +
Texture2Soilcode {LPJmLmdi}R Documentation
+ +

Convert soil texture to a LPJ soilcode

+ +

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".

+ + +

Usage

+ +
Texture2Soilcode(sand, silt, clay, lpj.soilcodes = c("Cl", "SiCl", 
+    "SaCl", "ClLo", "SiClLo", "SaClLo", "Lo", "SiLo", "SaLo", 
+    "Si", "LoSa", "Sa"), plot = TRUE, ...)
+ + +

Arguments

+ + + + + + + + + + + + + + +
sand +

percentage of sand

+
silt +

percentage of silt

+
clay +

percentage of clay

+
lpj.soilcodes +

LPJ soil codes

+
plot +

plot soil triangle?

+
... +

Further arguments (currently not used).

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns the LPJ soilcode

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadBIN

+ + +

Examples

+ +
+
+# data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m))
+# WriteBIN(data.sp, file="data.bin")	
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/VarCovMatrix.html b/LPJmLmdi/html/VarCovMatrix.html new file mode 100644 index 0000000..4216773 --- /dev/null +++ b/LPJmLmdi/html/VarCovMatrix.html @@ -0,0 +1,49 @@ +R: Compute variance-covariance matrix + + + + +
VarCovMatrix {LPJmLmdi}R Documentation
+ +

Compute variance-covariance matrix

+ +

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.

+ + +

Usage

+ +
VarCovMatrix(hessian, nms = paste("P", 1:n, sep = ""))
+ + +

Arguments

+ + + + + + +
hessian +

Hessian matrix

+
nms +

names of the parameters (rows and columns in the matrix

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/WriteBIN.html b/LPJmLmdi/html/WriteBIN.html new file mode 100644 index 0000000..64c427a --- /dev/null +++ b/LPJmLmdi/html/WriteBIN.html @@ -0,0 +1,77 @@ +R: Write a BIN file from SpatialPointsDataFrame + + + + +
WriteBIN {LPJmLmdi}R Documentation
+ +

Write a BIN file from SpatialPointsDataFrame

+ +

Description

+ +

The function writes BIN files from a SpatialPointsDataFrame or SpatialPixelsDataFrame.

+ + +

Usage

+ +
WriteBIN(data.sp, file.bin, size = 1, ...)
+ + +

Arguments

+ + + + + + + + + + +
data.sp +

SpatialPointsDataFrame or SpatialPixelsDataFrame with data

+
file.bin +

binary file name with extension *.bin

+
size +

The number of bytes per element in the byte stream.

+
... +

Further arguments (currently not used).

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns TRUE if the CLM file was created.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadBIN

+ + +

Examples

+ +
+
+# data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m))
+# WriteBIN(data.sp, file="data.bin")	
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/WriteCLM.html b/LPJmLmdi/html/WriteCLM.html new file mode 100644 index 0000000..24892da --- /dev/null +++ b/LPJmLmdi/html/WriteCLM.html @@ -0,0 +1,102 @@ +R: Write a CLM file from SpatialPointsDataFrame + + + + +
WriteCLM {LPJmLmdi}R Documentation
+ +

Write a CLM file from SpatialPointsDataFrame

+ +

Description

+ +

The function writes CLM files from a SpatialPointsDataFrame or SpatialPixelsDataFrame. The LPJmL program cru2clm needs to be installed.

+ + +

Usage

+ +
WriteCLM(data.sp, file.clm, start, nbands, size = 2, scale = 1, 
+    na.replace = -9999, path.lpj = NULL, res = 0.5, ...)
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
data.sp +

SpatialPointsDataFrame or SpatialPixelsDataFrame with data

+
file.clm +

CLM file name with extension *.clm

+
start +

integer. First year in data.

+
nbands +

Number of bands per year.

+
size +

The number of bytes per element in the byte stream.

+
scale +

Scaling factor to be written to the header of the CLM file. The factor will be not applied to the data.

+
na.replace +

integer to replace NA values.

+
path.lpj +

path to LPJ installation

+
res +

spatial resolution of the grid cells

+
... +

Further arguments (currently not used).

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns TRUE if the CLM file was created.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

WriteLPJinput

+ + +

Examples

+ +
+
+# data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m))
+# WriteCLM(data.sp, file="data.clm", start=1901, nbands=12, size=2)	
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/WriteGrid.html b/LPJmLmdi/html/WriteGrid.html new file mode 100644 index 0000000..ee67203 --- /dev/null +++ b/LPJmLmdi/html/WriteGrid.html @@ -0,0 +1,74 @@ +R: Write a *.grid file from a matrix of coordiantes or a... + + + + +
WriteGrid {LPJmLmdi}R Documentation
+ +

Write a *.grid file from a matrix of coordiantes or a SpatialPointsDataFrame

+ +

Description

+ +

Writes a grid file for LPJ input data. The functions needs the LPJmL module txt2grid to be installed.

+ + +

Usage

+ +
WriteGrid(grid, file.grid, ...)
+ + +

Arguments

+ + + + + + + + +
grid +

SpatialPointsDataFrame; SpatialPixelsDataFrame, matrix or data.frame with coordinates

+
file.grid +

Grid file name

+
... +

Further arguments (currently not used).

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns TRUE if the grid file was created.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

WriteLPJinput

+ + +

Examples

+ +
+
+lon <- c(59.75, 68.25)
+lat <- c(61.25, 65.75)
+WriteGrid(cbind(lon, lat), "test.grid")
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/WriteLPJinput.html b/LPJmLmdi/html/WriteLPJinput.html new file mode 100644 index 0000000..b193fe8 --- /dev/null +++ b/LPJmLmdi/html/WriteLPJinput.html @@ -0,0 +1,78 @@ +R: Write an object of class 'LPJinput' to CLM files + + + + +
WriteLPJinput {LPJmLmdi}R Documentation
+ +

Write an object of class 'LPJinput' to CLM files

+ +

Description

+ +

The function writes CLM input files for LPJ.

+ + +

Usage

+ +
WriteLPJinput(lpjinput, files = NULL, path.lpj = NULL, ...)
+ + +

Arguments

+ + + + + + + + + + +
lpjinput +

Object of class 'LPJinput' to be written.

+
files +

names of the output CLM or binary files.

+
path.lpj +

path to LPJ installation

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns TRUE if the CLM file was created.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

WriteLPJinput

+ + +

Examples

+ +
+
+# 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)))
+# str(lpjinput)
+# WriteLPJinput(lpjinput)
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/WriteLPJpar.html b/LPJmLmdi/html/WriteLPJpar.html new file mode 100644 index 0000000..a77a73f --- /dev/null +++ b/LPJmLmdi/html/WriteLPJpar.html @@ -0,0 +1,76 @@ +R: Writes an object of class 'LPJpar' as parameter file or... + + + + +
WriteLPJpar {LPJmLmdi}R Documentation
+ +

Writes an object of class 'LPJpar' as parameter file or table.

+ +

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.

+ + +

Usage

+ +
WriteLPJpar(x, file = "LPJpar", pft.par = NULL, param.par = NULL, 
+    param.only = TRUE, ...)
+ + +

Arguments

+ + + + + + + + + + + + + + +
x +

object of class 'LPJpar'

+
file +

basic file name for all output files, e.g. name of the optimization experiment

+
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.

+
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.

+
param.only +

write only parameters to table (TRUE) or also parameter prior ranges (FALSE)?

+
... +

further arguments for CheckLPJpar

+
+ + +

Details

+ +

No details.

+ + +

Value

+ +

The function returns a data.frame with an overview of the written files

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

LPJpar, CheckLPJpar

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/plot.IntegrationData.html b/LPJmLmdi/html/plot.IntegrationData.html new file mode 100644 index 0000000..3b77cb7 --- /dev/null +++ b/LPJmLmdi/html/plot.IntegrationData.html @@ -0,0 +1,64 @@ +R: Plot an object of class IntegrationData + + + + +
plot.IntegrationData {LPJmLmdi}R Documentation
+ +

Plot an object of class IntegrationData

+ +

Description

+ +

The function plots an object of class IntegrationData, i.e. it produces a time series plots, scatterplots and a boxplot for the observations and LPJmL model outputs in IntegrationData.

+ + +

Usage

+ +
## S3 method for class 'IntegrationData'
+plot(x, ds = 1:length(x), CostMDS = CostMDS.SSE, 
+    ...)
+ + +

Arguments

+ + + + + + + + + + +
x +

object of class IntegrationData

+
ds +

Which data sets in x should be plotted (integer)

+
CostMDS +

cost function for multiple data streams

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

IntegrationData

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/plot.LPJpar.html b/LPJmLmdi/html/plot.LPJpar.html new file mode 100644 index 0000000..0107575 --- /dev/null +++ b/LPJmLmdi/html/plot.LPJpar.html @@ -0,0 +1,95 @@ +R: Plot parameters in 'LPJpar' object. + + + + +
plot.LPJpar {LPJmLmdi}R Documentation
+ +

Plot parameters in 'LPJpar' object.

+ +

Usage

+ +
## S3 method for class 'LPJpar'
+plot(x, par.name = NULL, uncertainty = "uncertainty.iqr", 
+    col = NULL, ylim = NULL, xlim = NULL, which.pft = NULL, if.opt = FALSE, 
+    names = FALSE, xaxt = "s")
+ + +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
x +

object of class 'LPJpar'

+
par.name +

name(s) of the parameters that should be plotted

+
uncertainty +

name of the uncertainty estimate in LPJpar that should be used to plot posterior uncertainties

+
col +

vector of colours for PFT-specific parameters

+
ylim +

limits of the y-axis

+
xlim +

limits of the x-axis

+
which.pft +

character vector of PFT names that should be plotted. If NULL all

+
if.opt +

plot parameters only if optimized (i.e. best) parameters are in LPJpar

+
names +

plot PFT names within the plot?

+
xaxt +

x axis type. "n" suppresses the x axis.

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

LPJpar, CheckLPJpar

+ + +

Examples

+ +
+# plot(lpjpar, par.name="ALBEDO_LEAF_TeBS", uncertainty="uncertainty.iqr95")
+# plot(lpjpar, par.name="ALBEDO_LEAF", uncertainty="uncertainty.iqr")
+# plot(lpjpar, par.name="LIGHTEXTCOEFF", uncertainty="uncertainty.iqr")
+# par(mfrow=c(2,2))
+# plot(lpjpar, par.name=c("ALPHAA", "LIGHTEXTCOEFF", "ALBEDO_LEAF"))
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/plot.LPJsim.html b/LPJmLmdi/html/plot.LPJsim.html new file mode 100644 index 0000000..4013430 --- /dev/null +++ b/LPJmLmdi/html/plot.LPJsim.html @@ -0,0 +1,87 @@ +R: Plots a LPJsim object + + + + +
plot.LPJsim {LPJmLmdi}R Documentation
+ +

Plots a LPJsim object

+ +

Description

+ +

The function plots a LPJsim object: monthly, annual time series or map of grid cells

+ + +

Usage

+ +
## S3 method for class 'LPJsim'
+plot(x, what = "annual", start = NA, end = NA, omit0 = TRUE, 
+    AggFun = AggMeanNULL, ...)
+ + +

Arguments

+ + + + + + + + + + + + + + + + +
x +

an object of class 'LPJsim'

+
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

+
start +

first year for time series plot

+
end +

last year for time series plot

+
omit0 +

omit variables from plotting that are only 0?

+
AggFun +

aggregation function to aggregate results to the temporal resolution as selected in 'what', for example AggMeanNULL for monthly or annual means, AggSumNULL for monthly or annual sums.

+
... +

further arguments (currently not used)

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

ReadLPJ2ts, ReadLPJsim

+ + +

Examples

+ +
+
+# setwd(path.mylpjresult)
+# sim <- ReadLPJ2ts(start=1982, end=2011)
+# plot(sim, what="annual")
+
+
+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/html/plot.rescue.html b/LPJmLmdi/html/plot.rescue.html new file mode 100644 index 0000000..f18de71 --- /dev/null +++ b/LPJmLmdi/html/plot.rescue.html @@ -0,0 +1,76 @@ +R: plot an object of class "rescue" / monitor OptimizeLPJgenoud + + + + +
plot.rescue {LPJmLmdi}R Documentation
+ +

plot an object of class "rescue" / monitor OptimizeLPJgenoud

+ +

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)".

+ + +

Usage

+ +
## S3 method for class 'rescue'
+plot(x, ylim = NULL, xlim = NULL, ylab = "Cost", xlab = "Individuals of genetic optimization", 
+    only.cost = FALSE, ...)
+ + +

Arguments

+ + + + + + + + + + + + + + + + +
x +

a list of class "rescue", see CombineRescueFiles

+
ylim +

limits of the y-axis of the plot

+
xlim +

limits of the x-axis of the plot

+
ylab +

label for the y axis

+
xlab +

label for the x axis

+
only.cost +

plot all integration datasets (TRUE) or only these ones with cost=TRUE

+
... +

further arguments for plot

+
+ + +

Details

+ +

No details.

+ + +

Author(s)

+ +

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

+ + +

References

+ +

No reference.

+ + +

See Also

+ +

CombineRescueFiles

+ +
[Package LPJmLmdi version 1.0 Index]
+ diff --git a/LPJmLmdi/inst_LPJmL35/LPJmL-MDI_example.R b/LPJmLmdi/inst_LPJmL35/LPJmL-MDI_example.R new file mode 100644 index 0000000..90f5ea9 --- /dev/null +++ b/LPJmLmdi/inst_LPJmL35/LPJmL-MDI_example.R @@ -0,0 +1,260 @@ +#-------------------------------------------------------------------------------- +# NAME: +filename <- "LPJmL-MDI_example.R" +# PROJECT: Example script for the use of LPJmL-MDI +# CREATION DATE: 2015-09-24 +# AUTHOR: Matthias Forkel, mforkel@bgc-jena.mpg.de +# UPDATE: +#-------------------------------------------------------------------------------- + + +#--------------------------------------------------------------------- +# 1. Set directories, load packages and define optimization experiment +#--------------------------------------------------------------------- + + +# define directories +#------------------- + +rm(list=ls(all=TRUE)) +for (i in 1:10) gc() +options(error=traceback) + +# paths +path.me <- "/Net/Groups/BGI/people/mforkel/" # main directory +# path.me <- "Z://" +path.geodata <- paste0(path.me, "geodata/") # directory with data +path.lpj.fun <- paste0(path.me, "R_packages/LPJmLmdi/") # LPJmL-MDI package +path.lpj.input <- paste0(path.me, "lpj/input_global/") # LPJmL input data +path.lpj <- paste0(path.me, "lpj/LPJmL_131016/") # LPJmL installation +path.tmp <- "/scratch/mforkel/" # temporay model outputs +path.out <- paste0(path.lpj, "/out_optim/opt_Example/") +dir.create(path.out) + + +# load packages and functions +#---------------------------- + +# load packages +library(raster) +library(plyr) +library(rgenoud) +library(snow) +library(doSNOW) +library(RColorBrewer) +library(quantreg) +library(numDeriv) + +# load functions of the LPJmL-MDI package +setwd(paste0(path.lpj.fun, "R/")) +files <- list.files(pattern=".R") +for (i in 1:length(files)) source(files[i]) + +setwd(paste0(path.lpj.fun, "data/")) +load("data110.RData") + + +# define optimization experiment +#------------------------------- + +# define the optimization experiment +name <- "Opt_Example" # name of the optimization experiment: base name for all output files +calcnew <- TRUE # extract LPJmL forcing data for the selected grid cells or take previously extracted data? +CostMDS <- CostMDS.SSE # cost function for multiple data sets +restart <- 0 # restart from previous optimization experiment? + # 0 = no restart + # 1 = continue with optimization + # 2 = do only post-processing of optimization results +path.rescue <- NULL # directory with rescue files to restart from previous optimization (restart > 0) + +# settings for genetic optimization +nodes <- 1 # number of cluster nodes for parallel computing within genoud() +pop.size <- 10 # population size: 10 for testing, production run should have 800-1000 +max.generations <- 10 # maximum number of generations: 10 for testing, production run 20-60 +wait.generations <- 9 # minimum number of gnereations to wait before optimum parameter set is returned +BFGSburnin <- 11 # number of generations before the gradient search algorithm if first used + + +# remove temporary files at scratch? uncomment if you have two jobs at the same machine +system(paste("rm -rf", path.tmp)) +system(paste("mkdir", path.tmp)) + + +#---------------------------- +# 2. Prepare LPJmL input data +#---------------------------- + +# select grid cells for optimization +#----------------------------------- + +# Carefully select grid cells that are representative for the process or PFT that you want to optimize! +# For example, to optimize phenology of the boreal needle-leaved summergreen PFT, we need grid cells where this PFT is growing and has a dominant coverage: + +grid.name <- "BoNS_3cells" # name of the new grid +grid <- cbind(lon=c(104.25, 105.25, 105.25), lat=c(61.75, 61.25, 62.25)) + + +# define LPJmL input data +#------------------------ + +files.clm <- c( + # monthly CRU and ERI data: + TMP_FILE = paste(path.lpj.input, "cru3-2/cru_ts_3.20.1901.2011.tmp.clm", sep="/"), + PRE_FILE = paste(path.lpj.input, "cru3-2/cru_ts3.20.1901.2011.pre.dat.clm", sep="/"), + SWDOWN_FILE = paste(path.lpj.input, "era/swdown_erainterim_1901-2011.clm", sep="/"), + LWNET_FILE = paste(path.lpj.input, "era/lwnet_erainterim_1901-2011.clm", sep="/"), + + # extra data: + WINDSPEED_FILE = paste(path.lpj.input, "spitfire/mwindspeed_1860-2100_67420.clm", sep="/"), + DTR_FILE = paste(path.lpj.input, "cru3-2/cru_ts3.20.1901.2011.dtr.dat.clm", sep="/"), + BURNTAREA_FILE = paste(path.lpj.input, "burntarea/GFED_CNFDB_ALFDB_Extrap2.BA.360.720.1901.2012.30days.clm", sep="/"), + DRAINCLASS_FILE = paste(path.lpj.input, "drainclass.bin", sep="/"), + SOILCODE_FILE = paste(path.lpj.input, "soil_new_67420.bin", sep="/"), + WET_FILE = paste(path.lpj.input, "cru3-2/cru_ts3.20.1901.2011.wet.dat.clm", sep="/") +) + + +# subset global input data for the selected grid cells +#----------------------------------------------------- + +# directory for regional LPJmL inputs +path.lpj.input.reg <- paste0(path.lpj.input, grid.name) +dir.create(path.lpj.input.reg) + +# file names for regional LPJmL inputs +files.new <- strsplit(files.clm, "/") +files.new <- unlist(llply(files.new, function(file) { + file <- paste(path.lpj.input.reg, paste0(grid.name, "_", file[length(file)]), sep="/") + file <- gsub("//", "/", file) + return(file) +})) + +# read LPJmL input data for actual grid cells and write new *.clm files: +setwd(path.lpj.input.reg) +if (any(!file.exists(files.new)) | calcnew) { + # read input data and subset for new grid + lpjinput <- ReadLPJinput(files.clm, grid=grid) + + # write LPJmL input data with new grid + setwd(path.lpj.input.reg) + WriteLPJinput(lpjinput, files=files.new) +} + + +#------------------------------------------ +# 3. Define LPJmL directories and templates +#------------------------------------------ + +# data.frame with input data +input.df <- data.frame( + name=c("GRID_FILE", names(files.clm)), + file=c(c(paste0(files.new[1], ".grid"), files.new)) +) + +# LPJmL directories and configuration template files +dir.create(path.tmp) +lpjfiles <- LPJfiles(path.lpj = path.lpj, path.tmp = path.tmp, path.out = path.out, + sim.start.year = 1901, # starting year of transient simulation + lpj.conf = paste0(path.lpj.fun, "inst/lpjml_template.conf"), # template file for LPJmL configuration + param.conf = paste0(path.lpj.fun, "inst/param_template.conf"), # template file for parameter configuration + pft.par = paste0(path.lpj.fun, "inst/pft_template.par"), # template file for PFT-specific parameters + param.par = paste0(path.lpj.fun, "inst/param_template.par"), # template file for global parameters + input.conf = paste0(path.lpj.fun, "inst/input_template.conf"), # template file for input data + input=input.df) + + + +#------------------------------------ +# 4. Define and read integration data +#------------------------------------ + +# define all integration data sets +fapar.gimms <- IntegrationDataset(name="FAPAR", unit="", + data.val.file = paste0(path.geodata, "gimms_ndvi_3g/fpar3g/GIMMS3g.FPAR.720.360.1982.2011.30days.nc"), + data.unc.file = 0.18, + data.time = seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + model.val.file = "mfapar.bin", + xy = grid, AggFun = NULL, data.factor=NULL, cost=TRUE, CostFunction=SSE, weight=1) + +ndaymonth <- c(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) # convert gC m-2 day-1 -> gC m-2 month-1 +gpp.mte <- IntegrationDataset(name="GPP", unit="gC m-2 month-1", + data.val.file = paste0(path.geodata, "mte_gpp/GPP.MA.MSC.1982.2011.GPP_MSC.nc"), + data.unc.file = paste0(path.geodata, "mte_gpp/GPP.MA.MSC.1982.2011.GPP_MSC_unc.nc"), + data.time = seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + model.val.file = "mgpp.bin", + xy = grid, AggFun = AggMSC, data.factor=ndaymonth, cost=TRUE, CostFunction=SSE, weight=1) + + +# make list of IntegrationData +integrationdata <- IntegrationData(fapar.gimms, gpp.mte) +plot(integrationdata, 1) +plot(integrationdata, 2) + + +#-------------------------------------------------- +# 5. Define LPJmL prior parameter values and ranges +#-------------------------------------------------- + +# Depending on your application, you might need to define additional parameters in param_template.par and pft_template.par + + +# read parameter priors and ranges from *.txt file +#------------------------------------------------- + +# It is helpful to save all parameter names, prior values and prior ranges in a Excel table or *.csv file + +setwd(path.lpj.fun) +par.df <- read.table("inst/parameters_prior.txt", header=TRUE, sep="\t") + +# make LPJpar object +lpjpar <- LPJpar(par.prior=par.df$par.prior, par.lower=par.df$par.lower, par.upper=par.df$par.upper, par.pftspecif=par.df$par.pftspecif, par.names=par.df$par.names) +plot(lpjpar, "ALPHAA") +plot(lpjpar, "ALBEDO_LEAF") + + +# select parameters for optimization +#----------------------------------- + +# Which parameters should be included in optimization? +par.optim <- c("ALPHAA", "ALBEDO_LEAF", "LIGHTEXTCOEFF", "TMIN_BASE", "WATER_BASE", "LIGHT_BASE", "TPHOTO_LOW", "TPHOTO_HIGH") + +# For which PFTs? +pft.sel <- c("BoNS", "PoH") +par.optim <- paste(rep(par.optim, each=length(pft.sel)), pft.sel, sep="_") +par.optim + + +#------------------------ +# 6. Perform optimization +#------------------------ + + +# do optimization +OptimizeLPJgenoud(xy = grid, # matrix of grid cell coordinates to run LPJ + name = name, # name of the experiment (basic file name for all outputs) + lpjpar = lpjpar, # see LPJpar + par.optim = par.optim, # names of the parameters in LPJpar that should be optimized + lpjfiles = lpjfiles, # see LPJfiles + copy.input = TRUE, # Should LPJmL input data be copied to the directory for temporary output? + integrationdata = integrationdata, # see IntegrationData + plot = TRUE, # plot results? + pop.size = pop.size, # population size + max.generations = max.generations, # max number of generations + wait.generations = wait.generations, # minimum number of generations to wait + BFGSburnin = BFGSburnin, # number of generations before the gradient search algorithm if first used + calc.jacob = FALSE, # Compute Hessian and Jacobian (yes = TRUE, no = FALSE)? + restart = restart, # Restart? 0 = at beginning, 1 = continue with genoud, 2 = post-processing + path.rescue = path.rescue, # directory with 'resuce' files from a previous optimization if restart > 0 + restart.jacob = FALSE, # Compute Hessian and Jacobian if restart > 0 (yes = TRUE, no = FALSE)? + nodes = nodes, # How many nodes to use for parallel computing within genoud? + maxAutoRestart = max.generations-1, # maximum number of automatic restarts in case something crashes + runonly=FALSE, # make only model run (TRUE) or do full optimization? + CostMDS=CostMDS) # Cost function for multiple data stes to use + + +# # check the progress of the optimization: +# setwd("Z:/lpj/LPJmL_131016/out_optim/opt_Example/Opt_Example_0_2_rescue") # directory with rescue files +# files <- list.files(pattern=".RData") +# rescue <- CombineRescueFiles(files, remove=FALSE) +# plot(rescue, ylim=c(0, 1.5)) + diff --git a/LPJmLmdi/inst_LPJmL35/LPJmL_OFPC_parameters.csv b/LPJmLmdi/inst_LPJmL35/LPJmL_OFPC_parameters.csv new file mode 100644 index 0000000..0669cf2 --- /dev/null +++ b/LPJmLmdi/inst_LPJmL35/LPJmL_OFPC_parameters.csv @@ -0,0 +1,313 @@ +pft,par.names,par.prior,par.lower,par.upper,par.pftspecif,check,comment,sensitivity +TrBE,ALPHAA_TrBE,0.6321,0.1,0.9,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,TPHOTO_LOW_TrBE,25,5,27,TRUE,WAHRWAHR,LPJmL default,S +TrBE,TPHOTO_HIGH_TrBE,30,27.1,50,TRUE,WAHRWAHR,LPJmL default,S +TrBE,ALBEDO_LEAF_TrBE,0.13,0,0.19,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,ALBEDO_STEM_TrBE,0.1,0.06,0.29,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,N +TrBE,ALBEDO_LITTER_TrBE,0.1,0.06,0.24,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,N +TrBE,SNOWCANOPYFRAC_TrBE,0.4,0.1,0.9,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,N +TrBE,LIGHTEXTCOEFF_TrBE,0.5174,0.1,2,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,TMIN_SL_TrBE,1.01,0.19,1.93,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,TMIN_BASE_TrBE,8.3,-50,50,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,TMIN_TAU_TrBE,0.2,0.01,0.9,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,TMAX_SL_TrBE,1.86,0.12,2.98,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,N +TrBE,TMAX_BASE_TrBE,1000,999,1001,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,N +TrBE,TMAX_TAU_TrBE,0.2,0.01,0.9,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,N +TrBE,LIGHT_SL_TrBE,77.17,0.05,157,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,LIGHT_BASE_TrBE,55.53,-100,200,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,LIGHT_TAU_TrBE,0.52,0.01,0.9,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,WATER_SL_TrBE,5.14,0.1,9.02,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,WATER_BASE_TrBE,4.997,-100,100,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,WATER_TAU_TrBE,0.44,0.01,0.85,TRUE,WAHRWAHR,lpj_parameters_for_optim_NewPhen_NewPFT_3_grasses_postHerb_postTree1_postAll.txt,S +TrBE,MORT_MAX_TrBE,0.03,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TrBE,K_EST_TrBE,0.12,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TrBE,TWMAX_TrBE,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +TrBE,TSAP_TrBE,20,5,100,TRUE,WAHRWAHR,LPJmL default,S +TrBR,ALPHAA_TrBR,0.5153,0.22,0.89,TRUE,WAHRWAHR,LPJmL default,S +TrBR,TPHOTO_LOW_TrBR,25,5,27,TRUE,WAHRWAHR,LPJmL default,S +TrBR,TPHOTO_HIGH_TrBR,30,27.1,50,TRUE,WAHRWAHR,LPJmL default,S +TrBR,ALBEDO_LEAF_TrBR,0.12,0,0.2,TRUE,WAHRWAHR,LPJmL default,S +TrBR,ALBEDO_STEM_TrBR,0.1,0.06,0.2,TRUE,WAHRWAHR,LPJmL default,N +TrBR,ALBEDO_LITTER_TrBR,0.1,0.06,0.24,TRUE,WAHRWAHR,LPJmL default,N +TrBR,SNOWCANOPYFRAC_TrBR,0.4,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,N +TrBR,LIGHTEXTCOEFF_TrBR,0.7439,0.2,2,TRUE,WAHRWAHR,LPJmL default,S +TrBR,TMIN_SL_TrBR,0.24,0.1,2,TRUE,WAHRWAHR,LPJmL default,S +TrBR,TMIN_BASE_TrBR,7.66,-50,50,TRUE,WAHRWAHR,LPJmL default,S +TrBR,TMIN_TAU_TrBR,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TrBR,TMAX_SL_TrBR,1.625,0.15,2.88,TRUE,WAHRWAHR,LPJmL default,S +TrBR,TMAX_BASE_TrBR,38.64,25,1000,TRUE,WAHRWAHR,LPJmL default,S +TrBR,TMAX_TAU_TrBR,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TrBR,LIGHT_SL_TrBR,23,0.05,94,TRUE,WAHRWAHR,LPJmL default,S +TrBR,LIGHT_BASE_TrBR,13.01,-100,200,TRUE,WAHRWAHR,LPJmL default,S +TrBR,LIGHT_TAU_TrBR,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TrBR,WATER_SL_TrBR,7.97,0.1,9.24,TRUE,WAHRWAHR,LPJmL default,S +TrBR,WATER_BASE_TrBR,22.21,-100,100,TRUE,WAHRWAHR,LPJmL default,S +TrBR,WATER_TAU_TrBR,0.1348,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TrBR,MORT_MAX_TrBR,0.03,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TrBR,K_EST_TrBR,0.12,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TrBR,TWMAX_TrBR,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +TrBR,TSAP_TrBR,20,5,100,TRUE,WAHRWAHR,LPJmL default,S +TrBR,MINWSCAL_TrBR,0.85,0,1,TRUE,WAHRWAHR,LPJmL default,N +TeNE,ALPHAA_TeNE,0.4389,0.29,0.8,TRUE,WAHRWAHR,LPJmL default,S +TeNE,TPHOTO_LOW_TeNE,20,5,27,TRUE,WAHRWAHR,LPJmL default,S +TeNE,TPHOTO_HIGH_TeNE,30,27.1,50,TRUE,WAHRWAHR,LPJmL default,S +TeNE,ALBEDO_LEAF_TeNE,0.1162,0.01,0.25,TRUE,WAHRWAHR,LPJmL default,S +TeNE,ALBEDO_STEM_TeNE,0.04,0,0.28,TRUE,WAHRWAHR,LPJmL default,N +TeNE,ALBEDO_LITTER_TeNE,0.05,0.04,0.18,TRUE,WAHRWAHR,LPJmL default,N +TeNE,SNOWCANOPYFRAC_TeNE,0.1,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,N +TeNE,LIGHTEXTCOEFF_TeNE,0.4744,0.1,2,TRUE,WAHRWAHR,LPJmL default,S +TeNE,TMIN_SL_TeNE,0.2172,0.1,1.95,TRUE,WAHRWAHR,LPJmL default,S +TeNE,TMIN_BASE_TeNE,-7.813,-50,50,TRUE,WAHRWAHR,LPJmL default,S +TeNE,TMIN_TAU_TeNE,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TeNE,TMAX_SL_TeNE,1.83,0.03,2.96,TRUE,WAHRWAHR,LPJmL default,N +TeNE,TMAX_BASE_TeNE,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +TeNE,TMAX_TAU_TeNE,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,N +TeNE,LIGHT_SL_TeNE,20,0.05,90,TRUE,WAHRWAHR,LPJmL default,S +TeNE,LIGHT_BASE_TeNE,4.872,-100,200,TRUE,WAHRWAHR,LPJmL default,S +TeNE,LIGHT_TAU_TeNE,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TeNE,WATER_SL_TeNE,5,0.1,10,TRUE,WAHRWAHR,LPJmL default,S +TeNE,WATER_BASE_TeNE,8.613,-100,100,TRUE,WAHRWAHR,LPJmL default,S +TeNE,WATER_TAU_TeNE,0.8,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeNE,MORT_MAX_TeNE,0.03,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeNE,K_EST_TeNE,0.12,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeNE,TWMAX_TeNE,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +TeNE,TSAP_TeNE,20,5,100,TRUE,WAHRWAHR,LPJmL default,S +TeBE,ALPHAA_TeBE,0.446,0.12,0.88,TRUE,WAHRWAHR,LPJmL default,S +TeBE,TPHOTO_LOW_TeBE,20,5,27,TRUE,WAHRWAHR,LPJmL default,S +TeBE,TPHOTO_HIGH_TeBE,30,27.1,50,TRUE,WAHRWAHR,LPJmL default,S +TeBE,ALBEDO_LEAF_TeBE,0.1238,0.01,0.22,TRUE,WAHRWAHR,LPJmL default,S +TeBE,ALBEDO_STEM_TeBE,0.04,0.03,0.27,TRUE,WAHRWAHR,LPJmL default,N +TeBE,ALBEDO_LITTER_TeBE,0.1,0.04,0.29,TRUE,WAHRWAHR,LPJmL default,N +TeBE,SNOWCANOPYFRAC_TeBE,0.4,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,N +TeBE,LIGHTEXTCOEFF_TeBE,0.6967,0.2,2,TRUE,WAHRWAHR,LPJmL default,S +TeBE,TMIN_SL_TeBE,0.55,0.15,1.87,TRUE,WAHRWAHR,LPJmL default,S +TeBE,TMIN_BASE_TeBE,-0.6297,-50,50,TRUE,WAHRWAHR,LPJmL default,S +TeBE,TMIN_TAU_TeBE,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TeBE,TMAX_SL_TeBE,0.98,0.11,2.81,TRUE,WAHRWAHR,LPJmL default,N +TeBE,TMAX_BASE_TeBE,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +TeBE,TMAX_TAU_TeBE,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,N +TeBE,LIGHT_SL_TeBE,18.83,1,35.45,TRUE,WAHRWAHR,LPJmL default,S +TeBE,LIGHT_BASE_TeBE,39.32,-100,200,TRUE,WAHRWAHR,LPJmL default,S +TeBE,LIGHT_TAU_TeBE,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TeBE,WATER_SL_TeBE,5,0.1,10,TRUE,WAHRWAHR,LPJmL default,S +TeBE,WATER_BASE_TeBE,8.821,-100,100,TRUE,WAHRWAHR,LPJmL default,S +TeBE,WATER_TAU_TeBE,0.8,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeBE,MORT_MAX_TeBE,0.03,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeBE,K_EST_TeBE,0.12,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeBE,TWMAX_TeBE,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +TeBE,TSAP_TeBE,20,5,100,TRUE,WAHRWAHR,LPJmL default,S +TeBS,ALPHAA_TeBS,0.61,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,S +TeBS,TPHOTO_LOW_TeBS,20,0,22.5,TRUE,WAHRWAHR,LPJmL default,S +TeBS,TPHOTO_HIGH_TeBS,25,22.51,50,TRUE,WAHRWAHR,LPJmL default,S +TeBS,ALBEDO_LEAF_TeBS,0.1798,0.1,0.3,TRUE,WAHRWAHR,LPJmL default,S +TeBS,ALBEDO_STEM_TeBS,0.04,0.01,0.1,TRUE,WAHRWAHR,LPJmL default,N +TeBS,ALBEDO_LITTER_TeBS,0.14,0.01,0.15,TRUE,WAHRWAHR,LPJmL default,N +TeBS,SNOWCANOPYFRAC_TeBS,0.4,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,N +TeBS,LIGHTEXTCOEFF_TeBS,0.6037,0.2,2,TRUE,WAHRWAHR,LPJmL default,S +TeBS,TMIN_SL_TeBS,0.2591,0.21,0.84,TRUE,WAHRWAHR,LPJmL default,S +TeBS,TMIN_BASE_TeBS,13.69,-50,50,TRUE,WAHRWAHR,LPJmL default,S +TeBS,TMIN_TAU_TeBS,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TeBS,TMAX_SL_TeBS,1.74,0.68,2.76,TRUE,WAHRWAHR,LPJmL default,N +TeBS,TMAX_BASE_TeBS,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +TeBS,TMAX_TAU_TeBS,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,N +TeBS,LIGHT_SL_TeBS,58,0.05,160,TRUE,WAHRWAHR,LPJmL default,S +TeBS,LIGHT_BASE_TeBS,59.78,-100,200,TRUE,WAHRWAHR,LPJmL default,S +TeBS,LIGHT_TAU_TeBS,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TeBS,WATER_SL_TeBS,5.24,0.73,9.4,TRUE,WAHRWAHR,LPJmL default,S +TeBS,WATER_BASE_TeBS,20.96,-100,100,TRUE,WAHRWAHR,LPJmL default,S +TeBS,WATER_TAU_TeBS,0.8,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeBS,RAMP_TeBS,300,150,400,TRUE,WAHRWAHR,LPJmL default,N +TeBS,APHEN_MIN_TeBS,10,1,600,TRUE,WAHRWAHR,LPJmL default,N +TeBS,APHEN_MAX_TeBS,201.97,1,600,TRUE,WAHRWAHR,LPJmL default,N +TeBS,MORT_MAX_TeBS,0.03,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeBS,K_EST_TeBS,0.12,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeBS,TWMAX_TeBS,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +TeBS,TSAP_TeBS,20,5,100,TRUE,WAHRWAHR,LPJmL default,S +BoNE,ALPHAA_BoNE,0.223,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,S +BoNE,TPHOTO_LOW_BoNE,15,0,20,TRUE,WAHRWAHR,LPJmL default,S +BoNE,TPHOTO_HIGH_BoNE,25,20.1,50,TRUE,WAHRWAHR,LPJmL default,S +BoNE,ALBEDO_LEAF_BoNE,0.09828,0.001,0.25,TRUE,WAHRWAHR,LPJmL default,S +BoNE,ALBEDO_STEM_BoNE,0.06,0,0.19,TRUE,WAHRWAHR,LPJmL default,N +BoNE,ALBEDO_LITTER_BoNE,0.01065,0.01,0.2,TRUE,WAHRWAHR,LPJmL default,N +BoNE,SNOWCANOPYFRAC_BoNE,0.1,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,N +BoNE,LIGHTEXTCOEFF_BoNE,0.442,0.1,2,TRUE,WAHRWAHR,LPJmL default,S +BoNE,TMIN_SL_BoNE,0.1008,0.1,1.93,TRUE,WAHRWAHR,LPJmL default,S +BoNE,TMIN_BASE_BoNE,-7.516,-50,50,TRUE,WAHRWAHR,LPJmL default,S +BoNE,TMIN_TAU_BoNE,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +BoNE,TMAX_SL_BoNE,0.24,0.01,3,TRUE,WAHRWAHR,LPJmL default,N +BoNE,TMAX_BASE_BoNE,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +BoNE,TMAX_TAU_BoNE,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,N +BoNE,LIGHT_SL_BoNE,14,0.05,80,TRUE,WAHRWAHR,LPJmL default,S +BoNE,LIGHT_BASE_BoNE,3.04,-100,200,TRUE,WAHRWAHR,LPJmL default,S +BoNE,LIGHT_TAU_BoNE,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +BoNE,WATER_SL_BoNE,5,0.1,10,TRUE,WAHRWAHR,LPJmL default,S +BoNE,WATER_BASE_BoNE,0.007695,-100,100,TRUE,WAHRWAHR,LPJmL default,S +BoNE,WATER_TAU_BoNE,0.8,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +BoNE,MORT_MAX_BoNE,0.03,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +BoNE,K_EST_BoNE,0.12,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +BoNE,TWMAX_BoNE,23,0,40,TRUE,WAHRWAHR,LPJmL default,S +BoNE,TSAP_BoNE,20,5,100,TRUE,WAHRWAHR,LPJmL default,S +BoBS,ALPHAA_BoBS,0.41,0.19,0.7,TRUE,WAHRWAHR,LPJmL default,S +BoBS,TPHOTO_LOW_BoBS,15,0,20,TRUE,WAHRWAHR,LPJmL default,S +BoBS,TPHOTO_HIGH_BoBS,25,20.1,50,TRUE,WAHRWAHR,LPJmL default,S +BoBS,ALBEDO_LEAF_BoBS,0.1617,0.01,0.25,TRUE,WAHRWAHR,LPJmL default,S +BoBS,ALBEDO_STEM_BoBS,0.06,0,0.11,TRUE,WAHRWAHR,LPJmL default,N +BoBS,ALBEDO_LITTER_BoBS,0.004618,0,0.19,TRUE,WAHRWAHR,LPJmL default,N +BoBS,SNOWCANOPYFRAC_BoBS,0.15,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,N +BoBS,LIGHTEXTCOEFF_BoBS,0.4058,0.19,2,TRUE,WAHRWAHR,LPJmL default,S +BoBS,TMIN_SL_BoBS,0.2153,0.11,1.35,TRUE,WAHRWAHR,LPJmL default,S +BoBS,TMIN_BASE_BoBS,2.045,-50,50,TRUE,WAHRWAHR,LPJmL default,S +BoBS,TMIN_TAU_BoBS,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +BoBS,TMAX_SL_BoBS,1.74,0.01,3,TRUE,WAHRWAHR,LPJmL default,N +BoBS,TMAX_BASE_BoBS,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +BoBS,TMAX_TAU_BoBS,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,N +BoBS,LIGHT_SL_BoBS,58,32.76,188.94,TRUE,WAHRWAHR,LPJmL default,S +BoBS,LIGHT_BASE_BoBS,59.78,-100,200,TRUE,WAHRWAHR,LPJmL default,S +BoBS,LIGHT_TAU_BoBS,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +BoBS,WATER_SL_BoBS,5.24,1.04,9.84,TRUE,WAHRWAHR,LPJmL default,S +BoBS,WATER_BASE_BoBS,20.96,-100,100,TRUE,WAHRWAHR,LPJmL default,S +BoBS,WATER_TAU_BoBS,0.8,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +BoBS,MORT_MAX_BoBS,0.03,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +BoBS,K_EST_BoBS,0.12,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +BoBS,TWMAX_BoBS,23,0,40,TRUE,WAHRWAHR,LPJmL default,S +BoBS,TSAP_BoBS,20,5,100,TRUE,WAHRWAHR,LPJmL default,S +BoBS,APHEN_MIN_BoBS,10,1,600,TRUE,WAHRWAHR,LPJmL default,N +BoBS,APHEN_MAX_BoBS,105.78,1,600,TRUE,WAHRWAHR,LPJmL default,N +BoNS,ALPHAA_BoNS,0.3393,0.17,0.8,TRUE,WAHRWAHR,LPJmL default,S +BoNS,TPHOTO_LOW_BoNS,15,0,30,TRUE,WAHRWAHR,LPJmL default,S +BoNS,TPHOTO_HIGH_BoNS,25,20.1,50,TRUE,WAHRWAHR,LPJmL default,S +BoNS,ALBEDO_LEAF_BoNS,0.1185,0.01,0.25,TRUE,WAHRWAHR,LPJmL default,S +BoNS,ALBEDO_STEM_BoNS,0.04,0.01,0.1,TRUE,WAHRWAHR,LPJmL default,N +BoNS,ALBEDO_LITTER_BoNS,0.01,0,0.15,TRUE,WAHRWAHR,LPJmL default,N +BoNS,SNOWCANOPYFRAC_BoNS,0.18,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,N +BoNS,LIGHTEXTCOEFF_BoNS,0.6559,0.2,2,TRUE,WAHRWAHR,LPJmL default,S +BoNS,TMIN_SL_BoNS,0.15,0.1,0.24,TRUE,WAHRWAHR,LPJmL default,S +BoNS,TMIN_BASE_BoNS,-4.165,-50,50,TRUE,WAHRWAHR,LPJmL default,S +BoNS,TMIN_TAU_BoNS,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +BoNS,TMAX_SL_BoNS,0.24,0.01,3,TRUE,WAHRWAHR,LPJmL default,N +BoNS,TMAX_BASE_BoNS,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +BoNS,TMAX_TAU_BoNS,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,N +BoNS,LIGHT_SL_BoNS,95,0.05,200,TRUE,WAHRWAHR,LPJmL default,S +BoNS,LIGHT_BASE_BoNS,130.1,-100,200,TRUE,WAHRWAHR,LPJmL default,S +BoNS,LIGHT_TAU_BoNS,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +BoNS,WATER_SL_BoNS,5,0.1,10,TRUE,WAHRWAHR,LPJmL default,S +BoNS,WATER_BASE_BoNS,2.344,-100,100,TRUE,WAHRWAHR,LPJmL default,S +BoNS,WATER_TAU_BoNS,0.8,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +BoNS,MORT_MAX_BoNS,0.03,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +BoNS,K_EST_BoNS,0.12,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +BoNS,TWMAX_BoNS,23,0,40,TRUE,WAHRWAHR,LPJmL default,S +BoNS,TSAP_BoNS,20,5,100,TRUE,WAHRWAHR,LPJmL default,S +BoNS,APHEN_MIN_BoNS,10,1,600,TRUE,WAHRWAHR,LPJmL default,N +BoNS,APHEN_MAX_BoNS,105.78,1,600,TRUE,WAHRWAHR,LPJmL default,N +TrH,ALPHAA_TrH,0.4002,0.4,0.83,TRUE,WAHRWAHR,LPJmL default,S +TrH,TPHOTO_LOW_TrH,20,0,28,TRUE,WAHRWAHR,LPJmL default,S +TrH,TPHOTO_HIGH_TrH,45,28.1,55,TRUE,WAHRWAHR,LPJmL default,S +TrH,ALBEDO_LEAF_TrH,0.2363,0.01,0.24,TRUE,WAHRWAHR,LPJmL default,S +TrH,ALBEDO_STEM_TrH,0.15,0.09,0.21,TRUE,WAHRWAHR,LPJmL default,N +TrH,ALBEDO_LITTER_TrH,0.1211,0.02,0.13,TRUE,WAHRWAHR,LPJmL default,N +TrH,SNOWCANOPYFRAC_TrH,0.4,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,N +TrH,LIGHTEXTCOEFF_TrH,0.51,0.16,2,TRUE,WAHRWAHR,LPJmL default,S +TrH,TMIN_SL_TrH,0.91,0.12,1.97,TRUE,WAHRWAHR,LPJmL default,S +TrH,TMIN_BASE_TrH,6.418,-50,50,TRUE,WAHRWAHR,LPJmL default,S +TrH,TMIN_TAU_TrH,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TrH,TMAX_SL_TrH,1.47,0.03,2.71,TRUE,WAHRWAHR,LPJmL default,S +TrH,TMAX_BASE_TrH,29.16,20,1000,TRUE,WAHRWAHR,LPJmL default,S +TrH,TMAX_TAU_TrH,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TrH,LIGHT_SL_TrH,64.23,0.08,128.57,TRUE,WAHRWAHR,LPJmL default,S +TrH,LIGHT_BASE_TrH,69.9,-100,200,TRUE,WAHRWAHR,LPJmL default,S +TrH,LIGHT_TAU_TrH,0.4,0.06,0.88,TRUE,WAHRWAHR,LPJmL default,S +TrH,WATER_SL_TrH,0.1,0.01,1,TRUE,WAHRWAHR,LPJmL default,S +TrH,WATER_BASE_TrH,41.72,-100,100,TRUE,WAHRWAHR,LPJmL default,S +TrH,WATER_TAU_TrH,0.17,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TrH,RAMP_TrH,100,1,1000,TRUE,WAHRWAHR,LPJmL default,S +TrH,TWMAX_TrH,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +TeH,ALPHAA_TeH,0.3183,0.12,0.82,TRUE,WAHRWAHR,LPJmL default,S +TeH,TPHOTO_LOW_TeH,10,0,20,TRUE,WAHRWAHR,LPJmL default,S +TeH,TPHOTO_HIGH_TeH,30,20.1,40,TRUE,WAHRWAHR,LPJmL default,S +TeH,ALBEDO_LEAF_TeH,0.1839,0.11,0.28,TRUE,WAHRWAHR,LPJmL default,S +TeH,ALBEDO_STEM_TeH,0.15,0.077,0.21,TRUE,WAHRWAHR,LPJmL default,N +TeH,ALBEDO_LITTER_TeH,0.06767,0.01,0.16,TRUE,WAHRWAHR,LPJmL default,N +TeH,SNOWCANOPYFRAC_TeH,0.4,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,N +TeH,LIGHTEXTCOEFF_TeH,0.502,0.16,2,TRUE,WAHRWAHR,LPJmL default,S +TeH,TMIN_SL_TeH,0.3111,0.1,1.94,TRUE,WAHRWAHR,LPJmL default,S +TeH,TMIN_BASE_TeH,4.979,-50,50,TRUE,WAHRWAHR,LPJmL default,S +TeH,TMIN_TAU_TeH,0.01011,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TeH,TMAX_SL_TeH,0.24,0.01,3,TRUE,WAHRWAHR,LPJmL default,S +TeH,TMAX_BASE_TeH,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,S +TeH,TMAX_TAU_TeH,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +TeH,LIGHT_SL_TeH,23,0.05,160,TRUE,WAHRWAHR,LPJmL default,S +TeH,LIGHT_BASE_TeH,75.94,-100,200,TRUE,WAHRWAHR,LPJmL default,S +TeH,LIGHT_TAU_TeH,0.22,0.01,0.82,TRUE,WAHRWAHR,LPJmL default,S +TeH,WATER_SL_TeH,0.5222,0.1,9.38,TRUE,WAHRWAHR,LPJmL default,S +TeH,WATER_BASE_TeH,53.07,-100,100,TRUE,WAHRWAHR,LPJmL default,S +TeH,WATER_TAU_TeH,0.01001,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +TeH,RAMP_TeH,100,1,150,TRUE,WAHRWAHR,LPJmL default,N +TeH,TWMAX_TeH,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +PoH,ALPHAA_PoH,0.426,0.1,0.8,TRUE,WAHRWAHR,LPJmL default,S +PoH,TPHOTO_LOW_PoH,10,0,20,TRUE,WAHRWAHR,LPJmL default,S +PoH,TPHOTO_HIGH_PoH,30,20.1,40,TRUE,WAHRWAHR,LPJmL default,S +PoH,ALBEDO_LEAF_PoH,0.07,0.06,0.3,TRUE,WAHRWAHR,LPJmL default,S +PoH,ALBEDO_STEM_PoH,0.15,0.077,0.21,TRUE,WAHRWAHR,LPJmL default,N +PoH,ALBEDO_LITTER_PoH,0.03,0.01,0.23,TRUE,WAHRWAHR,LPJmL default,N +PoH,SNOWCANOPYFRAC_PoH,0.4,0.1,0.9,TRUE,WAHRWAHR,LPJmL default,N +PoH,LIGHTEXTCOEFF_PoH,0.51,0.1,2,TRUE,WAHRWAHR,LPJmL default,S +PoH,TMIN_SL_PoH,0.13,0.1,1.94,TRUE,WAHRWAHR,LPJmL default,S +PoH,TMIN_BASE_PoH,2.79,-50,50,TRUE,WAHRWAHR,LPJmL default,S +PoH,TMIN_TAU_PoH,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,S +PoH,TMAX_SL_PoH,0.24,0.01,3,TRUE,WAHRWAHR,LPJmL default,N +PoH,TMAX_BASE_PoH,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +PoH,TMAX_TAU_PoH,0.2,0.01,0.9,TRUE,WAHRWAHR,LPJmL default,N +PoH,LIGHT_SL_PoH,23,0.05,160,TRUE,WAHRWAHR,LPJmL default,S +PoH,LIGHT_BASE_PoH,50,-100,200,TRUE,WAHRWAHR,LPJmL default,S +PoH,LIGHT_TAU_PoH,0.38,0.01,0.88,TRUE,WAHRWAHR,LPJmL default,S +PoH,WATER_SL_PoH,0.88,0.1,8.26,TRUE,WAHRWAHR,LPJmL default,S +PoH,WATER_BASE_PoH,1,-100,100,TRUE,WAHRWAHR,LPJmL default,S +PoH,WATER_TAU_PoH,0.94,0.01,0.99,TRUE,WAHRWAHR,LPJmL default,S +PoH,RAMP_PoH,100,1,150,TRUE,WAHRWAHR,LPJmL default,N +PoH,TWMAX_PoH,1000,999,1001,TRUE,WAHRWAHR,LPJmL default,N +global,ALPHAC3,0.08,0.07,0.09,FALSE,WAHRWAHR,LPJmL default,S +global,ALPHAC4,0.053,0.05,0.06,FALSE,WAHRWAHR,LPJmL default,S +TrBE,GDD_MIN_TrBE,5928.8,3000,8000,TRUE,WAHRWAHR,BCL analysis,S +TeBE,GDD_MIN_TeBE,3000,0,5000,TRUE,WAHRWAHR,BCL analysis,S +TrBR,GDD_MIN_TrBR,5171,3000,7000,TRUE,WAHRWAHR,BCL analysis,S +TeBS,GDD_MIN_TeBS,3000,1000,5000,TRUE,WAHRWAHR,BCL analysis,S +BoBS,GDD_MIN_BoBS,1500,300,3000,TRUE,WAHRWAHR,BCL analysis,S +TeNE,GDD_MIN_TeNE,3000,1000,4000,TRUE,WAHRWAHR,BCL analysis,S +BoNE,GDD_MIN_BoNE,416.05,0,1500,TRUE,WAHRWAHR,BCL analysis,S +BoNS,GDD_MIN_BoNS,358.05,0,1500,TRUE,WAHRWAHR,BCL analysis,S +TrH,GDD_MIN_TrH,5000,1000,6000,TRUE,WAHRWAHR,BCL analysis,S +TeH,GDD_MIN_TeH,1106.28,500,2000,TRUE,WAHRWAHR,BCL analysis,S +PoH,GDD_MIN_PoH,-1000,-1001,-999,TRUE,WAHRWAHR,BCL analysis,N +TrBE,TC_MIN_TrBE,7.9,0,15,TRUE,WAHRWAHR,BCL analysis,S +TeBE,TC_MIN_TeBE,0,-60,10,TRUE,WAHRWAHR,BCL analysis,S +TrBR,TC_MIN_TrBR,10,-5,20,TRUE,WAHRWAHR,BCL analysis,S +TeBS,TC_MIN_TeBS,-15,-30,-5,TRUE,WAHRWAHR,BCL analysis,S +BoBS,TC_MIN_BoBS,-35,-60,-20,TRUE,WAHRWAHR,BCL analysis,S +TeNE,TC_MIN_TeNE,-10,-30,5,TRUE,WAHRWAHR,BCL analysis,S +BoNE,TC_MIN_BoNE,-40,-60,-20,TRUE,WAHRWAHR,BCL analysis,S +BoNS,TC_MIN_BoNS,-53.4,-60,-40,TRUE,WAHRWAHR,BCL analysis,S +TrH,TC_MIN_TrH,10,-40,20,TRUE,WAHRWAHR,BCL analysis,S +TeH,TC_MIN_TeH,-35.7,-40,20,TRUE,WAHRWAHR,BCL analysis,S +PoH,TC_MIN_PoH,-47,-60,-20,TRUE,WAHRWAHR,BCL analysis,S +TrBE,TC_MAX_TrBE,1000,999,1001,TRUE,WAHRWAHR,BCL analysis,N +TeBE,TC_MAX_TeBE,18.8,15,28,TRUE,WAHRWAHR,BCL analysis,S +TrBR,TC_MAX_TrBR,1000,999,1001,TRUE,WAHRWAHR,BCL analysis,N +TeBS,TC_MAX_TeBS,15.5,10,25,TRUE,WAHRWAHR,BCL analysis,S +BoBS,TC_MAX_BoBS,2.8,-5,10,TRUE,WAHRWAHR,BCL analysis,S +TeNE,TC_MAX_TeNE,22,15,30,TRUE,WAHRWAHR,BCL analysis,S +BoNE,TC_MAX_BoNE,1.7,-5,10,TRUE,WAHRWAHR,BCL analysis,S +BoNS,TC_MAX_BoNS,-20,-30,5,TRUE,WAHRWAHR,BCL analysis,S +TrH,TC_MAX_TrH,1000,999,1001,TRUE,WAHRWAHR,BCL analysis,N +TeH,TC_MAX_TeH,15.5,10,25,TRUE,WAHRWAHR,BCL analysis,S +PoH,TC_MAX_PoH,0,-10,10,TRUE,WAHRWAHR,BCL analysis,S +TrBE,TWC_MIN_TrBE,-1000,-1001,-999,TRUE,WAHRWAHR,BCL analysis,N +TeBE,TWC_MIN_TeBE,-1000,-1001,-999,TRUE,WAHRWAHR,BCL analysis,N +TrBR,TWC_MIN_TrBR,-1000,-1001,-999,TRUE,WAHRWAHR,BCL analysis,N +TeBS,TWC_MIN_TeBS,-1000,-1001,-999,TRUE,WAHRWAHR,BCL analysis,N +BoBS,TWC_MIN_BoBS,13.9,5,25,TRUE,WAHRWAHR,BCL analysis,S +TeNE,TWC_MIN_TeNE,-1000,-1001,-999,TRUE,WAHRWAHR,BCL analysis,N +BoNE,TWC_MIN_BoNE,14.35,10,20,TRUE,WAHRWAHR,BCL analysis,S +BoNS,TWC_MIN_BoNS,35,20,50,TRUE,WAHRWAHR,BCL analysis,S +TrH,TWC_MIN_TrH,-1000,-1001,-999,TRUE,WAHRWAHR,BCL analysis,N +TeH,TWC_MIN_TeH,-1000,-1001,-999,TRUE,WAHRWAHR,BCL analysis,N +PoH,TWC_MIN_PoH,10,-1,20,TRUE,WAHRWAHR,BCL analysis,S diff --git a/LPJmLmdi/inst_LPJmL35/input_template.conf b/LPJmLmdi/inst_LPJmL35/input_template.conf new file mode 100644 index 0000000..0488c00 --- /dev/null +++ b/LPJmLmdi/inst_LPJmL35/input_template.conf @@ -0,0 +1,64 @@ +/*********************************************************************/ +/* */ +/* i n p u t . c o n f */ +/* */ +/* Configuration file for input dataset for LPJ C Version 3.5.003 */ +/* */ +/* Last change 17.01.2013 */ +/* */ +/*********************************************************************/ + +#include "include/conf.h" /* include constant definitions */ +#undef LPJ + +RAW SOILCODE_FILE +0.5 0.5 /* resolution in degrees */ +CLM GRID_FILE +RAW DRAINCLASS_FILE +#ifdef WITH_LANDUSE +CLM2 /Net/Groups/BGI/people/mforkel/lpj/input_global/landuse/cow_mg_2006_full.bin +CLM2 /Net/Groups/BGI/people/mforkel/lpj/input_global/landuse/cft1700_2005_bioenergy_sc.bin +#endif +#ifdef RIVER_ROUTING +RAW //Net/Groups/BGI/people/mforkel/lpj/input_global/lakes.bin +CLM2 /Net/Groups/BGI/people/mforkel/lpj/input_global/drainage.bin +#ifdef WITH_LANDUSE +CLM2 /Net/Groups/BGI/people/mforkel/lpj/input_global/neighb_irrigation.bin +#ifdef WITH_RESERVOIRS +CLM2 /Net/Groups/BGI/people/mforkel/lpj/input_global/elevation.bin +CLM2 /Net/Groups/BGI/people/mforkel/lpj/input_global/reservoir_info_grand5.bin +#endif +#endif +#endif +CLM TMP_FILE +CLM PRE_FILE +#ifdef USE_RADIATION +CLM LWNET_FILE +CLM SWDOWN_FILE +#else +CLM2 /Net/Groups/BGI/people/mforkel/lpj/input_global/cru3-2/cru_ts3.20.1901.2011.cld.dat.clm +#endif +#ifdef WITH_SPITFIRE +CLM WINDSPEED_FILE +CLM DTR_FILE /* diurnal temp. range */ +CLM /Net/Groups/BGI/people/mforkel/lpj/input_global/spitfire/mlightning.clm +CLM /Net/Groups/BGI/people/mforkel/lpj/input_global/spitfire/popdens_HYDE3_1901_2011_bi.clm +#endif +#if defined(WITH_SPITFIRE) || defined(WITH_FIREWOOD) +#if defined(FROM_RESTART) +CLM /Net/Groups/BGI/people/mforkel/lpj/input_global/spitfire/popdens_HYDE3_1901_2011_bi.clm +#endif +#endif +#ifdef USE_BURNTAREA +CLM BURNTAREA_FILE +#endif +#ifdef USE_LANDCOVER +CLM /Net/Groups/BGI/people/mforkel/lpj/input_global/landcover/synmap_koeppen_vcf_NewPFT_3grasses_11PFT_forLPJ.clm +#endif +TXT /Net/Groups/BGI/people/mforkel/lpj/input_global/co2_1841-2011.dat + +#ifdef ISRANDOM + +CLM WET_FILE + +#endif diff --git a/LPJmLmdi/inst_LPJmL35/lpjml_template.conf b/LPJmLmdi/inst_LPJmL35/lpjml_template.conf new file mode 100644 index 0000000..e79e397 --- /dev/null +++ b/LPJmLmdi/inst_LPJmL35/lpjml_template.conf @@ -0,0 +1,250 @@ +/*********************************************************************/ +/* */ +/* l p j m l . c o n f */ +/* */ +/* Default configuration file for LPJmL C Version 3.5.003 */ +/* */ +/* Configuration file is divided into five sections: */ +/* */ +/* I. Simulation description and type section */ +/* II. Input parameter section */ +/* III. Input data section */ +/* IV. Output data section */ +/* V. Run settings section */ +/* */ +/* Last change: 17.01.2013 */ +/* */ +/*********************************************************************/ + +#include "include/conf.h" /* include constant definitions */ + +#define CONST 2 +#define NEW 3 +/*#define BENCHMARK_LAI*/ +/*#define RIVER_ROUTING */ /* river routing enabled; exclude this line to disable river routing */ +#define ISRANDOM /* random generation of daily precipitation */ +#define NEW_HYDROLOGY +#define PERMAFROST +#define USE_RADIATION +#define WITH_SPITFIRE +#define USE_BURNTAREA +/*#define WITH_LANDUSE 1*/ /*NO_LANDUSE: land use disabled; WITH_LANDUSE 1: land use enabled */ +/*#define USE_LANDCOVER*/ +#define GSI_PHENOLOGY +#define OUTPATH CELL_OUTPATH + + +/*===================================================================*/ +/* I. Simulation description and type section */ +/*===================================================================*/ + +"LPJmL Run" /* Simulation description */ +LPJML /*LPJML Simulation type with managed land use */ +#ifdef ISRANDOM +RANDOM_PREC /* Random weather generator for precipitation enabled */ +RANDOM_SEED /* seed for random number generator */ +#else +INTERPOLATE_PREC +#endif +#ifdef CLIMATE_MODEL +CLIMATE_SCENARIO +#else +NO_CLIMATE_SCENARIO +#endif +#ifdef USE_RADIATION +RADIATION +#else +CLOUDINESS +#endif +#ifdef WITH_SPITFIRE +SPITFIRE +#else +NO_FIRE /* fire disturbance enabled */ +#endif +#ifdef WITH_FIREWOOD +FIREWOOD +#ifndef WITH_LANDUSE +#define WITH_LANDUSE 0 +#endif +#else +NO_FIREWOOD +#endif +#if defined(WITH_SPITFIRE) || defined(WITH_FIREWOOD) +# ifndef FROM_RESTART + NO_POPULATION +# else + POPULATION +# endif +#else +NO_POPULATION +#endif +#ifdef USE_BURNTAREA +PRESCRIBE_BURNTAREA +#else +NO_PRESCRIBE_BURNTAREA +#endif +#ifdef USE_LANDCOVER +LANDCOVEREST /* LANDCOVEREST to prescribe establishment or LANDCOVERFPC to prescribe maximum FPC */ +#else +NO_LANDCOVER +#endif +#ifdef GSI_PHENOLOGY +NEW_PHENOLOGY +#else +OLD_PHENOLOGY +#endif +#ifdef RIVER_ROUTING +DRAINAGE +#else +NO_DRAINAGE +#endif +#ifdef PERMAFROST +#define NEW_HYDROLOGY +PERM +#else +NO_PERM +#endif +#ifdef NEW_HYDROLOGY +NEW_PERC +#else +OLD_PERC +#endif +#ifdef WITH_LANDUSE +#if WITH_LANDUSE == CONST +CONST_LANDUSE /* constant land use */ +#elif WITH_LANDUSE == NEW +NEW_LANDUSE /* new land use */ +#elif WITH_LANDUSE == ALL_CROPS +ALL_CROPS /* all crops everywhere */ +#else +LANDUSE /* land use enabled */ +#endif +#if defined(FIX_SDATES) +FIXED_SDATE +#elif defined(READ_SDATES) +PRESCRIBED_SDATE +#else +NO_FIXED_SDATE +#endif +NO_IRRIGATION /* NO_IRRIGATION, LIM_IRRIGATION, POT_IRRIGATION, + ALL_IRRIGATION, + IRRIG_ON_RAINFED (for keeping rainfed sowing dates in all_irrigation) */ +#ifdef BENCHMARK_LAI + CONST_LAI_MAX + #undef WITH_LAIMAX_CFT +#else + #ifdef WITH_LAIMAX_CFT + LAIMAX_CFT /* laimax values from manage parameter file */ + #else + LAIMAX_INTERPOLATE + #endif +#endif +#ifdef RIVER_ROUTING +#ifdef WITH_RESERVOIRS +RESERVOIR +#else +NO_RESERVOIR +#endif +#endif +#else +NO_LANDUSE +#endif +#ifdef WITH_WATERUSE +WATERUSE +#else +NO_WATERUSE +#endif + +/*===================================================================*/ +/* II. Input parameter section */ +/*===================================================================*/ + +#include "CELL_PARCONF_FILE" /* Input parameter file */ + +/*===================================================================*/ +/* III. Input data section */ +/*===================================================================*/ + +#include "CELL_INPUT_FILE" /* Input files of CRU dataset */ + +#ifdef WITH_WATERUSE +CLM2 /iplex/01/2012/open/input_VERSION2/wateruse1901_2003.bin /* water consumption for industry, + household and livestock */ +#endif + +/*===================================================================*/ +/* IV. Output data section */ +/*===================================================================*/ + +#ifdef WITH_GRIDBASED +GRIDBASED +#define SUFFIX grid.bin +#else +PFTBASED +#define SUFFIX pft.bin +#endif + +#ifndef FROM_RESTART + +END /* no output files */ + +#else + +/* +ID Fmt filename +------------------- --- ----------------------------- */ +GRID RAW OUTPATH/grid.bin +FPC RAW OUTPATH/fpc.bin +MGPP RAW OUTPATH/mgpp.bin +VEGC RAW OUTPATH/vegc.bin +SOILC RAW OUTPATH/soilc.bin +LITC RAW OUTPATH/litc.bin +MFAPAR RAW OUTPATH/mfapar.bin +MALBEDO RAW OUTPATH/malbedo.bin +#ifdef GSI_PHENOLOGY +MPHEN_TMIN RAW OUTPATH/mphen_tmin.bin +MPHEN_TMAX RAW OUTPATH/mphen_tmax.bin +MPHEN_LIGHT RAW OUTPATH/mphen_light.bin +MPHEN_WATER RAW OUTPATH/mphen_water.bin +#endif + +/*----------------- --- ------------------------------- */ +END +#ifdef DAILY_OUTPUT +TEMPERATE_BROADLEAVED_SUMMERGREEN_TREE /* CFT for daily output */ +DAILY_RAINFED /* irrigation flag for daily output */ +#endif +#endif + +/*===================================================================*/ +/* V. Run settings section */ +/*===================================================================*/ + +CELL_START +CELL_END + +#ifndef FROM_RESTART + +5000 /* spinup years */ +/* exclude next line in case of 0 spinup years */ +30 /* cycle length during spinup */ +1901 /* first year of simulation */ +1901 /* last year of simulation */ +NO_RESTART /* do not start from restart file */ +RESTART /* create restart file: the last year of simulation=restart-year */ +CELL_RESTART_FILE /* filename of restart file */ +1901 /* write restart at year; exclude line in case of no restart to be written */ + +#else +100 /* spinup years */ +/* exclude next line in case of 0 spinup years */ +30 /*cycle length during spinup (yr)*/ +1901 /* first year of simulation */ +2011 /* last year of simulation */ +RESTART /* start from restart file */ +CELL_RESTART_FILE /* filename of restart file */ +NO_RESTART /* create restart file */ +restart/restart_1900_crop_stdfire.lpj /* filename of restart file */ +/* 2011 write restart at year; exclude line in case of no restart to be written */ + +#endif diff --git a/LPJmLmdi/inst_LPJmL35/param_template.conf b/LPJmLmdi/inst_LPJmL35/param_template.conf new file mode 100644 index 0000000..0c162c3 --- /dev/null +++ b/LPJmLmdi/inst_LPJmL35/param_template.conf @@ -0,0 +1,29 @@ +/*********************************************************************/ +/* */ +/* p a r a m . c o n f */ +/* */ +/* Default input parameter file for LPJmL C Version 3.5.003 */ +/* */ +/* Last change: 17.01.2009 */ +/* */ +/*********************************************************************/ + +#include "PAR_FILE_CELL" /* LPJ parameter file */ +#ifdef NEW_HYDROLOGY +#include "par/soil_new.par" /* Soil parameter file */ +#include "PAR_PFT_FILE_CELL" /* PFT parameter file */ +#else +#include "par/soil_2layers.par" /* Soil parameter file for original 2-layer hydrology */ +#include "par/pft_2layers.par" /* PFT parameter file for original 2-layer hydrology (rootdist vs. beta_root) */ +#endif + + +#ifdef WITH_LANDUSE +#ifdef WITH_LAIMAX_CFT +#include "par/manage_laimax_alphaa_revision_1241_sc.par" /* Management parameter file */ +#else +#include "par/manage.par" /* Management parameter file */ +#endif +#include "par/manage_reg.par" /* Management parameter file for regions*/ +#endif +#include "par/outputvars.par" diff --git a/LPJmLmdi/inst_LPJmL35/param_template.par b/LPJmLmdi/inst_LPJmL35/param_template.par new file mode 100644 index 0000000..1c9f393 --- /dev/null +++ b/LPJmLmdi/inst_LPJmL35/param_template.par @@ -0,0 +1,39 @@ +/**********************************************************************/ +/** **/ +/** p a r a m . p a r **/ +/** **/ +/** LPJ parameter file for LPJmL version 3.5.003 **/ +/** **/ +/** Last change: $Date:: 2013-08-19 12:43:56 +0200 (Mon, 19 Au#$ **/ +/** By : $Author:: sibylls $ **/ +/** **/ +/**********************************************************************/ + +0.3 /* k_litter10 (1/yr) */ +0.03 /* fast k_soil10 (1/yr) */ +0.001 /* slow k_soil10 (1/yr) */ +20000.0 /* max. snow pack (mm) */ +278.0 /* pre-industrial CO2 (ppmv) */ +0.0548 /* k */ +0.7 /* theta */ +0.5 /* k_beer */ +ALPHAC3 /* alphac3 */ +ALPHAC4 /* alphac4 */ +0.015 /* bc3 leaf respiration as fraction of Vmax for C3 plants */ +0.035 /* bc4 leaf respiration as fraction of Vmax for C4 plants */ +0.25 /* r_growth */ +3.26 /* GM */ +1.391 /* ALPHAM Priestlex-Taylor coefficient*/ +3.0e4 /* Michaelis constant for O2 (Pa) at 25 deg C */ +30 /* Michaelis constant for CO2 (Pa) at 25 deg C */ +0.7 /* atmfrac */ +0.98 /* fastfrac */ +#ifdef WITH_LANDUSE +0.9 /* irrigation threshold */ +1.0 /* fraction of soil filled with water during irrigation event */ +5 /* maximum LAI */ +1 /* intercrops on setaside (0:FALSE, 1:TRUE) */ +0 /* remove residuals (0:FALSE, 1:TRUE) */ +1900 /* year in which sowing dates shall be fixed */ +2000 /* set landuse year for LANDUSE_CONST case */ +#endif diff --git a/LPJmLmdi/inst_LPJmL35/parameters_prior.txt b/LPJmLmdi/inst_LPJmL35/parameters_prior.txt new file mode 100644 index 0000000..1c5af24 --- /dev/null +++ b/LPJmLmdi/inst_LPJmL35/parameters_prior.txt @@ -0,0 +1,342 @@ +pft par.names par.prior par.lower par.upper par.pftspecif comment sensitivity +TrBE ALPHAA_TrBE 0.6321 0.1 0.9 TRUE Forkel et al. 2014 BG S +TrBE ALBEDO_LEAF_TrBE 0.13 0 0.25 TRUE Forkel et al. 2014 BG S +TrBE ALBEDO_STEM_TrBE 0.1 0.06 0.29 TRUE Forkel et al. 2014 BG N +TrBE ALBEDO_LITTER_TrBE 0.1 0.06 0.24 TRUE Forkel et al. 2014 BG N +TrBE SNOWCANOPYFRAC_TrBE 0.4 0.1 0.9 TRUE Forkel et al. 2014 BG N +TrBE LIGHTEXTCOEFF_TrBE 0.5174 0.1 1.5 TRUE Forkel et al. 2014 BG S +TrBE TMIN_SL_TrBE 1.01 0.19 1.93 TRUE Forkel et al. 2014 BG N +TrBE TMIN_BASE_TrBE 8.3 -50 50 TRUE Forkel et al. 2014 BG S +TrBE TMIN_TAU_TrBE 0.2 0.01 0.9 TRUE Forkel et al. 2014 BG N +TrBE TMAX_SL_TrBE 1.86 0.12 2.98 TRUE Forkel et al. 2014 BG N +TrBE TMAX_BASE_TrBE 1000 999 1001 TRUE Forkel et al. 2014 BG N +TrBE TMAX_TAU_TrBE 0.2 0.01 0.9 TRUE Forkel et al. 2014 BG N +TrBE LIGHT_SL_TrBE 77.17 0.05 157 TRUE Forkel et al. 2014 BG N +TrBE LIGHT_BASE_TrBE 55.53 -100 200 TRUE Forkel et al. 2014 BG S +TrBE LIGHT_TAU_TrBE 0.52 0.01 0.9 TRUE Forkel et al. 2014 BG N +TrBE WATER_SL_TrBE 5.14 0.1 9.02 TRUE Forkel et al. 2014 BG N +TrBE WATER_BASE_TrBE 4.997 -100 100 TRUE Forkel et al. 2014 BG S +TrBE WATER_TAU_TrBE 0.44 0.01 0.85 TRUE Forkel et al. 2014 BG N +TrBE MORT_MAX_TrBE 0.03 0.01 0.06 TRUE LPJmL default S +TrBE K_EST_TrBE 0.12 0.01 0.3 TRUE LPJmL default S +TrBE TWMAX_TrBE 1000 999 1001 TRUE LPJmL default N +TrBE TSAP_TrBE 20 5 50 TRUE LPJmL default S +TrBR ALPHAA_TrBR 0.5153 0.22 0.89 TRUE LPJmL default S +TrBR ALBEDO_LEAF_TrBR 0.12 0 0.25 TRUE LPJmL default S +TrBR ALBEDO_STEM_TrBR 0.1 0.06 0.2 TRUE LPJmL default N +TrBR ALBEDO_LITTER_TrBR 0.1 0.06 0.24 TRUE LPJmL default N +TrBR SNOWCANOPYFRAC_TrBR 0.4 0.1 0.9 TRUE LPJmL default N +TrBR LIGHTEXTCOEFF_TrBR 0.7439 0.2 1.5 TRUE LPJmL default S +TrBR TMIN_SL_TrBR 0.24 0.1 2 TRUE LPJmL default N +TrBR TMIN_BASE_TrBR 7.66 -50 50 TRUE LPJmL default S +TrBR TMIN_TAU_TrBR 0.2 0.01 0.9 TRUE LPJmL default N +TrBR TMAX_SL_TrBR 1.625 0.15 2.88 TRUE LPJmL default N +TrBR TMAX_BASE_TrBR 38.64 25 1000 TRUE LPJmL default S +TrBR TMAX_TAU_TrBR 0.2 0.01 0.9 TRUE LPJmL default N +TrBR LIGHT_SL_TrBR 23 0.05 94 TRUE LPJmL default N +TrBR LIGHT_BASE_TrBR 13.01 -100 200 TRUE LPJmL default S +TrBR LIGHT_TAU_TrBR 0.2 0.01 0.9 TRUE LPJmL default N +TrBR WATER_SL_TrBR 7.97 0.1 9.24 TRUE LPJmL default N +TrBR WATER_BASE_TrBR 22.21 -100 100 TRUE LPJmL default S +TrBR WATER_TAU_TrBR 0.1348 0.01 0.9 TRUE LPJmL default N +TrBR MORT_MAX_TrBR 0.03 0.01 0.06 TRUE LPJmL default S +TrBR K_EST_TrBR 0.12 0.01 0.3 TRUE LPJmL default S +TrBR TWMAX_TrBR 1000 999 1001 TRUE LPJmL default N +TrBR TSAP_TrBR 20 5 50 TRUE LPJmL default S +TrBR MINWSCAL_TrBR 0.85 0 1 TRUE LPJmL default N +TeNE ALPHAA_TeNE 0.4389 0.29 0.8 TRUE LPJmL default S +TeNE ALBEDO_LEAF_TeNE 0.1162 0.01 0.25 TRUE LPJmL default S +TeNE ALBEDO_STEM_TeNE 0.04 0 0.28 TRUE LPJmL default N +TeNE ALBEDO_LITTER_TeNE 0.05 0.04 0.18 TRUE LPJmL default N +TeNE SNOWCANOPYFRAC_TeNE 0.1 0.01 0.9 TRUE LPJmL default N +TeNE LIGHTEXTCOEFF_TeNE 0.4744 0.1 1.5 TRUE LPJmL default S +TeNE TMIN_SL_TeNE 0.2172 0.1 1.95 TRUE LPJmL default N +TeNE TMIN_BASE_TeNE -7.813 -50 50 TRUE LPJmL default S +TeNE TMIN_TAU_TeNE 0.2 0.01 0.9 TRUE LPJmL default N +TeNE TMAX_SL_TeNE 1.83 0.03 2.96 TRUE LPJmL default N +TeNE TMAX_BASE_TeNE 1000 999 1001 TRUE LPJmL default N +TeNE TMAX_TAU_TeNE 0.2 0.01 0.9 TRUE LPJmL default N +TeNE LIGHT_SL_TeNE 20 0.05 90 TRUE LPJmL default N +TeNE LIGHT_BASE_TeNE 4.872 -100 200 TRUE LPJmL default S +TeNE LIGHT_TAU_TeNE 0.2 0.01 0.9 TRUE LPJmL default N +TeNE WATER_SL_TeNE 5 0.1 10 TRUE LPJmL default N +TeNE WATER_BASE_TeNE 8.613 -100 100 TRUE LPJmL default S +TeNE WATER_TAU_TeNE 0.8 0.01 0.99 TRUE LPJmL default N +TeNE MORT_MAX_TeNE 0.03 0.01 0.06 TRUE LPJmL default S +TeNE K_EST_TeNE 0.12 0.01 0.3 TRUE LPJmL default S +TeNE TWMAX_TeNE 1000 999 1001 TRUE LPJmL default N +TeNE TSAP_TeNE 20 5 50 TRUE LPJmL default S +TeBE ALPHAA_TeBE 0.446 0.12 0.88 TRUE LPJmL default S +TeBE ALBEDO_LEAF_TeBE 0.1238 0.01 0.22 TRUE LPJmL default S +TeBE ALBEDO_STEM_TeBE 0.04 0.03 0.27 TRUE LPJmL default N +TeBE ALBEDO_LITTER_TeBE 0.1 0.04 0.29 TRUE LPJmL default N +TeBE SNOWCANOPYFRAC_TeBE 0.4 0.1 0.9 TRUE LPJmL default N +TeBE LIGHTEXTCOEFF_TeBE 0.6967 0.2 1.5 TRUE LPJmL default S +TeBE TMIN_SL_TeBE 0.55 0.15 1.87 TRUE LPJmL default N +TeBE TMIN_BASE_TeBE -0.6297 -50 50 TRUE LPJmL default S +TeBE TMIN_TAU_TeBE 0.2 0.01 0.9 TRUE LPJmL default N +TeBE TMAX_SL_TeBE 0.98 0.11 2.81 TRUE LPJmL default N +TeBE TMAX_BASE_TeBE 1000 999 1001 TRUE LPJmL default N +TeBE TMAX_TAU_TeBE 0.2 0.01 0.9 TRUE LPJmL default N +TeBE LIGHT_SL_TeBE 18.83 1 35.45 TRUE LPJmL default N +TeBE LIGHT_BASE_TeBE 39.32 -100 200 TRUE LPJmL default S +TeBE LIGHT_TAU_TeBE 0.2 0.01 0.9 TRUE LPJmL default N +TeBE WATER_SL_TeBE 5 0.1 10 TRUE LPJmL default N +TeBE WATER_BASE_TeBE 8.821 -100 100 TRUE LPJmL default S +TeBE WATER_TAU_TeBE 0.8 0.01 0.99 TRUE LPJmL default N +TeBE MORT_MAX_TeBE 0.03 0.01 0.06 TRUE LPJmL default S +TeBE K_EST_TeBE 0.12 0.01 0.3 TRUE LPJmL default S +TeBE TWMAX_TeBE 1000 999 1001 TRUE LPJmL default N +TeBE TSAP_TeBE 20 5 50 TRUE LPJmL default S +TeBS ALPHAA_TeBS 0.61 0.1 0.9 TRUE LPJmL default S +TeBS ALBEDO_LEAF_TeBS 0.1798 0.1 0.3 TRUE LPJmL default S +TeBS ALBEDO_STEM_TeBS 0.04 0.01 0.1 TRUE LPJmL default N +TeBS ALBEDO_LITTER_TeBS 0.14 0.01 0.15 TRUE LPJmL default N +TeBS SNOWCANOPYFRAC_TeBS 0.4 0.1 0.9 TRUE LPJmL default N +TeBS LIGHTEXTCOEFF_TeBS 0.6037 0.2 1.5 TRUE LPJmL default S +TeBS TMIN_SL_TeBS 0.2591 0.21 0.84 TRUE LPJmL default N +TeBS TMIN_BASE_TeBS 13.69 -50 50 TRUE LPJmL default S +TeBS TMIN_TAU_TeBS 0.2 0.01 0.9 TRUE LPJmL default N +TeBS TMAX_SL_TeBS 1.74 0.68 2.76 TRUE LPJmL default N +TeBS TMAX_BASE_TeBS 1000 999 1001 TRUE LPJmL default N +TeBS TMAX_TAU_TeBS 0.2 0.01 0.9 TRUE LPJmL default N +TeBS LIGHT_SL_TeBS 58 0.05 160 TRUE LPJmL default N +TeBS LIGHT_BASE_TeBS 59.78 -100 200 TRUE LPJmL default S +TeBS LIGHT_TAU_TeBS 0.2 0.01 0.9 TRUE LPJmL default N +TeBS WATER_SL_TeBS 5.24 0.73 9.4 TRUE LPJmL default N +TeBS WATER_BASE_TeBS 20.96 -100 100 TRUE LPJmL default S +TeBS WATER_TAU_TeBS 0.8 0.01 0.99 TRUE LPJmL default N +TeBS RAMP_TeBS 300 150 400 TRUE LPJmL default N +TeBS APHEN_MIN_TeBS 10 1 600 TRUE LPJmL default N +TeBS APHEN_MAX_TeBS 201.97 1 600 TRUE LPJmL default N +TeBS MORT_MAX_TeBS 0.03 0.01 0.06 TRUE LPJmL default S +TeBS K_EST_TeBS 0.12 0.01 0.3 TRUE LPJmL default S +TeBS TWMAX_TeBS 1000 999 1001 TRUE LPJmL default N +TeBS TSAP_TeBS 20 5 50 TRUE LPJmL default S +BoNE ALPHAA_BoNE 0.223 0.1 0.9 TRUE LPJmL default S +BoNE ALBEDO_LEAF_BoNE 0.09828 0.001 0.25 TRUE LPJmL default S +BoNE ALBEDO_STEM_BoNE 0.06 0 0.19 TRUE LPJmL default N +BoNE ALBEDO_LITTER_BoNE 0.01065 0.01 0.2 TRUE LPJmL default N +BoNE SNOWCANOPYFRAC_BoNE 0.1 0.01 0.9 TRUE LPJmL default N +BoNE LIGHTEXTCOEFF_BoNE 0.442 0.1 2.5 TRUE LPJmL default S +BoNE TMIN_SL_BoNE 0.1008 0.1 1.93 TRUE LPJmL default N +BoNE TMIN_BASE_BoNE -7.516 -50 50 TRUE LPJmL default S +BoNE TMIN_TAU_BoNE 0.2 0.01 0.9 TRUE LPJmL default N +BoNE TMAX_SL_BoNE 0.24 0.01 3 TRUE LPJmL default N +BoNE TMAX_BASE_BoNE 1000 999 1001 TRUE LPJmL default N +BoNE TMAX_TAU_BoNE 0.2 0.01 0.9 TRUE LPJmL default N +BoNE LIGHT_SL_BoNE 14 0.05 80 TRUE LPJmL default N +BoNE LIGHT_BASE_BoNE 3.04 -100 200 TRUE LPJmL default S +BoNE LIGHT_TAU_BoNE 0.2 0.01 0.9 TRUE LPJmL default N +BoNE WATER_SL_BoNE 5 0.1 10 TRUE LPJmL default N +BoNE WATER_BASE_BoNE 0.007695 -100 100 TRUE LPJmL default S +BoNE WATER_TAU_BoNE 0.8 0.01 0.99 TRUE LPJmL default N +BoNE MORT_MAX_BoNE 0.03 0.01 0.06 TRUE LPJmL default S +BoNE K_EST_BoNE 0.12 0.01 0.3 TRUE LPJmL default S +BoNE TWMAX_BoNE 23 0 40 TRUE LPJmL default S +BoNE TSAP_BoNE 20 5 50 TRUE LPJmL default S +BoBS ALPHAA_BoBS 0.41 0.19 0.7 TRUE LPJmL default S +BoBS ALBEDO_LEAF_BoBS 0.1617 0.01 0.25 TRUE LPJmL default S +BoBS ALBEDO_STEM_BoBS 0.06 0 0.11 TRUE LPJmL default N +BoBS ALBEDO_LITTER_BoBS 0.004618 0 0.19 TRUE LPJmL default N +BoBS SNOWCANOPYFRAC_BoBS 0.15 0.1 0.9 TRUE LPJmL default N +BoBS LIGHTEXTCOEFF_BoBS 0.4058 0.19 1.5 TRUE LPJmL default S +BoBS TMIN_SL_BoBS 0.2153 0.11 1.35 TRUE LPJmL default N +BoBS TMIN_BASE_BoBS 2.045 -50 50 TRUE LPJmL default S +BoBS TMIN_TAU_BoBS 0.2 0.01 0.9 TRUE LPJmL default N +BoBS TMAX_SL_BoBS 1.74 0.01 3 TRUE LPJmL default N +BoBS TMAX_BASE_BoBS 1000 999 1001 TRUE LPJmL default N +BoBS TMAX_TAU_BoBS 0.2 0.01 0.9 TRUE LPJmL default N +BoBS LIGHT_SL_BoBS 58 32.76 188.94 TRUE LPJmL default N +BoBS LIGHT_BASE_BoBS 59.78 -100 200 TRUE LPJmL default S +BoBS LIGHT_TAU_BoBS 0.2 0.01 0.9 TRUE LPJmL default N +BoBS WATER_SL_BoBS 5.24 1.04 9.84 TRUE LPJmL default N +BoBS WATER_BASE_BoBS 20.96 -100 100 TRUE LPJmL default S +BoBS WATER_TAU_BoBS 0.8 0.01 0.99 TRUE LPJmL default N +BoBS MORT_MAX_BoBS 0.03 0.01 0.06 TRUE LPJmL default S +BoBS K_EST_BoBS 0.12 0.01 0.3 TRUE LPJmL default S +BoBS TWMAX_BoBS 23 0 40 TRUE LPJmL default S +BoBS TSAP_BoBS 20 5 50 TRUE LPJmL default S +BoBS APHEN_MIN_BoBS 10 1 600 TRUE LPJmL default N +BoBS APHEN_MAX_BoBS 105.78 1 600 TRUE LPJmL default N +BoNS ALPHAA_BoNS 0.3393 0.17 0.8 TRUE LPJmL default S +BoNS ALBEDO_LEAF_BoNS 0.1185 0.01 0.25 TRUE LPJmL default S +BoNS ALBEDO_STEM_BoNS 0.04 0.01 0.1 TRUE LPJmL default N +BoNS ALBEDO_LITTER_BoNS 0.01 0 0.15 TRUE LPJmL default N +BoNS SNOWCANOPYFRAC_BoNS 0.18 0.1 0.9 TRUE LPJmL default N +BoNS LIGHTEXTCOEFF_BoNS 0.6559 0.2 2.5 TRUE LPJmL default S +BoNS TMIN_SL_BoNS 0.15 0.1 0.24 TRUE LPJmL default N +BoNS TMIN_BASE_BoNS -4.165 -50 50 TRUE LPJmL default S +BoNS TMIN_TAU_BoNS 0.2 0.01 0.9 TRUE LPJmL default N +BoNS TMAX_SL_BoNS 0.24 0.01 3 TRUE LPJmL default N +BoNS TMAX_BASE_BoNS 1000 999 1001 TRUE LPJmL default N +BoNS TMAX_TAU_BoNS 0.2 0.01 0.9 TRUE LPJmL default N +BoNS LIGHT_SL_BoNS 95 0.05 200 TRUE LPJmL default N +BoNS LIGHT_BASE_BoNS 130.1 -100 200 TRUE LPJmL default S +BoNS LIGHT_TAU_BoNS 0.2 0.01 0.9 TRUE LPJmL default N +BoNS WATER_SL_BoNS 5 0.1 10 TRUE LPJmL default N +BoNS WATER_BASE_BoNS 2.344 -100 100 TRUE LPJmL default S +BoNS WATER_TAU_BoNS 0.8 0.01 0.99 TRUE LPJmL default N +BoNS MORT_MAX_BoNS 0.03 0.01 0.06 TRUE LPJmL default S +BoNS K_EST_BoNS 0.12 0.01 0.3 TRUE LPJmL default S +BoNS TWMAX_BoNS 23 0 40 TRUE LPJmL default S +BoNS TSAP_BoNS 20 5 50 TRUE LPJmL default S +BoNS APHEN_MIN_BoNS 10 1 600 TRUE LPJmL default N +BoNS APHEN_MAX_BoNS 105.78 1 600 TRUE LPJmL default N +TrH ALPHAA_TrH 0.4002 0.4 0.83 TRUE LPJmL default S +TrH ALBEDO_LEAF_TrH 0.2363 0.01 0.25 TRUE LPJmL default S +TrH ALBEDO_STEM_TrH 0.15 0.09 0.21 TRUE LPJmL default N +TrH ALBEDO_LITTER_TrH 0.1211 0.02 0.13 TRUE LPJmL default N +TrH SNOWCANOPYFRAC_TrH 0.4 0.1 0.9 TRUE LPJmL default N +TrH LIGHTEXTCOEFF_TrH 0.51 0.16 1.5 TRUE LPJmL default S +TrH TMIN_SL_TrH 0.91 0.12 1.97 TRUE LPJmL default N +TrH TMIN_BASE_TrH 6.418 -50 50 TRUE LPJmL default S +TrH TMIN_TAU_TrH 0.2 0.01 0.9 TRUE LPJmL default N +TrH TMAX_SL_TrH 1.47 0.03 2.71 TRUE LPJmL default N +TrH TMAX_BASE_TrH 29.16 20 1000 TRUE LPJmL default S +TrH TMAX_TAU_TrH 0.2 0.01 0.9 TRUE LPJmL default N +TrH LIGHT_SL_TrH 64.23 0.08 128.57 TRUE LPJmL default N +TrH LIGHT_BASE_TrH 69.9 -100 200 TRUE LPJmL default S +TrH LIGHT_TAU_TrH 0.4 0.06 0.88 TRUE LPJmL default N +TrH WATER_SL_TrH 0.1 0.01 1 TRUE LPJmL default N +TrH WATER_BASE_TrH 41.72 -100 100 TRUE LPJmL default S +TrH WATER_TAU_TrH 0.17 0.01 0.99 TRUE LPJmL default N +TrH RAMP_TrH 100 1 1000 TRUE LPJmL default S +TrH TWMAX_TrH 1000 999 1001 TRUE LPJmL default N +TeH ALPHAA_TeH 0.3183 0.12 0.82 TRUE LPJmL default S +TeH ALBEDO_LEAF_TeH 0.1839 0.11 0.28 TRUE LPJmL default S +TeH ALBEDO_STEM_TeH 0.15 0.077 0.21 TRUE LPJmL default N +TeH ALBEDO_LITTER_TeH 0.06767 0.01 0.16 TRUE LPJmL default N +TeH SNOWCANOPYFRAC_TeH 0.4 0.1 0.9 TRUE LPJmL default N +TeH LIGHTEXTCOEFF_TeH 0.502 0.16 1.5 TRUE LPJmL default S +TeH TMIN_SL_TeH 0.3111 0.1 1.94 TRUE LPJmL default N +TeH TMIN_BASE_TeH 4.979 -50 50 TRUE LPJmL default S +TeH TMIN_TAU_TeH 0.01011 0.01 0.9 TRUE LPJmL default N +TeH TMAX_SL_TeH 0.24 0.01 3 TRUE LPJmL default N +TeH TMAX_BASE_TeH 32.04 -50 1000 TRUE LPJmL default S +TeH TMAX_TAU_TeH 0.2 0.01 0.9 TRUE LPJmL default N +TeH LIGHT_SL_TeH 23 0.05 160 TRUE LPJmL default N +TeH LIGHT_BASE_TeH 75.94 -100 200 TRUE LPJmL default S +TeH LIGHT_TAU_TeH 0.22 0.01 0.82 TRUE LPJmL default N +TeH WATER_SL_TeH 0.5222 0.1 9.38 TRUE LPJmL default N +TeH WATER_BASE_TeH 53.07 -100 100 TRUE LPJmL default S +TeH WATER_TAU_TeH 0.01001 0.01 0.99 TRUE LPJmL default N +TeH RAMP_TeH 100 1 150 TRUE LPJmL default N +TeH TWMAX_TeH 1000 999 1001 TRUE LPJmL default N +PoH ALPHAA_PoH 0.426 0.1 0.8 TRUE LPJmL default S +PoH ALBEDO_LEAF_PoH 0.07 0.06 0.3 TRUE LPJmL default S +PoH ALBEDO_STEM_PoH 0.15 0.077 0.21 TRUE LPJmL default N +PoH ALBEDO_LITTER_PoH 0.03 0.01 0.23 TRUE LPJmL default N +PoH SNOWCANOPYFRAC_PoH 0.4 0.1 0.9 TRUE LPJmL default N +PoH LIGHTEXTCOEFF_PoH 0.51 0.1 2 TRUE LPJmL default S +PoH TMIN_SL_PoH 0.13 0.1 1.94 TRUE LPJmL default N +PoH TMIN_BASE_PoH 2.79 -50 50 TRUE LPJmL default S +PoH TMIN_TAU_PoH 0.2 0.01 0.9 TRUE LPJmL default N +PoH TMAX_SL_PoH 0.24 0.01 3 TRUE LPJmL default N +PoH TMAX_BASE_PoH 1000 999 1001 TRUE LPJmL default N +PoH TMAX_TAU_PoH 0.2 0.01 0.9 TRUE LPJmL default N +PoH LIGHT_SL_PoH 23 0.05 160 TRUE LPJmL default N +PoH LIGHT_BASE_PoH 50 -100 200 TRUE LPJmL default S +PoH LIGHT_TAU_PoH 0.38 0.01 0.88 TRUE LPJmL default N +PoH WATER_SL_PoH 0.88 0.1 8.26 TRUE LPJmL default N +PoH WATER_BASE_PoH 1 -100 100 TRUE LPJmL default S +PoH WATER_TAU_PoH 0.94 0.01 0.99 TRUE LPJmL default N +PoH RAMP_PoH 100 1 150 TRUE LPJmL default N +PoH TWMAX_PoH 1000 999 1001 TRUE LPJmL default N +global ALPHAC3 0.08 0.07 0.09 FALSE LPJmL default S +global ALPHAC4 0.053 0.05 0.06 FALSE LPJmL default S +TrBE GDD_MIN_TrBE 5928.8 3000 8000 TRUE BCL analysis S +TeBE GDD_MIN_TeBE 3000 0 5000 TRUE BCL analysis S +TrBR GDD_MIN_TrBR 5171 3000 7000 TRUE BCL analysis S +TeBS GDD_MIN_TeBS 3000 1000 5000 TRUE BCL analysis S +BoBS GDD_MIN_BoBS 1500 300 3000 TRUE BCL analysis S +TeNE GDD_MIN_TeNE 3000 1000 4000 TRUE BCL analysis S +BoNE GDD_MIN_BoNE 416.05 0 1500 TRUE BCL analysis S +BoNS GDD_MIN_BoNS 358.05 0 1500 TRUE BCL analysis S +TrH GDD_MIN_TrH 5000 1000 6000 TRUE BCL analysis S +TeH GDD_MIN_TeH 1106.28 500 2000 TRUE BCL analysis S +PoH GDD_MIN_PoH -1000 -1001 -999 TRUE BCL analysis N +TrBE TC_MIN_TrBE 7.9 0 15 TRUE BCL analysis S +TeBE TC_MIN_TeBE 0 -60 10 TRUE BCL analysis S +TrBR TC_MIN_TrBR 10 -5 20 TRUE BCL analysis S +TeBS TC_MIN_TeBS -15 -30 -5 TRUE BCL analysis S +BoBS TC_MIN_BoBS -35 -60 -20 TRUE BCL analysis S +TeNE TC_MIN_TeNE -10 -30 5 TRUE BCL analysis S +BoNE TC_MIN_BoNE -40 -60 -20 TRUE BCL analysis S +BoNS TC_MIN_BoNS -53.4 -60 -40 TRUE BCL analysis S +TrH TC_MIN_TrH 10 -40 20 TRUE BCL analysis S +TeH TC_MIN_TeH -35.7 -40 20 TRUE BCL analysis S +PoH TC_MIN_PoH -47 -60 -20 TRUE BCL analysis S +TrBE TC_MAX_TrBE 1000 999 1001 TRUE BCL analysis N +TeBE TC_MAX_TeBE 18.8 15 28 TRUE BCL analysis S +TrBR TC_MAX_TrBR 1000 999 1001 TRUE BCL analysis N +TeBS TC_MAX_TeBS 15.5 10 25 TRUE BCL analysis S +BoBS TC_MAX_BoBS 2.8 -5 10 TRUE BCL analysis S +TeNE TC_MAX_TeNE 22 15 30 TRUE BCL analysis S +BoNE TC_MAX_BoNE 1.7 -5 10 TRUE BCL analysis S +BoNS TC_MAX_BoNS -20 -30 5 TRUE BCL analysis S +TrH TC_MAX_TrH 1000 999 1001 TRUE BCL analysis N +TeH TC_MAX_TeH 15.5 10 25 TRUE BCL analysis S +PoH TC_MAX_PoH 0 -10 10 TRUE BCL analysis S +TrBE TWC_MIN_TrBE -1000 -1001 -999 TRUE BCL analysis N +TeBE TWC_MIN_TeBE -1000 -1001 -999 TRUE BCL analysis N +TrBR TWC_MIN_TrBR -1000 -1001 -999 TRUE BCL analysis N +TeBS TWC_MIN_TeBS -1000 -1001 -999 TRUE BCL analysis N +BoBS TWC_MIN_BoBS 13.9 5 25 TRUE BCL analysis S +TeNE TWC_MIN_TeNE -1000 -1001 -999 TRUE BCL analysis N +BoNE TWC_MIN_BoNE 14.35 10 20 TRUE BCL analysis S +BoNS TWC_MIN_BoNS 35 20 50 TRUE BCL analysis S +TrH TWC_MIN_TrH -1000 -1001 -999 TRUE BCL analysis N +TeH TWC_MIN_TeH -1000 -1001 -999 TRUE BCL analysis N +PoH TWC_MIN_PoH 10 -1 20 TRUE BCL analysis S +TrBE LEAF_LONGEVITY_TrBE 2 1 6 TRUE LPJmL default S +TrBR LEAF_LONGEVITY_TrBR 0.65 0.4 1 TRUE LPJmL default S +TeBE LEAF_LONGEVITY_TeBE 1 0.8 6 TRUE LPJmL default S +TeBS LEAF_LONGEVITY_TeBS 0.5 0.4 0.8 TRUE LPJmL default S +TeNE LEAF_LONGEVITY_TeNE 4 1 6 TRUE LPJmL default S +BoNE LEAF_LONGEVITY_BoNE 4 1 6 TRUE LPJmL default S +BoBS LEAF_LONGEVITY_BoBS 0.5 0.4 0.8 TRUE LPJmL default S +BoNS LEAF_LONGEVITY_BoNS 0.5 0.4 0.8 TRUE LPJmL default S +TrH LEAF_LONGEVITY_TrH 0.5 0.3 1.1 TRUE LPJmL default S +TeH LEAF_LONGEVITY_TeH 0.5 0.3 1.1 TRUE LPJmL default S +PoH LEAF_LONGEVITY_PoH 0.5 0.3 1.1 TRUE LPJmL default S +TrBE ALLOM1_TrBE 100 75 125 TRUE LPJmL default S +TrBR ALLOM1_TrBR 100 75 125 TRUE LPJmL default S +TeBE ALLOM1_TeBE 100 75 125 TRUE LPJmL default S +TeBS ALLOM1_TeBS 100 75 125 TRUE LPJmL default S +TeNE ALLOM1_TeNE 100 75 125 TRUE LPJmL default S +BoNE ALLOM1_BoNE 100 75 125 TRUE LPJmL default S +BoBS ALLOM1_BoBS 100 75 125 TRUE LPJmL default S +BoNS ALLOM1_BoNS 100 75 125 TRUE LPJmL default S +TrBE ALLOM2_TrBE 40 20 60 TRUE LPJmL default S +TrBR ALLOM2_TrBR 40 20 60 TRUE LPJmL default S +TeBE ALLOM2_TeBE 40 20 60 TRUE LPJmL default S +TeBS ALLOM2_TeBS 40 20 60 TRUE LPJmL default S +TeNE ALLOM2_TeNE 40 20 60 TRUE LPJmL default S +BoNE ALLOM2_BoNE 40 20 60 TRUE LPJmL default S +BoBS ALLOM2_BoBS 40 20 60 TRUE LPJmL default S +BoNS ALLOM2_BoNS 40 20 60 TRUE LPJmL default S +TrBE ALLOM3_TrBE 0.67 0.4 0.8 TRUE LPJmL default S +TrBR ALLOM3_TrBR 0.67 0.4 0.8 TRUE LPJmL default S +TeBE ALLOM3_TeBE 0.67 0.4 0.8 TRUE LPJmL default S +TeBS ALLOM3_TeBS 0.67 0.4 0.8 TRUE LPJmL default S +TeNE ALLOM3_TeNE 0.67 0.4 0.8 TRUE LPJmL default S +BoNE ALLOM3_BoNE 0.67 0.4 0.8 TRUE LPJmL default S +BoBS ALLOM3_BoBS 0.67 0.4 0.8 TRUE LPJmL default S +BoNS ALLOM3_BoNS 0.67 0.4 0.8 TRUE LPJmL default S +TrBE ALLOM4_TrBE 0.3 0.2 0.4 TRUE LPJmL default S +TrBR ALLOM4_TrBR 0.3 0.2 0.4 TRUE LPJmL default S +TeBE ALLOM4_TeBE 0.3 0.2 0.4 TRUE LPJmL default S +TeBS ALLOM4_TeBS 0.3 0.2 0.4 TRUE LPJmL default S +TeNE ALLOM4_TeNE 0.3 0.2 0.4 TRUE LPJmL default S +BoNE ALLOM4_BoNE 0.3 0.2 0.4 TRUE LPJmL default S +BoBS ALLOM4_BoBS 0.3 0.2 0.4 TRUE LPJmL default S +BoNS ALLOM4_BoNS 0.3 0.2 0.4 TRUE LPJmL default S +TrBE CROWNAREA_MAX_TrBE 15 10 100 TRUE LPJmL default S +TrBR CROWNAREA_MAX_TrBR 12 8 100 TRUE LPJmL default S +TeBE CROWNAREA_MAX_TeBE 15 10 100 TRUE LPJmL default S +TeBS CROWNAREA_MAX_TeBS 15 10 100 TRUE LPJmL default S +TeNE CROWNAREA_MAX_TeNE 15 10 50 TRUE LPJmL default S +BoNE CROWNAREA_MAX_BoNE 15 10 50 TRUE LPJmL default S +BoBS CROWNAREA_MAX_BoBS 15 10 50 TRUE LPJmL default S +BoNS CROWNAREA_MAX_BoNS 15 10 50 TRUE LPJmL default S diff --git a/LPJmLmdi/inst_LPJmL35/pft_template.par b/LPJmLmdi/inst_LPJmL35/pft_template.par new file mode 100644 index 0000000..826a2c9 --- /dev/null +++ b/LPJmLmdi/inst_LPJmL35/pft_template.par @@ -0,0 +1,2034 @@ +/**********************************************************************/ +/** **/ +/** p f t . p a r **/ +/** **/ +/** PFT and CFT parameter file for LPJmL version 3.5.003 **/ +/** CFTs parameters must be put after PFTs **/ +/** **/ +/** Last change: 25.01.2006 by S.Jachner, M.Gumpenberger **/ +/** Last change: 14.01.2013 by W. von Bloh **/ +/** **/ +/**********************************************************************/ + +#include "../include/pftpar.h" /* include constant definitions */ + +#define CTON_LEAF 29 +#define CTON_ROOT 29 +#define CTON_POOL 100 +#define CTON_SO 100 +#define CTON_SAP 330 +#define FLAM_TREE 0.3 +#define FLAM_GRASS 0.3 +#define K_LITTER10 0.3 +#define APREC_MIN 100 +#define ALLOM1 100.0 +#define ALLOM2 40.0 +#define ALLOM3 0.67 /*0.5*/ +#define ALLOM4 0.3 +#define APHEN_MAX 245 +#define APHEN_MIN 60 /* minimum aphen for cold-induced senescence */ +#define HEIGHT_MAX 100 /* maximum height of trees */ +#define REPROD_COST 0.1 /* reproduction cost */ +#define K_EST 0.12 /* maximum overall sapling establishment rate (indiv/m2) */ + +26 /* number of PFT's (natural + crops + bioenergy) */ + +/* first pft */ +TROPICAL_BROADLEAVED_EVERGREEN_TREE +"tropical broadleaved evergreen tree" +TREE +NONE /* cultivation_type */ +30 55 70 77 /* curve number */ +0.962 /* beta_root */ +0.0 /* minwscal 3*/ +0.5 /* gmin 4*/ +0.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.12 /* resist 8*/ +LEAF_LONGEVITY_TrBE /* leaf longevity 10*/ +1.0 /* lmro_ratio 18*/ +1000 /* ramp 19*/ +1.500 /* lai_sapl 21*/ +GDD_MIN_TrBE /* gdd5min 30*/ +TWMAX_TrBE /* twmax 31*/ +0.0 /* gddbase (deg C) 33*/ +TWC_MIN_TrBE /* min_temprange 34*/ +7 /* emax 35*/ +0.02 /* intc 36*/ +ALPHAA_TrBE /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TrBE /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TrBE /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TrBE /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TrBE /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TrBE /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TrBE /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TrBE /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TrBE /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TrBE /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TrBE /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TrBE /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TrBE /* new phenology: slope of light limiting function */ +LIGHT_BASE_TrBE /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TrBE /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TrBE /* new phenology: slope of water limiting function */ +WATER_BASE_TrBE /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TrBE /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_TrBE /* asymptotic maximum mortality rate (1/year) */ +EVERGREEN /* phenology */ +C3 /* pathway */ +2.0 55.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_TrBE TPHOTO_HIGH_TrBE /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_TrBE TC_MAX_TrBE /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.38009 /* shape factor for soil organic matter vertical distribution*/ +25.0 /* fuel bulk density */ +1580.0 103.0 6.80 8.10 8.50 1.999 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +2.0 /* roughness length */ +BROADLEAVED /* leaftype */ +2.0 TSAP_TrBE 2.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT/* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +CROWNAREA_MAX_TrBE /* crownarea_max 20*/ +1.2 /* sapwood sapling 22*/ +REPROD_COST /* reproduction cost */ +ALLOM1_TrBE /* allometry */ +ALLOM2_TrBE +ALLOM3_TrBE +ALLOM4_TrBE +HEIGHT_MAX /* maximum height of tree */ +0.1487 /* scorch height (F) */ +0.3334 /* crown length (CL) */ +0.0301 /* bark thickness par1 */ +0.0281 /* bark thickness par2 */ +1.00 /* crown damage (rCK) */ +3.00 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +K_EST_TrBE /* k_est */ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 2. pft */ +TROPICAL_BROADLEAVED_RAINGREEN_TREE +"tropical broadleaved raingreen tree" +TREE +NONE /* cultivation_type */ +30 55 70 77 /* curve number */ +0.961 /* beta_root 1 */ +0.85 /* minwscal 3*/ +0.5 /* gmin 4*/ +0.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.5 /* resist 8*/ +LEAF_LONGEVITY_TrBR /* leaf longivity 10*/ +1.0 /* lmro_ratio 18*/ +1000 /* ramp 19*/ +1.500 /* lai_sapl 21*/ +GDD_MIN_TrBR /* gdd5min 30*/ +TWMAX_TrBR /* twmax 31*/ +0.0 /* gddbase (deg C) 33*/ +TWC_MIN_TrBR /* min_temprange 34*/ +7.0 /* emax 35*/ +0.02 /* intc 36*/ +ALPHAA_TrBR /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TrBR /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TrBR /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TrBR /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TrBR /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TrBR /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TrBR /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TrBR /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TrBR /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TrBR /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TrBR /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TrBR /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TrBR /* new phenology: slope of light limiting function */ +LIGHT_BASE_TrBR /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TrBR /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TrBR /* new phenology: slope of water limiting function */ +WATER_BASE_TrBR /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TrBR /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_TrBR /* asymptotic maximum mortality rate (1/year) */ +RAINGREEN /* phenology */ +C3 /* pathway */ +2.0 55.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_TrBR TPHOTO_HIGH_TrBR /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_TrBR TC_MAX_TrBR /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.51395 /* shape factor for soil organic matter vertical distribution*/ +13.0 /* fuel bulk density */ +1664.0 63.0 2.20 3.40 8.50 2.540 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +2.0 /* roughness length */ +BROADLEAVED /* leaftype */ +1.0 TSAP_TrBR 1.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT/* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +CROWNAREA_MAX_TrBR /* crownarea_max 20*/ +1.2 /* sapwood sapling 22*/ +REPROD_COST /* reproduction cost */ +ALLOM1_TrBR /* allometry */ +ALLOM2_TrBR +ALLOM3_TrBR +ALLOM4_TrBR +HEIGHT_MAX /* maximum height of tree */ +0.061 /* scorch height (F) */ +0.10 /* crown length (CL) */ +0.1085 /* bark thickness par1 */ +0.2120 /* bark thickness par2 */ +0.05 /* crown damage (rCK) */ +3.00 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +K_EST_TrBR /* k_est */ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 3. pft */ +TEMPERATE_NEEDLELEAVED_EVERGREEN_TREE +"temperate needleleaved evergreen tree" +TREE +NONE /* cultivation_type */ +30 55 70 77 /* curve number */ +0.976 /* beta_root 1 */ +0.00 /* minwscal 3*/ +0.3 /* gmin 4*/ +1.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.12 /* resist 8*/ +LEAF_LONGEVITY_TeNE /* leaf longevity 10*/ +1.0 /* lmro_ratio 18*/ +1000 /* ramp 19*/ +1.500 /* lai_sapl 21*/ +GDD_MIN_TeNE /* gdd5min 30*/ +TWMAX_TeNE /* twmax 31*/ +0.0 /* gddbase (deg C) 33*/ +TWC_MIN_TeNE /* min_temprange 34*/ +5.0 /* emax 35*/ +0.02 /* intc 36*/ +ALPHAA_TeNE /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TeNE /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TeNE /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TeNE /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TeNE /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TeNE /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TeNE /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TeNE /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TeNE /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TeNE /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TeNE /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TeNE /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TeNE /* new phenology: slope of light limiting function */ +LIGHT_BASE_TeNE /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TeNE /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TeNE /* new phenology: slope of water limiting function */ +WATER_BASE_TeNE /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TeNE /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_TeNE /* asymptotic maximum mortality rate (1/year) */ +EVERGREEN /* phenology */ +C3 /* pathway */ +-4.0 42.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_TeNE TPHOTO_HIGH_TeNE /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_TeNE TC_MAX_TeNE /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.32198 /* shape factor for soil organic matter vertical distribution*/ +25.0 /* fuel bulk density */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +1.0 /* roughness length */ +NEEDLELEAVED /* leaftype */ +4.0 TSAP_TeNE 4.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT/* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +CROWNAREA_MAX_TeNE /* crownarea_max 20*/ +1.2 /* sapwood sapling 22*/ +REPROD_COST /* reproduction cost */ +ALLOM1_TeNE /* allometry */ +ALLOM2_TeNE +ALLOM3_TeNE +ALLOM4_TeNE +HEIGHT_MAX /* maximum height of tree */ +0.1000 /* scorch height (F) */ +0.3334 /* crown length (CL) */ +0.0367 /* bark thickness par1 */ +0.0592 /* bark thickness par2 */ +1.00 /* crown damage (rCK) */ +3.75 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +K_EST_TeNE /* k_est */ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 4. pft */ +TEMPERATE_BROADLEAVED_EVERGREEN_TREE +"temperate broadleaved evergreen tree" +TREE +NONE +30 55 70 77 /* curve number */ +0.964 /* beta_root 1 */ +0.00 /* minwscal 3*/ +0.5 /* gmin 4*/ +1.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.5 /* resist 8*/ +LEAF_LONGEVITY_TeBE /* leaf longevity 10*/ +1.0 /* lmro_ratio 18*/ +1000 /* ramp 19*/ +1.500 /* lai_sapl 21*/ +GDD_MIN_TeBE /* gdd5min 30*/ +TWMAX_TeBE /* twmax 31*/ +0.0 /* gddbase (deg C) 33*/ +TWC_MIN_TeBE /* min_temprange 34*/ +5.0 /* emax 35*/ +0.02 /* intc 36*/ +ALPHAA_TeBE /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TeBE /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TeBE /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TeBE /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TeBE /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TeBE /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TeBE /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TeBE /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TeBE /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TeBE /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TeBE /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TeBE /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TeBE /* new phenology: slope of light limiting function */ +LIGHT_BASE_TeBE /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TeBE /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TeBE /* new phenology: slope of water limiting function */ +WATER_BASE_TeBE /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TeBE /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_TeBE /* asymptotic maximum mortality rate (1/year) */ +EVERGREEN /* phenology */ +C3 /* pathway */ +-4.0 42.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_TeBE TPHOTO_HIGH_TeBE /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_TeBE TC_MAX_TeBE /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.43740 /* shape factor for soil organic matter vertical distribution*/ +13.0 /* fuel bulk density (pb) */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +1.0 /* roughness length */ +BROADLEAVED /* leaftype */ +1.0 TSAP_TeBE 1.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT/* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +CROWNAREA_MAX_TeBE /* crownarea_max 20*/ +1.2 /* sapwood sapling 22*/ +REPROD_COST /* reproduction cost */ +ALLOM1_TeBE /* allometry */ +ALLOM2_TeBE +ALLOM3_TeBE +ALLOM4_TeBE +HEIGHT_MAX /* maximum height of tree */ +0.3710 /* scorch height (F) */ +0.3334 /* crown length (CL) */ +0.0451 /* bark thickness par1 */ +0.1412 /* bark thickness par2 */ +0.95 /* crown damage (rCK) */ +3.00 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +K_EST_TeBE /* k_est */ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 5. pft */ +TEMPERATE_BROADLEAVED_SUMMERGREEN_TREE +"temperate broadleaved summergreen tree" +TREE +NONE /* cultivation_type */ +30 55 70 77 /* curve number */ +0.966 /* beta_root 1 */ +0.00 /* minwscal 3*/ +0.5 /* gmin 4*/ +1.2 /* respcoeff 5*/ +120 /* nmax 7*/ +0.12 /* resist 8*/ +LEAF_LONGEVITY_TeBS /* leaf longevity 10*/ +1.0 /* lmro_ratio 18*/ +300 /* ramp 19*/ +1.500 /* lai_sapl 21*/ +GDD_MIN_TeBS /* gdd5min 30*/ +TWMAX_TeBS /* twmax 31*/ +0.0 /* gddbase (deg C) 33*/ +TWC_MIN_TeBS /* min_temprange 34*/ +5.0 /* emax 35*/ +0.02 /* intc 36*/ +ALPHAA_TeBS /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TeBS /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TeBS /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TeBS /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TeBS /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TeBS /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TeBS /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TeBS /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TeBS /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TeBS /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TeBS /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TeBS /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TeBS /* new phenology: slope of light limiting function */ +LIGHT_BASE_TeBS /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TeBS /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TeBS /* new phenology: slope of water limiting function */ +WATER_BASE_TeBS /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TeBS /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_TeBS /* asymptotic maximum mortality rate (1/year) */ +SUMMERGREEN /* phenology */ +C3 /* pathway */ +-4.0 38.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_TeBS TPHOTO_HIGH_TeBS /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_TeBS TC_MAX_TeBS /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.28880 /* shape factor for soil organic matter vertical distribution*/ +22.0 /* fuel bulk density */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +1.0 /* roughness length */ +BROADLEAVED /* leaftype */ +1.0 TSAP_TeBS 1.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT/* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +CROWNAREA_MAX_TeBS /* crownarea_max 20*/ +1.2 /* sapwood sapling 22*/ +10 +201.97 +REPROD_COST /* reproduction cost */ +ALLOM1_TeBS /* allometry */ +ALLOM2_TeBS +ALLOM3_TeBS +ALLOM4_TeBS +HEIGHT_MAX /* maximum height of tree */ +0.0940 /* scorch height (F) */ +0.3334 /* crown length (CL) */ +0.0347 /* bark thickness par1 */ +0.1086 /* bark thickness par2 */ +1.00 /* crown damage (rCK) */ +3.00 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +K_EST_TeBS /* k_est */ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 6. pft */ +BOREAL_NEEDLELEAVED_EVERGREEN_TREE +"boreal needleleaved evergreen tree" +TREE +NONE /* cultivation_type */ +30 55 70 77 /* curve number */ +0.943 /* beta_root 1 */ +0.00 /* minwscal 3*/ +0.3 /* gmin 4*/ +1.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.12 /* resist 8*/ +LEAF_LONGEVITY_BoNE /* leaf longevity 10*/ +1.0 /* lmro_ratio 18*/ +1000 /* ramp 19*/ +1.500 /* lai_sapl 21*/ +GDD_MIN_BoNE /* gdd5min 30*/ +TWMAX_BoNE /* twmax 31*/ +5.0 /* gddbase (deg C) 33*/ +TWC_MIN_BoNE /* min_temprange 34*/ +5.0 /* emax 35*/ +0.06 /* intc 36*/ +ALPHAA_BoNE /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_BoNE /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_BoNE /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_BoNE /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_BoNE /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_BoNE /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_BoNE /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_BoNE /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_BoNE /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_BoNE /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_BoNE /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_BoNE /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_BoNE /* new phenology: slope of light limiting function */ +LIGHT_BASE_BoNE /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_BoNE /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_BoNE /* new phenology: slope of water limiting function */ +WATER_BASE_BoNE /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_BoNE /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_BoNE /* asymptotic maximum mortality rate (1/year) */ +EVERGREEN /* phenology */ +C3 /* pathway */ +-4.0 38.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_BoNE TPHOTO_HIGH_BoNE /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_BoNE TC_MAX_BoNE /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.28670 /* shape factor for soil organic matter vertical distribution*/ +25.0 /* fuel bulk density (pb) */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +1.0 /* roughness length */ +NEEDLELEAVED /* leaftype */ +4.0 TSAP_BoNE 4.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT/* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +CROWNAREA_MAX_BoNE /* crownarea_max 20*/ +1.2 /* sapwood sapling 22*/ +REPROD_COST /* reproduction cost */ +ALLOM1_BoNE /* allometry */ +ALLOM2_BoNE +ALLOM3_BoNE +ALLOM4_BoNE +HEIGHT_MAX /* maximum height of tree */ +0.1100 /* scorch height (F) */ +0.3334 /* crown length (CL) */ +0.0292 /* bark thickness par1 */ +0.2632 /* bark thickness par2 */ +1.00 /* crown damage (rCK) */ +3.00 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +K_EST_BoNE /* k_est */ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 7. pft */ +BOREAL_BROADLEAVED_SUMMERGREEN_TREE +"boreal broadleaved summergreen tree" +TREE +NONE /* cultivation_type */ +30 55 70 77 /* curve number */ +0.943 /* beta_root 1 */ +0.00 /* minwscal 3*/ +0.5 /* gmin 4*/ +1.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.12 /* resist 8*/ +LEAF_LONGEVITY_BoBS /* leaf longevity 10*/ +1.0 /* lmro_ratio 18*/ +200 /* ramp 19*/ +1.500 /* lai_sapl 21*/ +GDD_MIN_BoBS /* gdd5min 30*/ +TWMAX_BoBS /* twmax 31*/ +5.0 /* gddbase (deg C) 33*/ +TWC_MIN_BoBS /* min_temprange 34*/ +5.0 /* emax 35*/ +0.06 /* intc 36*/ +ALPHAA_BoBS /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_BoBS /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_BoBS /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_BoBS /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_BoBS /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_BoBS /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_BoBS /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_BoBS /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_BoBS /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_BoBS /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_BoBS /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_BoBS /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_BoBS /* new phenology: slope of light limiting function */ +LIGHT_BASE_BoBS /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_BoBS /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_BoBS /* new phenology: slope of water limiting function */ +WATER_BASE_BoBS /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_BoBS /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_BoBS /* asymptotic maximum mortality rate (1/year) */ +SUMMERGREEN /* phenology */ +C3 /* pathway */ +-4.0 38.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_BoBS TPHOTO_HIGH_BoBS /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_BoBS TC_MAX_BoBS /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.28670 /* shape factor for soil organic matter vertical distribution*/ +22.0 /* fuel bulk density (pb) */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +1.0 /* roughness length */ +BROADLEAVED /* leaftype */ +1.0 TSAP_BoBS 1.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT/* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +CROWNAREA_MAX_BoBS /* crownarea_max 20*/ +1.2 /* sapwood sapling 22*/ +10 +181.62 +REPROD_COST /* reproduction cost */ +ALLOM1_BoBS /* allometry */ +ALLOM2_BoBS +ALLOM3_BoBS +ALLOM4_BoBS +HEIGHT_MAX /* maximum height of tree */ +0.0940 /* scorch height (F) */ +0.3334 /* crown length (CL) */ +0.0347 /* bark thickness par1 */ +0.1086 /* bark thickness par2 */ +1.00 /* crown damage (rCK) */ +3.00 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +K_EST_BoBS /* k_est */ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 8. pft */ +BOREAL_NEEDLELEAVED_SUMMERGREEN_TREE +"boreal needleleaved summergreen tree" +TREE +NONE /* cultivation_type */ +30 55 70 77 /* curve number */ +0.943 /* beta_root 1 */ +0.00 /* minwscal 3*/ +0.5 /* gmin 4*/ +1.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.12 /* resist 8*/ +LEAF_LONGEVITY_BoNS /* leaf longevity 10*/ +1.0 /* lmro_ratio 18*/ +200 /* ramp 19*/ +1.500 /* lai_sapl 21*/ +GDD_MIN_BoNS /* gdd5min 30*/ +TWMAX_BoNS /* twmax 31*/ +5.0 /* gddbase (deg C) 33*/ +TWC_MIN_BoNS /* min_temprange 34*/ +5.0 /* emax 35*/ +0.06 /* intc 36*/ +ALPHAA_BoNS /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_BoNS /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_BoNS /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_BoNS /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_BoNS /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_BoNS /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_BoNS /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_BoNS /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_BoNS /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_BoNS /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_BoNS /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_BoNS /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_BoNS /* new phenology: slope of light limiting function */ +LIGHT_BASE_BoNS /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_BoNS /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_BoNS /* new phenology: slope of water limiting function */ +WATER_BASE_BoNS /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_BoNS /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_BoNS /* asymptotic maximum mortality rate (1/year) */ +SUMMERGREEN /* phenology */ +C3 /* pathway */ +-4.0 38.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_BoNS TPHOTO_HIGH_BoNS /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_BoNS TC_MAX_BoNS /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.28670 /* shape factor for soil organic matter vertical distribution*/ +22.0 /* fuel bulk density (pb) */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +230 /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +1.0 /* roughness length */ +NEEDLELEAVED /* leaftype */ +1.0 TSAP_BoNS 1.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT/* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +CROWNAREA_MAX_BoNS /* crownarea_max 20*/ +1.2 /* sapwood sapling 22*/ +10 +105.78 +REPROD_COST /* reproduction cost */ +ALLOM1_BoNS /* allometry */ +ALLOM2_BoNS +ALLOM3_BoNS +ALLOM4_BoNS +HEIGHT_MAX /* maximum height of tree */ +0.0940 /* scorch height (F) */ +0.3334 /* crown length (CL) */ +0.0347 /* bark thickness par1 */ +0.1086 /* bark thickness par2 */ +1.00 /* crown damage (rCK) */ +3.00 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +K_EST_BoNS /* k_est */ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 9. pft */ +TROPICAL_HERBACEOUS +"Tropical C4 grass" +GRASS +NONE /* cultivation_type */ +39 61 74 80 /* curve number */ +0.972 /* beta_root 1 */ +0.20 /* minwscal 3*/ +0.5 /* gmin 4*/ +0.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.01 /* resist 8*/ +LEAF_LONGEVITY_TrH /* leaf longevity 10*/ +0.75 /* lmro_ratio 18*/ +100 /* ramp 19*/ +0.001 /* lai_sapl 21*/ +GDD_MIN_TrH /* gdd5min 30*/ +TWMAX_TrH /* twmax 31*/ +5.0 /* gddbase (deg C) 33*/ +TWC_MIN_TrH /* min_temprange 34*/ +7.0 /* emax 35*/ +0.01 /* intc 36*/ +ALPHAA_TrH /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TrH /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TrH /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TrH /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TrH /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TrH /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TrH /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TrH /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TrH /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TrH /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TrH /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TrH /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TrH /* new phenology: slope of light limiting function */ +LIGHT_BASE_TrH /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TrH /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TrH /* new phenology: slope of water limiting function */ +WATER_BASE_TrH /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TrH /* new phenology: change rate of actual to previous day water limiting function */ +0.03 /* asymptotic maximum mortality rate (1/year) */ +ANY /* phenology */ +C4 /* pathway */ +6.0 55.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_TrH TPHOTO_HIGH_TrH /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_TrH TC_MAX_TrH /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.46513 /* shape factor for soil organic matter vertical distribution*/ +2.0 /* fuel bulk density (pb) */ +1664.0 63.0 2.20 3.40 8.50 2.540 /* emission factors */ +180 /* minimum annual precipitation to establish */ +FLAM_GRASS /* flam */ +K_LITTER10 +K_LITTER10 +0.6 /* windspeed dampening */ +0.03 /* roughness length */ +1.0 2.0 /* turnover leaf root 9 12*/ +CTON_LEAF CTON_ROOT /* C:N mass ratio for leaf and root 13,15*/ +REPROD_COST /* reproduction cost */ +/*--------------------------------------------------------------------------*/ +/* 10. pft */ +TEMPERATE_HERBACEOUS +"Temperate C3 grass" +GRASS +NONE /* cultivation_type */ +39 61 74 80 /* curve number */ +0.943 /* beta_root 1 */ +0.20 /* minwscal 3*/ +0.5 /* gmin 4*/ +1.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.01 /* resist 8*/ +LEAF_LONGEVITY_TeH /* leaf longevity 10*/ +0.75 /* lmro_ratio 18*/ +100 /* ramp 19*/ +0.001 /* lai_sapl 21*/ +GDD_MIN_TeH /* gdd5min 30*/ +TWMAX_TeH /* twmax 31*/ +5.0 /* gddbase (deg C) 33*/ +TWC_MIN_TeH /* min_temprange 34*/ +5.0 /* emax 35*/ +0.01 /* intc 36*/ +ALPHAA_TeH /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TeH /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TeH /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TeH /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TeH /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TeH /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TeH /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TeH /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TeH /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TeH /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TeH /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TeH /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TeH /* new phenology: slope of light limiting function */ +LIGHT_BASE_TeH /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TeH /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TeH /* new phenology: slope of water limiting function */ +WATER_BASE_TeH /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TeH /* new phenology: change rate of actual to previous day water limiting function */ +0.03 /* asymptotic maximum mortality rate (1/year) */ +ANY /* phenology */ +C3 /* pathway */ +-4.0 45.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_TeH TPHOTO_HIGH_TeH /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_TeH TC_MAX_TeH /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.38184 /* shape factor for soil organic matter vertical distribution*/ +2.0 /* fuel bulk density (pb) */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +100 /* minimum annual precipitation to establish */ +FLAM_GRASS /* flam */ +K_LITTER10 +K_LITTER10 +0.6 /* windspeed dampening */ +0.03 /* roughness length */ +1.0 2.0 /* turnover leaf root 9 12*/ +CTON_LEAF CTON_ROOT /* C:N mass ratio for leaf and root 13,15*/ +REPROD_COST /* reproduction cost */ +/*--------------------------------------------------------------------------*/ +/* 11. pft */ +POLAR_HERBACEOUS +"Polar C3 grass" +GRASS +NONE /* cultivation_type */ +39 61 74 80 /* curve number */ +0.943 /* beta_root 1 */ +0.20 /* minwscal 3*/ +0.5 /* gmin 4*/ +1.2 /* respcoeff 5*/ +100 /* nmax 7*/ +0.01 /* resist 8*/ +LEAF_LONGEVITY_PoH /* leaf longevity 10*/ +0.75 /* lmro_ratio 18*/ +100 /* ramp 19*/ +0.001 /* lai_sapl 21*/ +GDD_MIN_PoH /* gdd5min 30*/ +TWMAX_PoH /* twmax 31*/ +5.0 /* gddbase (deg C) 33*/ +TWC_MIN_PoH /* min_temprange 34*/ +5.0 /* emax 35*/ +0.01 /* intc 36*/ +ALPHAA_PoH /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_PoH /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_PoH /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_PoH /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_PoH /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_PoH /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_PoH /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_PoH /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_PoH /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_PoH /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_PoH /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_PoH /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_PoH /* new phenology: slope of light limiting function */ +LIGHT_BASE_PoH /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_PoH /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_PoH /* new phenology: slope of water limiting function */ +WATER_BASE_PoH /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_PoH /* new phenology: change rate of actual to previous day water limiting function */ +0.03 /* asymptotic maximum mortality rate (1/year) */ +ANY /* phenology */ +C3 /* pathway */ +-4.0 45.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +TPHOTO_LOW_PoH TPHOTO_HIGH_PoH /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +TC_MIN_PoH TC_MAX_PoH /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.38184 /* shape factor for soil organic matter vertical distribution*/ +2.0 /* fuel bulk density (pb) */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +10 /* minimum annual precipitation to establish */ +FLAM_GRASS /* flam */ +K_LITTER10 +K_LITTER10 +0.6 /* windspeed dampening */ +0.03 /* roughness length */ +1.0 2.0 /* turnover leaf root 9 12*/ +CTON_LEAF CTON_ROOT /* C:N mass ratio for leaf and root 13,15*/ +REPROD_COST /* reproduction cost */ +/*--------------------------------------------------------------------------*/ +/* 1. bft */ +BIOENERGY_TROPICAL_TREE +"bioenergy tropical tree" +TREE +BIOMASS /* cultivation_type */ +30 55 70 77 /* curvenumbers*/ +0.962 /* beta_root */ +0.00 /* minwscal 3*/ +0.2 /* gmin 4, normal 0.5 */ +0.2 /* respcoeff 5 */ +100 /* nmax 7*/ +1.0 /* resist 8*/ +2.0 /* sla 10 */ +1.0 /* lmro_ratio 18*/ +1000 /* ramp 19*/ +1.6 /* lai_sapl 21, normal 1.5 TIM 1.9*/ +0.0 /* gdd5min 30*/ +1000 /* twmax 31*/ +5.0 /* gddbase (deg C) 33*/ +-1000 /* min_temprange 34*/ +7.0 /* emax 35, normal 7 */ +0.02 /* intc 36*/ +ALPHAA_TrBE /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TrBE /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TrBE /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TrBE /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TrBE /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TrBE /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TrBE /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TrBE /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TrBE /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TrBE /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TrBE /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TrBE /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TrBE /* new phenology: slope of light limiting function */ +LIGHT_BASE_TrBE /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TrBE /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TrBE /* new phenology: slope of water limiting function */ +WATER_BASE_TrBE /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TrBE /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_TrBE /* asymptotic maximum mortality rate (1/year) */ +EVERGREEN /* phenology */ +C3 /* pathway */ +2.0 55.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +25 38 /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26 (Almeida, 2004, FEM) 8 38*/ +7 1000 /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.38009 /* shape factor for soil organic matter vertical distribution*/ +13.0 /* fuel bulk density */ +1664.0 63.0 2.20 3.40 8.50 2.540 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +1.0 /* roughness length */ +BROADLEAVED /* leaftype */ +2.0 10 2.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +2.0 /* crownarea_max 20*/ +2.2 /* sapwood sapling 22 TIM 2.5*/ +REPROD_COST /* reproduction cost */ +110 /* allometry */ +35 +0.75 +ALLOM4 +HEIGHT_MAX /* maximum height of tree */ +0.061 /* scorch height (F) */ +0.10 /* crown length (CL) */ +0.1085 /* bark thickness par1 */ +0.2120 /* bark thickness par2 */ +0.05 /* crown damage (rCK) */ +3.00 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +0.5 /* k_est, Giardina, 2002 */ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 2. bft */ +BIOENERGY_TEMPERATE_TREE +"bioenergy temperate tree" +TREE +BIOMASS /* cultivation_type */ +30 55 70 77 /* curvenumbers */ +0.966 /* beta_root 1 */ +0.00 /* minwscal 3 */ +0.3 /* gmin 4 */ +1.2 /* respcoeff 5 */ +120 /* nmax 7*/ +0.95 /* resist 8, no fires on plantations */ +0.5 /* sla 10*/ +1.0 /* lmro_ratio 18*/ +300 /* ramp 19*/ +1.6 /* lai_sapl 2.1, larger sapling used for plantations, original value 1.5 */ +300.0 /* gdd5min 30*/ +1000 /* twmax 31*/ +5.0 /* gddbase (deg C) 33*/ +-1000 /* min_temprange 34*/ +5.0 /* emax 35*/ +0.02 /* intc 36*/ +ALPHAA_TeBS /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TeBS /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TeBS /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TeBS /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TeBS /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TeBS /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TeBS /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TeBS /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TeBS /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TeBS /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TeBS /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TeBS /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TeBS /* new phenology: slope of light limiting function */ +LIGHT_BASE_TeBS /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TeBS /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TeBS /* new phenology: slope of water limiting function */ +WATER_BASE_TeBS /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TeBS /* new phenology: change rate of actual to previous day water limiting function */ +MORT_MAX_TeBS /* asymptotic maximum mortality rate (1/year) */ +SUMMERGREEN /* phenology */ +C3 /* pathway */ +-4.0 38.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +15 30 /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +-30 8 /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.28880 /* shape factor for soil organic matter vertical distribution*/ +22.0 /* fuel bulk density */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_TREE /* flam */ +K_LITTER10 +K_LITTER10 +0.4 /* windspeed dampening */ +1.0 /* roughness length */ +BROADLEAVED /* leaftype */ +1.0 10 1.0 /* turnover leaf sapwood root 9 11 12*/ +CTON_LEAF CTON_SAP CTON_ROOT /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ +1.25 /* crownarea_max 20*/ +2.3 /* sapwood sapling 22 TIM 3.0*/ +10 +201.97 +REPROD_COST /* reproduction cost */ +110 /* allometry */ +35 +0.75 +ALLOM4 +HEIGHT_MAX /* maximum height of tree */ +0.0940 /* scorch height (F) */ +0.3334 /* crown length (CL) */ +0.0347 /* bark thickness par1 */ +0.1086 /* bark thickness par2 */ +1.0 /* crown damage (rCK) */ +3.00 /* crown damage (p) */ +0.045 0.075 0.21 0.67 /* fuel fraction */ +0.8 /* k_est TIM 1.5*/ +8 /* rotation */ +40 /* max_rotation_length */ +/*--------------------------------------------------------------------------*/ +/* 3. bft ONLY FOR BIOENERGY*/ +BIOENERGY_C4_GRASS +"bioenergy C4 grass" +GRASS +BIOMASS /* cultivation_type */ +39 61 74 80 /*curvenumbers */ +0.972 /* beta_root 1 */ +0.20 /* minwscal 3*/ +0.5 /* gmin 4*/ +0.2 /* respcoeff 5*/ +100 /* nmax 7*/ +1.0 /* resist 8*/ +0.5 /* sla 10*/ +0.75 /* lmro_ratio 18*/ +100 /* ramp 19*/ +0.001 /* lai_sapl 21*/ +0 /* gdd5min 30*/ +1000 /* twmax 31*/ +5.0 /* gddbase (deg C) 33*/ +-1000 /* min_temprange 34*/ +7.0 /* emax 35*/ +0.01 /* intc 36*/ +ALPHAA_TrH /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +ALBEDO_LEAF_TrH /* albedo of green leaves, MF 2013-05-30 */ +ALBEDO_STEM_TrH /* albedo of stems, MF 2013-05-30 */ +ALBEDO_LITTER_TrH /* albedo of litter, MF 2013-05-30 */ +SNOWCANOPYFRAC_TrH /* maximum snow coverage in green canopy, MF 2013-05-30 */ +LIGHTEXTCOEFF_TrH /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +TMIN_SL_TrH /* new phenology: slope of cold-temperature limiting function */ +TMIN_BASE_TrH /* new phenology: inflection point of cold-temperature limiting function (C) */ +TMIN_TAU_TrH /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +TMAX_SL_TrH /* new phenology: slope of warm-temperature limiting function tmax_sl */ +TMAX_BASE_TrH /* new phenology: inflection point of warm-temperature limiting function (C) */ +TMAX_TAU_TrH /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +LIGHT_SL_TrH /* new phenology: slope of light limiting function */ +LIGHT_BASE_TrH /* new phenology: inflection point of light limiting function (Wm-2) */ +LIGHT_TAU_TrH /* new phenology: change rate of actual to previous day light limiting function */ +WATER_SL_TrH /* new phenology: slope of water limiting function */ +WATER_BASE_TrH /* new phenology: inflection point of water limiting function (% water availability) */ +WATER_TAU_TrH /* new phenology: change rate of actual to previous day water limiting function */ +0.03 /* asymptotic maximum mortality rate (1/year) */ +ANY /* phenology */ +C4 /* pathway */ +4.0 55.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +15 45 /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +-40 1000 /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ +0.46513 /* shape factor for soil organic matter vertical distribution*/ +2.0 /* fuel bulk density (pb) */ +1664.0 63.0 2.20 3.40 8.50 2.540 /* emission factors */ +APREC_MIN /* minimum annual precipitation to establish */ +FLAM_GRASS /* flam */ +K_LITTER10 +K_LITTER10 +0.6 /* windspeed dampening */ +0.03 /* roughness length */ +1.0 2.0 /* turnover leaf root 9 12*/ +CTON_LEAF CTON_ROOT /* C:N mass ratio for leaf and root 13,15*/ +REPROD_COST /* reproduction cost */ +/*--------------------------------------------------------------------------*/ +/* 1. cft */ +TEMPERATE_CEREALS +"temperate cereals" +CROP +ANNUAL_CROP /* cultivation_type */ +60 72 80 84 /* curve number */ +0.9690 /* beta_root 1 */ +0.3 /* minwscal 3*/ +0.5 /* gmin 4*/ +1.0 /* respcoeff 5*/ +100 /* nmax 7 value of 8. PFT*/ +0.5 /* resist 8*/ +0.5 /* leaf longevity 10*/ +1.5 /* lmro_ratio 18*/ +500 /* ramp 19*/ +0.0001 /* lai_sapl 21 not used, computed internally*/ +0.0 /* gdd5min 30 */ +1000 /* twmax 31 value of 8. PFT*/ +0.0 /* gddbase (deg C) 33 */ +-1000 /* min_temprange 34 */ +8.0 /* emax 35*/ +0.01 /* intc 36*/ +1.0 /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ +0.1839 /* albedo of green leaves, MF 2013-05-30 */ +0.15 /* albedo of stems, MF 2013-05-30 */ +0.06767 /* albedo of litter, MF 2013-05-30 */ +0.4 /* maximum snow coverage in green canopy, MF 2013-05-30 */ +0.502 /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation, MF 2013-05-21 */ +0.3111 /* new phenology: slope of cold-temperature limiting function */ +4.979 /* new phenology: inflection point of cold-temperature limiting function (C) */ +0.01011 /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ +0.24 /* new phenology: slope of warm-temperature limiting function tmax_sl */ +32.04 /* new phenology: inflection point of warm-temperature limiting function (C) */ +0.2 /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ +23 /* new phenology: slope of light limiting function */ +75.94 /* new phenology: inflection point of light limiting function (Wm-2) */ +0.22 /* new phenology: change rate of actual to previous day light limiting function */ +0.5222 /* new phenology: slope of water limiting function */ +53.07 /* new phenology: inflection point of water limiting function (% water availability) */ +0.01001 /* new phenology: change rate of actual to previous day water limiting function */ +0.03 /* asymptotic maximum mortality rate (1/year) */ +CROPGREEN /* phenology */ +C3 /* pathway */ +0.0 40.0 /* lower and upper temperature limit for co2 (deg C) 24 27*/ +12 17 /* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ +-1000 1000 /* lower and upper coldest monthly mean temperature(deg C) 28 29 */ +0.40428 /* shape factor for soil organic matter vertical distribution*/ +2.0 /* fuel bulk density (pb) */ +1568.0 106.0 4.80 5.70 17.60 3.240 /* emission factors */ +0 /* minimum annual precipitation to establish */ +FLAM_GRASS /* flam */ +K_LITTER10 +K_LITTER10 +0.6 /* windspeed dampening */ +0.03 /* roughness length */ +TEMP_WTYP_CALC_SDATE /* calc_sdate: method to calculate the sowing date */ +258 90 /* sdatenh,sdatesh: init sowing date for northern and southern hemisphere (julian day) */ +330 /* hlimit: max length of crop cycle */ +30 /* fallow_days: wait after harvest until next sowing */ +12 5 12 /* temp_fall, temp_spring, temp_vernalization: thresholds for sowing date f(T)*/ +3 10 /* min & max trg: temperature under which vernalization is possible (deg C)*/ +0 /* pvd: number of vernalising days required*/ +1.0 /* psens: sensitivity to the photoperiod effect [0-1](1 means no sensitivity)*/ +8 /* pb: basal photoperiod (h)(pb 0) + +# settings for genetic optimization +nodes <- 1 # number of cluster nodes for parallel computing within genoud() +pop.size <- 50 # population size: 10 for testing, production run should have 800-1000 +max.generations <- 10 # maximum number of generations: 10 for testing, production run 20-60 +wait.generations <- 14 # minimum number of gnereations to wait before optimum parameter set is returned +BFGSburnin <- 11 # number of generations before the gradient search algorithm if first used + + +# remove temporary files at scratch? uncomment if you have two jobs at the same machine +system(paste("rm -rf", path.tmp)) +system(paste("mkdir", path.tmp)) + + +#---------------------------- +# 2. Prepare LPJmL input data +#---------------------------- + +# select grid cells for optimization +#----------------------------------- + +# Carefully select grid cells that are representative for the process or PFT that you want to optimize! +# For example, to optimize phenology of the boreal needle-leaved summergreen PFT, we need grid cells where this PFT is growing and has a dominant coverage: + +grid.name <- "SA_1cell" # name of the new grid +#grid <- cbind(lon=c(-44.75,64.75,29.75,132.75,112.25), lat=c(-12.75,45.75,10.75,-12.75,54.25)) +grid <- cbind(lon=c(-38.75,-46.75,-55.75,-65.25,-54.75), lat=c(-7.75,-9.75,-10.25,-6.75,-20.75)) + + +# define LPJmL input data +#------------------------ + +files.clm <- c( + # monthly CRU and ERI data: + TMP_FILE = paste(path.lpj.input, "GLDAS_NOAH05_daily_1948-2017.Tair_f_inst.clm", sep="/"), + PRE_FILE = paste(path.lpj.input, "GLDAS_NOAH05_daily_1948-2017.Prec.clm", sep="/"), + SWDOWN_FILE = paste(path.lpj.input, "GLDAS_NOAH05_daily_1948-2017.SWdown_f_tavg.clm", sep="/"), + LWNET_FILE = paste(path.lpj.input, "GLDAS_NOAH05_daily_1948-2017.Lwnet_tavg.clm", sep="/"), + + # extra data: + WINDSPEED_FILE = paste(path.lpj.input, "GLDAS_NOAH05_daily_1948-2017.Wind_f_inst.clm", sep="/"), + #DTR_FILE = paste(path.lpj.input, "cru3-2/cru_ts3.20.1901.2011.dtr.dat.clm", sep="/"), + #BURNTAREA_FILE = paste(path.lpj.input, "burntarea/GFED_CNFDB_ALFDB_Extrap2.BA.360.720.1901.2012.30days.clm", sep="/"), + #DRAINCLASS_FILE = paste(path.lpj.input, "drainclass.bin", sep="/"), + SOILCODE_FILE = paste(path.lpj.input, "soil_GLDAS.bin", sep="/"), + #WET_FILE = paste("/p/projects/lpjml/input/historical/CRUDATA_TS3_23/gpcc_v7_cruts3_23_wet_1901_2013.clm", sep="/"), + TMIN_FILE = paste(path.lpj.input, "GLDAS_NOAH05_daily_1948-2017.Tair_min.clm", sep="/"), + TMAX_FILE = paste(path.lpj.input, "GLDAS_NOAH05_daily_1948-2017.Tair_max.clm", sep="/"), + HUMID_FILE = paste(path.lpj.input, "GLDAS_NOAH05_daily_1948-2017.Qair_f_inst.clm", sep="/"), + LIGHTNING_FILE = paste(path.lpj.input, "dlightning.clm", sep="/"), + POPDENS_FILE = paste(path.lpj.input, "popdens_GLDAS.clm", sep="/"), + HUMANIGN_FILE = paste(path.lpj.input, "human_ignition_GLDAS.clm", sep="/"), + LANDUSE_FILE = paste(path.lpj.input, "landuse_GLDAS.clm", sep="/"), + COUNTRY_FILE = paste(path.lpj.input, "country_GLDAS.clm", sep="/"), + LANDCOVER_FILE = paste(path.lpj.input, "landcover_gldas.clm", sep="/") + +) + +input.df <- RegridLPJinput(files.clm, "/p/projects/lpjml/input/GLDAS/INPUT/grid_GLDAS.clm", grid, "/p/tmp/drueke/LPJmLmdi_input") + + +#------------------------------------------ +# 3. Define LPJmL directories and templates +#------------------------------------------ + + +# LPJmL directories and configuration template files +dir.create(path.tmp) +lpjfiles <- LPJfiles(path.lpj = path.lpj, path.tmp = path.tmp, path.out = path.out, + sim.start.year = 1948, sim.end.year = 2011, # starting year of transient simulation + lpj.conf = paste0(path.lpj.fun, "inst_gldas/lpjml_template.js"), # template file for LPJmL configuration + param.conf = paste0(path.lpj.fun, "inst_gldas/param_template.js"), # template file for parameter configuration + pft.par = paste0(path.lpj.fun, "inst_gldas/pft_template.js"), # template file for PFT-specific parameters + param.par = paste0(path.lpj.fun, "inst_gldas/lpjparam_template.js"), # template file for global parameters + input.conf = paste0(path.lpj.fun, "inst_gldas/input_template.js"), # template file for input data + input=input.df) + + + +#------------------------------------ +# 4. Define and read integration data +#------------------------------------ + +# define all integration data sets + +mburnt_area.gimms <- IntegrationDataset(name="BA_nocrop", unit="ha", + data.val.file = paste0(path.geodata, "test.nc"), + data.unc.file = 0.1, + data.time = seq(as.Date("1997-12-31"), as.Date("2011-12-31"), by="year"), + model.val.file = "aburnt_area.bin", + xy = grid, AggFun = NULL, data.factor=NULL, cost=TRUE, CostFunction=SSE, weight=1) + + + + +ndaymonth <- c(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31) # convert gC m-2 day-1 -> gC m-2 month-1 +vegc.mte <- IntegrationDataset(name="cVeg", unit="gC m-2", + data.val.file = paste0(path.geodata, "Carvalhais.cVeg.200.720.1.nc"), + data.unc.file = 1, + data.time = seq(as.Date("2005-01-01"), as.Date("2010-12-31"), by="year"), + model.val.file = "vegc.bin", + xy = grid, AggFun = AggNULLMean, data.factor=NULL, cost=FALSE, CostFunction=SSE, weight=1) + + +# make list of IntegrationData +integrationdata <- IntegrationData(mburnt_area.gimms, vegc.mte) +#pdf("out.pdf") +#plot(integrationdata, 1) +#plot(integrationdata, 2) +#dev.off() + +#-------------------------------------------------- +# 5. Define LPJmL prior parameter values and ranges +#-------------------------------------------------- + +# Depending on your application, you might need to define additional parameters in param_template.par and pft_template.par + + +# read parameter priors and ranges from *.txt file +#------------------------------------------------- + +# It is helpful to save all parameter names, prior values and prior ranges in a Excel table or *.csv file + +setwd(path.lpj.fun) +par.df <- read.table("inst_gldas/LPJmL_parameter-table.csv", header=TRUE, sep=",") + +# make LPJpar object +lpjpar <- LPJpar(par.prior=par.df$par.prior, par.lower=par.df$par.lower, par.upper=par.df$par.upper, par.pftspecif=par.df$par.pftspecif, par.names=par.df$par.names, correct=TRUE) +pdf("plot.pdf") +plot(lpjpar, "ALPHAA") +plot(lpjpar, "ALBEDO_LEAF") +#plot(lpjpar) #doesnt work yet +dev.off() + +#setwd(paste0(path.lpj, "par/")) +#WriteLPJpar(lpjpar, file="LPJmLmdi_test", pft.par=paste0(path.lpj.fun, "inst_gldas/pft_template.js"), param.par=paste0(path.lpj.fun, "inst_gldas/lpjparam_template.js")) + + +# select parameters for optimization +#----------------------------------- + +# Which parameters should be included in optimization? +par.optim <- c("ALPHA_FUELP_TrBE", "ALPHA_FUELP_TrBR", "ALPHA_FUELP_TrH", "CROWN_MORT_RCK_TrBE", "CROWN_MORT_RCK_TrBR", "SCORCHHEIGHT_F_TrBR", "SCORCHHEIGHT_F_TrBE") + +# For which PFTs? +#pft.sel <- c("BoNS", "PoH") +#par.optim <- paste(rep(par.optim, each=length(pft.sel)), pft.sel, sep="_") +#par.optim + + +#------------------------ +# 6. Perform optimization +#------------------------ + + +# do optimization +OptimizeLPJgenoud(xy = grid, # matrix of grid cell coordinates to run LPJ + name = name, # name of the experiment (basic file name for all outputs) + lpjpar = lpjpar, # see LPJpar + par.optim = par.optim, # names of the parameters in LPJpar that should be optimized + lpjfiles = lpjfiles, # see LPJfiles + copy.input = FALSE, # Should LPJmL input data be copied to the directory for temporary output? + integrationdata = integrationdata, # see IntegrationData + plot = TRUE, # plot results? + pop.size = pop.size, # population size + max.generations = max.generations, # max number of generations + wait.generations = wait.generations, # minimum number of generations to wait + BFGSburnin = BFGSburnin, # number of generations before the gradient search algorithm if first used + calc.jacob = FALSE, # Compute Hessian and Jacobian (yes = TRUE, no = FALSE)? + restart = restart, # Restart? 0 = at beginning, 1 = continue with genoud, 2 = post-processing + path.rescue = path.rescue, # directory with 'resuce' files from a previous optimization if restart > 0 + restart.jacob = FALSE, # Compute Hessian and Jacobian if restart > 0 (yes = TRUE, no = FALSE)? + nodes = nodes, # How many nodes to use for parallel computing within genoud? + maxAutoRestart = max.generations-1, # maximum number of automatic restarts in case something crashes + runonly=FALSE, # make only model run (TRUE) or do full optimization? + CostMDS=CostMDS) # Cost function for multiple data stes to use + + +# # check the progress of the optimization: + #setwd("/p/projects/biodiversity/drueke/internal_lpjml/out_optim/opt_Example/Opt_test4/Opt_test4_rescue") # directory with rescue files + #files <- list.files(pattern=".RData") + #rescue <- CombineRescueFiles(files, remove=FALSE) + #pdf("progress.pdf") + #plot(rescue) + #dev.off() diff --git a/LPJmLmdi/inst_gldas/LPJmL_parameter-table.csv b/LPJmLmdi/inst_gldas/LPJmL_parameter-table.csv new file mode 100644 index 0000000..17c45e1 --- /dev/null +++ b/LPJmLmdi/inst_gldas/LPJmL_parameter-table.csv @@ -0,0 +1,554 @@ +pft,par.names,par.prior,par.lower,par.upper,par.pftspecif,par.unit,reference,description,comment,Zaehle2005,process +BoBS,ALBEDO_LEAF_BoBS,0.180000,0.110000,0.250000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +BoNE,ALBEDO_LEAF_BoNE,0.130000,0.060000,0.200000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +BoNS,ALBEDO_LEAF_BoNS,0.120000,0.050000,0.190000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +PoH,ALBEDO_LEAF_PoH,0.210000,0.140000,0.280000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +TeBE,ALBEDO_LEAF_TeBE,0.150000,0.080000,0.220000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +TeBS,ALBEDO_LEAF_TeBS,0.150000,0.080000,0.220000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +TeH,ALBEDO_LEAF_TeH,0.200000,0.130000,0.270000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +TeNE,ALBEDO_LEAF_TeNE,0.137000,0.067000,0.207000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +TrBE,ALBEDO_LEAF_TrBE,0.140000,0.070000,0.210000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +TrBR,ALBEDO_LEAF_TrBR,0.130000,0.060000,0.200000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +TrH,ALBEDO_LEAF_TrH,0.210000,0.140000,0.280000,TRUE,-,S18a Tab S5,leaf albedo,LPJmL4 default,,albedo +BoBS,ALBEDO_LITTER_BoBS,0.100000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +BoNE,ALBEDO_LITTER_BoNE,0.100000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +BoNS,ALBEDO_LITTER_BoNS,0.010000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +PoH,ALBEDO_LITTER_PoH,0.100000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +TeBE,ALBEDO_LITTER_TeBE,0.100000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +TeBS,ALBEDO_LITTER_TeBS,0.100000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +TeH,ALBEDO_LITTER_TeH,0.100000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +TeNE,ALBEDO_LITTER_TeNE,0.100000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +TrBE,ALBEDO_LITTER_TrBE,0.100000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +TrBR,ALBEDO_LITTER_TrBR,0.060000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +TrH,ALBEDO_LITTER_TrH,0.100000,0.000000,0.200000,TRUE,-,S18a Tab S5,litter albedo,LPJmL4 default,,albedo +BoBS,ALBEDO_STEM_BoBS,0.100000,0.010000,0.150000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +BoNE,ALBEDO_STEM_BoNE,0.100000,0.010000,0.150000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +BoNS,ALBEDO_STEM_BoNS,0.050000,0.010000,0.150000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +PoH,ALBEDO_STEM_PoH,999.000000,998.000000,1000.000000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +TeBE,ALBEDO_STEM_TeBE,0.040000,0.010000,0.150000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +TeBS,ALBEDO_STEM_TeBS,0.040000,0.010000,0.150000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +TeH,ALBEDO_STEM_TeH,999.000000,998.000000,1000.000000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +TeNE,ALBEDO_STEM_TeNE,0.040000,0.010000,0.150000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +TrBE,ALBEDO_STEM_TrBE,0.100000,0.010000,0.150000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +TrBR,ALBEDO_STEM_TrBR,0.070000,0.010000,0.150000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +TrH,ALBEDO_STEM_TrH,999.000000,998.000000,1000.000000,TRUE,-,S18a Tab S5,stem albedo,LPJmL4 default,,albedo +BoBS,ALLOM1_BoBS,100.000000,50.000000,150.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 50,LPJmL4 default,TRUE,allometry +BoNE,ALLOM1_BoNE,100.000000,50.000000,150.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 50,LPJmL4 default,TRUE,allometry +BoNS,ALLOM1_BoNS,100.000000,50.000000,150.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 50,LPJmL4 default,TRUE,allometry +TeBE,ALLOM1_TeBE,100.000000,50.000000,150.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 50,LPJmL4 default,TRUE,allometry +TeBS,ALLOM1_TeBS,100.000000,50.000000,150.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 50,LPJmL4 default,TRUE,allometry +TeNE,ALLOM1_TeNE,100.000000,50.000000,150.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 50,LPJmL4 default,TRUE,allometry +TrBE,ALLOM1_TrBE,100.000000,50.000000,150.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 50,LPJmL4 default,TRUE,allometry +TrBR,ALLOM1_TrBR,100.000000,50.000000,150.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 50,LPJmL4 default,TRUE,allometry +BoBS,ALLOM2_BoBS,40.000000,20.000000,60.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +BoNE,ALLOM2_BoNE,40.000000,20.000000,60.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +BoNS,ALLOM2_BoNS,40.000000,20.000000,60.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TeBE,ALLOM2_TeBE,40.000000,20.000000,60.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TeBS,ALLOM2_TeBS,40.000000,20.000000,60.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TeNE,ALLOM2_TeNE,40.000000,20.000000,60.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TrBE,ALLOM2_TrBE,40.000000,20.000000,60.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TrBR,ALLOM2_TrBR,40.000000,20.000000,60.000000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +BoBS,ALLOM3_BoBS,0.670000,0.335000,1.005000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +BoNE,ALLOM3_BoNE,0.670000,0.335000,1.005000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +BoNS,ALLOM3_BoNS,0.670000,0.335000,1.005000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TeBE,ALLOM3_TeBE,0.670000,0.335000,1.005000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TeBS,ALLOM3_TeBS,0.670000,0.335000,1.005000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TeNE,ALLOM3_TeNE,0.670000,0.335000,1.005000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TrBE,ALLOM3_TrBE,0.670000,0.335000,1.005000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +TrBR,ALLOM3_TrBR,0.670000,0.335000,1.005000,TRUE,-,S18a Tab S6,Parameter for allometric relation ship Eq. 49,LPJmL4 default,TRUE,allometry +BoBS,ALLOM4_BoBS,0.300000,0.150000,0.450000,TRUE,NA,unused,unused,LPJmL4 default,,allometry +BoNE,ALLOM4_BoNE,0.300000,0.150000,0.450000,TRUE,NA,unused,unused,LPJmL4 default,,allometry +BoNS,ALLOM4_BoNS,0.300000,0.150000,0.450000,TRUE,NA,unused,unused,LPJmL4 default,,allometry +TeBE,ALLOM4_TeBE,0.300000,0.150000,0.450000,TRUE,NA,unused,unused,LPJmL4 default,,allometry +TeBS,ALLOM4_TeBS,0.300000,0.150000,0.450000,TRUE,NA,unused,unused,LPJmL4 default,,allometry +TeNE,ALLOM4_TeNE,0.300000,0.150000,0.450000,TRUE,NA,unused,unused,LPJmL4 default,,allometry +TrBE,ALLOM4_TrBE,0.300000,0.150000,0.450000,TRUE,NA,unused,unused,LPJmL4 default,,allometry +TrBR,ALLOM4_TrBR,0.300000,0.150000,0.450000,TRUE,NA,unused,unused,LPJmL4 default,,allometry +BoBS,ALPHA_FUELP_BoBS,0.000067,0.000007,0.000133,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +BoNE,ALPHA_FUELP_BoNE,0.000067,0.000007,0.000133,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +BoNS,ALPHA_FUELP_BoNS,0.000067,0.000007,0.000133,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +PoH,ALPHA_FUELP_PoH,0.000067,0.000007,0.000133,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +TeBE,ALPHA_FUELP_TeBE,0.000067,0.000007,0.000133,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +TeBS,ALPHA_FUELP_TeBS,0.000067,0.000007,0.000133,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +TeH,ALPHA_FUELP_TeH,0.000067,0.000007,0.000133,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +TeNE,ALPHA_FUELP_TeNE,0.000067,0.000007,0.000133,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +TrBE,ALPHA_FUELP_TrBE,0.000033,0.000003,0.000067,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +TrBR,ALPHA_FUELP_TrBR,0.000033,0.000003,0.000067,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +TrH,ALPHA_FUELP_TrH,0.000067,0.000007,0.000133,TRUE,-,Drueke et al.,scaling factor fire danger index,LPJmL4 default,,fire danger +global,ALPHA_M,1.391000,1.377090,1.404910,FALSE,-,Sitch et al. 2003,Priestley-Taylor coefficient,LPJmL4 default,TRUE,evapotranspiration +BoBS,ALPHAA_BoBS,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +BoNE,ALPHAA_BoNE,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +BoNS,ALPHAA_BoNS,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +PoH,ALPHAA_PoH,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +TeBE,ALPHAA_TeBE,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +TeBS,ALPHAA_TeBS,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +TeH,ALPHAA_TeH,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +TeNE,ALPHAA_TeNE,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +TrBE,ALPHAA_TrBE,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +TrBR,ALPHAA_TrBR,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +TrH,ALPHAA_TrH,0.400000,0.350000,0.650000,TRUE,-,S18a Tab S5,"scaling factor from leaf to ecosystem level (Haxeltine and Prentice, 1996)",LPJmL4 default,TRUE,productivity +global,ALPHAC3,0.080000,0.070000,0.090000,FALSE,-,S18a Tab S6,Intrinsic quantum efficiency of CO2 uptake in C3 plants,LPJmL4 default,TRUE,productivity +global,ALPHAC4,0.053000,0.050000,0.060000,FALSE,-,S18a Tab S6,Intrinsic quantum efficiency of CO2 uptake in C4 plants,LPJmL4 default,TRUE,productivity +global,ATMFRAC,0.700000,0.500000,0.900000,FALSE,, Zaehle et al. 2005,,LPJmL4 default,TRUE,respiration +global,BC3,0.015000,0.012000,0.018000,FALSE,day-1,S18a Tab S6,leaf respiration as fraction of Vmax for C3 plants,LPJmL4 default,,respiration +global,BC4,0.035000,0.028000,0.042000,FALSE,day-1,S18a Tab S6,leaf respiration as fraction of Vmax for C4 plants,LPJmL4 default,,respiration +BoBS,BETA_ROOT_BoBS,0.943000,0.913000,0.993000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +BoNE,BETA_ROOT_BoNE,0.943000,0.913000,0.993000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +BoNS,BETA_ROOT_BoNS,0.943000,0.913000,0.993000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +PoH,BETA_ROOT_PoH,0.943000,0.913000,0.993000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +TeBE,BETA_ROOT_TeBE,0.964000,0.934000,1.014000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +TeBS,BETA_ROOT_TeBS,0.966000,0.936000,1.016000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +TeH,BETA_ROOT_TeH,0.943000,0.913000,0.993000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +TeNE,BETA_ROOT_TeNE,0.976000,0.946000,1.026000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +TrBE,BETA_ROOT_TrBE,0.962000,0.932000,1.012000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +TrBR,BETA_ROOT_TrBR,0.961000,0.931000,1.011000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +TrH,BETA_ROOT_TrH,0.972000,0.942000,1.022000,TRUE,-,S18a Tab S8,root distribution slope parameter for water availability,LPJmL4 default,,water availability +BoBS,CROWN_MORT_RCK_BoBS,1.000000,0.500000,1.010000,TRUE,-,S18a Tab S9,resistance factor for crown damage,LPJmL4 default,,fire mortality +BoNE,CROWN_MORT_RCK_BoNE,1.000000,0.500000,1.010000,TRUE,-,S18a Tab S9,resistance factor for crown damage,LPJmL4 default,,fire mortality +BoNS,CROWN_MORT_RCK_BoNS,1.000000,0.500000,1.010000,TRUE,-,S18a Tab S9,resistance factor for crown damage,LPJmL4 default,,fire mortality +TeBE,CROWN_MORT_RCK_TeBE,0.950000,0.500000,1.010000,TRUE,-,S18a Tab S9,resistance factor for crown damage,LPJmL4 default,,fire mortality +TeBS,CROWN_MORT_RCK_TeBS,1.000000,0.500000,1.010000,TRUE,-,S18a Tab S9,resistance factor for crown damage,LPJmL4 default,,fire mortality +TeNE,CROWN_MORT_RCK_TeNE,1.000000,0.500000,1.010000,TRUE,-,S18a Tab S9,resistance factor for crown damage,LPJmL4 default,,fire mortality +TrBE,CROWN_MORT_RCK_TrBE,1.000000,0.500000,1.010000,TRUE,-,S18a Tab S9,resistance factor for crown damage,LPJmL4 default,,fire mortality +TrBR,CROWN_MORT_RCK_TrBR,0.050000,0.000000,0.500000,TRUE,-,S18a Tab S9,resistance factor for crown damage,LPJmL4 default,,fire mortality +BoBS,CROWNAREA_MAX_BoBS,15.000000,10.000000,30.000000,TRUE,m2,(S18a Tab S13),maximum crown area,LPJmL4 default,TRUE,allometry +BoNE,CROWNAREA_MAX_BoNE,15.000000,10.000000,30.000000,TRUE,m2,(S18a Tab S13),maximum crown area,LPJmL4 default,TRUE,allometry +BoNS,CROWNAREA_MAX_BoNS,15.000000,10.000000,30.000000,TRUE,m2,(S18a Tab S13),maximum crown area,LPJmL4 default,TRUE,allometry +TeBE,CROWNAREA_MAX_TeBE,15.000000,10.000000,30.000000,TRUE,m2,(S18a Tab S13),maximum crown area,LPJmL4 default,TRUE,allometry +TeBS,CROWNAREA_MAX_TeBS,15.000000,10.000000,30.000000,TRUE,m2,(S18a Tab S13),maximum crown area,LPJmL4 default,TRUE,allometry +TeNE,CROWNAREA_MAX_TeNE,15.000000,10.000000,30.000000,TRUE,m2,(S18a Tab S13),maximum crown area,LPJmL4 default,TRUE,allometry +TrBE,CROWNAREA_MAX_TrBE,15.000000,10.000000,30.000000,TRUE,m2,(S18a Tab S13),maximum crown area,LPJmL4 default,TRUE,allometry +TrBR,CROWNAREA_MAX_TrBR,12.000000,8.000000,30.000000,TRUE,m2,(S18a Tab S13),maximum crown area,LPJmL4 default,TRUE,allometry +global,E0,308.560000,273.000000,325.000000,FALSE,K,NA,Activation energy for respiration ,LPJmL4 default,TRUE,respiration +BoBS,EMAX_BoBS,5.000000,2.500000,7.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +BoNE,EMAX_BoNE,5.000000,2.500000,7.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +BoNS,EMAX_BoNS,5.000000,2.500000,7.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +PoH,EMAX_PoH,5.000000,2.500000,7.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +TeBE,EMAX_TeBE,5.000000,2.500000,7.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +TeBS,EMAX_TeBS,5.000000,2.500000,7.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +TeH,EMAX_TeH,5.000000,2.500000,7.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +TeNE,EMAX_TeNE,5.000000,2.500000,7.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +TrBE,EMAX_TrBE,7.000000,3.500000,10.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +TrBR,EMAX_TrBR,7.000000,3.500000,10.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +TrH,EMAX_TrH,7.000000,3.500000,10.500000,TRUE,mm day-1,S18a SI p26,Maximum water transport capacity,LPJmL4 default,TRUE,evapotranspiration +BoBS,GDD5MIN_BoBS,350.000000,100.000000,2000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +BoNE,GDD5MIN_BoNE,600.000000,100.000000,1000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +BoNS,GDD5MIN_BoNS,350.000000,100.000000,1000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +PoH,GDD5MIN_PoH,1.000000,0.100000,500.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +TeBE,GDD5MIN_TeBE,1200.000000,100.000000,4000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +TeBS,GDD5MIN_TeBS,1200.000000,100.000000,4000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +TeH,GDD5MIN_TeH,1.000000,0.100000,2000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +TeNE,GDD5MIN_TeNE,900.000000,100.000000,4000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +TrBE,GDD5MIN_TrBE,1.000000,0.100000,6000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +TrBR,GDD5MIN_TrBR,1.000000,0.100000,6000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +TrH,GDD5MIN_TrH,1.000000,0.100000,6000.000000,TRUE,°C,S18a Tab S4,Minimum number of growing degree days for establishment,LPJmL4 default,,bioclimatic limits +global,GMAX,3.260000,2.282000,4.238000,FALSE,-,S18a SI p26,maximum canopy conductance analogue (gm),LPJmL4 default,TRUE,evapotranspiration +BoBS,GMIN_BoBS,0.500000,0.350000,0.650000,TRUE,mm s-1,S18a Tab S8,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +BoNE,GMIN_BoNE,0.300000,0.210000,0.390000,TRUE,mm s-2,S18a Tab S9,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +BoNS,GMIN_BoNS,0.500000,0.350000,0.650000,TRUE,mm s-3,S18a Tab S10,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +PoH,GMIN_PoH,0.500000,0.350000,0.650000,TRUE,mm s-4,S18a Tab S11,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +TeBE,GMIN_TeBE,0.500000,0.350000,0.650000,TRUE,mm s-5,S18a Tab S12,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +TeBS,GMIN_TeBS,0.500000,0.350000,0.650000,TRUE,mm s-6,S18a Tab S13,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +TeH,GMIN_TeH,0.500000,0.350000,0.650000,TRUE,mm s-7,S18a Tab S14,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +TeNE,GMIN_TeNE,0.500000,0.350000,0.650000,TRUE,mm s-8,S18a Tab S15,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +TrBE,GMIN_TrBE,0.500000,0.350000,0.650000,TRUE,mm s-9,S18a Tab S16,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +TrBR,GMIN_TrBR,0.500000,0.350000,0.650000,TRUE,mm s-10,S18a Tab S17,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +TrH,GMIN_TrH,0.500000,0.350000,0.650000,TRUE,mm s-11,S18a Tab S18,minimum canopy conductance,LPJmL4 default,TRUE,evapotranspiration +BoBS,INTC_BoBS,0.060000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +BoNE,INTC_BoNE,0.060000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +BoNS,INTC_BoNS,0.060000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +PoH,INTC_PoH,0.010000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +TeBE,INTC_TeBE,0.020000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +TeBS,INTC_TeBS,0.020000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +TeH,INTC_TeH,0.010000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +TeNE,INTC_TeNE,0.020000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +TrBE,INTC_TrBE,0.020000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +TrBR,INTC_TrBR,0.020000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +TrH,INTC_TrH,0.010000,0.010000,0.300000,TRUE,-,S18a SI p26,interception storage parameter,LPJmL4 default,TRUE,evapotranspiration +BoBS,K_EST_BoBS,0.120000,0.012000,0.228000,TRUE,saplings m-2,S18a Tab S6,establishment rate,LPJmL4 default,TRUE,establishment +BoNE,K_EST_BoNE,0.120000,0.012000,0.228000,TRUE,saplings m-2,S18a Tab S6,establishment rate,LPJmL4 default,TRUE,establishment +BoNS,K_EST_BoNS,0.120000,0.012000,0.228000,TRUE,saplings m-2,S18a Tab S6,establishment rate,LPJmL4 default,TRUE,establishment +TeBE,K_EST_TeBE,0.120000,0.012000,0.228000,TRUE,saplings m-2,S18a Tab S6,establishment rate,LPJmL4 default,TRUE,establishment +TeBS,K_EST_TeBS,0.120000,0.012000,0.228000,TRUE,saplings m-2,S18a Tab S6,establishment rate,LPJmL4 default,TRUE,establishment +TeNE,K_EST_TeNE,0.120000,0.012000,0.228000,TRUE,saplings m-2,S18a Tab S6,establishment rate,LPJmL4 default,TRUE,establishment +TrBE,K_EST_TrBE,0.120000,0.012000,0.228000,TRUE,saplings m-2,S18a Tab S6,establishment rate,LPJmL4 default,TRUE,establishment +TrBR,K_EST_TrBR,0.120000,0.012000,0.228000,TRUE,saplings m-2,S18a Tab S6,establishment rate,LPJmL4 default,TRUE,establishment +BoBS,K_LATOSA_BoBS,4000.000000,2000.000000,6000.000000,TRUE,-,S18a Tab S6,leaf area to sapwood area,LPJmL4 default,TRUE,allometry +BoNE,K_LATOSA_BoNE,4000.000000,2000.000000,6000.000000,TRUE,-,S18a Tab S6,leaf area to sapwood area,LPJmL4 default,TRUE,allometry +BoNS,K_LATOSA_BoNS,4000.000000,2000.000000,6000.000000,TRUE,-,S18a Tab S6,leaf area to sapwood area,LPJmL4 default,TRUE,allometry +TeBE,K_LATOSA_TeBE,4000.000000,2000.000000,6000.000000,TRUE,-,S18a Tab S6,leaf area to sapwood area,LPJmL4 default,TRUE,allometry +TeBS,K_LATOSA_TeBS,4000.000000,2000.000000,6000.000000,TRUE,-,S18a Tab S6,leaf area to sapwood area,LPJmL4 default,TRUE,allometry +TeNE,K_LATOSA_TeNE,4000.000000,2000.000000,6000.000000,TRUE,-,S18a Tab S6,leaf area to sapwood area,LPJmL4 default,TRUE,allometry +TrBE,K_LATOSA_TrBE,4000.000000,2000.000000,6000.000000,TRUE,-,S18a Tab S6,leaf area to sapwood area,LPJmL4 default,TRUE,allometry +TrBR,K_LATOSA_TrBR,4000.000000,2000.000000,6000.000000,TRUE,-,S18a Tab S6,leaf area to sapwood area,LPJmL4 default,TRUE,allometry +global,K_ROOT10_LITTER,0.300000,0.150000,0.450000,FALSE,a-1,S18a Tab S6,mean residence time of roots in litter,LPJmL4 default,,decomposition +BoBS,K_LITTER10_LEAF_BoBS,0.940000,0.470000,1.410000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +BoNE,K_LITTER10_LEAF_BoNE,0.760000,0.380000,1.140000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +BoNS,K_LITTER10_LEAF_BoNS,0.760000,0.380000,1.140000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +PoH,K_LITTER10_LEAF_PoH,1.200000,0.600000,1.800000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +TeBE,K_LITTER10_LEAF_TeBE,0.860000,0.430000,1.290000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +TeBS,K_LITTER10_LEAF_TeBS,0.950000,0.475000,1.425000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +TeH,K_LITTER10_LEAF_TeH,1.200000,0.600000,1.800000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +TeNE,K_LITTER10_LEAF_TeNE,0.700000,0.350000,1.050000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +TrBE,K_LITTER10_LEAF_TrBE,0.930000,0.465000,1.395000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +TrBR,K_LITTER10_LEAF_TrBR,1.170000,0.585000,1.755000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +TrH,K_LITTER10_LEAF_TrH,0.970000,0.485000,1.455000,TRUE,a-1,S18a Tab S7,leaf litter turnover rate,LPJmL4 default,,turnover +BoBS,K_LITTER10_WOOD_BoBS,0.104000,0.052000,0.156000,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +BoNE,K_LITTER10_WOOD_BoNE,0.041000,0.020500,0.061500,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +BoNS,K_LITTER10_WOOD_BoNS,0.041000,0.020500,0.061500,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +PoH,K_LITTER10_WOOD_PoH,999.000000,998.000000,1000.000000,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +TeBE,K_LITTER10_WOOD_TeBE,0.104000,0.052000,0.156000,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +TeBS,K_LITTER10_WOOD_TeBS,0.104000,0.052000,0.156000,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +TeH,K_LITTER10_WOOD_TeH,999.000000,998.000000,1000.000000,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +TeNE,K_LITTER10_WOOD_TeNE,0.041000,0.020500,0.061500,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +TrBE,K_LITTER10_WOOD_TrBE,0.039000,0.019500,0.058500,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +TrBR,K_LITTER10_WOOD_TrBR,0.039000,0.019500,0.058500,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +TrH,K_LITTER10_WOOD_TrH,999.000000,998.000000,1000.000000,TRUE,a-1,S18a Tab S7,woody litter turnover rate,LPJmL4 default,,turnover +global,K_MORT,0.200000,0.050000,0.350000,FALSE,-,S18a Tab S6,coefficient of growth efficiency for mortality,LPJmL4 default,TRUE,mortality +global,K_ROOT10_FASTSOIL,0.030000,0.015000,0.045000,FALSE,a-1,S18a Tab S6,mean residence time of roots in fast soil carbon pool,LPJmL4 default,,decomposition +global,K_ROOT10_SLOWSOIL,0.001000,0.000500,0.001500,FALSE,a-1,S18a Tab S6,mean residence time of roots in slow soil carbon pool,LPJmL4 default,,decomposition +BoBS,LIGHT_BASE_BoBS,59.780000,29.890000,89.670000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +BoNE,LIGHT_BASE_BoNE,3.040000,1.520000,4.560000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +BoNS,LIGHT_BASE_BoNS,130.100000,65.050000,195.150000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +PoH,LIGHT_BASE_PoH,50.000000,25.000000,75.000000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +TeBE,LIGHT_BASE_TeBE,39.320000,19.660000,58.980000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +TeBS,LIGHT_BASE_TeBS,59.780000,29.890000,89.670000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +TeH,LIGHT_BASE_TeH,75.940000,37.970000,113.910000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +TeNE,LIGHT_BASE_TeNE,4.872000,2.436000,7.308000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +TrBE,LIGHT_BASE_TrBE,55.530000,27.765000,83.295000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +TrBR,LIGHT_BASE_TrBR,13.010000,6.505000,19.515000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +TrH,LIGHT_BASE_TrH,69.900000,34.950000,104.850000,TRUE,W m-2,F14 Tab S5,inflection point of light-limiting function,LPJmL4 default,,phenology +BoBS,LIGHT_SLOPE_BoBS,58.000000,29.000000,87.000000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +BoNE,LIGHT_SLOPE_BoNE,14.000000,7.000000,21.000000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +BoNS,LIGHT_SLOPE_BoNS,95.000000,47.500000,142.500000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +PoH,LIGHT_SLOPE_PoH,23.000000,11.500000,34.500000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +TeBE,LIGHT_SLOPE_TeBE,18.830000,9.415000,28.245000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +TeBS,LIGHT_SLOPE_TeBS,58.000000,29.000000,87.000000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +TeH,LIGHT_SLOPE_TeH,23.000000,11.500000,34.500000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +TeNE,LIGHT_SLOPE_TeNE,20.000000,10.000000,30.000000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +TrBE,LIGHT_SLOPE_TrBE,77.170000,38.585000,115.755000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +TrBR,LIGHT_SLOPE_TrBR,23.000000,11.500000,34.500000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +TrH,LIGHT_SLOPE_TrH,64.230000,32.115000,96.345000,TRUE,1/(W m2),F14 Tab S5,Slope of light-limiting function,LPJmL4 default,,phenology +BoBS,LIGHT_TAU_BoBS,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoNE,LIGHT_TAU_BoNE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoNS,LIGHT_TAU_BoNS,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +PoH,LIGHT_TAU_PoH,0.380000,0.190000,0.570000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeBE,LIGHT_TAU_TeBE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeBS,LIGHT_TAU_TeBS,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeH,LIGHT_TAU_TeH,0.220000,0.110000,0.330000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeNE,LIGHT_TAU_TeNE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrBE,LIGHT_TAU_TrBE,0.520000,0.260000,0.780000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrBR,LIGHT_TAU_TrBR,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrH,LIGHT_TAU_TrH,0.400000,0.200000,0.600000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoBS,LIGHTEXTCOEFF_BoBS,0.500000,0.400000,0.600000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +BoNE,LIGHTEXTCOEFF_BoNE,0.500000,0.400000,0.600000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +BoNS,LIGHTEXTCOEFF_BoNS,0.600000,0.500000,0.700000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +PoH,LIGHTEXTCOEFF_PoH,0.500000,0.400000,0.600000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +TeBE,LIGHTEXTCOEFF_TeBE,0.500000,0.400000,0.600000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +TeBS,LIGHTEXTCOEFF_TeBS,0.600000,0.500000,0.700000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +TeH,LIGHTEXTCOEFF_TeH,0.500000,0.400000,0.600000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +TeNE,LIGHTEXTCOEFF_TeNE,0.400000,0.300000,0.500000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +TrBE,LIGHTEXTCOEFF_TrBE,0.500000,0.400000,0.600000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +TrBR,LIGHTEXTCOEFF_TrBR,0.500000,0.400000,0.600000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +TrH,LIGHTEXTCOEFF_TrH,0.400000,0.300000,0.500000,TRUE,-,S18a Tab S5,light extinction coefficient in Lambert-Beer relationship,LPJmL4 default,TRUE,albedo/FAPAR +BoBS,LONGEVITY_BoBS,0.500000,0.250000,0.750000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +BoNE,LONGEVITY_BoNE,4.000000,2.000000,6.000000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +BoNS,LONGEVITY_BoNS,0.650000,0.325000,0.975000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +PoH,LONGEVITY_PoH,0.350000,0.175000,0.525000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +TeBE,LONGEVITY_TeBE,1.600000,0.800000,2.400000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +TeBS,LONGEVITY_TeBS,0.450000,0.225000,0.675000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +TeH,LONGEVITY_TeH,0.350000,0.175000,0.525000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +TeNE,LONGEVITY_TeNE,4.000000,2.000000,6.000000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +TrBE,LONGEVITY_TrBE,1.600000,0.800000,2.400000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +TrBR,LONGEVITY_TrBR,0.500000,0.250000,0.750000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +TrH,LONGEVITY_TrH,0.400000,0.200000,0.600000,TRUE,a,S18a Tab S8,leaf longevity,LPJmL4 default,TRUE,turnover +BoBS,MIN_TEMPRANGE_BoBS,-999.000000,-1000.000000,-998.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +BoNE,MIN_TEMPRANGE_BoNE,-999.000000,-1000.000000,-998.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +BoNS,MIN_TEMPRANGE_BoNS,30.000000,25.000000,35.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +PoH,MIN_TEMPRANGE_PoH,18.000000,13.000000,23.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +TeBE,MIN_TEMPRANGE_TeBE,-999.000000,-1000.000000,-998.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +TeBS,MIN_TEMPRANGE_TeBS,-999.000000,-1000.000000,-998.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +TeH,MIN_TEMPRANGE_TeH,-999.000000,-1000.000000,-998.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +TeNE,MIN_TEMPRANGE_TeNE,-999.000000,-1000.000000,-998.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +TrBE,MIN_TEMPRANGE_TrBE,-999.000000,-1000.000000,-998.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +TrBR,MIN_TEMPRANGE_TrBR,-999.000000,-1000.000000,-998.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +TrH,MIN_TEMPRANGE_TrH,-999.000000,-1000.000000,-998.000000,TRUE,K,NA,Minimum temperature amplitude for survival,LPJmL4 default,,bioclimatic limits +TrBR,MINWSCAL_TrBR,0.850000,0.000000,1.000000,TRUE,-,Sitch et al. 2003,Water avilability treshold for leaf development,LPJmL4 default,,old phenology +BoBS,MORT_MAX_BoBS,0.030000,0.003000,0.060000,TRUE,a-1,S18a Tab S6,asymptotic maximum mortality rate,LPJmL4 default,TRUE,mortality +BoNE,MORT_MAX_BoNE,0.030000,0.003000,0.060000,TRUE,a-1,S18a Tab S6,asymptotic maximum mortality rate,LPJmL4 default,TRUE,mortality +BoNS,MORT_MAX_BoNS,0.030000,0.003000,0.060000,TRUE,a-1,S18a Tab S6,asymptotic maximum mortality rate,LPJmL4 default,TRUE,mortality +TeBE,MORT_MAX_TeBE,0.030000,0.003000,0.060000,TRUE,a-1,S18a Tab S6,asymptotic maximum mortality rate,LPJmL4 default,TRUE,mortality +TeBS,MORT_MAX_TeBS,0.030000,0.003000,0.060000,TRUE,a-1,S18a Tab S6,asymptotic maximum mortality rate,LPJmL4 default,TRUE,mortality +TeNE,MORT_MAX_TeNE,0.030000,0.003000,0.060000,TRUE,a-1,S18a Tab S6,asymptotic maximum mortality rate,LPJmL4 default,TRUE,mortality +TrBE,MORT_MAX_TrBE,0.030000,0.003000,0.060000,TRUE,a-1,S18a Tab S6,asymptotic maximum mortality rate,LPJmL4 default,TRUE,mortality +TrBR,MORT_MAX_TrBR,0.030000,0.003000,0.060000,TRUE,a-1,S18a Tab S6,asymptotic maximum mortality rate,LPJmL4 default,TRUE,mortality +BoBS,REPROD_COST_BoBS,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +BoNE,REPROD_COST_BoNE,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +BoNS,REPROD_COST_BoNS,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +PoH,REPROD_COST_PoH,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TeBE,REPROD_COST_TeBE,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TeBS,REPROD_COST_TeBS,0.100000,0.050000,0.130000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TeH,REPROD_COST_TeH,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TeNE,REPROD_COST_TeNE,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TrBE,REPROD_COST_TrBE,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TrBR,REPROD_COST_TrBR,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TrH,REPROD_COST_TrH,0.100000,0.050000,0.200000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +BoBS,RESPCOEFF_BoBS,1.200000,0.600000,1.800000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +BoNE,RESPCOEFF_BoNE,1.200000,0.600000,1.800000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +BoNS,RESPCOEFF_BoNS,1.200000,0.600000,1.800000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +PoH,RESPCOEFF_PoH,1.200000,0.600000,1.800000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TeBE,RESPCOEFF_TeBE,1.200000,0.600000,1.800000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TeBS,RESPCOEFF_TeBS,1.200000,0.600000,1.800000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TeH,RESPCOEFF_TeH,1.200000,0.600000,1.800000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TeNE,RESPCOEFF_TeNE,1.200000,0.600000,1.800000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TrBE,RESPCOEFF_TrBE,0.200000,0.100000,0.300000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TrBR,RESPCOEFF_TrBR,0.200000,0.100000,0.300000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +TrH,RESPCOEFF_TrH,0.200000,0.100000,0.300000,TRUE,NA,pft.js,NA,LPJmL4 default,,NA +BoBS,SCORCHHEIGHT_F_BoBS,0.094000,0.047000,0.141000,TRUE,NA,S18a Tab S9,scorch height,LPJmL4 default,,fire mortality +BoNE,SCORCHHEIGHT_F_BoNE,0.110000,0.055000,0.165000,TRUE,NA,S18a Tab S9,scorch height,LPJmL4 default,,fire mortality +BoNS,SCORCHHEIGHT_F_BoNS,0.094000,0.047000,0.141000,TRUE,NA,S18a Tab S9,scorch height,LPJmL4 default,,fire mortality +TeBE,SCORCHHEIGHT_F_TeBE,0.371000,0.185500,0.556500,TRUE,NA,S18a Tab S9,scorch height,LPJmL4 default,,fire mortality +TeBS,SCORCHHEIGHT_F_TeBS,0.094000,0.047000,0.141000,TRUE,NA,S18a Tab S9,scorch height,LPJmL4 default,,fire mortality +TeNE,SCORCHHEIGHT_F_TeNE,0.100000,0.050000,0.150000,TRUE,NA,S18a Tab S9,scorch height,LPJmL4 default,,fire mortality +TrBE,SCORCHHEIGHT_F_TrBE,0.148700,0.074350,0.223050,TRUE,NA,S18a Tab S9,scorch height,LPJmL4 default,,fire mortality +TrBR,SCORCHHEIGHT_F_TrBR,0.061000,0.030500,0.091500,TRUE,NA,S18a Tab S9,scorch height,LPJmL4 default,,fire mortality +BoBS,SNOWCANOPYFRAC_BoBS,0.150000,0.100000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +BoNE,SNOWCANOPYFRAC_BoNE,0.100000,0.010000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +BoNS,SNOWCANOPYFRAC_BoNS,0.150000,0.100000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +PoH,SNOWCANOPYFRAC_PoH,0.400000,0.100000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +TeBE,SNOWCANOPYFRAC_TeBE,0.400000,0.100000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +TeBS,SNOWCANOPYFRAC_TeBS,0.400000,0.100000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +TeH,SNOWCANOPYFRAC_TeH,0.400000,0.100000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +TeNE,SNOWCANOPYFRAC_TeNE,0.100000,0.010000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +TrBE,SNOWCANOPYFRAC_TrBE,0.400000,0.100000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +TrBR,SNOWCANOPYFRAC_TrBR,0.500000,0.100000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +TrH,SNOWCANOPYFRAC_TrH,0.400000,0.100000,0.900000,TRUE,-,F14 Tab S4,Maximum fraction of snow in the green canopy,LPJmL4 default,,albedo/FAPAR +BoBS,TEMP_CO2_HIGH_BoBS,38.000000,33.000000,43.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +BoNE,TEMP_CO2_HIGH_BoNE,38.000000,33.000000,43.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +BoNS,TEMP_CO2_HIGH_BoNS,38.000000,33.000000,43.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +PoH,TEMP_CO2_HIGH_PoH,45.000000,40.000000,50.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +TeBE,TEMP_CO2_HIGH_TeBE,42.000000,37.000000,47.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +TeBS,TEMP_CO2_HIGH_TeBS,38.000000,33.000000,43.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +TeH,TEMP_CO2_HIGH_TeH,45.000000,40.000000,50.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +TeNE,TEMP_CO2_HIGH_TeNE,42.000000,37.000000,47.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +TrBE,TEMP_CO2_HIGH_TrBE,55.000000,50.000000,60.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +TrBR,TEMP_CO2_HIGH_TrBR,55.000000,50.000000,60.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +TrH,TEMP_CO2_HIGH_TrH,55.000000,50.000000,60.000000,TRUE,°C,(S18a Tab S13),upper temperature limit for CO2,LPJmL4 default,,productivity +BoBS,TEMP_CO2_LOW_BoBS,-4.000000,-9.000000,1.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +BoNE,TEMP_CO2_LOW_BoNE,-4.000000,-9.000000,1.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +BoNS,TEMP_CO2_LOW_BoNS,-4.000000,-9.000000,1.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +PoH,TEMP_CO2_LOW_PoH,-4.000000,-9.000000,1.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +TeBE,TEMP_CO2_LOW_TeBE,-4.000000,-9.000000,1.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +TeBS,TEMP_CO2_LOW_TeBS,-4.000000,-9.000000,1.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +TeH,TEMP_CO2_LOW_TeH,-4.000000,-9.000000,1.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +TeNE,TEMP_CO2_LOW_TeNE,-4.000000,-9.000000,1.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +TrBE,TEMP_CO2_LOW_TrBE,2.000000,-3.000000,7.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +TrBR,TEMP_CO2_LOW_TrBR,2.000000,-3.000000,7.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +TrH,TEMP_CO2_LOW_TrH,6.000000,1.000000,11.000000,TRUE,°C,(S18a Tab S13),lower temperature limit for CO2,LPJmL4 default,,productivity +BoBS,TEMP_HIGH_BoBS,-2.000000,-17.000000,13.000000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +BoNE,TEMP_HIGH_BoNE,-2.000000,-17.000000,13.000000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +BoNS,TEMP_HIGH_BoNS,-5.400000,-20.400000,9.600000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +PoH,TEMP_HIGH_PoH,-2.600000,-17.600000,12.400000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TeBE,TEMP_HIGH_TeBE,18.800000,3.800000,33.800000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TeBS,TEMP_HIGH_TeBS,15.500000,0.500000,30.500000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TeH,TEMP_HIGH_TeH,15.500000,0.500000,30.500000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TeNE,TEMP_HIGH_TeNE,22.000000,7.000000,37.000000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TrBE,TEMP_HIGH_TrBE,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TrBR,TEMP_HIGH_TrBR,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TrH,TEMP_HIGH_TrH,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S4,upper coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +BoBS,TEMP_LOW_BoBS,-999.000000,-1000.000000,-998.000000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +BoNE,TEMP_LOW_BoNE,-32.500000,-47.500000,-17.500000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +BoNS,TEMP_LOW_BoNS,-46.000000,-61.000000,-31.000000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +PoH,TEMP_LOW_PoH,-999.000000,-1000.000000,-998.000000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TeBE,TEMP_LOW_TeBE,3.000000,-12.000000,18.000000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TeBS,TEMP_LOW_TeBS,-17.700000,-32.700000,-2.700000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TeH,TEMP_LOW_TeH,-39.000000,-54.000000,-24.000000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TeNE,TEMP_LOW_TeNE,-2.000000,-17.000000,13.000000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TrBE,TEMP_LOW_TrBE,15.500000,0.500000,30.500000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TrBR,TEMP_LOW_TrBR,15.500000,0.500000,30.500000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +TrH,TEMP_LOW_TrH,7.000000,-8.000000,22.000000,TRUE,°C,S18a Tab S4,lower coldest monthly mean temperature,LPJmL4 default,,bioclimatic limits +BoBS,TEMP_PHOTOS_HIGH_BoBS,25.000000,20.000000,30.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +BoNE,TEMP_PHOTOS_HIGH_BoNE,25.000000,20.000000,30.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +BoNS,TEMP_PHOTOS_HIGH_BoNS,25.000000,20.000000,30.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +PoH,TEMP_PHOTOS_HIGH_PoH,30.000000,25.000000,35.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TeBE,TEMP_PHOTOS_HIGH_TeBE,30.000000,25.000000,35.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TeBS,TEMP_PHOTOS_HIGH_TeBS,25.000000,20.000000,30.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TeH,TEMP_PHOTOS_HIGH_TeH,30.000000,25.000000,35.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TeNE,TEMP_PHOTOS_HIGH_TeNE,30.000000,25.000000,35.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TrBE,TEMP_PHOTOS_HIGH_TrBE,30.000000,25.000000,35.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TrBR,TEMP_PHOTOS_HIGH_TrBR,30.000000,25.000000,35.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TrH,TEMP_PHOTOS_HIGH_TrH,45.000000,40.000000,50.000000,TRUE,°C,(S18a Tab S13),upper limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +BoBS,TEMP_PHOTOS_LOW_BoBS,15.000000,10.000000,20.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +BoNE,TEMP_PHOTOS_LOW_BoNE,15.000000,10.000000,20.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +BoNS,TEMP_PHOTOS_LOW_BoNS,15.000000,10.000000,20.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +PoH,TEMP_PHOTOS_LOW_PoH,10.000000,5.000000,15.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TeBE,TEMP_PHOTOS_LOW_TeBE,20.000000,15.000000,25.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TeBS,TEMP_PHOTOS_LOW_TeBS,20.000000,15.000000,25.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TeH,TEMP_PHOTOS_LOW_TeH,10.000000,5.000000,15.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TeNE,TEMP_PHOTOS_LOW_TeNE,20.000000,15.000000,25.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TrBE,TEMP_PHOTOS_LOW_TrBE,25.000000,20.000000,30.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TrBR,TEMP_PHOTOS_LOW_TrBR,25.000000,20.000000,30.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +TrH,TEMP_PHOTOS_LOW_TrH,20.000000,15.000000,25.000000,TRUE,°C,(S18a Tab S13),lower limit of temperature optimum for photosynthesis,LPJmL4 default,,productivity +global,THETA,0.700000,0.560000,0.840000,FALSE,-,S18a Tab S6,Co-limitation (shape) parameter,LPJmL4 default,TRUE,productivity +BoBS,TMAX_BASE_BoBS,41.510000,20.755000,62.265000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +BoNE,TMAX_BASE_BoNE,27.320000,13.660000,40.980000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +BoNS,TMAX_BASE_BoNS,44.600000,22.300000,66.900000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +PoH,TMAX_BASE_PoH,26.120000,13.060000,39.180000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +TeBE,TMAX_BASE_TeBE,41.120000,20.560000,61.680000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +TeBS,TMAX_BASE_TeBS,41.510000,20.755000,62.265000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +TeH,TMAX_BASE_TeH,32.040000,16.020000,48.060000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +TeNE,TMAX_BASE_TeNE,35.260000,17.630000,52.890000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +TrBE,TMAX_BASE_TrBE,38.640000,19.320000,57.960000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +TrBR,TMAX_BASE_TrBR,38.640000,19.320000,57.960000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +TrH,TMAX_BASE_TrH,29.160000,14.580000,43.740000,TRUE,°C,F14 Tab S5,inflection point of heat-limiting function,LPJmL4 default,,phenology +BoBS,TMAX_SLOPE_BoBS,1.740000,0.870000,2.610000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +BoNE,TMAX_SLOPE_BoNE,0.240000,0.120000,0.360000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +BoNS,TMAX_SLOPE_BoNS,0.240000,0.120000,0.360000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +PoH,TMAX_SLOPE_PoH,0.240000,0.120000,0.360000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +TeBE,TMAX_SLOPE_TeBE,0.980000,0.490000,1.470000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +TeBS,TMAX_SLOPE_TeBS,1.740000,0.870000,2.610000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +TeH,TMAX_SLOPE_TeH,0.240000,0.120000,0.360000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +TeNE,TMAX_SLOPE_TeNE,1.830000,0.915000,2.745000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +TrBE,TMAX_SLOPE_TrBE,1.860000,0.930000,2.790000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +TrBR,TMAX_SLOPE_TrBR,1.625000,0.812500,2.437500,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +TrH,TMAX_SLOPE_TrH,1.470000,0.735000,2.205000,TRUE,1/°C,F14 Tab S5,Slope of heat-limiting function,LPJmL4 default,,phenology +BoBS,TMAX_TAU_BoBS,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoNE,TMAX_TAU_BoNE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoNS,TMAX_TAU_BoNS,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +PoH,TMAX_TAU_PoH,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeBE,TMAX_TAU_TeBE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeBS,TMAX_TAU_TeBS,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeH,TMAX_TAU_TeH,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeNE,TMAX_TAU_TeNE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrBE,TMAX_TAU_TrBE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrBR,TMAX_TAU_TrBR,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrH,TMAX_TAU_TrH,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoBS,TMIN_BASE_BoBS,2.045000,1.022500,3.067500,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +BoNE,TMIN_BASE_BoNE,-7.516000,-3.758000,-11.274000,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +BoNS,TMIN_BASE_BoNS,-4.165000,-2.082500,-6.247500,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +PoH,TMIN_BASE_PoH,2.790000,1.395000,4.185000,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +TeBE,TMIN_BASE_TeBE,-0.629700,-0.314850,-0.944550,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +TeBS,TMIN_BASE_TeBS,13.690000,6.845000,20.535000,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +TeH,TMIN_BASE_TeH,4.979000,2.489500,7.468500,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +TeNE,TMIN_BASE_TeNE,-7.813000,-3.906500,-11.719500,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +TrBE,TMIN_BASE_TrBE,8.300000,4.150000,12.450000,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +TrBR,TMIN_BASE_TrBR,7.660000,3.830000,11.490000,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +TrH,TMIN_BASE_TrH,6.418000,3.209000,9.627000,TRUE,°C,F14 Tab S5,inflection point of cold-limiting function,LPJmL4 default,,phenology +BoBS,TMIN_SLOPE_BoBS,0.215300,0.107650,0.322950,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +BoNE,TMIN_SLOPE_BoNE,0.100800,0.050400,0.151200,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +BoNS,TMIN_SLOPE_BoNS,0.150000,0.075000,0.225000,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +PoH,TMIN_SLOPE_PoH,0.130000,0.065000,0.195000,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +TeBE,TMIN_SLOPE_TeBE,0.550000,0.275000,0.825000,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +TeBS,TMIN_SLOPE_TeBS,0.259100,0.129550,0.388650,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +TeH,TMIN_SLOPE_TeH,0.311100,0.155550,0.466650,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +TeNE,TMIN_SLOPE_TeNE,0.217200,0.108600,0.325800,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +TrBE,TMIN_SLOPE_TrBE,1.010000,0.505000,1.515000,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +TrBR,TMIN_SLOPE_TrBR,0.240000,0.120000,0.360000,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +TrH,TMIN_SLOPE_TrH,0.910000,0.455000,1.365000,TRUE,1/°C,F14 Tab S5,Slope of cold-limiting function,LPJmL4 default,,phenology +BoBS,TMIN_TAU_BoBS,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoNE,TMIN_TAU_BoNE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoNS,TMIN_TAU_BoNS,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +PoH,TMIN_TAU_PoH,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeBE,TMIN_TAU_TeBE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeBS,TMIN_TAU_TeBS,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeH,TMIN_TAU_TeH,0.010110,0.005055,0.015165,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeNE,TMIN_TAU_TeNE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrBE,TMIN_TAU_TrBE,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrBR,TMIN_TAU_TrBR,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrH,TMIN_TAU_TrH,0.200000,0.100000,0.300000,TRUE,-,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoBS,TURNOVER_LEAF_BoBS,1.000000,0.500000,1.500000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +BoNE,TURNOVER_LEAF_BoNE,4.000000,2.000000,6.000000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +BoNS,TURNOVER_LEAF_BoNS,1.000000,0.500000,1.500000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +PoH,TURNOVER_LEAF_PoH,1.000000,0.500000,1.500000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +TeBE,TURNOVER_LEAF_TeBE,1.000000,0.500000,1.500000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +TeBS,TURNOVER_LEAF_TeBS,1.000000,0.500000,1.500000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +TeH,TURNOVER_LEAF_TeH,1.000000,0.500000,1.500000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +TeNE,TURNOVER_LEAF_TeNE,4.000000,2.000000,6.000000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +TrBE,TURNOVER_LEAF_TrBE,2.000000,1.000000,3.000000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +TrBR,TURNOVER_LEAF_TrBR,1.000000,0.500000,1.500000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +TrH,TURNOVER_LEAF_TrH,1.000000,0.500000,1.500000,TRUE,a,S18a Tab S8,leaf turnover time,LPJmL4 default,,turnover +BoBS,TURNOVER_SAPWOOD_BoBS,20.000000,10.000000,100.000000,TRUE,a,S18a Tab S8,sapwood turnover time,LPJmL4 default,TRUE,turnover +BoNE,TURNOVER_SAPWOOD_BoNE,20.000000,10.000000,100.000000,TRUE,a,S18a Tab S8,sapwood turnover time,LPJmL4 default,TRUE,turnover +BoNS,TURNOVER_SAPWOOD_BoNS,20.000000,10.000000,100.000000,TRUE,a,S18a Tab S8,sapwood turnover time,LPJmL4 default,TRUE,turnover +TeBE,TURNOVER_SAPWOOD_TeBE,20.000000,10.000000,100.000000,TRUE,a,S18a Tab S8,sapwood turnover time,LPJmL4 default,TRUE,turnover +TeBS,TURNOVER_SAPWOOD_TeBS,20.000000,10.000000,100.000000,TRUE,a,S18a Tab S8,sapwood turnover time,LPJmL4 default,TRUE,turnover +TeNE,TURNOVER_SAPWOOD_TeNE,20.000000,10.000000,100.000000,TRUE,a,S18a Tab S8,sapwood turnover time,LPJmL4 default,TRUE,turnover +TrBE,TURNOVER_SAPWOOD_TrBE,20.000000,10.000000,100.000000,TRUE,a,S18a Tab S8,sapwood turnover time,LPJmL4 default,TRUE,turnover +TrBR,TURNOVER_SAPWOOD_TrBR,20.000000,10.000000,100.000000,TRUE,a,S18a Tab S8,sapwood turnover time,LPJmL4 default,TRUE,turnover +BoBS,TWMAX_BoBS,23.000000,18.000000,30.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +BoNE,TWMAX_BoNE,23.000000,18.000000,30.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +BoNS,TWMAX_BoNS,23.000000,18.000000,30.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +BoBS,TWMAX_DAILY_BoBS,25.000000,18.000000,32.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +BoNE,TWMAX_DAILY_BoNE,25.000000,18.000000,32.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +BoNS,TWMAX_DAILY_BoNS,25.000000,18.000000,32.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +PoH,TWMAX_DAILY_PoH,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TeBE,TWMAX_DAILY_TeBE,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TeBS,TWMAX_DAILY_TeBS,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TeH,TWMAX_DAILY_TeH,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TeNE,TWMAX_DAILY_TeNE,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TrBE,TWMAX_DAILY_TrBE,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TrBR,TWMAX_DAILY_TrBR,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TrH,TWMAX_DAILY_TrH,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +PoH,TWMAX_PoH,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TeBE,TWMAX_TeBE,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TeBS,TWMAX_TeBS,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TeH,TWMAX_TeH,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TeNE,TWMAX_TeNE,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TrBE,TWMAX_TrBE,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TrBR,TWMAX_TrBR,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +TrH,TWMAX_TrH,999.000000,998.000000,1000.000000,TRUE,°C,S18a Tab S6,Parameter for heat damage function,LPJmL4 default,,mortality +BoBS,WSCAL_BASE_BoBS,20.960000,10.480000,31.440000,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +BoNE,WSCAL_BASE_BoNE,0.007695,0.003848,0.011543,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +BoNS,WSCAL_BASE_BoNS,2.344000,1.172000,3.516000,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +PoH,WSCAL_BASE_PoH,1.000000,0.500000,1.500000,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +TeBE,WSCAL_BASE_TeBE,8.821000,4.410500,13.231500,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +TeBS,WSCAL_BASE_TeBS,20.960000,10.480000,31.440000,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +TeH,WSCAL_BASE_TeH,53.070000,26.535000,79.605000,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +TeNE,WSCAL_BASE_TeNE,8.613000,4.306500,12.919500,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +TrBE,WSCAL_BASE_TrBE,4.997000,2.498500,7.495500,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +TrBR,WSCAL_BASE_TrBR,22.210000,11.105000,33.315000,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +TrH,WSCAL_BASE_TrH,41.720000,20.860000,62.580000,TRUE,%/100,F14 Tab S5,inflection point of water-limiting function,LPJmL4 default,,phenology +BoBS,WSCAL_SLOPE_BoBS,5.240000,2.620000,7.860000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +BoNE,WSCAL_SLOPE_BoNE,5.000000,2.500000,7.500000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +BoNS,WSCAL_SLOPE_BoNS,5.000000,2.500000,7.500000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +PoH,WSCAL_SLOPE_PoH,0.880000,0.440000,1.320000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +TeBE,WSCAL_SLOPE_TeBE,5.000000,2.500000,7.500000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +TeBS,WSCAL_SLOPE_TeBS,5.240000,2.620000,7.860000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +TeH,WSCAL_SLOPE_TeH,0.522200,0.261100,0.783300,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +TeNE,WSCAL_SLOPE_TeNE,5.000000,2.500000,7.500000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +TrBE,WSCAL_SLOPE_TrBE,5.140000,2.570000,7.710000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +TrBR,WSCAL_SLOPE_TrBR,7.970000,3.985000,11.955000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +TrH,WSCAL_SLOPE_TrH,0.100000,0.050000,0.150000,TRUE,%/100,F14 Tab S5,Slope of water-limiting function,LPJmL4 default,,phenology +BoBS,WSCAL_TAU_BoBS,0.800000,0.400000,1.200000,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoNE,WSCAL_TAU_BoNE,0.800000,0.400000,1.200000,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoNS,WSCAL_TAU_BoNS,0.800000,0.400000,1.200000,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +PoH,WSCAL_TAU_PoH,0.940000,0.470000,1.410000,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeBE,WSCAL_TAU_TeBE,0.800000,0.400000,1.200000,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeBS,WSCAL_TAU_TeBS,0.800000,0.400000,1.200000,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeH,WSCAL_TAU_TeH,0.010010,0.005005,0.015015,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TeNE,WSCAL_TAU_TeNE,0.800000,0.400000,1.200000,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrBE,WSCAL_TAU_TrBE,0.440000,0.220000,0.660000,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrBR,WSCAL_TAU_TrBR,0.134800,0.067400,0.202200,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +TrH,WSCAL_TAU_TrH,0.170000,0.085000,0.255000,TRUE,%/100,F14 Tab S5,Change rate of actual to previous day value,LPJmL4 default,,phenology +BoBS,SIF_A_BoBS,0.311000,0.217700,0.404300,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +BoNE,SIF_A_BoNE,0.190000,0.133000,0.247000,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +BoNS,SIF_A_BoNS,0.233000,0.163100,0.302900,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +PoH,SIF_A_PoH,0.469000,0.328300,0.609700,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +TeBE,SIF_A_TeBE,0.216000,0.151200,0.280800,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +TeBS,SIF_A_TeBS,0.278000,0.194600,0.361400,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +TeH,SIF_A_TeH,0.421000,0.294700,0.547300,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +TeNE,SIF_A_TeNE,0.220000,0.154000,0.286000,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +TrBE,SIF_A_TrBE,0.100000,0.080000,0.487500,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +TrBR,SIF_A_TrBR,0.258000,0.180600,0.335400,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +TrH,SIF_A_TrH,0.375000,0.262500,0.487500,TRUE,-,Linear regression against FLUXCOM GPP,slope in GPP-SIF relationship,LPJmL4 default,,productivity +BoBS,SIF_B_BoBS,0.092000,0.064400,0.119600,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +BoNE,SIF_B_BoNE,0.128000,0.089600,0.166400,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +BoNS,SIF_B_BoNS,-0.019000,-0.024700,-0.013300,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +PoH,SIF_B_PoH,-0.043000,-0.055900,-0.030100,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +TeBE,SIF_B_TeBE,0.445000,0.311500,0.578500,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +TeBS,SIF_B_TeBS,0.404000,0.282800,0.525200,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +TeH,SIF_B_TeH,0.106000,0.074200,0.137800,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +TeNE,SIF_B_TeNE,0.261000,0.182700,0.339300,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +TrBE,SIF_B_TrBE,1.349000,0.137900,1.753700,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +TrBR,SIF_B_TrBR,0.448000,0.313600,0.582400,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity +TrH,SIF_B_TrH,0.197000,0.137900,0.256100,TRUE,-,Linear regression against FLUXCOM GPP,Intercept in GPP-SIF relationship,LPJmL4 default,,productivity diff --git a/LPJmLmdi/inst_gldas/LPJmL_parameter-table.xlsx b/LPJmLmdi/inst_gldas/LPJmL_parameter-table.xlsx new file mode 100644 index 0000000..c1b272d Binary files /dev/null and b/LPJmLmdi/inst_gldas/LPJmL_parameter-table.xlsx differ diff --git a/LPJmLmdi/inst_gldas/input_template.js b/LPJmLmdi/inst_gldas/input_template.js new file mode 100644 index 0000000..8643f14 --- /dev/null +++ b/LPJmLmdi/inst_gldas/input_template.js @@ -0,0 +1,48 @@ +/**************************************************************************************/ +/** \n**/ +/** i n p u t _ c r u m o n t h l y . j s \n**/ +/** \n**/ +/** Configuration file for input dataset for LPJ C Version 4.0.001 \n**/ +/** \n**/ +/** (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file \n**/ +/** authors, and contributors see AUTHORS file \n**/ +/** This file is part of LPJmL and licensed under GNU AGPL Version 3 \n**/ +/** or later. See LICENSE file or go to http://www.gnu.org/licenses/ \n**/ +/** Contact: https://gitlab.pik-potsdam.de/lpjml \n**/ +/** \n**/ +/**************************************************************************************/ + +#include "include/conf.h" /* include constant definitions */ + +"input" : +{ + "soil" : { "fmt" : RAW, "name" : "SOILCODE_FILE"}, + "coord" : { "fmt" : CLM, "name" : "GRID_FILE"}, + "countrycode" : { "fmt" : CLM, "name" : "COUNTRY_FILE"}, + "landuse" : { "fmt" : CLM, "name" : "LANDUSE_FILE"}, + /* insert prescribed sdate file name here */ + "grassland_fixed_pft" : { "fmt" : RAW, "name" : "/home/rolinski/LPJ/Newinput/scenario_MO0.bin"}, + "lakes" : { "fmt" : META, "name" : "/p/projects/lpjml/input/historical/input_VERSION2/glwd_lakes_and_rivers.descr"}, + "drainage" : { "fmt" : CLM, "name" : "/p/projects/lpjml/input/historical/input_VERSION2/drainagestn.bin"}, + "neighb_irrig" : { "fmt" : CLM, "name" : "/p/projects/lpjml/input/historical/input_VERSION2/neighb_irrig_stn.bin"}, + "elevation" : { "fmt" : CLM, "name" : "/p/projects/lpjml/input/historical/input_VERSION2/elevation.bin"}, + "reservoir" : { "fmt" : CLM, "name" : "/p/projects/lpjml/input/historical/input_VERSION2/reservoir_info_grand5.bin"}, + "temp" : { "fmt" : CLM, "name" : "TMP_FILE"}, + "prec" : { "fmt" : CLM, "name" : "PRE_FILE"}, + "lwnet" : { "fmt" : CLM, "name" : "LWNET_FILE"}, + "swdown" : { "fmt" : CLM, "name" : "SWDOWN_FILE"}, + "cloud": { "fmt" : CLM2, "name" : "/p/projects/lpjml/input/historical/CRUDATA_TS3_23/cru_ts3.23.1901.2014.cld.dat.clm"}, + "wind": { "fmt" : CLM, "name" : "WINDSPEED_FILE"}, + "tamp": { "fmt" : CLM, "name" : "/p/projects/lpjml/input/historical/CRUDATA_TS3_23/cru_ts3.23.1901.2014.dtr.dat.clm"}, /* diurnal temp. range */ + "tmin": { "fmt" : CLM, "name" : "TMIN_FILE"}, + "tmax": { "fmt" : CLM, "name" : "TMAX_FILE"}, + "humid": { "fmt" : CLM, "name" : "HUMID_FILE"}, + "lightning": { "fmt" : CLM, "name" : "LIGHTNING_FILE"}, + "human_ignition": { "fmt" : CLM, "name" : "HUMANIGN_FILE"}, + "popdens" : { "fmt" : CLM, "name" : "POPDENS_FILE"}, + "burntarea" : { "fmt" : CLM, "name" : "/p/projects/biodiversity/drueke/mburntarea.clm"}, + "landcover": { "fmt" : CLM, "name" : "/data/biosx/mforkel/input_new/landcover_synmap_koeppen_vcf_newPFT_forLPJ_20130910.clm"},/*synmap_koeppen_vcf_NewPFT_adjustedByLanduse_SpinupTransitionPrescribed_forLPJ.clm*/ + "co2" : { "fmt" : TXT, "name" : "/p/projects/lpjml/input/historical/input_VERSION2/co2_1841-2017.dat"}, + "wetdays" : { "fmt" : CLM, "name" : "/p/projects/lpjml/input/historical/CRUDATA_TS3_23/gpcc_v7_cruts3_23_wet_1901_2013.clm"}, + "wateruse" : { "fmt" : CLM, "name" : "/p/projects/lpjml/input/historical/input_VERSION2/wateruse_1900_2000.bin" } /* water consumption for industry,household and livestock */ +}, diff --git a/LPJmLmdi/inst_gldas/lpjml_template.js b/LPJmLmdi/inst_gldas/lpjml_template.js new file mode 100644 index 0000000..4309ee4 --- /dev/null +++ b/LPJmLmdi/inst_gldas/lpjml_template.js @@ -0,0 +1,160 @@ +/**************************************************************************************/ +/** \n**/ +/** l p j m l . j s \n**/ +/** \n**/ +/** Default configuration file for LPJmL C Version 4.0.001 \n**/ +/** \n**/ +/** Configuration file is divided into five sections: \n**/ +/** \n**/ +/** I. Simulation description and type section \n**/ +/** II. Input parameter section \n**/ +/** III. Input data section \n**/ +/** IV. Output data section \n**/ +/** V. Run settings section \n**/ +/** \n**/ +/** (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file \n**/ +/** authors, and contributors see AUTHORS file \n**/ +/** This file is part of LPJmL and licensed under GNU AGPL Version 3 \n**/ +/** or later. See LICENSE file or go to http://www.gnu.org/licenses/ \n**/ +/** Contact: https://gitlab.pik-potsdam.de/lpjml \n**/ +/** \n**/ +/**************************************************************************************/ + +#include "include/conf.h" /* include constant definitions */ + +#define BENCHMARK_LAI 5 /* also set value here directly (1 to 7), not in /par/lpjparam.js */ +#define OUTPATH CELL_OUTPATH +//#define DAILY_OUTPUT /* enables daily output */ + +{ /* LPJmL configuration in JSON format */ + +/*===================================================================*/ +/* I. Simulation description and type section */ +/*===================================================================*/ + + "sim_name" : "LPJmL Run", /* Simulation description */ + "sim_id" : LPJML, /* LPJML Simulation type with managed land use */ + "random_prec" : false, /* Random weather generator for precipitation enabled */ + "random_seed" : 2, /* seed for random number generator */ + "radiation" : RADIATION, /* other options: CLOUDINESS, RADIATION, RADIATION_SWONLY, RADIATION_LWDOWN */ + "fire" : SPITFIRE_TMAX, /* fire disturbance enabled, other options: NO_FIRE, FIRE, SPITFIRE, SPITFIRE_TMAX (for GLDAS input data) */ + "firewood" : false, + "new_phenology": true, /* GSI phenology enabled */ + "river_routing" : false, + "permafrost" : true, +#ifdef FROM_RESTART + "population" : true, + "landuse" : LANDUSE, /* other options: NO_LANDUSE, LANDUSE, CONST_LANDUSE, ALL_CROPS */ + "reservoir" : true, + "wateruse" : true, +#else + "population" : false, + "landuse" : NO_LANDUSE, + "reservoir" : false, + "wateruse" : false, +#endif + "prescribe_burntarea" : false, + "prescribe_landcover" : NO_LANDCOVER, /* NO_LANDCOVER, LANDCOVERFPC, LANCOVEREST */ + "sowing_date_option" : FIXED_SDATE, /* NO_FIXED_SDATE, FIXED_SDATE, PRESCRIBED_SDATE */ + "irrigation" : LIM_IRRIGATION, /* NO_IRRIGATION, LIM_IRRIGATION, POT_IRRIGATION, ALL_IRRIGATION */ + "laimax_interpolate" : LAIMAX_CFT, /* laimax values from manage parameter file, */ + /* other options: LAIMAX_CFT, CONST_LAI_MAX, LAIMAX_INTERPOLATE */ + "grassland_fixed_pft" : false, + + "landuse_year_const" : 2000, /* set landuse year for CONST_LANDUSE case */ + "sdate_fixyear" : 1970, /* year in which sowing dates shall be fixed */ + "intercrop" : true, /* intercrops on setaside */ + "remove_residuals" : false, /* remove residuals */ + "residues_fire" : false, /* fire in residuals */ + "laimax" : 5, /* maximum LAI for CONST_LAI_MAX */ + + +/*===================================================================*/ +/* II. Input parameter section */ +/*===================================================================*/ + +#include "CELL_PARCONF_FILE" /* Input parameter file */ + +/*===================================================================*/ +/* III. Input data section */ +/*===================================================================*/ + +#include "CELL_INPUT_FILE" /* Input files of CRU dataset */ + +/*===================================================================*/ +/* IV. Output data section */ +/*===================================================================*/ + +#ifdef WITH_GRIDBASED + "pft_output_scaled" : GRIDBASED, +#define SUFFIX grid.bin +#else + "pft_output_scaled" : PFTBASED, +#define SUFFIX pft.bin +#endif + +#define mkstr(s) xstr(s) /* putting string in quotation marks */ +#define xstr(s) #s + + "crop_index" : TEMPERATE_CEREALS, /* CFT for daily output */ + "crop_irrigation" : DAILY_RAINFED, /* irrigation flag for daily output */ + +#ifdef FROM_RESTART + + "output" : + [ +/* +ID Fmt filename +-------------------------- ---------------------- ----------------------------- */ + { "id" : GRID, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/grid.bin" }}, + { "id" : FPC, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/fpc.bin"}}, + { "id" : ABURNTAREA, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/aburnt_area.bin"}}, + { "id" : MGPP, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/mgpp.bin"}}, + { "id" : FIREC, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/firec.bin"}}, + { "id" : VEGC, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/vegc.bin"}}, + { "id" : SOILC, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/soilc.bin"}}, + { "id" : LITC, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATHlitc.bin"}}, + { "id" : MBURNTAREA, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/mburnt_area.bin"}}, + { "id" : MALBEDO, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/malbedo.bin"}}, + { "id" : AGB, "file" : { "fmt" : RAW, "name" : "CELL_OUTPATH/agb.bin"}}, +/*------------------------ ---------------------- ------------------------------- */ + ], + +#else + + "output" : [], /* no output written */ + +#endif + +/*===================================================================*/ +/* V. Run settings section */ +/*===================================================================*/ + + "startgrid" : CELL_START, /*18714,*/ /*7385,*/ /*7841,*/ /* 27410, 67208 60400 all grid cells */ + "endgrid" : CELL_END, /*18714,*/ /*8765,*/ /*7385,*/ /*7841,*/ + +#ifndef FROM_RESTART + + "nspinup" : 5000, /* spinup years */ + "nspinyear" : 30, /* cycle length during spinup (yr) */ + "firstyear": YEAR_START, /* first year of simulation */ + "lastyear" : YEAR_START, /* last year of simulation */ + "restart" : false, /* do not start from restart file */ + "write_restart" : true, /* create restart file: the last year of simulation=restart-year */ + "write_restart_filename" : "CELL_RESTART_FILE", /* filename of restart file */ + "restart_year": YEAR_START /* write restart at year */ + +#else + + "nspinup" : 100, /* spinup years */ + "nspinyear" : 30, /* cycle length during spinup (yr)*/ + "firstyear": YEAR_START, /* first year of simulation */ + "lastyear" : YEAR_END, /* last year of simulation */ + "restart" : true, /* start from restart file */ + "restart_filename" : "CELL_RESTART_FILE", /* filename of restart file */ + "write_restart" : false, /* create restart file */ + "write_restart_filename" : "restart/restart_1900_crop_stdfire.lpj", /* filename of restart file */ + "restart_year": YEAR_START /* write restart at year */ + +#endif +} diff --git a/LPJmLmdi/inst_gldas/lpjparam_template.js b/LPJmLmdi/inst_gldas/lpjparam_template.js new file mode 100644 index 0000000..31f0b95 --- /dev/null +++ b/LPJmLmdi/inst_gldas/lpjparam_template.js @@ -0,0 +1,56 @@ + /**************************************************************************************/ +/** \n**/ +/** l p j p a r a m . j s \n**/ +/** \n**/ +/** LPJ parameter file for LPJmL version 4.0.001 \n**/ +/** \n**/ +/** (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file \n**/ +/** authors, and contributors see AUTHORS file \n**/ +/** This file is part of LPJmL and licensed under GNU AGPL Version 3 \n**/ +/** or later. See LICENSE file or go to http://www.gnu.org/licenses/ \n**/ +/** Contact: https://github.com/PIK-LPJmL/LPJmL \n**/ +/** \n**/ +/** \n**/ +/**************************************************************************************/ + +"param" : +{ + "k_litter10" : K_ROOT10_LITTER, /* k_litter10 (1/yr) */ + "k_soil10" : { + "fast" : K_ROOT10_FASTSOIL, + "slow": K_ROOT10_SLOWSOIL + }, + "maxsnowpack": 20000.0, /* max. snow pack (mm) */ + "soildepth_evap" : 300, /* depth of sublayer at top of upper soil layer (mm) */ + "co2_p" : 278.0, /* pre-industrial CO2 (ppmv) */ + "k" : 0.0548, /* k k = 7.4e-7 * atomic_mass_C / atomic_mass_N * seconds_per_day = 0.0548 Sprugel et al. 1996, Eqn 7*/ + "theta" : THETA, /* theta */ + "k_beer" : 0.5, /* k_beer */ + "alphac3" : ALPHAC3, /* alphac3 */ + "alphac4" : ALPHAC4, /* alphac4 */ + "bc3" : BC3, /* bc3 leaf respiration as fraction of Vmax for C3 plants */ + "bc4" : BC4, /* bc4 leaf respiration as fraction of Vmax for C4 plants */ + "r_growth" : 0.25, /* r_growth */ + "GM" : GMAX, /* GM empirical parameter in demand function */ + "ALPHAM" : ALPHA_M, /* ALPHAM Priestley-Taylor coefficient*/ + "ko25" : 3.0e4, /* Michaelis constant for O2 (Pa) at 25 deg C */ + "kc25" : 30., /* Michaelis constant for CO2 (Pa) at 25 deg C */ + "atmfrac" : ATMFRAC, /* atmfrac */ + "fastfrac" : 0.98, /* fastfrac */ + "k_mort" : K_MORT, /* coefficient of growth efficiency in mortality equation (k_mort2) */ + "aprec_lim" : 900, /* annual prec limit for C3 threshold*/ + "irrig_threshold_c3_dry" : 0.8, /* irrigation threshold C3, prec < aprec_lim */ + "irrig_threshold_c3_humid" : 0.9, /* irrigation threshold C3, prec >= aprec_lim */ + "irrig_threshold_c4" : 0.7, /* irrigation threshold C4 */ + "irrig_threshold_rice" : 1.0, /* irrigation threshold RICE */ + "irrig_soilfrac" : 1.0, /* fraction of soil filled with water during irrigation event */ + "canal_conveyance_eff_sand" : 0.7, /* open canal conveyance efficiency, soil type sand (Ks > 20)*/ + "canal_conveyance_eff_loam" : 0.75, /* open canal conveyance efficiency, soil type loam (10<=Ks<=20)*/ + "canal_conveyance_eff_clay" : 0.8, /* open canal conveyance efficiency, soil type clay (Ks<10) */ + "pipe_conveyance_eff" : 0.95, /* pressurized conveyance efficiency*/ + "saturation_level_surf" : 1.15, /* saturation level surface irrigation*/ + "saturation_level_sprink" : 0.55, /* saturation level sprinkler irrigation*/ + "saturation_level_drip" : 0.05, /* saturation level drip irrigation*/ + "drip_evap_reduction" : 0.6, /* reduction of drip soil evap */ + "residues_in_soil" : 0.1 /* minimum residues in soil*/ +}, diff --git a/LPJmLmdi/inst_gldas/param_template.js b/LPJmLmdi/inst_gldas/param_template.js new file mode 100644 index 0000000..8d48fef --- /dev/null +++ b/LPJmLmdi/inst_gldas/param_template.js @@ -0,0 +1,21 @@ +/**************************************************************************************/ +/** \n**/ +/** p a r a m . j s \n**/ +/** \n**/ +/** Default input parameter file for LPJmL C Version 4.0.001 \n**/ +/** \n**/ +/** (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file \n**/ +/** authors, and contributors see AUTHORS file \n**/ +/** This file is part of LPJmL and licensed under GNU AGPL Version 3 \n**/ +/** or later. See LICENSE file or go to http://www.gnu.org/licenses/ \n**/ +/** Contact: https://github.com/PIK-LPJmL/LPJmL \n**/ +/** \n**/ +/**************************************************************************************/ + +#include "PAR_FILE_CELL" /* LPJ parameter file */ +#include "par/soil.js" /* Soil parameter file */ +#include "PAR_PFT_FILE_CELL" /* PFT parameter file*/ + +#include "par/manage_laimax_alphaa_fao.y.1999.2009_date.2017-10-19_lpj.rev.4176-4184M.js" /* Management parameter file */ +#include "par/manage_reg.js" /* Management parameter file for regions*/ +#include "par/outputvars.js" diff --git a/LPJmLmdi/inst_gldas/pft_template.js b/LPJmLmdi/inst_gldas/pft_template.js new file mode 100644 index 0000000..7d4a1df --- /dev/null +++ b/LPJmLmdi/inst_gldas/pft_template.js @@ -0,0 +1,2466 @@ +/**************************************************************************************/ +/** \n**/ +/** p f t . j s \n**/ +/** \n**/ +/** PFT and CFT parameter file for LPJmL version 4.0.001 \n**/ +/** CFTs parameters must be put after PFTs \n**/ +/** \n**/ +/** (C) Potsdam Institute for Climate Impact Research (PIK), see COPYRIGHT file \n**/ +/** authors, and contributors see AUTHORS file \n**/ +/** This file is part of LPJmL and licensed under GNU AGPL Version 3 \n**/ +/** or later. See LICENSE file or go to http://www.gnu.org/licenses/ \n**/ +/** Contact: https://github.com/PIK-LPJmL/LPJmL \n**/ +/** \n**/ +/**************************************************************************************/ + +#include "../include/pftpar.h" /* include constant definitions */ + +#define CTON_LEAF 30. +#define CTON_ROOT 30. +#define CTON_POOL 100. +#define CTON_SO 100. +#define CTON_SAP 330. +#ifdef WITH_SPITFIRE +#define FLAM_TREE 0.3 +#define FLAM_GRASS 0.3 +#else +#define FLAM_TREE 0.3 +#define FLAM_GRASS 0.3 +#endif +#define KLITTER10 0.97 /* now only used for crops and value a middle value of C4 grasses; need to be updated with TRY-database*/ + +#define APREC_MIN 100.0 +#define ALLOM1 100.0 +#define ALLOM2 40.0 +#define ALLOM3 0.67 /*0.5*/ +#define ALLOM4 0.3 +#define APHEN_MAX 245 +#define APHEN_MIN 60 /* minimum aphen for cold-induced senescence */ +#define ALPHA_FUELP_TROP 0.0000334 +#define ALPHA_FUELP_EXTRATROP 0.0000667 +#define HEIGHT_MAX 100. /* maximum height of trees */ +#define REPROD_COST 0.1 /* reproduction cost */ +#define K_EST 0.12 /* maximum overall sapling establishment rate (indiv/m2) */ +#ifdef WITH_SPITFIRE +#define MORT_MAX 0.03 +#else +#define MORT_MAX 0.03 +#endif + +"pftpar" : +[ + /* first pft */ + { + "id" : TROPICAL_BROADLEAVED_EVERGREEN_TREE, + "name" : "tropical broadleaved evergreen tree", + "type" : TREE, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : BETA_ROOT_TrBE, /* beta_root */ + "minwscal" : 0.0, /* minwscal 3*/ + "gmin" : GMIN_TrBE, /* gmin 4*/ + "respcoeff" : RESPCOEFF_TrBE, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.12, /* resist 8*/ + "longevity" : LONGEVITY_TrBE, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 1000., /* ramp 19*/ + "lai_sapl" : 1.500, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_TrBE, /* gdd5min 30*/ + "twmax" : TWMAX_TrBE, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_TrBE, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_TrBE, /* min_temprange 34*/ + "emax": EMAX_TrBE, /* emax 35*/ + "intc" : INTC_TrBE, /* intc 36*/ + "alphaa" : ALPHAA_TrBE, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_TrBE, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_TrBE, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_TrBE, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_TrBE, /* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_TrBE, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_TrBE, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_TrBE, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_TrBE /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_TrBE, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_TrBE, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_TrBE /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_TrBE, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_TrBE, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_TrBE /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_TrBE, /* new phenology: slope of water limiting function */ + "base": WSCAL_BASE_TrBE, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_TrBE /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_TrBE, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : EVERGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_TrBE, "high" : TEMP_CO2_HIGH_TrBE }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_TrBE, "high" : TEMP_PHOTOS_HIGH_TrBE },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_TrBE, "high" : TEMP_HIGH_TrBE }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.38009, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_TrBE, /* scaling factor fire danger index */ + "fuelbulkdensity" : 25.0, /* 25 fuel bulk density */ + "emission_factor" : { "co2" : 1580.0, "co" : 103.0, "ch4" : 6.80, "voc" : 8.10, "tpm" : 8.50, "nox" : 1.999}, /* emission factors */ + "aprec_min" : APREC_MIN, /* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_TrBE, "wood" : K_LITTER10_WOOD_TrBE }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 2.75, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 2.0, /* roughness length */ + "leaftype" : BROADLEAVED, /* leaftype */ + "turnover" : {"leaf" : 2.0, "sapwood" : TURNOVER_SAPWOOD_TrBE, "root" : 2.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : CROWNAREA_MAX_TrBE, /* crownarea_max 20*/ + "wood_sapl" : 1.2, /* sapwood sapling 22*/ + "reprod_cost" : REPROD_COST_TrBE, /* reproduction cost */ + "allom1" : ALLOM1_TrBE, /* allometry */ + "allom2" : ALLOM2_TrBE, + "allom3" : ALLOM3_TrBE, + "allom4" : ALLOM4_TrBE, + "height_max" : HEIGHT_MAX, /* maximum height of tree */ + "scorchheight_f_param" : SCORCHHEIGHT_F_TrBE, /* scorch height (F) */ + "crownlength" : 0.3334, /* crown length (CL) */ + "barkthick_par1" : 0.0301, /* bark thickness par1 */ + "barkthick_par2" : 0.0281, /* bark thickness par2 */ + "crown_mort_rck" : CROWN_MORT_RCK_TrBE, /* crown damage (rCK) */ + "crown_mort_p" : 3.00, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est": K_EST_TrBE, /* k_est */ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*--------------------------------------------------------------------------*/ +/* 2. pft */ + { + "id" : TROPICAL_BROADLEAVED_RAINGREEN_TREE, + "name" : "tropical broadleaved raingreen tree", + "type" : TREE, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : BETA_ROOT_TrBR, /* beta_root */ + "minwscal" : 0.35, /* minwscal 3*/ + "gmin" : GMIN_TrBR, /* gmin 4*/ + "respcoeff" : RESPCOEFF_TrBR, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.5, /* resist 8*/ + "longevity" : LONGEVITY_TrBR, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 1000., /* ramp 19*/ + "lai_sapl" : 1.500, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_TrBR, /* gdd5min 30*/ + "twmax" : TWMAX_TrBR, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_TrBR, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_TrBR, /* min_temprange 34*/ + "emax": EMAX_TrBR, /* emax 35*/ + "intc" : INTC_TrBE, /* intc 36*/ + "alphaa" : ALPHAA_TrBR, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_TrBR, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_TrBR, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_TrBR, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_TrBR, /* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_TrBR, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_TrBR, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_TrBR, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_TrBR /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_TrBR, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_TrBR, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_TrBR /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_TrBR, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_TrBR, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_TrBR /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_TrBR, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_TrBR, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_TrBR /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_TrBR, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : RAINGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_TrBR, "high" : TEMP_CO2_HIGH_TrBR }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_TrBR, "high" : TEMP_PHOTOS_HIGH_TrBR },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_TrBR, "high" : TEMP_HIGH_TrBR }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.51395, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_TrBR, /* scaling factor fire danger index */ + "fuelbulkdensity" : 13.0, /* 13 fuel bulk density */ + "emission_factor" : { "co2" : 1664.0, "co" : 63.0, "ch4" : 2.20, "voc" : 3.40, "tpm" : 8.50, "nox" : 2.540}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_TrBR, "wood" : K_LITTER10_WOOD_TrBR }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 2.75, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 2.0, /* roughness length */ + "leaftype" : BROADLEAVED, /* leaftype */ + "turnover" : {"leaf" : 1.0, "sapwood" : TURNOVER_SAPWOOD_TrBR, "root" : 1.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : CROWNAREA_MAX_TrBR, /* crownarea_max 20*/ + "wood_sapl" : 1.2, /* sapwood sapling 22*/ + "reprod_cost" : REPROD_COST_TrBR, /* reproduction cost */ + "allom1" : ALLOM1_TrBR, /* allometry */ + "allom2" : ALLOM2_TrBR, + "allom3" : ALLOM3_TrBR, + "allom4" : ALLOM4_TrBR, + "height_max" : HEIGHT_MAX, /* maximum height of tree */ + "scorchheight_f_param" : SCORCHHEIGHT_F_TrBR, /* scorch height (F) */ + "crownlength" : 0.10, /* crown length (CL) */ + "barkthick_par1" : 0.1085, /* bark thickness par1 */ + "barkthick_par2" : 0.2120, /* bark thickness par2 */ + "crown_mort_rck" : CROWN_MORT_RCK_TrBR, /* 0.05 crown damage (rCK) */ + "crown_mort_p" : 3.00, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est": K_EST_TrBR, /* k_est */ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*---------------------------------------------------------------------------------------------*/ +/* 3. pft */ + { + "id" : TEMPERATE_NEEDLELEAVED_EVERGREEN_TREE, + "name": "temperate needleleaved evergreen tree", + "type" : TREE, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : BETA_ROOT_TeNE, /* beta_root 1 */ + "minwscal" : 0.00, /* minwscal 3*/ + "gmin" : GMIN_TeNE, /* gmin 4*/ + "respcoeff" : RESPCOEFF_TeNE, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.12, /* resist 8*/ + "longevity" : LONGEVITY_TeNE, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 1000., /* ramp 19*/ + "lai_sapl" : 1.500, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_TeNE, /* gdd5min 30*/ + "twmax" : TWMAX_TeNE, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_TeNE, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_TeNE, /* min_temprange 34*/ + "emax": EMAX_TeNE, /* emax 35*/ + "intc" : INTC_TeNE, /* intc 36*/ + "alphaa" : ALPHAA_TeNE, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_TeNE, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_TeNE, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_TeNE, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_TeNE, /* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_TeNE, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_TeNE, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_TeNE, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_TeNE /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_TeNE, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_TeNE, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_TeNE /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_TeNE, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_TeNE, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_TeNE /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_TeNE, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_TeNE, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_TeNE /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_TeNE, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : EVERGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_TeNE, "high" : TEMP_CO2_HIGH_TeNE }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_TeNE, "high" : TEMP_PHOTOS_HIGH_TeNE },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_TeNE, "high" : TEMP_HIGH_TeNE }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.32198, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_TeNE, /* scaling factor fire danger index */ + "fuelbulkdensity" : 25.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_TeNE, "wood" : K_LITTER10_WOOD_TeNE }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1.97, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 1.0, /* roughness length */ + "leaftype" : NEEDLELEAVED,/* leaftype */ + "turnover" : {"leaf" : 4.0, "sapwood" : TURNOVER_SAPWOOD_TeNE, "root" : 4.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : CROWNAREA_MAX_TeNE, /* crownarea_max 20*/ + "wood_sapl" : 1.2, /* sapwood sapling 22*/ + "reprod_cost" : REPROD_COST_TeNE, /* reproduction cost */ + "allom1" : ALLOM1_TeNE, /* allometry */ + "allom2" : ALLOM2_TeNE, + "allom3" : ALLOM3_TeNE, + "allom4" : ALLOM4_TeNE, + "height_max" : HEIGHT_MAX, /* maximum height of tree */ + "scorchheight_f_param" : SCORCHHEIGHT_F_TeNE,/* scorch height (F) */ + "crownlength" : 0.3334, /* crown length (CL) */ + "barkthick_par1" : 0.0367, /* bark thickness par1 */ + "barkthick_par2" : 0.0592, /* bark thickness par2 */ + "crown_mort_rck" : CROWN_MORT_RCK_TeNE, /* crown damage (rCK) */ + "crown_mort_p" : 3.75, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est": K_EST_TeNE, /* k_est */ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*--------------------------------------------------------------------------*/ +/* 4. pft */ + { + "id" : TEMPERATE_BROADLEAVED_EVERGREEN_TREE, + "name" : "temperate broadleaved evergreen tree", + "type" : TREE, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : BETA_ROOT_TeBE, /* beta_root 1 */ + "minwscal" : 0.00, /* minwscal 3*/ + "gmin" : GMIN_TeBE, /* gmin 4*/ + "respcoeff" : RESPCOEFF_TeBE, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.5, /* resist 8*/ + "longevity" : LONGEVITY_TeBE, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 1000., /* ramp 19*/ + "lai_sapl" : 1.500, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_TeBE, /* gdd5min 30*/ + "twmax" : TWMAX_TeBE, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_TeBE, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_TeBE, /* min_temprange 34*/ + "emax": EMAX_TeBE, /* emax 35*/ + "intc" : INTC_TeBE, /* intc 36*/ + "alphaa" : ALPHAA_TeBE, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_TeBE, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_TeBE, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_TeBE, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_TeBE, /* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_TeBE, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_TeBE, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_TeBE, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_TeBE /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_TeBE, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_TeBE, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_TeBE /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_TeBE, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_TeBE, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_TeBE /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_TeBE, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_TeBE, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_TeBE /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_TeBE, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : EVERGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_TeBE, "high" : TEMP_CO2_HIGH_TeBE }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_TeBE, "high" : TEMP_PHOTOS_HIGH_TeBE },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_TeBE, "high" : TEMP_HIGH_TeBE }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.43740, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_TeBE, /* scaling factor fire danger index */ + "fuelbulkdensity" : 22.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_TeBE, "wood" : K_LITTER10_WOOD_TeBE }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1.37, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 1.0, /* roughness length */ + "leaftype" : BROADLEAVED,/* leaftype */ + "turnover" : {"leaf" : 1.0, "sapwood" : TURNOVER_SAPWOOD_TeBE, "root" : 1.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : CROWNAREA_MAX_TeBE, /* crownarea_max 20*/ + "wood_sapl" : 1.2, /* sapwood sapling 22*/ + "reprod_cost" : REPROD_COST_TeBE, /* reproduction cost */ + "allom1" : ALLOM1_TeBE, /* allometry */ + "allom2" : ALLOM2_TeBE, + "allom3" : ALLOM3_TeBE, + "allom4" : ALLOM4_TeBE, + "height_max" : HEIGHT_MAX, /* maximum height of tree */ + "scorchheight_f_param" : SCORCHHEIGHT_F_TeBE,/* scorch height (F) */ + "crownlength" : 0.3334, /* crown length (CL) */ + "barkthick_par1" : 0.0451, /* bark thickness par1 */ + "barkthick_par2" : 0.1412, /* bark thickness par2 */ + "crown_mort_rck" : CROWN_MORT_RCK_TeBE, /* crown damage (rCK) */ + "crown_mort_p" : 3.00, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est": K_EST_TeBE, /* k_est */ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*--------------------------------------------------------------------------*/ +/* 5. pft */ + { + "id" : TEMPERATE_BROADLEAVED_SUMMERGREEN_TREE, + "name" : "temperate broadleaved summergreen tree", + "type" : TREE, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : BETA_ROOT_TeBS, /* beta_root */ + "minwscal" : 0.00, /* minwscal 3*/ + "gmin" : GMIN_TeBS, /* gmin 4*/ + "respcoeff" : RESPCOEFF_TeBS, /* respcoeff 5*/ + "nmax" : 120., /* nmax 7*/ + "resist" : 0.3, /* resist 8*/ + "longevity" : LONGEVITY_TeBS, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 300., /* ramp 19*/ + "lai_sapl" : 1.500, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_TeBS, /* gdd5min 30*/ + "twmax" : TWMAX_TeBS, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_TeBS, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_TeBS, /* min_temprange 34*/ + "emax": EMAX_TeBS, /* emax 35*/ + "intc" : INTC_TeBS, /* intc 36*/ + "alphaa" : ALPHAA_TeBS, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_TeBS, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_TeBS, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_TeBS, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_TeBS, /* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_TeBS, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_TeBS, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_TeBS, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_TeBS /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_TeBS, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_TeBS, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_TeBS /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_TeBS, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_TeBS, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_TeBS /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_TeBS, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_TeBS, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_TeBS /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_TeBS, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : SUMMERGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_TeBS, "high" : TEMP_CO2_HIGH_TeBS }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_TeBS, "high" : TEMP_PHOTOS_HIGH_TeBS },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_TeBS, "high" : TEMP_HIGH_TeBS }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.28880, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_TeBS, /* scaling factor fire danger index */ + "fuelbulkdensity" : 22.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_TeBS, "wood" : K_LITTER10_WOOD_TeBS }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1.37, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 1.0, /* roughness length */ + "leaftype" : BROADLEAVED,/* leaftype */ + "turnover" : {"leaf" : 1.0, "sapwood" : TURNOVER_SAPWOOD_TeBS, "root" : 1.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : CROWNAREA_MAX_TeBS, /* crownarea_max 20*/ + "wood_sapl" : 1.2, /* sapwood sapling 22*/ + "aphen_min" : APHEN_MIN, + "aphen_max" : APHEN_MAX, + "reprod_cost" : REPROD_COST_TeBS, /* reproduction cost */ + "allom1" : ALLOM1_TeBS, /* allometry */ + "allom2" : ALLOM2_TeBS, + "allom3" : ALLOM3_TeBS, + "allom4" : ALLOM4_TeBS, + "height_max" : HEIGHT_MAX, /* maximum height of tree */ + "scorchheight_f_param" : SCORCHHEIGHT_F_TeBS,/* scorch height (F) */ + "crownlength" : 0.3334, /* crown length (CL) */ + "barkthick_par1" : 0.0347, /* bark thickness par1 */ + "barkthick_par2" : 0.1086, /* bark thickness par2 */ + "crown_mort_rck" : CROWN_MORT_RCK_TeBS, /* crown damage (rCK) */ + "crown_mort_p" : 3.00, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est": K_EST_TeBS, /* k_est */ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*--------------------------------------------------------------------------*/ +/* 6. pft */ + { + "id" : BOREAL_NEEDLELEAVED_EVERGREEN_TREE, + "name" : "boreal needleleaved evergreen tree", + "type" : TREE, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : BETA_ROOT_BoNE, /* beta_root */ + "minwscal" : 0.00, /* minwscal 3*/ + "gmin" : GMIN_BoNE, /* gmin 4*/ + "respcoeff" : 1.2, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.12, /* resist 8*/ + "longevity" : LONGEVITY_BoNE, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 1000., /* ramp 19*/ + "lai_sapl" : 1.500, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_BoNE, /* gdd5min 30*/ + "twmax" : TWMAX_BoNE, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_BoNE, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_BoNE, /* min_temprange 34*/ + "emax": EMAX_BoNE, /* emax 35*/ + "intc" : INTC_BoNE, /* intc 36*/ + "alphaa" : ALPHAA_BoNE, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_BoNE, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_BoNE, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_BoNE, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_BoNE, /* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_BoNE, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_BoNE, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_BoNE, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_BoNE /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_BoNE, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_BoNE, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_BoNE /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_BoNE, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_BoNE, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_BoNE /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_BoNE, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_BoNE, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_BoNE /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_BoNE, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : EVERGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_BoNE, "high" : TEMP_CO2_HIGH_BoNE }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_BoNE, "high" : TEMP_PHOTOS_HIGH_BoNE },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_BoNE, "high" : TEMP_HIGH_BoNE }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.28670, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_BoNE, /* scaling factor fire danger index */ + "fuelbulkdensity" : 25.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_BoNE, "wood" : K_LITTER10_WOOD_BoNE }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1.97, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 1.0, /* roughness length */ + "leaftype" : NEEDLELEAVED,/* leaftype */ + "turnover" : {"leaf" : 4.0, "sapwood" : TURNOVER_SAPWOOD_BoNE, "root" : 4.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : CROWNAREA_MAX_BoNE, /* crownarea_max 20*/ + "wood_sapl" : 1.2, /* sapwood sapling 22*/ + "reprod_cost" : REPROD_COST_BoNE, /* reproduction cost */ + "allom1" : ALLOM1_BoNE, /* allometry */ + "allom2" : ALLOM2_BoNE, + "allom3" : ALLOM3_BoNE, + "allom4" : ALLOM4_BoNE, + "height_max" : HEIGHT_MAX, /* maximum height of tree */ + "scorchheight_f_param" : SCORCHHEIGHT_F_BoNE,/* scorch height (F) */ + "crownlength" : 0.3334, /* crown length (CL) */ + "barkthick_par1" : 0.0292, /* bark thickness par1 */ + "barkthick_par2" : 0.2632, /* bark thickness par2 */ + "crown_mort_rck" : CROWN_MORT_RCK_BoNE, /* crown damage (rCK) */ + "crown_mort_p" : 3.00, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est": K_EST_BoNE, /* k_est */ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*--------------------------------------------------------------------------*/ +/* 7. pft */ + { + "id" : BOREAL_BROADLEAVED_SUMMERGREEN_TREE, + "name" : "boreal broadleaved summergreen tree", + "type" : TREE, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : BETA_ROOT_BoBS, /* beta_root */ + "minwscal" : 0.00, /* minwscal 3*/ + "gmin" : GMIN_BoBS, /* gmin 4*/ + "respcoeff" : RESPCOEFF_BoBS, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.3, /* resist 8*/ + "longevity" : LONGEVITY_BoBS, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 200., /* ramp 19*/ + "lai_sapl" : 1.500, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_BoBS, /* gdd5min 30*/ + "twmax" : TWMAX_BoBS, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_BoBS, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_BoBS, /* min_temprange 34*/ + "emax": EMAX_BoBS, /* emax 35*/ + "intc" : INTC_BoBS, /* intc 36*/ + "alphaa" : ALPHAA_BoBS, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_BoBS, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_BoBS, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_BoBS, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_BoBS,/* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_BoBS, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_BoBS, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_BoBS, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_BoBS /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_BoBS, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_BoBS, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_BoBS /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_BoBS, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_BoBS, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_BoBS /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_BoBS, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_BoBS, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_BoBS /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_BoBS, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : SUMMERGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_BoBS, "high" : TEMP_CO2_HIGH_BoBS }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_BoBS, "high" : TEMP_PHOTOS_HIGH_BoBS },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_BoBS, "high" : TEMP_HIGH_BoBS }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.28670, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_BoBS, /* scaling factor fire danger index */ + "fuelbulkdensity" : 22.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_BoBS, "wood" : K_LITTER10_WOOD_BoBS }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1.37, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 1.0, /* roughness length */ + "leaftype" : BROADLEAVED,/* leaftype */ + "turnover" : {"leaf" : 1.0, "sapwood" : TURNOVER_SAPWOOD_BoBS, "root" : 1.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : CROWNAREA_MAX_BoBS, /* crownarea_max 20*/ + "wood_sapl" : 1.2, /* sapwood sapling 22*/ + "aphen_min" : APHEN_MIN, + "aphen_max" : APHEN_MAX, + "reprod_cost" : REPROD_COST_BoBS, /* reproduction cost */ + "allom1" : ALLOM1_BoBS, /* allometry */ + "allom2" : ALLOM2_BoBS, + "allom3" : ALLOM3_BoBS, + "allom4" : ALLOM4_BoBS, + "height_max" : HEIGHT_MAX, /* maximum height of tree */ + "scorchheight_f_param" : SCORCHHEIGHT_F_BoBS,/* scorch height (F) */ + "crownlength" : 0.3334, /* crown length (CL) */ + "barkthick_par1" : 0.0347, /* bark thickness par1 */ + "barkthick_par2" : 0.1086, /* bark thickness par2 */ + "crown_mort_rck" : CROWN_MORT_RCK_BoBS, /* crown damage (rCK) */ + "crown_mort_p" : 3.00, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est": K_EST_BoBS, /* k_est */ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*--------------------------------------------------------------------------*/ +/* 8. pft */ + { + "id" : BOREAL_NEEDLELEAVED_SUMMERGREEN_TREE, + "name" : "boreal needleleaved summergreen tree", + "type" : TREE, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : BETA_ROOT_BoNS, /* beta_root */ + "minwscal" : 0.00, /* minwscal 3*/ + "gmin" : GMIN_BoNS, /* gmin 4*/ + "respcoeff" : RESPCOEFF_BoNS, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.12, /* resist 8*/ + "longevity" : LONGEVITY_BoNS, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 200., /* ramp 19*/ + "lai_sapl" : 1.500, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_BoNS, /* gdd5min 30*/ + "twmax" : TWMAX_BoNS, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_BoNS, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_BoNS, /* min_temprange 34*/ + "emax": EMAX_BoNS, /* emax 35*/ + "intc" : INTC_BoNS, /* intc 36*/ + "alphaa" : ALPHAA_BoNS, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_BoNS, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_BoNS, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_BoNS, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_BoNS,/* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_BoNS, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_BoNS, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_BoNS, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_BoNS /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_BoNS, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_BoNS, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_BoNS /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_BoNS, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_BoNS, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_BoNS /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_BoNS, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_BoNS, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_BoNS /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_BoNS, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : SUMMERGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_BoNS, "high" : TEMP_CO2_HIGH_BoNS }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_BoNS, "high" : TEMP_PHOTOS_HIGH_BoNS },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_BoNS, "high" : TEMP_HIGH_BoNS }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.28670, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_BoNS, /* scaling factor fire danger index */ + "fuelbulkdensity" : 22.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : 0.76, "wood" : 0.041 }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1.97, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 1.0, /* roughness length */ + "leaftype" : NEEDLELEAVED,/* leaftype */ + "turnover" : {"leaf" : 1.0, "sapwood" : TURNOVER_SAPWOOD_BoNS, "root" : 1.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : CROWNAREA_MAX_BoNS, /* crownarea_max 20*/ + "wood_sapl" : 1.2, /* sapwood sapling 22*/ + "aphen_min" : 10, + "aphen_max" : 200, + "reprod_cost" : REPROD_COST_BoNS, /* reproduction cost */ + "allom1" : ALLOM1_BoNS, /* allometry */ + "allom2" : ALLOM2_BoNS, + "allom3" : ALLOM3_BoNS, + "allom4" : ALLOM4_BoNS, + "height_max" : HEIGHT_MAX, /* maximum height of tree */ + "scorchheight_f_param" : SCORCHHEIGHT_F_BoNS,/* scorch height (F) */ + "crownlength" : 0.3334, /* crown length (CL) */ + "barkthick_par1" : 0.0347, /* bark thickness par1 */ + "barkthick_par2" : 0.1086, /* bark thickness par2 */ + "crown_mort_rck" : CROWN_MORT_RCK_BoNS, /* crown damage (rCK) */ + "crown_mort_p" : 3.00, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est": K_EST_BoNS, /* k_est */ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*--------------------------------------------------------------------------*/ +/* 9. pft */ + { + "id" : TROPICAL_HERBACEOUS, + "name" : "Tropical C4 grass", + "type" : GRASS, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [39., 61., 74., 80.], /* curve number */ + "beta_root" : BETA_ROOT_TrH, /* beta_root */ + "minwscal" : 0.20, /* minwscal 3*/ + "gmin" : GMIN_TrH, /* gmin 4*/ + "respcoeff" : RESPCOEFF_TrH, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.01, /* resist 8*/ + "longevity" : LONGEVITY_TrH, /* leaf longevity 10*/ + "lmro_ratio" : 0.6, /* lmro_ratio 18*/ + "ramp" : 100., /* ramp 19*/ + "lai_sapl" : 0.001, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_TrH, /* gdd5min 30*/ + "twmax" : TWMAX_TrH, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_TrH, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_TrH,/* min_temprange 34*/ + "emax": EMAX_TrH, /* emax 35*/ + "intc" : INTC_TrH, /* intc 36*/ + "alphaa" : ALPHAA_TrH, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_TrH, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_TrH, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_TrH, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_TrH, /* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_TrH, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_TrH, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_TrH, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_TrH /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_TrH, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_TrH, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_TrH /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_TrH, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_TrH, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_TrH /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_TrH, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_TrH, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_TrH /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_TrH, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : ANY, /* phenology */ + "path" : C4, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_TrH, "high" : TEMP_CO2_HIGH_TrH }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_TrH, "high" : TEMP_PHOTOS_HIGH_TrH },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_TrH, "high" : TEMP_HIGH_TrH }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.46513, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_TrH, /* scaling factor fire danger index */ + "fuelbulkdensity" : 2.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1664.0, "co" : 63.0, "ch4" : 2.20, "voc" : 3.40, "tpm" : 8.50, "nox" : 2.540}, /* emission factors */ + "aprec_min" : 100, /* minimum annual precipitation to establish */ + "flam" : FLAM_GRASS, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_TrH, "wood" : K_LITTER10_WOOD_TrH }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1., /* Q10_wood */ + "windspeed_dampening" : 0.6,/* windspeed dampening */ + "roughness_length" : 0.03, /* roughness length */ + "turnover" : {"leaf" : 1.0, "root" : 2.0}, /* turnover leaf root 9 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, and root 13,15*/ + "reprod_cost" : REPROD_COST_TrH /* reproduction cost */ + }, +/*--------------------------------------------------------------------------*/ +/* 10. pft */ + { + "id" : TEMPERATE_HERBACEOUS, + "name" : "Temperate C3 grass", + "type" : GRASS, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [39., 61., 74., 80.], /* curve number */ + "beta_root" : BETA_ROOT_TeH, /* beta_root */ + "minwscal" : 0.20, /* minwscal 3*/ + "gmin" : GMIN_TeH, /* gmin 4*/ + "respcoeff" : RESPCOEFF_TeH, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.01, /* resist 8*/ + "longevity" : LONGEVITY_TeH, /* leaf longevity 10*/ + "lmro_ratio" : 0.6, /* lmro_ratio 18*/ + "ramp" : 100., /* ramp 19*/ + "lai_sapl" : 0.001, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_TeH, /* gdd5min 30*/ + "twmax" : TWMAX_TeH, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_TeH, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_TeH,/* min_temprange 34*/ + "emax": EMAX_TeH, /* emax 35*/ + "intc" : INTC_TeH, /* intc 36*/ + "alphaa" : ALPHAA_TeH, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_TeH, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_TeH, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_TeH, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_TeH, /* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_TeH, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_TeH, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_TeH, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_TeH /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_TeH, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_TeH, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_TeH /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_TeH, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_TeH, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_TeH /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_TeH, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_TeH, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_TeH /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_TeH, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : ANY, /* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_TeH, "high" : TEMP_CO2_HIGH_TeH }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_TeH, "high" : TEMP_PHOTOS_HIGH_TeH },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_TeH, "high" : TEMP_HIGH_TeH }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.38184, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_TeH, /* scaling factor fire danger index */ + "fuelbulkdensity" : 4.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : 100, /* minimum annual precipitation to establish */ + "flam" : FLAM_GRASS, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_TrH, "wood" : K_LITTER10_WOOD_TrH }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1., /* Q10_wood */ + "windspeed_dampening" : 0.6, /* windspeed dampening */ + "roughness_length" : 0.03, /* roughness length */ + "turnover" : {"leaf" : 1.0, "root" : 2.0}, /* turnover leaf root 9 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, and root 13,15*/ + "reprod_cost" : REPROD_COST_TrH /* reproduction cost */ + }, +/*--------------------------------------------------------------------------*/ +/* 11. pft */ + { + "id" : POLAR_HERBACEOUS, + "name" : "Polar C3 grass", + "type" : GRASS, + "cultivation_type" : NONE, /* cultivation_type */ + "cn" : [39., 61., 74., 80.], /* curve number */ + "beta_root" : BETA_ROOT_PoH, /* beta_root */ + "minwscal" : 0.20, /* minwscal 3*/ + "gmin" : GMIN_PoH, /* gmin 4*/ + "respcoeff" : RESPCOEFF_PoH, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.01, /* resist 8*/ + "longevity" : LONGEVITY_PoH, /* leaf longevity 10*/ + "lmro_ratio" : 0.6, /* lmro_ratio 18*/ + "ramp" : 100., /* ramp 19*/ + "lai_sapl" : 0.001, /* lai_sapl 21*/ + "gdd5min" : GDD5MIN_PoH, /* gdd5min 30*/ + "twmax" : TWMAX_PoH, /* twmax 31*/ + "twmax_daily" : TWMAX_DAILY_PoH, /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : MIN_TEMPRANGE_PoH, /* min_temprange 34*/ + "emax": EMAX_PoH, /* emax 35*/ + "intc" : INTC_PoH, /* intc 36*/ + "alphaa" : ALPHAA_PoH, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : ALBEDO_LEAF_PoH, /* albedo of green leaves */ + "albedo_stem" : ALBEDO_STEM_PoH, /* albedo of stems */ + "albedo_litter" : ALBEDO_LITTER_PoH, /* albedo of litter */ + "snowcanopyfrac" : SNOWCANOPYFRAC_PoH, /* maximum snow coverage in green canopy */ + "lightextcoeff" : LIGHTEXTCOEFF_PoH, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : TMIN_SLOPE_PoH, /* new phenology: slope of cold-temperature limiting function */ + "base" : TMIN_BASE_PoH, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : TMIN_TAU_PoH /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : TMAX_SLOPE_PoH, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : TMAX_BASE_PoH, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : TMAX_TAU_PoH /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : LIGHT_SLOPE_PoH, /* new phenology: slope of light limiting function */ + "base" : LIGHT_BASE_PoH, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : LIGHT_TAU_PoH /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : WSCAL_SLOPE_PoH, /* new phenology: slope of water limiting function */ + "base" : WSCAL_BASE_PoH, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : WSCAL_TAU_PoH /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX_PoH, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : ANY, /* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : TEMP_CO2_LOW_PoH, "high" : TEMP_CO2_HIGH_PoH }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : TEMP_PHOTOS_LOW_PoH, "high" : TEMP_PHOTOS_HIGH_PoH },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : TEMP_LOW_PoH, "high" : TEMP_HIGH_PoH }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.38184, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_PoH, /* scaling factor fire danger index */ + "fuelbulkdensity" : 4.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_GRASS, /* flam */ + "k_litter10" : { "leaf" : K_LITTER10_LEAF_PoH, "wood" : K_LITTER10_WOOD_PoH }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1., /* Q10_wood */ + "windspeed_dampening" : 0.6, /* windspeed dampening */ + "roughness_length" : 0.03, /* roughness length */ + "turnover" : {"leaf" : 1.0, "root" : 2.0}, /* turnover leaf root 9 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, and root 13,15*/ + "reprod_cost" : REPROD_COST_PoH /* reproduction cost */ + }, +/*----------------------------------------------------------------------------------------*/ +/* 1. bft */ + { + "id" : BIOENERGY_TROPICAL_TREE, + "name" : "bioenergy tropical tree", + "type" : TREE, + "cultivation_type" : BIOMASS,/* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : 0.975, /* beta_root */ + "minwscal" : 0.00, /* minwscal 3*/ + "gmin" : 0.2, /* gmin 4*/ + "respcoeff" : 0.2, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 1.0, /* resist 8*/ + "longevity" : 2.0, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 1000., /* ramp 19*/ + "lai_sapl" : 1.6, /* lai_sapl 21*/ + "gdd5min" : 0.0, /* gdd5min 30*/ + "twmax" : 1000., /* twmax 31*/ + "twmax_daily" : 1000., /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : -1000.,/* min_temprange 34*/ + "emax": 7.0, /* emax 35*/ + "intc" : 0.02, /* intc 36*/ + "alphaa" : 0.8, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : 0.13, /* albedo of green leaves */ + "albedo_stem" : 0.04, /* albedo of stems */ + "albedo_litter" : 0.1, /* albedo of litter */ + "snowcanopyfrac" : 0.4, /* maximum snow coverage in green canopy */ + "lightextcoeff" : 0.6, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : 1.01, /* new phenology: slope of cold-temperature limiting function */ + "base" : 8.3, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : 0.2 /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : 1.86, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : 38.64, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : 0.2 /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : 77.17, /* new phenology: slope of light limiting function */ + "base" : 55.53, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : 0.52 /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : 5.14, /* new phenology: slope of water limiting function */ + "base" : 4.997, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : 0.44 /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : 0.005, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : EVERGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : 2.0, "high" : 55.0 }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : 25., "high" : 38. },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : 7.0, "high" : 1000 }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.38009, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_TROP, /* scaling factor fire danger index */ + "fuelbulkdensity" : 13.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1664.0, "co" : 63.0, "ch4" : 2.20, "voc" : 3.40, "tpm" : 8.50, "nox" : 2.540}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : 0.93, "wood" : 0.039 }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 2.75, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 1.0,/* roughness length */ + "leaftype" : BROADLEAVED,/* leaftype */ + "turnover" : {"leaf" : 2.0, "sapwood" : 10.0, "root" : 2.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : 2.0, /* crownarea_max 20*/ + "wood_sapl" : 2.2, /* sapwood sapling 22*/ + "reprod_cost" : REPROD_COST, /* reproduction cost */ + "allom1" : 110, /* allometry */ + "allom2" : 35, + "allom3" : 0.75, + "allom4" : ALLOM4, + "height_max" : 8, /* maximum height of tree */ + "scorchheight_f_param" : 0.061,/* scorch height (F) */ + "crownlength" : 0.10 , /* crown length (CL) */ + "barkthick_par1" : 0.1085, /* bark thickness par1 */ + "barkthick_par2" : 0.2120, /* bark thickness par2 */ + "crown_mort_rck" : 0.05, /* crown damage (rCK) */ + "crown_mort_p" : 3.00, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est" : 0.5, /* k_est, Giardina, 2002 */ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*--------------------------------------------------------------------------*/ +/* 2. bft */ + { + "id" : BIOENERGY_TEMPERATE_TREE, + "name" : "bioenergy temperate tree", + "type" : TREE, + "cultivation_type" : BIOMASS,/* cultivation_type */ + "cn" : [30., 55., 70., 77.], /* curve number */ + "beta_root" : 0.966, /* beta_root */ + "minwscal" : 0.00, /* minwscal 3*/ + "gmin" : 0.2, /* gmin 4*/ + "respcoeff" : 1.0, /* respcoeff 5*/ + "nmax" : 120., /* nmax 7*/ + "resist" : 0.95, /* resist 8*/ + "longevity" : 0.45, /* leaf longevity 10*/ + "lmro_ratio" : 1.0, /* lmro_ratio 18*/ + "ramp" : 300., /* ramp 19*/ + "lai_sapl" : 1.6, /* lai_sapl 2.1, larger sapling used for plantations, original value 1.5 */ + "gdd5min" : 300.0, /* gdd5min 30*/ + "twmax" : 1000., /* twmax 31*/ + "twmax_daily" : 1000., /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : -1000.,/* min_temprange 34*/ + "emax": 5.0, /* emax 35*/ + "intc" : 0.02, /* intc 36*/ + "alphaa" : 0.8, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : 0.14, /* albedo of green leaves */ + "albedo_stem" : 0.04, /* albedo of stems */ + "albedo_litter" : 0.1, /* albedo of litter */ + "snowcanopyfrac" : 0.4, /* maximum snow coverage in green canopy */ + "lightextcoeff" : 0.6, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : 0.2153, /* new phenology: slope of cold-temperature limiting function */ + "base" : 5, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : 0.2 /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : 1.74, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : 41.51, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : 0.2 /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : 58, /* new phenology: slope of light limiting function */ + "base" : 59.78, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : 0.2 /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : 5.24, /* new phenology: slope of water limiting function */ + "base" : 20.96, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : 0.8 /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : 0.005, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : SUMMERGREEN, /* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : -4.0, "high" : 38.0 }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : 15., "high" : 30. },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : -30.0, "high" : 8 }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.28880, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_EXTRATROP, /* scaling factor fire danger index */ + "fuelbulkdensity" : 22.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_TREE, /* flam */ + "k_litter10" : { "leaf" : 0.95, "wood" : 0.104 }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1.37, /* Q10_wood */ + "windspeed_dampening" : 0.4, /* windspeed dampening */ + "roughness_length" : 1.0, /* roughness length */ + "leaftype" : BROADLEAVED,/* leaftype */ + "turnover" : {"leaf" : 1.0, "sapwood" : 10.0, "root" : 1.0}, /* turnover leaf sapwood root 9 11 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "sapwood" : CTON_SAP, "root" : CTON_ROOT}, /* C:N mass ratio for leaf, sapwood, and root 13,14,15*/ + "crownarea_max" : 1.5, /* crownarea_max 20*/ + "wood_sapl" : 2.5, /* sapwood sapling 22*/ + "aphen_min" : APHEN_MIN, + "aphen_max" : APHEN_MAX, + "reprod_cost" : REPROD_COST, /* reproduction cost */ + "allom1" : 110, /* allometry */ + "allom2" : 35, + "allom3" : 0.75, + "allom4" : ALLOM4, + "height_max" : 8, /* maximum height of tree */ + "scorchheight_f_param" : 0.0940, /* scorch height (F) */ + "crownlength" : 0.3334, /* crown length (CL) */ + "barkthick_par1" : 0.0347, /* bark thickness par1 */ + "barkthick_par2" : 0.1086, /* bark thickness par2 */ + "crown_mort_rck" : 1.0, /* crown damage (rCK) */ + "crown_mort_p" : 3.00, /* crown damage (p) */ + "fuelfraction" : [0.045,0.075,0.21,0.67], /* fuel fraction */ + "k_est" : 0.8, /* k_est TIM 1.5*/ + "rotation" : 8, /* rotation */ + "max_rotation_length" : 40 /* max_rotation_length */ + }, +/*--------------------------------------------------------------------------*/ +/* 3. bft ONLY FOR BIOENERGY*/ + { + "id" : BIOENERGY_C4_GRASS, + "name" : "bioenergy C4 grass", + "type" : GRASS, + "cultivation_type" : BIOMASS, /* cultivation_type */ + "cn" : [39., 61., 74., 80.], /* curve number */ + "beta_root" : 0.972, /* beta_root */ + "minwscal" : 0.20, /* minwscal 3*/ + "gmin" : 0.5, /* gmin 4*/ + "respcoeff" : 0.2, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 1.0, /* resist 8*/ + "longevity" : 0.25, /* leaf longevity 10*/ + "lmro_ratio" : 0.75, /* lmro_ratio 18*/ + "ramp" : 100., /* ramp 19*/ + "lai_sapl" : 0.001, /* lai_sapl 21*/ + "gdd5min" : 0.0, /* gdd5min 30*/ + "twmax" : 1000., /* twmax 31*/ + "twmax_daily" : 1000., /* twmax_daily 31*/ + "gddbase" : 5.0, /* gddbase (deg C) 33*/ + "min_temprange" : -1000.,/* min_temprange 34*/ + "emax": 7.0, /* emax 35*/ + "intc" : 0.01, /* intc 36*/ + "alphaa" : 0.8, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : 0.21, /* albedo of green leaves */ + "albedo_stem" : 0.15, /* albedo of stems */ + "albedo_litter" : 0.1, /* albedo of litter */ + "snowcanopyfrac" : 0.4, /* maximum snow coverage in green canopy */ + "lightextcoeff" : 0.6, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : 0.91, /* new phenology: slope of cold-temperature limiting function */ + "base" : 6.418, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : 0.2 /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : 1.47, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : 29.16, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : 0.2 /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : 64.23, /* new phenology: slope of light limiting function */ + "base" : 69.9, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : 0.4 /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : 0.1, /* new phenology: slope of water limiting function */ + "base" : 41.72, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : 0.17 /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : ANY, /* phenology */ + "path" : C4, /* pathway */ + "temp_co2" : { "low" : 4.0, "high" : 55.0 }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : 15., "high" : 45. },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : -40.0, "high" : 1000 }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.46513, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_EXTRATROP, /* scaling factor fire danger index */ + "fuelbulkdensity" : 2.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1664.0, "co" : 63.0, "ch4" : 2.20, "voc" : 3.40, "tpm" : 8.50, "nox" : 2.540}, /* emission factors */ + "aprec_min" : APREC_MIN,/* minimum annual precipitation to establish */ + "flam" : FLAM_GRASS, /* flam */ + "k_litter10" : { "leaf" : 0.97, "wood" : 0.97 }, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1., /* Q10_wood */ + "windspeed_dampening" : 0.6,/* windspeed dampening */ + "roughness_length" : 0.03, /* roughness length */ + "turnover" : {"leaf" : 1.0, "root" : 2.0}, /* turnover leaf root 9 12*/ + "cn_ratio" : {"leaf" : CTON_LEAF, "root" : CTON_ROOT}, /* C:N mass ratio for leaf and root 13,15*/ + "reprod_cost" : REPROD_COST /* reproduction cost */ + }, +/*--------------------------------------------------------------------------*/ +/* 1. cft */ + { + "id" : TEMPERATE_CEREALS, + "name" : "temperate cereals", + "type" : CROP, + "cultivation_type" : ANNUAL_CROP, /* cultivation_type */ + "cn" : [60., 72., 80., 84.], /* curve number */ + "beta_root" : 0.969, /* beta_root */ + "minwscal" : 0.30, /* minwscal 3*/ + "gmin" : 0.5, /* gmin 4*/ + "respcoeff" : 1.0, /* respcoeff 5*/ + "nmax" : 100., /* nmax 7*/ + "resist" : 0.5, /* resist 8*/ + "longevity" : 0.5, /* leaf longevity 10*/ + "lmro_ratio" : 1.5, /* lmro_ratio 18*/ + "ramp" : 500., /* ramp 19*/ + "lai_sapl" : 0.0001, /* lai_sapl 21*/ + "gdd5min" : 0.0, /* gdd5min 30*/ + "twmax" : 1000., /* twmax 31*/ + "twmax_daily" : 1000., /* twmax_daily 31*/ + "gddbase" : 0.0, /* gddbase (deg C) 33*/ + "min_temprange" : -1000.,/* min_temprange 34*/ + "emax": 8.0, /* emax 35*/ + "intc" : 0.01, /* intc 36*/ + "alphaa" : 1.0, /* alphaa, fraction of PAR assimilated at ecosystem level, relative to leaf level */ + "albedo_leaf" : 0.18, /* albedo of green leaves */ + "albedo_stem" : 0.15, /* albedo of stems */ + "albedo_litter" : 0.06, /* albedo of litter */ + "snowcanopyfrac" : 0.4, /* maximum snow coverage in green canopy */ + "lightextcoeff" : 0.5, /* lightextcoeff, light extinction coeffcient in Lambert-Beer equation */ + "tmin" : + { + "slope" : 0.3111, /* new phenology: slope of cold-temperature limiting function */ + "base" : 4.979, /* new phenology: inflection point of cold-temperature limiting function (deg C) */ + "tau" : 0.01011 /* new phenology: change rate of actual to previous day cold-temperature limiting fct */ + }, + "tmax" : + { + "slope" : 0.24, /* new phenology: slope of warm-temperature limiting function tmax_sl */ + "base" : 32.04, /* new phenology: inflection point of warm-temperature limiting function (deg C) */ + "tau" : 0.2 /* new phenology: change rate of actual to previous day warm-temperature limiting fct */ + }, + "light" : + { + "slope" : 23, /* new phenology: slope of light limiting function */ + "base" : 75.94, /* new phenology: inflection point of light limiting function (Wm-2) */ + "tau" : 0.22, /* new phenology: change rate of actual to previous day light limiting function */ + }, + "wscal" : + { + "slope" : 0.5222, /* new phenology: slope of water limiting function */ + "base" : 53.07, /* new phenology: inflection point of water limiting function (% water availability) */ + "tau" : 0.01001 /* new phenology: change rate of actual to previous day water limiting function */ + }, + "mort_max" : MORT_MAX, /* asymptotic maximum mortality rate (1/year) */ + "phenology" : CROPGREEN,/* phenology */ + "path" : C3, /* pathway */ + "temp_co2" : { "low" : 0.0, "high" : 40.0 }, /* lower and upper temperature limit for co2 (deg C) 24 27*/ + "temp_photos" : { "low" : 12., "high" : 17. },/* lower and upper limit of temperature optimum for photosynthesis(deg C) 25 26*/ + "temp" : { "low" : -1000.0, "high" : 1000 }, /* lower and upper coldest monthly mean temperature(deg C) 28 29*/ + "soc_k" : 0.40428, /* shape factor for soil organic matter vertical distribution*/ + "alpha_fuelp" : ALPHA_FUELP_TROP, /* scaling factor fire danger index */ + "fuelbulkdensity" : 2.0, /* fuel bulk density */ + "emission_factor" : { "co2" : 1568.0, "co" : 106.0, "ch4" : 4.80, "voc" : 5.70, "tpm" : 17.60, "nox" : 3.240}, /* emission factors */ + "aprec_min" : 0, /* minimum annual precipitation to establish */ + "flam" : FLAM_GRASS, /* flam */ + "k_litter10" : { "leaf" : KLITTER10, "wood" : KLITTER10}, /* K_LITTER10 turnover rate after Brovkin etal 2012*/ + "k_litter10_q10_wood" : 1, /* Q10_wood */ + "windspeed_dampening" : 0.6, /* windspeed dampening */ + "roughness_length" : 0.03, /* roughness length */ + "calcmethod_sdate" : TEMP_WTYP_CALC_SDATE, /* calc_sdate: method to calculate the sowing date*/ + "sdatenh" : 258, "sdatesh" : 90, /* sdatenh,sdatesh: init sowing date for northern and southern hemisphere (julian day) */ + "hlimit" : 330, /* hlimit: max length of crop cycle */ + "fallow_days" : 30, /* fallow_days: wait after harvest until next sowing */ + "temp_fall" : 12, "temp_spring" : 5, "temp_vern" : 12, /* temp_fall, temp_spring, temp_vernalization: thresholds for sowing date f(T)*/ + "trg" : { "low" : 3, "high" : 10 }, /* min & max trg: temperature under which vernalization is possible (deg C)*/ + "pvd" : 0, /* pvd: number of vernalising days required*/ + "psens": 1.0, /* psens: sensitivity to the photoperiod effect [0-1](1 means no sensitivity)*/ + "pb" : 8, /* pb: basal photoperiod (h)(pb [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggFPCBoNE.Rd b/LPJmLmdi/man/AggFPCBoNE.Rd new file mode 100644 index 0000000..5797f75 --- /dev/null +++ b/LPJmLmdi/man/AggFPCBoNE.Rd @@ -0,0 +1,18 @@ +\name{AggFPCBoNE} +\alias{AggFPCBoNE} +\title{Temporal aggregation for BoNE PFT: get BoNE from vector of all PFTs, average over years} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggFPCBoNE(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggFPCBoNS.Rd b/LPJmLmdi/man/AggFPCBoNS.Rd new file mode 100644 index 0000000..c704142 --- /dev/null +++ b/LPJmLmdi/man/AggFPCBoNS.Rd @@ -0,0 +1,18 @@ +\name{AggFPCBoNS} +\alias{AggFPCBoNS} +\title{Temporal aggregation for BoNS PFT: get BoNS from vector of all PFTs, average over years} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggFPCBoNS(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggFPCPoH.Rd b/LPJmLmdi/man/AggFPCPoH.Rd new file mode 100644 index 0000000..a510b67 --- /dev/null +++ b/LPJmLmdi/man/AggFPCPoH.Rd @@ -0,0 +1,18 @@ +\name{AggFPCPoH} +\alias{AggFPCPoH} +\title{Temporal aggregation for PoH PFT: get PoH from vector of all PFTs, average over years} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggFPCPoH(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggFPCTeBE.Rd b/LPJmLmdi/man/AggFPCTeBE.Rd new file mode 100644 index 0000000..841b5c8 --- /dev/null +++ b/LPJmLmdi/man/AggFPCTeBE.Rd @@ -0,0 +1,18 @@ +\name{AggFPCTeBE} +\alias{AggFPCTeBE} +\title{Temporal aggregation for PFTs: get TeBE from vector of all PFTs, average over years} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggFPCTeBE(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggFPCTeBS.Rd b/LPJmLmdi/man/AggFPCTeBS.Rd new file mode 100644 index 0000000..2e6313d --- /dev/null +++ b/LPJmLmdi/man/AggFPCTeBS.Rd @@ -0,0 +1,18 @@ +\name{AggFPCTeBS} +\alias{AggFPCTeBS} +\title{Temporal aggregation for PFTs: get TeBS from vector of all PFTs, average over years} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggFPCTeBS(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggFPCTeH.Rd b/LPJmLmdi/man/AggFPCTeH.Rd new file mode 100644 index 0000000..7459831 --- /dev/null +++ b/LPJmLmdi/man/AggFPCTeH.Rd @@ -0,0 +1,18 @@ +\name{AggFPCTeH} +\alias{AggFPCTeH} +\title{Temporal aggregation for PFTs: get TeH from vector of all PFTs, average over years} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggFPCTeH(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggFPCTeNE.Rd b/LPJmLmdi/man/AggFPCTeNE.Rd new file mode 100644 index 0000000..80799b4 --- /dev/null +++ b/LPJmLmdi/man/AggFPCTeNE.Rd @@ -0,0 +1,18 @@ +\name{AggFPCTeNE} +\alias{AggFPCTeNE} +\title{Temporal aggregation for PFTs: get TeNE from vector of all PFTs, average over years} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggFPCTeNE(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggFPCTrBE.Rd b/LPJmLmdi/man/AggFPCTrBE.Rd new file mode 100644 index 0000000..8b74d54 --- /dev/null +++ b/LPJmLmdi/man/AggFPCTrBE.Rd @@ -0,0 +1,18 @@ +\name{AggFPCTrBE} +\alias{AggFPCTrBE} +\title{Temporal aggregation for PFTs: get TrBE from vector of all PFTs, average over years} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggFPCTrBE(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggFPCTrBR.Rd b/LPJmLmdi/man/AggFPCTrBR.Rd new file mode 100644 index 0000000..34b2d72 --- /dev/null +++ b/LPJmLmdi/man/AggFPCTrBR.Rd @@ -0,0 +1,18 @@ +\name{AggFPCTrBR} +\alias{AggFPCTrBR} +\title{Temporal aggregation for PFTs: get TrBR from vector of all PFTs, average over years} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggFPCTrBR(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggMSC.Rd b/LPJmLmdi/man/AggMSC.Rd new file mode 100644 index 0000000..c6dee13 --- /dev/null +++ b/LPJmLmdi/man/AggMSC.Rd @@ -0,0 +1,18 @@ +\name{AggMSC} +\alias{AggMSC} +\title{Temporal aggregation: mean seasonal cycle} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggMSC(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns the mean seasonal cycle} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggMaxNULL.Rd b/LPJmLmdi/man/AggMaxNULL.Rd new file mode 100644 index 0000000..c65f6dc --- /dev/null +++ b/LPJmLmdi/man/AggMaxNULL.Rd @@ -0,0 +1,18 @@ +\name{AggMaxNULL} +\alias{AggMaxNULL} +\title{Temporal aggregation: aggregate by using annual maximum} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggMaxNULL(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggMeanMean.Rd b/LPJmLmdi/man/AggMeanMean.Rd new file mode 100644 index 0000000..336c8f8 --- /dev/null +++ b/LPJmLmdi/man/AggMeanMean.Rd @@ -0,0 +1,18 @@ +\name{AggMeanMean} +\alias{AggMeanMean} +\title{Temporal aggregation: first mean, then mean = mean over all values} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggMeanMean(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggMeanNULL.Rd b/LPJmLmdi/man/AggMeanNULL.Rd new file mode 100644 index 0000000..526104a --- /dev/null +++ b/LPJmLmdi/man/AggMeanNULL.Rd @@ -0,0 +1,18 @@ +\name{AggMeanNULL} +\alias{AggMeanNULL} +\title{Temporal aggregation: first mean, then nothing = mean per group} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggMeanNULL(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggNULLMean.Rd b/LPJmLmdi/man/AggNULLMean.Rd new file mode 100644 index 0000000..f2f4a61 --- /dev/null +++ b/LPJmLmdi/man/AggNULLMean.Rd @@ -0,0 +1,18 @@ +\name{AggNULLMean} +\alias{AggNULLMean} +\title{Temporal aggregation: mean over all values} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggNULLMean(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggQ09NULL.Rd b/LPJmLmdi/man/AggQ09NULL.Rd new file mode 100644 index 0000000..02e6fba --- /dev/null +++ b/LPJmLmdi/man/AggQ09NULL.Rd @@ -0,0 +1,18 @@ +\name{AggQ09NULL} +\alias{AggQ09NULL} +\title{Temporal aggregation: aggregate by using quantile with prob=0.9} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggQ09NULL(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggSumMean.Rd b/LPJmLmdi/man/AggSumMean.Rd new file mode 100644 index 0000000..6ae1b5f --- /dev/null +++ b/LPJmLmdi/man/AggSumMean.Rd @@ -0,0 +1,18 @@ +\name{AggSumMean} +\alias{AggSumMean} +\title{Temporal aggregation: first sum, then mean} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggSumMean(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggSumNULL.Rd b/LPJmLmdi/man/AggSumNULL.Rd new file mode 100644 index 0000000..2b90632 --- /dev/null +++ b/LPJmLmdi/man/AggSumNULL.Rd @@ -0,0 +1,18 @@ +\name{AggSumNULL} +\alias{AggSumNULL} +\title{Temporal aggregation: first sum, then nothing = sum per group} +\description{This function can be provided to \code{\link{IntegrationDataset}} to aggregate model results to the temporal resolution of the observations.} +\usage{AggSumNULL(x, agg)} +\arguments{ + \item{x}{full time series} + \item{agg}{vector of grouping elements (years)} +} +\details{No details.} +\value{The function returns a the aggregated result.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} + diff --git a/LPJmLmdi/man/AggregateNCDF.Rd b/LPJmLmdi/man/AggregateNCDF.Rd new file mode 100644 index 0000000..77d4aa9 --- /dev/null +++ b/LPJmLmdi/man/AggregateNCDF.Rd @@ -0,0 +1,38 @@ +\name{AggregateNCDF} +\alias{AggregateNCDF} +\title{Temporal aggregations and statistics on NetCDF files} +\description{Compute temporal aggregations and statistics of data in NetCDF files.} +\usage{AggregateNCDF(files, fun.agg = sum, var.name = NULL, tstep = NULL, + agg.monthly = TRUE, agg.annual = TRUE, agg.ndaily = TRUE, + ndays = 7, stat.annual = TRUE, stat.monthly = FALSE, stat.ndaily = FALSE, + stat.daily = FALSE, msc.monthly = TRUE, path.out = NULL, + path.out.prefix = "img", nodes = 1, stats = NULL, ...)} +\arguments{ + \item{files}{(character) file name or vector file names. In case of multiple file names, it is assumed that each file corresponds to a different time period (i.e. all files are a time series)} + \item{fun.agg}{function to be used for temporal aggregations} + \item{var.name}{(character) variable name in NetCDF files for which computations should be done. If NULL, all variables will be processed.} + \item{tstep}{(character) time step of input data: "daily", "ndaily" (period of n days), "monthly", "annual". If NULL tstep will be estimated from the files.} + \item{agg.monthly}{(boolean) aggregate to monthly data? This will be only done if 'tstep' is daily or ndaily.} + \item{agg.annual}{(boolean) aggregate to annual data? This will be only done if 'tstep' is < annual.} + \item{agg.ndaily}{(boolean) aggregate to N-daily periods? This will be only done if 'tstep' is < ndays.} + \item{ndays}{(integer) length of period [in days] for N-daily aggregations. For example, a aggregation to 7-daily periods will be done if ndays=7. A period starts always at the 1st January. Please note that a 7-daily aggregation does not necessarily correspond to calendar weeks (see \code{\link{GroupDates}} for details). This aggregation will be only done if 'tstep' is < ndays.} + \item{stat.annual}{(boolean) compute statistics based on annual data?} + \item{stat.monthly}{(boolean) compute statistics based on monthly data?} + \item{stat.ndaily}{(boolean) compute statistics based on N-daily data?} + \item{stat.daily}{(boolean) compute statistics based on daily data?} + \item{msc.monthly}{(boolean) compute (mean/median) seasonal cycles on monthly data and monthly anomalies? This computation is based on \code{\link{SeasonalCycleNCDF}} and uses CDO modules.} + \item{path.out}{directory for output files. If NULL, directories will be created within the location of the files, otherwise directories will be created under the specified directory.} + \item{path.out.prefix}{prefix for output directory names, directory names are created according to the following pattern 'prefix'_'resolution'_'timestep' (e.g. img_0d25_monthly)} + \item{nodes}{How many nodes should be used for parallel processing of files? Parallel computing can be only used if length(files) > 1.} + \item{stats}{statistical metrics to compute} + \item{\dots}{further agruments (unused)} +} + + + +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/AllEqual.Rd b/LPJmLmdi/man/AllEqual.Rd new file mode 100644 index 0000000..0e36133 --- /dev/null +++ b/LPJmLmdi/man/AllEqual.Rd @@ -0,0 +1,23 @@ +\name{AllEqual} +\alias{AllEqual} +\title{Check if all values in a vector are the same} +\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.} +\usage{AllEqual(x)} +\arguments{ + \item{x}{numeric, character vector, or time series of type ts} +} + +\value{The function returns TRUE if all values are equal and FALSE if it contains different values.} + +\author{Matthias Forkel [aut, cre]} + + + + +\examples{ +# check if all values are equal in the following vectors: +AllEqual(1:10) +AllEqual(rep(0, 10)) +AllEqual(letters) +AllEqual(rep(NA, 10)) +} diff --git a/LPJmLmdi/man/BarplotCost.Rd b/LPJmLmdi/man/BarplotCost.Rd new file mode 100644 index 0000000..73f398b --- /dev/null +++ b/LPJmLmdi/man/BarplotCost.Rd @@ -0,0 +1,26 @@ +\name{BarplotCost} +\alias{BarplotCost} +\title{plot a barplot of the cost change from prior to best parameter set} +\description{The function plots two barplots that are showing the change in the cost per dataset.} +\usage{BarplotCost(rescue.l, type = 1:2, ylim = NULL, set.par = TRUE, + ...)} +\arguments{ + \item{rescue.l}{a list of class "rescue", see \code{\link{CombineRescueFiles}}} + \item{type}{plot type: 1 barplot of total cost from prior and best, 2: change of cost per data set } + \item{ylim}{limits of y-axis (works for type = 2)} + \item{set.par}{set par() settings from \code{\link{DefaultParL}}} + \item{\dots}{further arguments for \code{\link{plot}}} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CombineRescueFiles}}} +\examples{ +# files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) +# rescue.l <- CombineRescueFiles(files, remove=FALSE) +# BarplotCost(rescue.l) +} diff --git a/LPJmLmdi/man/BreakColors.Rd b/LPJmLmdi/man/BreakColors.Rd new file mode 100644 index 0000000..4fc0d9d --- /dev/null +++ b/LPJmLmdi/man/BreakColors.Rd @@ -0,0 +1,41 @@ +\name{BreakColors} +\alias{BreakColors} +\title{Colours from class breaks} +\description{Creates colour palettes from a vector of class breaks} +\usage{BreakColors(x, pal = NULL, rev = FALSE, cols = NULL, ...)} +\arguments{ + \item{x}{numeric vector of class breaks} + \item{pal}{name of a colour palette from \code{\link{brewer.pal}}} + \item{rev}{should the colour palette be reversed?} + \item{cols}{alternatively, a colour vector to be interpolated} + \item{\dots}{Further arguments (unused)} +} +\details{No details.} +\value{The function returns a vector of colours.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{BreakColours}}} +\examples{ + +brks1 <- seq(0, 10, 2) +cols1 <- BreakColours(brks1) + +brks2 <- seq(-100, 100, 25) +cols2 <- BreakColours(brks2) + +brks3 <- seq(-100, 100, 25) +cols3 <- BreakColours(brks3, pal="BrBG") + +brks4 <- seq(0, 10, 1) +cols4 <- BreakColours(brks4, cols=c("red", "green", "blue"), rev=TRUE) + +MapRb() +LegendBarRb(brks=brks1, cols=cols1) +LegendBarRb(brks=brks2, cols=cols2, pos="top", lon = c(-180, 180), lat = c(-20, -15)) +LegendBarRb(brks=brks3, cols=cols3, pos="inside", lon = c(-180, 180), lat = c(15, 20)) +LegendBarRb(brks=brks4, cols=cols4, pos="inside", lon = c(-180, 180), lat = c(30, 35)) + +} diff --git a/LPJmLmdi/man/BreakColours.Rd b/LPJmLmdi/man/BreakColours.Rd new file mode 100644 index 0000000..9cdd025 --- /dev/null +++ b/LPJmLmdi/man/BreakColours.Rd @@ -0,0 +1,41 @@ +\name{BreakColours} +\alias{BreakColours} +\title{Colours from class breaks} +\description{Creates colour palettes from a vector of class breaks} +\usage{BreakColours(x, pal = NULL, rev = FALSE, cols = NULL, ...)} +\arguments{ + \item{x}{numeric vector of class breaks} + \item{pal}{name of a colour palette from \code{\link{brewer.pal}}} + \item{rev}{should the colour palette be reversed?} + \item{cols}{alternatively, a colour vector to be interpolated} + \item{\dots}{Further arguments (unused)} +} +\details{No details.} +\value{The function returns a vector of colours.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{BreakColours}}} +\examples{ + +brks1 <- seq(0, 10, 2) +cols1 <- BreakColours(brks1) + +brks2 <- seq(-100, 100, 25) +cols2 <- BreakColours(brks2) + +brks3 <- seq(-100, 100, 25) +cols3 <- BreakColours(brks3, pal="BrBG") + +brks4 <- seq(0, 10, 1) +cols4 <- BreakColours(brks4, cols=c("red", "green", "blue"), rev=TRUE) + +MapRb() +LegendBarRb(brks=brks1, cols=cols1) +LegendBarRb(brks=brks2, cols=cols2, pos="top", lon = c(-180, 180), lat = c(-20, -15)) +LegendBarRb(brks=brks3, cols=cols3, pos="inside", lon = c(-180, 180), lat = c(15, 20)) +LegendBarRb(brks=brks4, cols=cols4, pos="inside", lon = c(-180, 180), lat = c(30, 35)) + +} diff --git a/LPJmLmdi/man/Breaks.Rd b/LPJmLmdi/man/Breaks.Rd new file mode 100644 index 0000000..69cd841 --- /dev/null +++ b/LPJmLmdi/man/Breaks.Rd @@ -0,0 +1,28 @@ +\name{Breaks} +\alias{Breaks} +\title{Class breaks for plotting} +\description{Calculates class breakpoints based on quantiles.} +\usage{Breaks(x, n = 12, quantile = c(0.01, 0.99), zero.min = FALSE, + ...)} +\arguments{ + \item{x}{numeric vector} + \item{n}{number of breaks} + \item{quantile}{lower and upper quantiles that should be used to exclude outliers} + \item{zero.min}{should the minimum break be at 0? } + \item{\dots}{Further arguments (unused)} +} +\details{No details.} +\value{The function returns a vector of values.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{BreakColours}}} +\examples{ + +Breaks(rnorm(100, 50, 30)) +Breaks(runif(100, 10, 30)) +Breaks(rlnorm(100)) + +} diff --git a/LPJmLmdi/man/Cbalance.Rd b/LPJmLmdi/man/Cbalance.Rd new file mode 100644 index 0000000..02c6408 --- /dev/null +++ b/LPJmLmdi/man/Cbalance.Rd @@ -0,0 +1,62 @@ +\name{Cbalance} +\alias{Cbalance} +\title{Calculate global C balance, C fluxes and stocks} +\description{The function takes numeric vectors or NetCDF files with values of C fluxes and stocks, and calculates C balances and turnover times [years] (see details). In case of NetCDF files, global total C fluxes and stocks [PgC year-1] are computed from NetCDF files. Thereby the input data unit needs to be [gC m-2] for stocks and [gC m-2 year-1] for fluxes. However, the argument scale is a multiplier that can be used to convert to the original unit to [gC m-2]. The results are returned as a data.frame (table). If some values or files are not provided (i.e. NA), the function will first try to compute these from other metrics (see details). } +\usage{Cbalance(gpp = NA, npp = NA, ra = NA, rh = NA, reco = NA, firec = NA, + estab = NA, harvest = NA, vegc = NA, soilc = NA, litc = NA, + scale = 1, ti = NA, mask = NA, ...)} +\arguments{ + \item{gpp}{numeric vector or NetCDF file of gross primary production } + \item{npp}{numeric vector or NetCDF file of net primary production} + \item{ra}{numeric vector or NetCDF file of autotrophic respiration} + \item{rh}{numeric vector or NetCDF file of heterotrophic respiration} + \item{reco}{numeric vector or NetCDF file of ecosystem respiration} + \item{firec}{numeric vector or NetCDF file of fire C emissions} + \item{estab}{numeric vector or NetCDF file of establishment C flux (specific to LPJ)} + \item{harvest}{numeric vector or NetCDF file of C removal from vegetation through harvest} + \item{vegc}{numeric vector or NetCDF file of vegetation C stocks (or biomass)} + \item{soilc}{numeric vector or NetCDF file of soil C stocks} + \item{litc}{numeric vector or NetCDF file of litter C stocks} + \item{scale}{multiplier to convert original units to gC m-2 (stocks) or gC m-2 year-1 (fluxes)} + \item{ti}{time axis of the data. In case of NetCDF files, time will be extracted from the files.} + \item{mask}{A mask in a NetCDF file in order to compute the C fluxes, stocks, balances and turnover times only for specific regions.} + \item{\dots}{further arguments (currently not used)} +} +\details{The function computes (global) terrestrial C balances based on given input data. The used terminology is based on Schulze (2006) and Chapin et al. (2006). The following equations are used: +\itemize{ +\item{ Net primary production NPP = GPP - Ra } +\item{ Ecosystem respiration Reco = Rh + Ra } +\item{ Net ecosystem exchange NEE = Reco - GPP = Rh - NPP} +\item{ Net biome productivity NBP = (GPP + Estab) - (Reco + FireC + Harvest) } +} +Vegetation and total ecosystem turnover times are computed based on the formulas in Carvalhais et al. (2014) and Thurner et al. (2016): +\item{ Vegetation turnover time: TauVeg_NPP = VegC / NPP } +\item{ Vegetation turnover time based on GPP is a approximiation to the real vegetation turnover time (TauVeg_NPP) assuming that NPP is around 50\% of GPP: TauVeg_GPP = VegC / ((GPP+Estab) * 0.5) } +\item{ Total ecosystem turnover time as in Carvalhais et al. (2014): TauEco_GPP = (VegC + SoilC + LitC) / (GPP+Estab) } +\item{ Total ecosystem turnover time based on Reco: TauEco_Reco = (VegC + SoilC + LitC) / Reco } +\item{ Total ecosystem turnover time based on Reco and disturbances: TauEco_Dist = (VegC + SoilC + LitC) / (Reco + FireC + Harvest) } +}} + +\references{Carvalhais, N. et al. (2014), Global covariation of carbon turnover times with climate in terrestrial ecosystems, Nature, 514(7521), 213–217, doi:10.1038/nature13731. +Chapin, F. S. et al. (2006), Reconciling Carbon-cycle Concepts, Terminology, and Methods, Ecosystems, 9(7), 1041–1050, doi:10.1007/s10021-005-0105-7. +Schulze, E.-D. (2006), Biological control of the terrestrial carbon sink, Biogeosciences, 3(2), 147–166, doi:10.5194/bg-3-147-2006. +Thurner, M., C. Beer, N. Carvalhais, M. Forkel, M. Santoro, M. Tum, and C. Schmullius (2016), Large‐scale variation in boreal and temperate forest carbon turnover rate is related to climate, Geophysical Research Letters, doi:10.1002/2016GL068794.} +\author{Matthias Forkel [aut, cre]} + + + + +\examples{ + +# with some typical numbers for the global C budget: +cbal <- Cbalance(gpp=123, npp=61, rh=57, firec=2, vegc=400, soilc=2400) +cbal +plot(cbal) + +## using time series:: +#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) +#cbal +#plot(cbal) + + +} diff --git a/LPJmLmdi/man/ChangeParamFile.Rd b/LPJmLmdi/man/ChangeParamFile.Rd new file mode 100644 index 0000000..685651a --- /dev/null +++ b/LPJmLmdi/man/ChangeParamFile.Rd @@ -0,0 +1,27 @@ +\name{ChangeParamFile} +\alias{ChangeParamFile} +\title{Change parameters in a parameter file} +\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'.} +\usage{ChangeParamFile(newpar, file.template, file.new, wait = FALSE, + ...)} +\arguments{ + \item{newpar}{a named vector with new parameter values} + \item{file.template}{file name of the template parameter with flagged parameters} + \item{file.new}{file name of the new parameter file} + \item{wait}{If TRUE wait 1 second to check if file.template exists in order to relax slow file writting.} + \item{\dots}{further arguments (currently not used)} +} +\details{The function works only on Unix systems because it is based on 'sed'} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + + +\examples{ + +# newpar <- c(ALPHAA_BoNE=0.8) +# LPJChangeParamFile(newpar, file.template="pft_template.par", file.new="pft.par") + +} diff --git a/LPJmLmdi/man/ChangeSoilCodeFile.Rd b/LPJmLmdi/man/ChangeSoilCodeFile.Rd new file mode 100644 index 0000000..ddff0cc --- /dev/null +++ b/LPJmLmdi/man/ChangeSoilCodeFile.Rd @@ -0,0 +1,23 @@ +\name{ChangeSoilCodeFile} +\alias{ChangeSoilCodeFile} +\title{Change soil code in LPJ soil code file} +\description{The function changes the soil code for the specified grid cells and writes a new LPJ soil code file.} +\usage{ChangeSoilCodeFile(file.soilcode, file.soilcode.new, xy, newcode, + file.grid = "cru.grid", ...)} +\arguments{ + \item{file.soilcode}{original soil code file} + \item{file.soilcode.new}{new soil code file} + \item{xy}{matrix of grid cells (lon, lat) where the soil code should be changed} + \item{newcode}{new soil code at each grid cell (vector with length = nrow(xy))} + \item{file.grid}{grid file for the original soil code file} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadBIN}}} + diff --git a/LPJmLmdi/man/CheckLPJpar.Rd b/LPJmLmdi/man/CheckLPJpar.Rd new file mode 100644 index 0000000..c486c9f --- /dev/null +++ b/LPJmLmdi/man/CheckLPJpar.Rd @@ -0,0 +1,18 @@ +\name{CheckLPJpar} +\alias{CheckLPJpar} +\title{Checks LPJ parameters 'LPJpar'} +\description{The function checks if LPJ parameters are within the lower and upper boundaries or are 0. } +\usage{CheckLPJpar(lpjpar, correct = FALSE)} +\arguments{ + \item{lpjpar}{object of class 'LPJpar'} + \item{correct}{correct parameter values (TRUE) or return error message?} +} +\details{No details.} +\value{the function return an object of class 'LPJpar'} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{LPJpar}} } + diff --git a/LPJmLmdi/man/CheckMemoryUsage.Rd b/LPJmLmdi/man/CheckMemoryUsage.Rd new file mode 100644 index 0000000..e376b85 --- /dev/null +++ b/LPJmLmdi/man/CheckMemoryUsage.Rd @@ -0,0 +1,17 @@ +\name{CheckMemoryUsage} +\alias{CheckMemoryUsage} +\title{Check usage of memory by R objects} +\description{Prints a message about the used memory and writes a file with the used memory per each R object.} +\usage{CheckMemoryUsage(...)} +\arguments{ + \item{\dots}{The function has no arguments.} +} + +\value{a data.frame } + +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/CombineLPJpar.Rd b/LPJmLmdi/man/CombineLPJpar.Rd new file mode 100644 index 0000000..4e00f84 --- /dev/null +++ b/LPJmLmdi/man/CombineLPJpar.Rd @@ -0,0 +1,17 @@ +\name{CombineLPJpar} +\alias{CombineLPJpar} +\title{Combines several 'LPJpar' objects into one} +\description{The function takes several lpjpar objects and combines them into one LPJpar object} +\usage{CombineLPJpar(lpjpar.l)} +\arguments{ + \item{lpjpar.l}{a list of \code{\link{LPJpar}} objects} +} +\details{No details.} +\value{The function returns a list of class 'LPJparList'} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{LPJpar}}} + diff --git a/LPJmLmdi/man/CombineRescueFiles.Rd b/LPJmLmdi/man/CombineRescueFiles.Rd new file mode 100644 index 0000000..438488d --- /dev/null +++ b/LPJmLmdi/man/CombineRescueFiles.Rd @@ -0,0 +1,18 @@ +\name{CombineRescueFiles} +\alias{CombineRescueFiles} +\title{Combine single rescue files into one rescue file} +\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.} +\usage{CombineRescueFiles(files.rescue, remove = TRUE)} +\arguments{ + \item{files.rescue}{file names} + \item{remove}{save new rescue file and delete single rescue files?} +} +\details{No details.} +\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).} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CreateRestartFromRescue}}, \code{\link{plot.rescue}}} + diff --git a/LPJmLmdi/man/CorW.Rd b/LPJmLmdi/man/CorW.Rd new file mode 100644 index 0000000..8a15397 --- /dev/null +++ b/LPJmLmdi/man/CorW.Rd @@ -0,0 +1,25 @@ +\name{CorW} +\alias{CorW} +\title{Weighted correlation} +\description{Compute the correlation.} +\usage{CorW(x, y, w = rep(1, length(x)))} +\arguments{ + \item{x}{a vector of x values} + \item{y}{a vector of y values} + \item{w}{vector of weights} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ObjFct}}} +\examples{ + +x <- 1:5 +y <- x * -1 + rnorm(5) +cor(x, y) +CorW(x, y, w=c(1, 1, 1, 2, 2)) +} diff --git a/LPJmLmdi/man/CorrelationMatrixS.Rd b/LPJmLmdi/man/CorrelationMatrixS.Rd new file mode 100644 index 0000000..853d82e --- /dev/null +++ b/LPJmLmdi/man/CorrelationMatrixS.Rd @@ -0,0 +1,22 @@ +\name{CorrelationMatrixS} +\alias{CorrelationMatrixS} +\title{plot a correlation matrix} + +\usage{CorrelationMatrixS(data, method = "spearman", iscor = NULL, main = "", + ...)} +\arguments{ + \item{data}{a correlation matrix or a data.frame (} + \item{method}{method to compute the correlation} + \item{iscor}{Is 'data' a correlation matrix?} + \item{main}{main title for the plot} + \item{\dots}{further arguments for \code{\link{plot}}} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CombineRescueFiles}}} + diff --git a/LPJmLmdi/man/CostMDS.KGE.Rd b/LPJmLmdi/man/CostMDS.KGE.Rd new file mode 100644 index 0000000..03a758d --- /dev/null +++ b/LPJmLmdi/man/CostMDS.KGE.Rd @@ -0,0 +1,17 @@ +\name{CostMDS.KGE} +\alias{CostMDS.KGE} +\title{Cost function for multiple data streams based on Kling-Gupta efficiency} +\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.} +\usage{CostMDS.KGE(integrationdata)} +\arguments{ + \item{integrationdata}{object of class 'integrationdata', see \code{\link{IntegrationData}}} +} +\details{No details.} +\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).} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/CostMDS.KGEw.Rd b/LPJmLmdi/man/CostMDS.KGEw.Rd new file mode 100644 index 0000000..833f61b --- /dev/null +++ b/LPJmLmdi/man/CostMDS.KGEw.Rd @@ -0,0 +1,32 @@ +\name{CostMDS.KGEw} +\alias{CostMDS.KGEw} +\title{Cost function for multiple data streams based on a weighted Kling-Gupta efficiency} +\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.} +\usage{CostMDS.KGEw(integrationdata)} +\arguments{ + \item{integrationdata}{object of class 'integrationdata', see \code{\link{IntegrationData}}} +} +\details{No details.} +\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).} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + +\examples{ + +# load(paste0(path.me, "/lpj/LPJmL_131016/out_optim/opt_fpc/OFPC_BO-GI-BM_v1_all_0_59_posterior-best.RData")) +# x <- result.post.lpj$integrationdata +# plot(x, 2) + +# cost.see <- CostMDS.SSE(x) +# cost.kge <- CostMDS.KGE(x) +# cost.kgew <- CostMDS.KGEw(x) + +# DefaultParL(mfrow=c(1,3)) +# barplot(cost.see$per.ds) +# barplot(t(cost.kge$per.cell.ds)) +# barplot(t(cost.kgew$per.cell.ds)) + +} diff --git a/LPJmLmdi/man/CostMDS.SSE.Rd b/LPJmLmdi/man/CostMDS.SSE.Rd new file mode 100644 index 0000000..9beac82 --- /dev/null +++ b/LPJmLmdi/man/CostMDS.SSE.Rd @@ -0,0 +1,17 @@ +\name{CostMDS.SSE} +\alias{CostMDS.SSE} +\title{Cost function for multiple data streams based on SSE} +\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.} +\usage{CostMDS.SSE(integrationdata)} +\arguments{ + \item{integrationdata}{object of class 'integrationdata', see \code{\link{IntegrationData}}} +} +\details{No details.} +\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.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/CreateRestartFromRescue.Rd b/LPJmLmdi/man/CreateRestartFromRescue.Rd new file mode 100644 index 0000000..8769a9e --- /dev/null +++ b/LPJmLmdi/man/CreateRestartFromRescue.Rd @@ -0,0 +1,18 @@ +\name{CreateRestartFromRescue} +\alias{CreateRestartFromRescue} +\title{Create a *.pro file from binary rescue files to restart optimization} +\description{The function creates a *.pro file friom binary 'rescue' files. The *.pro file can be used to restart OptimizeLPJgenoud. } +\usage{CreateRestartFromRescue(path.rescue, pop.size)} +\arguments{ + \item{path.rescue}{directory where the resuce files from each iteration of the optimization are saved.} + \item{pop.size}{(estimated) population size of the genetic optimization} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{genoudLPJrescue}} } + diff --git a/LPJmLmdi/man/DefaultParL.Rd b/LPJmLmdi/man/DefaultParL.Rd new file mode 100644 index 0000000..832df84 --- /dev/null +++ b/LPJmLmdi/man/DefaultParL.Rd @@ -0,0 +1,32 @@ +\name{DefaultParL} +\alias{DefaultParL} +\title{default 'par' settings for plots} +\description{The function calls 'par' with some default settings to improve plots. See \code{\link{par}} for details.} +\usage{DefaultParL(mfrow = c(1, 1), mar = c(3.7, 3.5, 2.5, 0.5), oma = c(0.8, + 0.1, 0.1, 0.2), mgp = c(2.4, 1, 0), cex = 1.3, cex.lab = cex * + 1.1, cex.axis = cex * 1.1, cex.main = cex * 1.1, ...)} +\arguments{ + \item{mfrow}{number of rows/columns} + \item{mar}{margins} + \item{oma}{outer margins} + \item{mgp}{margin line for axis title, label and lines} + \item{cex}{text and symbol size} + \item{cex.lab}{label size} + \item{cex.axis}{axis anootation size } + \item{cex.main}{title size} + \item{\dots}{further arguments to \code{\link{par}}} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{par}}} +\examples{ + +DefaultParL() +plot(1:10) + +} diff --git a/LPJmLmdi/man/Df2optim.Rd b/LPJmLmdi/man/Df2optim.Rd new file mode 100644 index 0000000..f1f5e47 --- /dev/null +++ b/LPJmLmdi/man/Df2optim.Rd @@ -0,0 +1,25 @@ +\name{Df2optim} +\alias{Df2optim} +\title{Convert a data.frame to a \code{\link{optim}} list } +\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.} +\usage{Df2optim(optim.df, pop.size = NA, ...)} +\arguments{ + \item{optim.df}{a 'data.frame' as created by \code{\link{Rescue2DF}}} + \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.} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CombineRescueFiles}}} +\examples{ +# files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) +# rescue.l <- CombineRescueFiles(files, remove=FALSE) +# optim.df <- Rescue2Df(rescue.l) +# opt <- Rescue2optim(rescue.l) +# opt +} diff --git a/LPJmLmdi/man/EstOptimUse.Rd b/LPJmLmdi/man/EstOptimUse.Rd new file mode 100644 index 0000000..28724f3 --- /dev/null +++ b/LPJmLmdi/man/EstOptimUse.Rd @@ -0,0 +1,18 @@ +\name{EstOptimUse} +\alias{EstOptimUse} +\title{Estimate optimal number of jobs given a number of cluster nodes} + +\usage{EstOptimUse(nodes = 16, wish = 1000)} +\arguments{ + \item{nodes}{number of cluster nodes that you want to use} + \item{wish}{approx. number of elements} +} +\details{No details.} +\value{an integer value} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteCLM}}} + diff --git a/LPJmLmdi/man/FileExistsWait.Rd b/LPJmLmdi/man/FileExistsWait.Rd new file mode 100644 index 0000000..ad5f471 --- /dev/null +++ b/LPJmLmdi/man/FileExistsWait.Rd @@ -0,0 +1,27 @@ +\name{FileExistsWait} +\alias{FileExistsWait} +\title{Iterative checking and waiting for a file.} +\description{The function repeately checks if a file exists and returns TRUE if the file is existing.} +\usage{FileExistsWait(file, waitmin = 0, waitinterval = 0.5, waitmax = 2, + ...)} +\arguments{ + \item{file}{file for which checking and waiting should be applied} + \item{waitmin}{minimum waiting time (seconds) } + \item{waitinterval}{interval after which the existence of the file should be checked again (seconds)} + \item{waitmax}{maximum waiting time (seconds)} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + +\examples{ + +FileExistsWait(system.file("external/rlogo.grd", package="raster")) +FileExistsWait("nofile.txt") + +} diff --git a/LPJmLmdi/man/GridProperties.Rd b/LPJmLmdi/man/GridProperties.Rd new file mode 100644 index 0000000..784c8cf --- /dev/null +++ b/LPJmLmdi/man/GridProperties.Rd @@ -0,0 +1,19 @@ +\name{GridProperties} +\alias{GridProperties} +\title{Derive grid properties from an object of class 'LPJfiles'} +\description{The function reads the grid of the input files in 'LPJfiles' and computes the area per grid cell.} +\usage{GridProperties(lpjfiles, res = 0.5, ...)} +\arguments{ + \item{lpjfiles}{list of class 'LPJinput'} + \item{res}{resolution of LPJmL} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{the function returns a list with 'grid' (raster of grid cells), 'area' (vector of grid cell area) and 'ncell' (number of grid cells)} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{LPJfiles}} } + diff --git a/LPJmLmdi/man/InfoCLM.Rd b/LPJmLmdi/man/InfoCLM.Rd new file mode 100644 index 0000000..e2a366d --- /dev/null +++ b/LPJmLmdi/man/InfoCLM.Rd @@ -0,0 +1,19 @@ +\name{InfoCLM} +\alias{InfoCLM} +\title{Returns information about a CLM file} + +\usage{InfoCLM(file.clm, endian = "little", ...)} +\arguments{ + \item{file.clm}{CLM file name with extension *.clm} + \item{endian}{endianess of the file} + \item{\dots}{Further arguments (currently not used).} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteLPJinput}}} + diff --git a/LPJmLmdi/man/InfoLPJ.Rd b/LPJmLmdi/man/InfoLPJ.Rd new file mode 100644 index 0000000..82ce483 --- /dev/null +++ b/LPJmLmdi/man/InfoLPJ.Rd @@ -0,0 +1,28 @@ +\name{InfoLPJ} +\alias{InfoLPJ} +\title{Information about a LPJmL binary file} +\description{The function reads information about a LPJ binary output file.} +\usage{InfoLPJ(file.bin = "fpc.bin", file.grid = "grid.bin", file.annual = c("vegc.bin", + "litc.bin", "soilc.bin"), size = 4, data.type = numeric(), + ...)} +\arguments{ + \item{file.bin}{binary LPJ output file} + \item{file.grid}{binary LPJ grid file} + \item{file.annual}{one of the binary LPJ output files with annual data} + \item{size}{the number of bytes per element in the byte stream.} + \item{data.type}{data type of the file (default=numeric())} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\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).} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadLPJ}}} +\examples{ + +# InfoLPJ("vegc.bin") + +} diff --git a/LPJmLmdi/man/InfoNCDF.Rd b/LPJmLmdi/man/InfoNCDF.Rd new file mode 100644 index 0000000..3df7386 --- /dev/null +++ b/LPJmLmdi/man/InfoNCDF.Rd @@ -0,0 +1,17 @@ +\name{InfoNCDF} +\alias{InfoNCDF} +\title{Get information about variables in a NetCDF} + +\usage{InfoNCDF(file)} +\arguments{ + \item{file}{file name} +} + +\value{The function returns a list with information about the dimensions and variables in the NetCDF file.} + +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteNCDF4}}} + diff --git a/LPJmLmdi/man/IntegrationData.Rd b/LPJmLmdi/man/IntegrationData.Rd new file mode 100644 index 0000000..6169cac --- /dev/null +++ b/LPJmLmdi/man/IntegrationData.Rd @@ -0,0 +1,50 @@ +\name{IntegrationData} +\alias{IntegrationData} +\title{Create an object of class 'IntegrationData'} +\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}}. } +\usage{IntegrationData(...)} +\arguments{ + \item{\dots}{one or several objects of class 'IntegrationDataset'} +} +\details{No details.} +\value{The function returns a list of class 'IntegrationData' } +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationDataset}}} +\examples{ + +# # grid cells for which LPJmL should be run and for which the integration data should be extracted +# xy <- cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75)) + +# # use monthly FAPAR in model-data integration +# fapar <- IntegrationDataset(name="FAPAR", unit="", + # data.val.file="GIMMS.FAPAR.1982.2011.nc", + # data.unc.file=0.12, + # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + # model.val.file="mfapar.bin", + # model.agg=NULL, + # xy=xy, + # data.factor=NULL, + # cost=TRUE, + # CostFunction=SSE, + # weight=1) + +# # use mean annual GPP in model-data integration +# gpp <- IntegrationDataset(name="GPP", unit="gC m-2 yr-1", + # data.val.file="MTE.GPP.1982.2011.meanannual.nc", + # data.unc.file="MTE.GPPunc.1982.2011.meanannual.nc", + # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + # model.val.file="mgpp.bin", + # model.agg=AggSumMean, # sum of each year, mean over all years -> mean annual GPP + # xy=xy, + # data.factor=NULL, + # cost=TRUE, + # CostFunction=SSE, + # weight=1) + +# integrationdata <- IntegrationData(fapar, gpp) + +} diff --git a/LPJmLmdi/man/IntegrationData2Df.Rd b/LPJmLmdi/man/IntegrationData2Df.Rd new file mode 100644 index 0000000..6abbc31 --- /dev/null +++ b/LPJmLmdi/man/IntegrationData2Df.Rd @@ -0,0 +1,19 @@ +\name{IntegrationData2Df} +\alias{IntegrationData2Df} +\title{Converts IntegrationData to a data.frame} +\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.} +\usage{IntegrationData2Df(x, sim.name = "sim", ...)} +\arguments{ + \item{x}{object of class \code{\link{IntegrationData}}} + \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')} + \item{\dots}{further arguments (not used)} +} +\details{No details.} +\value{a data.frame} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationData}}} + diff --git a/LPJmLmdi/man/IntegrationDataset.Rd b/LPJmLmdi/man/IntegrationDataset.Rd new file mode 100644 index 0000000..1d9a75e --- /dev/null +++ b/LPJmLmdi/man/IntegrationDataset.Rd @@ -0,0 +1,65 @@ +\name{IntegrationDataset} +\alias{IntegrationDataset} +\title{Create an object of class 'IntegrationDataset'} +\description{The function sets up an object of class 'IntegrationDataset' to define a dataset that should be used in model optimization, including dataset properties and the corresponding model output files. The function also reads the data input files as defined in 'data.val.file' and subsets the input data for the grid cells in 'xy'. One or several 'IntegrationDataset's need to be collected in an object of class \code{\link{IntegrationData}} which is used in the \code{\link{RunLPJ}} and \code{\link{OptimizeLPJgenoud}} functions.} +\usage{IntegrationDataset(name, unit = "", data.val.file, data.unc.file, + data.time, model.time = data.time, model.val.file, xy, AggFun = NULL, + data.factor = 1, model.factor = 1, cost = TRUE, CostFunction = SSE, + weight = 1)} +\arguments{ + \item{name}{name of the dataset or variable} + \item{unit}{unit of the variable (same unit as in LPJmL model output file 'model.val.file')} + \item{data.val.file}{name of file with the observation values, should be a file that can be read with \code{\link{brick}}} + \item{data.unc.file}{name of file with the data uncertainties or a numeric value if the same uncertainty value should be used for all observations} + \item{data.time}{a vector of class 'Date' with the time steps of the observations. } + \item{model.time}{a vector of class 'Date' with the time steps for which model results should be read. For example, if data.val.file represents just one value (e.g. long-term mean), the full time period for which the model results should be averaged needs to be defined here. } + \item{model.val.file}{file name of the corresponding model result [e.g. model.val.file="mnpp.bin"] or function without arguments [e.g. model.val.file=function() { ReadLPJ("mnpp.bin", start=1901, end=2009, ...) }]. The option to pass a function allows to perform any calculations on LPJ model results or to combine several LPJ model outputs in order to be comparable with observations. } + \item{xy}{a matrix of grid cells that is used in \code{\link{RunLPJ}} and \code{\link{OptimizeLPJgenoud}}. The data in 'data.val.file' and 'data.unc.file' is extracted for these grid cells. } + \item{AggFun}{aggregation function to aggregate model results to the temporal resolution of the observations, for example \code{\link{AggSumMean}} for annual sums and mean over annual sums. If NULL no temporal aggregation is done.} + \item{data.factor}{scaling factor to be applied to the observation data, e.g. for unit conversions} + \item{model.factor}{scaling factor to be applied to model outputs, e.g. for unit conversions or scaling} + \item{cost}{Should the data stream be included in the computation of the total cost (TRUE) or not (FALSE). In case of FALSE, evaluation plots are produced for this dataset but the dataset is not considered in the compuation of the total cost and therfore not in optimization.} + \item{CostFunction}{cost function that should be used for this dataset, default \code{\link{SSE}}} + \item{weight}{weighting factor for the dataset in the cost function, cost = CostFunction / number of observations * weight} +} +\details{No details.} +\value{The function returns a list of class 'IntegrationDataset'} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationData}}} +\examples{ + +# # grid cells for which LPJmL should be run and for which the integration data should be extracted +# xy <- cbind(c(136.75, 137.25, 160.75,168.75), c(45.25, 65.25, 68.75, 63.75)) + +# # use monthly FAPAR in model-data integration +# fapar <- IntegrationDataset(name="FAPAR", unit="", + # data.val.file="GIMMS.FAPAR.1982.2011.nc", + # data.unc.file=0.12, + # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + # model.val.file="mfapar.bin", + # model.agg=NULL, + # xy=xy, + # data.factor=NULL, + # cost=TRUE, + # CostFunction=SSE, + # weight=1) + +# # use mean annual GPP in model-data integration +# gpp <- IntegrationDataset(name="GPP", unit="gC m-2 yr-1", + # data.val.file="MTE.GPP.1982.2011.meanannual.nc", + # data.unc.file="MTE.GPPunc.1982.2011.meanannual.nc", + # data.time=seq(as.Date("1982-01-01"), as.Date("2011-12-31"), by="month"), + # model.val.file="mgpp.bin", + # model.agg=AggSumMean, # sum of each year, mean over all years -> mean annual GPP + # xy=xy, + # data.factor=NULL, + # cost=TRUE, + # CostFunction=SSE, + # weight=1) + + +} diff --git a/LPJmLmdi/man/LE2ET.Rd b/LPJmLmdi/man/LE2ET.Rd new file mode 100644 index 0000000..ff69ff6 --- /dev/null +++ b/LPJmLmdi/man/LE2ET.Rd @@ -0,0 +1,30 @@ +\name{LE2ET} +\alias{LE2ET} +\title{Compute evapotranspiration (ET) from latent heat (LE).} + +\usage{LE2ET(le, temp = 20, rho_w = 1000)} +\arguments{ + \item{le}{latent heat (W m-2)} + \item{temp}{temperature (degC, default 20 degC)} + \item{rho_w}{ +} +} + +\value{The function returns evapotranspiration (mm day-1)} +\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} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteLPJinput}}} +\examples{ +# Example from FAO (1998) +le <- 12 # latent heat that is used to vapourize water (MJ m-2 day-1) +le <- le / 86400 # MJ m-2 day-1 -> MJ m-2 sec-1 +le <- le * 1E6 # MJ m-2 sec-1 -> W m-2 +LE2ET(le=le) + +temp <- -30:40 +et <- LE2ET(le=le, temp=temp) +plot(temp, et) +} diff --git a/LPJmLmdi/man/LPJ2NCDF.Rd b/LPJmLmdi/man/LPJ2NCDF.Rd new file mode 100644 index 0000000..c01d34e --- /dev/null +++ b/LPJmLmdi/man/LPJ2NCDF.Rd @@ -0,0 +1,34 @@ +\name{LPJ2NCDF} +\alias{LPJ2NCDF} +\title{Convert binary LPJmL model output files to NetCDF} +\description{The function converts a binary LPJmL output file to NetCDF } +\usage{LPJ2NCDF(file, var.name, var.unit, start = 1982, end = 2011, + sim.start.year = 1901, var.longname = var.name, run.name = "LPJmL", + run.description = "LPJmL run", provider = "M. Forkel, matthias.forkel@geo.tuwien.ac.at", + 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", + ...)} +\arguments{ + \item{file}{file name of LPJmL model output, e.g. "mgpp.bin"} + \item{var.name}{variable name, e.g. "GPP"} + \item{var.unit}{variable unit, e.g. "gC m-2 mon-1"} + \item{start}{first year for which the data should be converted to NetCDF} + \item{end}{last year for which the data should be converted to NetCDF} + \item{sim.start.year}{first year of the simulation} + \item{var.longname}{long variable name, e.g. "gross primary production"} + \item{run.name}{name of the LPJmL run (will be part of the file names)} + \item{run.description}{description of the LPJmL run} + \item{provider}{name of the provider} + \item{creator}{name of the creator} + \item{reference}{ +} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/LPJfiles.Rd b/LPJmLmdi/man/LPJfiles.Rd new file mode 100644 index 0000000..c274d75 --- /dev/null +++ b/LPJmLmdi/man/LPJfiles.Rd @@ -0,0 +1,30 @@ +\name{LPJfiles} +\alias{LPJfiles} +\title{Create an object of class 'LPJfiles'} +\description{The function creates a list of class 'LPJfiles' that defines all paths, input files, and configurations files for a LPJ run.} +\usage{LPJfiles(path.lpj, path.tmp, path.out, sim.start.year, sim.end.year = NA, + lpj.conf, param.conf, pft.par, param.par, input.conf, input, + ...)} +\arguments{ + \item{path.lpj}{path where LPJ is installed} + \item{path.tmp}{path for temporary outputs } + \item{path.out}{path for results} + \item{sim.start.year}{start year of the LPJ simulation as defined in lpjml.conf} + \item{sim.end.year}{last year of the LPJ simulation as defined in lpjml.conf} + \item{lpj.conf}{template for LPJ configuration file (create a template from lpjml.conf)} + \item{param.conf}{template for parameter configuration file (create a template from param.conf)} + \item{pft.par}{template file for PFT-specific parameters (create a template from pft.par)} + \item{param.par}{template file for global parameters (create a template from param.par)} + \item{input.conf}{template file for input data (create a template from input.conf)} + \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"))} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/LPJmLmdi-package.Rd b/LPJmLmdi/man/LPJmLmdi-package.Rd new file mode 100644 index 0000000..27d8b8d --- /dev/null +++ b/LPJmLmdi/man/LPJmLmdi-package.Rd @@ -0,0 +1,22 @@ +\name{LPJmLmdi-package} +\alias{LPJmLmdi-package} +\alias{LPJmLmdi} +\docType{package} +\title{Model-Data Integration for the LPJmL Dynamic Global Vegetation Model} +} +\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.} +} +\details{ + +The DESCRIPTION file: +\packageDESCRIPTION{LPJmLmdi} +\packageIndices{LPJmLmdi} +} +\author{Matthias Forkel [aut, cre]} + +Maintainer: \packageMaintainer{LPJmLmdi} +} + +\keyword{ package } + + diff --git a/LPJmLmdi/man/LPJpar.Rd b/LPJmLmdi/man/LPJpar.Rd new file mode 100644 index 0000000..5a1eff2 --- /dev/null +++ b/LPJmLmdi/man/LPJpar.Rd @@ -0,0 +1,24 @@ +\name{LPJpar} +\alias{LPJpar} +\title{Create an object of class 'LPJpar'} +\description{The function creates a data.frame of class 'LPJpar' that defines the parameters for LPJ runs.} +\usage{LPJpar(par.prior, par.lower, par.upper, par.pftspecif, par.names, + is.int = rep(FALSE, length(par.prior)), ...)} +\arguments{ + \item{par.prior}{parameter vector (prior)} + \item{par.lower}{lower boundaries for parameters} + \item{par.upper}{upper boundaries for parameters} + \item{par.pftspecif}{Which parameter is PFT specific (TRUE) or global (FALSE)?} + \item{par.names}{parameter name} + \item{is.int}{is parameter a integer?} + \item{\dots}{further arguments for CheckLPJpar} +} +\details{No details.} +\value{The function returns a list of class 'LPJpar'} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CheckLPJpar}} } + diff --git a/LPJmLmdi/man/LPJparList.Rd b/LPJmLmdi/man/LPJparList.Rd new file mode 100644 index 0000000..8fa73cb --- /dev/null +++ b/LPJmLmdi/man/LPJparList.Rd @@ -0,0 +1,17 @@ +\name{LPJparList} +\alias{LPJparList} +\title{Create a list of 'LPJpar' objects} +\description{The function creates a list of \code{\link{LPJpar}} objects that can be used to compare parameters from different optimization experiments} +\usage{LPJparList(...)} +\arguments{ + \item{\dots}{objects of class \code{\link{LPJpar}}} +} +\details{No details.} +\value{The function returns a list of class 'LPJparList'} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{LPJpar}}} + diff --git a/LPJmLmdi/man/LPJpp.Rd b/LPJmLmdi/man/LPJpp.Rd new file mode 100644 index 0000000..53c7ec3 --- /dev/null +++ b/LPJmLmdi/man/LPJpp.Rd @@ -0,0 +1,52 @@ +\name{LPJpp} +\alias{LPJpp} +\title{Post-process LPJmL model output} +\description{The function converts binary LPJmL output files to NetCDF and calculates summary statistics. Please note, climate data operators (CDO) is required.} +\usage{LPJpp(path, start = 1982, end = 2011, sim.start.year = 1901, + run.name = "LPJ", run.description = "LPJ run", provider = "M. Forkel, matthias.forkel@geo.tuwien.ac.at", + 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", + lpj.df = NULL, convert = TRUE, calc.nbp = FALSE, calc.cbalance = FALSE, + calc.tau = FALSE, calc.et = FALSE, calc.tree = FALSE, pft.istree = 2:9, + mask = NA, ...)} +\arguments{ + \item{path}{directory with LPJmL outputs in *.bin format} + \item{start}{first year for which the data should be converted to NetCDF} + \item{end}{last year for which the data should be converted to NetCDF} + \item{sim.start.year}{first year of the simulation} + \item{run.name}{name of the LPJmL run (will be part of the file names)} + \item{run.description}{description of the LPJmL run} + \item{provider}{name of the provider} + \item{creator}{name of the creator} + \item{reference}{ +} + \item{lpj.df}{A data.frame with information about LPJmL outputs that should be post-processed. If NULL, a set of default outputs will post-processed. See details for the required structure of this data.frame.} + \item{convert}{Convert files in lpj.df to NetCDF?} + \item{calc.nbp}{Calculate net biome productivity? NBP = Rh + FireC + HarvestC - (NPP + Estab)} + \item{calc.cbalance}{Calculate global total C stocks, fluxes, balances, and turnover times?} + \item{calc.tau}{Calculate spatial fields of turnover times?} + \item{calc.et}{Calculate evapotranspiration? ET = transp + evap + interc} + \item{calc.tree}{Calculate total tree cover? See also the argument pft.istree} + \item{pft.istree}{Which bands in fpc.bin represents tree?} + \item{mask}{A mask in a NetCDF file in order to compute the C fluxes, stocks, balances and turnover times only for specific regions.} + \item{\dots}{further arguments (currently not used)} +} +\details{The data.frame 'lpj.df' should have the following columns +\itemize{ +\item{ \code{file} name of binary LPJmL output file (e.g. mgpp.bin)} +\item{ \code{var.name} short name of the variable (e.g. GPP)} +\item{ \code{var.unit} units of the variables in the input file (e.g. "gC m-2")} +\item{ \code{var.longname} (optional) long name of the variable (e.g. "Gross primary production"). If this column is not provided 'var.name' will be used instead.} +\item{ \code{var.agg.fun} (optional) name of a function to aggregate the varibale to annual values (e.g "sum", "mean", "min", "max", or NA (no aggregation)). If this column is not provided, aggregations will be not computed.} +\item{ \code{subset.start} (optional) This can be used to additionally subset the NetCDF files to a shorter time period. Set to a year (e.g. 2000) or NA.} +\item{ \code{subset.end} (optional) This can be used to additionally subset the NetCDF files to a shorter time period. Set to a year (e.g. 2001) or NA. } +\item{ \code{stat.annual} (optional) Set to TRUE to compute statistical values based on annual aggregated data. If this is not provided, statistical values will be not computed} +\item{ \code{stat.monthly} (optional) Set to TRUE to compute statistical values based on monthly data. If this is not provided, statistical values will be not computed} +}} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/LPJppNBP.Rd b/LPJmLmdi/man/LPJppNBP.Rd new file mode 100644 index 0000000..9a020cc --- /dev/null +++ b/LPJmLmdi/man/LPJppNBP.Rd @@ -0,0 +1,22 @@ +\name{LPJppNBP} +\alias{LPJppNBP} +\title{Post-process LPJmL model output: calculate NEE} +\description{The function calculates NEE from LPJmL model output} +\usage{LPJppNBP(path, start = 1982, end = 2011, sim.start.year = 1901, + ...)} +\arguments{ + \item{path}{directory with LPJmL outputs in *.bin format} + \item{start}{first year for which the data should be converted to NetCDF} + \item{end}{last year for which the data should be converted to NetCDF} + \item{sim.start.year}{first year of the simulation} + \item{\dots}{further arguments (currently not used)} +} + + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/LWin2LWnet.Rd b/LPJmLmdi/man/LWin2LWnet.Rd new file mode 100644 index 0000000..b6df40d --- /dev/null +++ b/LPJmLmdi/man/LWin2LWnet.Rd @@ -0,0 +1,26 @@ +\name{LWin2LWnet} +\alias{LWin2LWnet} +\title{Compute long-wave net radiation from long-wave incoming radiation and temperature.} + +\usage{LWin2LWnet(lwin, temp, emissivity = 0.97)} +\arguments{ + \item{lwin}{long-wave incoming radiation (Wm-2)} + \item{temp}{temperature (degC, conversion to K is done within the function)} + \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). } +} +\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).} +\value{The function returns long-wave net radiation (Wm-2)} +\references{Campbell GS, Norman JM (1998) An Introduction to Environmental Biophysics. Springer New York, New York, NY.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteLPJinput}}} +\examples{ +lwin <- 200:380 # long-wave incoming radiation (Wm-2) +temp <- 0.14 * lwin - 32 + rnorm(length(lwin), 0, 5) # temperature (degC) +plot(lwin, temp) +lwnet <- LWin2LWnet(lwin, temp) +plot(temp, lwnet) +plot(lwin, lwnet) +} diff --git a/LPJmLmdi/man/LegendBar.Rd b/LPJmLmdi/man/LegendBar.Rd new file mode 100644 index 0000000..45f2adf --- /dev/null +++ b/LPJmLmdi/man/LegendBar.Rd @@ -0,0 +1,39 @@ +\name{LegendBar} +\alias{LegendBar} +\title{Add a colour legend bar to a plot} +\description{Adds a colour legend bar to a plot} +\usage{LegendBar(x, y, brks = seq(0, 1, by = 0.2), cols = NULL, brks.txt = NULL, + title = "", srt = NULL, col.txt = "black", cex.txt = 1, ...)} +\arguments{ + \item{x}{x coordinates for the legend bar} + \item{y}{y coordinates for the legend bar} + \item{brks}{class breaks for the legend bar} + \item{cols}{colours for each class. If NULL grey scales are used.} + \item{brks.txt}{text labels for the class breaks. If NULL, 'brks' are used} + \item{title}{title for the legend bar} + \item{srt}{rotation of breaks text labels} + \item{col.txt}{colour for text labels} + \item{cex.txt}{size of the text labels} + \item{\dots}{arguments (unused)} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CRSll}}} +\examples{ + +plot.new() +LegendBar(x=c(0.1, 0.9), y=c(0.4, 0.6)) +LegendBar(x=c(0.1, 0.5), y=c(0.7, 0.8)) + +brks <- seq(-1, 1, 0.2) +cols <- BreakColors(brks) +LegendBar(x=c(0.6, 1), y=c(0.7, 0.8), brks=brks, cols=cols, title="My title") + +LegendBar(x=c(0.2, 0.8), y=c(0.1, 0.2), brks=brks, cols=cols, col.txt="purple", title="purple", srt=90) + +} diff --git a/LPJmLmdi/man/MeanW.Rd b/LPJmLmdi/man/MeanW.Rd new file mode 100644 index 0000000..b6f093a --- /dev/null +++ b/LPJmLmdi/man/MeanW.Rd @@ -0,0 +1,23 @@ +\name{MeanW} +\alias{MeanW} +\title{Weighted mean} +\description{Compute the weighted mean.} +\usage{MeanW(x, w = rep(1, length(x)))} +\arguments{ + \item{x}{a vector} + \item{w}{vector of weights} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ObjFct}}} +\examples{ + +x <- 1:5 +mean(x) +MeanW(x, w=c(1, 1, 1, 2, 2)) +} diff --git a/LPJmLmdi/man/OptimizeLPJgenoud.Rd b/LPJmLmdi/man/OptimizeLPJgenoud.Rd new file mode 100644 index 0000000..d7566fb --- /dev/null +++ b/LPJmLmdi/man/OptimizeLPJgenoud.Rd @@ -0,0 +1,44 @@ +\name{OptimizeLPJgenoud} +\alias{OptimizeLPJgenoud} +\title{Optimize LPJ using the GENOUD optimizer (genetic optimization using derivatives)} +\description{This function performs an optimization of LPJmL model parameters for the specified grid cells unsing the GENOUD genetic optimization algorithm.} +\usage{OptimizeLPJgenoud(xy, name, lpjpar, par.optim, lpjfiles, lpjcmd = "srun ./bin/lpjml", + copy.input = TRUE, integrationdata, plot = TRUE, pop.size = 1000, + max.generations = 20, wait.generations = 19, BFGSburnin = 18, + calc.jacob = FALSE, restart = 0, path.rescue = NULL, restart.jacob = FALSE, + nodes = 1, maxAutoRestart = 5, runonly = FALSE, warnings = TRUE, + new.spinup4post = TRUE, CostMDS = CostMDS.SSE)} +\arguments{ + \item{xy}{matrix of grid cell coordinates to run LPJ} + \item{name}{name of the experiment (basic file name for all outputs)} + \item{lpjpar}{data.frame of class \code{\link{LPJpar}} that define all LPJ parameter values, ranges, and names} + \item{par.optim}{names of the parameters that should be optimized} + \item{lpjfiles}{list of class \code{\link{LPJfiles}} that define all LPJ directories, input files, configuration template files} + \item{lpjcmd}{How you usually run the LPJ model at the console: 'srun ./bin/lpjml' or './bin/lpjml' } + \item{copy.input}{Should LPJ input data be copied to the directory for temporary output? This might speed up computations if the directory is on the same machine where the program runs. } + \item{integrationdata}{list of integration data and information} + \item{plot}{plot diagnostic graphics of optimization results?} + \item{pop.size}{population size, see \code{\link{genoud}}} + \item{max.generations}{max number of generations, see \code{\link{genoud}}} + \item{wait.generations}{How many generations should genoud wait before returning an optimum, see \code{\link{genoud}}} + \item{BFGSburnin}{The number of generations before the L-BFGS-B algorithm is first used, see \code{\link{genoud}}} + \item{calc.jacob}{Should the Hessian and Jacobian matrix be computed (yes = TRUE, no = FALSE)?} + \item{restart}{Where to re-start the optimization? 0 = start at the beginning, 1 = continue with existing genoud optimization, 2 = start after genoud and post-process results. } + \item{path.rescue}{directory where the resuce files from each iteration of a previous optimization are saved. This is needed if restart > 0.} + \item{restart.jacob}{Should the Hessian and Jacobian matrix be recomputed if restart > 0 (yes = TRUE, no = FALSE)? Works only if calc.jacob is TRUE.} + \item{nodes}{use parallel computing? How many nodes to use?} + \item{maxAutoRestart}{maximum number of automatic restarts of the optimization if an error occurs within genoud()} + \item{runonly}{run only the model with prior parameters set but don't perform optimization. Produces only results of prior model run.} + \item{warnings}{print all LPJmL warning messages during optimization?} + \item{new.spinup4post}{What spinup conditions should be used for the posterior ('posterior-best' and 'posterior-median') model runs? If TRUE, a new spinup is computed based on the optimized parameters. If FALSE, the posterior model runs are started from the spinup conditions of the prior model run (like the runs during optimization).} + \item{CostMDS}{cost function for multiple data streams to calculate total cost, cost per data stream, and eventually cost per grid cell. See \code{\link{CostMDS.SSE}} (default) or \code{\link{CostMDS.KGE}}} +} + + + +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/PlotPar.Rd b/LPJmLmdi/man/PlotPar.Rd new file mode 100644 index 0000000..75d7004 --- /dev/null +++ b/LPJmLmdi/man/PlotPar.Rd @@ -0,0 +1,24 @@ +\name{PlotPar} +\alias{PlotPar} +\title{Plot parameter vs. cost} +\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.} +\usage{PlotPar(rescue.l, lpjpar, par.name = NULL, ...)} +\arguments{ + \item{rescue.l}{a list of class "rescue" (\code{\link{CombineRescueFiles}}) or alternatively a data.frame as created with \code{\link{Rescue2Df}}.} + \item{lpjpar}{a list of class "LPJpar" (see \code{\link{LPJpar}})} + \item{par.name}{name(s) of the parameters that should be plotted } + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CombineRescueFiles}}} +\examples{ +# files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) +# rescue.l <- CombineRescueFiles(files, remove=FALSE) +# PlotPar(rescue.l, lpjpar) +} diff --git a/LPJmLmdi/man/PlotParPCA.Rd b/LPJmLmdi/man/PlotParPCA.Rd new file mode 100644 index 0000000..d4a4b3e --- /dev/null +++ b/LPJmLmdi/man/PlotParPCA.Rd @@ -0,0 +1,18 @@ +\name{PlotParPCA} +\alias{PlotParPCA} +\title{plot a PCA of optimized parameters} +\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. } +\usage{PlotParPCA(rescue.l, ...)} +\arguments{ + \item{rescue.l}{a list of class "rescue", see \code{\link{CombineRescueFiles}}} + \item{\dots}{further arguments for \code{\link{plot}}} +} +\details{No details.} +\value{The function returns an object of class 'princomp'.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CombineRescueFiles}}, \code{\link{princomp}}} + diff --git a/LPJmLmdi/man/PlotParUnc.Rd b/LPJmLmdi/man/PlotParUnc.Rd new file mode 100644 index 0000000..b49c5dc --- /dev/null +++ b/LPJmLmdi/man/PlotParUnc.Rd @@ -0,0 +1,24 @@ +\name{PlotParUnc} +\alias{PlotParUnc} +\title{Plot the psoterior parameter uncertainty} +\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} +\usage{PlotParUnc(lpjpar, uncertainty = "uncertainty.005", ylab = "Relative parameter uncertainty", + main = NULL, ...)} +\arguments{ + \item{lpjpar}{a list of class "LPJpar" (see \code{\link{LPJpar}})} + \item{uncertainty}{name of the uncertainty estimate in LPJpar that should be used to compute posterior uncertainties} + \item{ylab}{label of y-axis} + \item{main}{title of plot} + \item{\dots}{further arguments for plot} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CombineRescueFiles}}} +\examples{ +# PlotParUnc(lpjpar) +} diff --git a/LPJmLmdi/man/PlotWorld110.Rd b/LPJmLmdi/man/PlotWorld110.Rd new file mode 100644 index 0000000..c937acc --- /dev/null +++ b/LPJmLmdi/man/PlotWorld110.Rd @@ -0,0 +1,27 @@ +\name{PlotWorld110} +\alias{PlotWorld110} +\title{Plot a world map based on 1:110Mio data} + +\usage{PlotWorld110(admin = FALSE, lakes = TRUE, rivers = TRUE, col = c("black", + "blue", "red"), bg = NA, ...)} +\arguments{ + \item{admin}{Plot administrative boundaries?} + \item{lakes}{Plot lakes?} + \item{rivers}{Plot rivers?} + \item{col}{Colors for (1) coastlines, (2) rivers and (3) administrative boundaries} + \item{bg}{background color, default: NA (no background)} + \item{\dots}{additional arguments to plot} +} + + + +\author{Matthias Forkel [aut, cre]} + + + + +\examples{ + +PlotWorld110() + +} diff --git a/LPJmLmdi/man/PrepareRestartFiles.Rd b/LPJmLmdi/man/PrepareRestartFiles.Rd new file mode 100644 index 0000000..8bd6699 --- /dev/null +++ b/LPJmLmdi/man/PrepareRestartFiles.Rd @@ -0,0 +1,18 @@ +\name{PrepareRestartFiles} +\alias{PrepareRestartFiles} +\title{Prepare restart files to restart OptimizeLPJgenoud} +\description{The function prepares all files that are needed to restart OptimizeLPJgenoud} +\usage{PrepareRestartFiles(file.optsetup, ...)} +\arguments{ + \item{file.optsetup}{OptimizeLPJgenoud setup file, ends with "_optsetup.RData"} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{LPJfiles}} } + diff --git a/LPJmLmdi/man/ReadBIN.Rd b/LPJmLmdi/man/ReadBIN.Rd new file mode 100644 index 0000000..99036bd --- /dev/null +++ b/LPJmLmdi/man/ReadBIN.Rd @@ -0,0 +1,29 @@ +\name{ReadBIN} +\alias{ReadBIN} +\title{Read simple binary files without header Read a CLM file to a SpatialPixelsDataFrame} +\description{The function is used to read for example the soil*.bin and drainclass.bin files} +\usage{ReadBIN(file.bin, nbands = 1, size = 1, file.grid = NA, endian.data = "little", + endian.grid = "little", data.type = integer(), ...)} +\arguments{ + \item{file.bin}{binary file name with extension *.bin} + \item{nbands}{number of bands per year} + \item{size}{The number of bytes per element in the byte stream.} + \item{file.grid}{file name of the corresponding grid file} + \item{endian.data}{endinaess of the data file} + \item{endian.grid}{endianess of the grid file} + \item{data.type}{type of the data} + \item{\dots}{Further arguments (currently not used).} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteCLM}}} +\examples{ + +# ReadBIN("soil_new_67420.bin") + +} diff --git a/LPJmLmdi/man/ReadCLM.Rd b/LPJmLmdi/man/ReadCLM.Rd new file mode 100644 index 0000000..f77ff88 --- /dev/null +++ b/LPJmLmdi/man/ReadCLM.Rd @@ -0,0 +1,30 @@ +\name{ReadCLM} +\alias{ReadCLM} +\title{Read a CLM file to a SpatialPixelsDataFrame} + +\usage{ReadCLM(file.clm, start = NA, end = NA, start.year = NA, grid = NULL, + nbands = NA, size = NA, file.grid = NA, endian.data = NA, + endian.grid = "big", data.type = integer(), ...)} +\arguments{ + \item{file.clm}{CLM file name with extension *.clm} + \item{start}{first year to be read} + \item{end}{last year to be read, reads until last year in case of NA} + \item{start.year}{first year in the dataset, read from header information in case NA} + \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} + \item{nbands}{number of bands per year, read from header information in case NA} + \item{size}{The number of bytes per element in the byte stream.} + \item{file.grid}{file name of the corresponding grid file} + \item{endian.data}{endinaess of the data file} + \item{endian.grid}{endianess of the grid file} + \item{data.type}{type of the data} + \item{\dots}{Further arguments (currently not used).} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteCLM}}} + diff --git a/LPJmLmdi/man/ReadGrid.Rd b/LPJmLmdi/man/ReadGrid.Rd new file mode 100644 index 0000000..6f1a262 --- /dev/null +++ b/LPJmLmdi/man/ReadGrid.Rd @@ -0,0 +1,19 @@ +\name{ReadGrid} +\alias{ReadGrid} +\title{Reads a binary input data grid file.} + +\usage{ReadGrid(file.grid = "cru.grid", endian = "little", ...)} +\arguments{ + \item{file.grid}{CLM file name with extension *.clm} + \item{endian}{endianess of the file} + \item{\dots}{Further arguments (currently not used).} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadCLM}}} + diff --git a/LPJmLmdi/man/ReadLPJ.Rd b/LPJmLmdi/man/ReadLPJ.Rd new file mode 100644 index 0000000..7d496f7 --- /dev/null +++ b/LPJmLmdi/man/ReadLPJ.Rd @@ -0,0 +1,33 @@ +\name{ReadLPJ} +\alias{ReadLPJ} +\title{Read a LPJ binary file} +\description{The function reads a binary LPJ output file and returns a SpatialPointsDataFrame} +\usage{ReadLPJ(file.bin, file.grid = "grid.bin", sim.start.year = 1901, + start = sim.start.year, end = NA, file.annual = c("vegc.bin", + "litc.bin", "soilc.bin"), size = 4, data.type = numeric(), + endian = "little", ...)} +\arguments{ + \item{file.bin}{binary LPJ output file} + \item{file.grid}{binary LPJ grid file} + \item{sim.start.year}{first year of the simulation} + \item{start}{first year to read} + \item{end}{last year to read, reads until last year if NA} + \item{file.annual}{one of the binary LPJ output files with annual data} + \item{size}{the number of bytes per element in the byte stream.} + \item{data.type}{data type of the file (default=numeric())} + \item{endian}{endianess of the binary file} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{The function returns a SpatialPointsDataFrame.} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadLPJsim}}} +\examples{ + +# ReadLPJ("mgpp.bin", start=1982, end=2011) + +} diff --git a/LPJmLmdi/man/ReadLPJ2IntegrationData.Rd b/LPJmLmdi/man/ReadLPJ2IntegrationData.Rd new file mode 100644 index 0000000..4f0a141 --- /dev/null +++ b/LPJmLmdi/man/ReadLPJ2IntegrationData.Rd @@ -0,0 +1,20 @@ +\name{ReadLPJ2IntegrationData} +\alias{ReadLPJ2IntegrationData} +\title{Read LPJ model results into an of class IntegrationData} +\description{The function reads for each dataset in \code{\link{IntegrationData}} the corresponding model output and performs temporal aggregation.} +\usage{ReadLPJ2IntegrationData(integrationdata, xy, lpjfiles, ...)} +\arguments{ + \item{integrationdata}{object of class \code{\link{IntegrationData}}} + \item{xy}{matrix of grid cell coordinates to run LPJ} + \item{lpjfiles}{list of class \code{\link{LPJfiles}} that define all LPJ directories, input files, configuration template files} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{The function returns the same list oc class 'IntegrationData' but with added model outputs.} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationData}}} + diff --git a/LPJmLmdi/man/ReadLPJ2ts.Rd b/LPJmLmdi/man/ReadLPJ2ts.Rd new file mode 100644 index 0000000..cc23d36 --- /dev/null +++ b/LPJmLmdi/man/ReadLPJ2ts.Rd @@ -0,0 +1,26 @@ +\name{ReadLPJ2ts} +\alias{ReadLPJ2ts} +\title{Read a LPJ binary file and returns a spatial averaged time series} +\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} +\usage{ReadLPJ2ts(file.bin, sim.start.year = 1901, start = sim.start.year, + end = NA, ...)} +\arguments{ + \item{file.bin}{binary LPJ output file} + \item{sim.start.year}{first year of the simulation} + \item{start}{first year to read} + \item{end}{last year to read, reads until last year if NA} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{The function returns a time series of class 'ts'.} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadLPJsim}}} +\examples{ + +# gpp <- ReadLPJ2ts("mgpp.bin") + +} diff --git a/LPJmLmdi/man/ReadLPJinput.Rd b/LPJmLmdi/man/ReadLPJinput.Rd new file mode 100644 index 0000000..67d0f6d --- /dev/null +++ b/LPJmLmdi/man/ReadLPJinput.Rd @@ -0,0 +1,25 @@ +\name{ReadLPJinput} +\alias{ReadLPJinput} +\title{Read and subset CLM files to LPJinput objects} +\description{The functions reads a CLM file, selects the data according to the provided grid and returns an object of class LPJinput. } +\usage{ReadLPJinput(files, grid = NULL, start = NA, ...)} +\arguments{ + \item{files}{character vector of CLM or binary file names} + \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.} + \item{start}{first year to read} + \item{\dots}{Further arguments to ReadCLM or ReadBIN} +} +\details{No details.} +\value{The function returns a list of class "LPJinput".} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteLPJinput}}} +\examples{ + +# 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))) +# str(lpjinput) + +} diff --git a/LPJmLmdi/man/ReadLPJsim.Rd b/LPJmLmdi/man/ReadLPJsim.Rd new file mode 100644 index 0000000..7195236 --- /dev/null +++ b/LPJmLmdi/man/ReadLPJsim.Rd @@ -0,0 +1,28 @@ +\name{ReadLPJsim} +\alias{ReadLPJsim} +\title{Read a LPJ simulation results} +\description{The function reads all binary output files from a LPJ simulation and returns regional aggregated time series.} +\usage{ReadLPJsim(sim.start.year = 1901, start = sim.start.year, end = NA, + files = NA, outputvars.par = NULL, ...)} +\arguments{ + \item{sim.start.year}{first year of the simulation} + \item{start}{first year to read} + \item{end}{last year to read. If NA, reads until last year} + \item{files}{Which LPJ binary output files should be read? If NA, all *.bin files in the current directory are read.} + \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. } + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{The function returns a list of class 'LPJsim'} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadLPJ2ts}}} +\examples{ + +# setwd(path.mylpjresult) +# sim <- ReadLPJsim(start=1982, end=2011) + +} diff --git a/LPJmLmdi/man/ReadOutputvars.Rd b/LPJmLmdi/man/ReadOutputvars.Rd new file mode 100644 index 0000000..0973b4b --- /dev/null +++ b/LPJmLmdi/man/ReadOutputvars.Rd @@ -0,0 +1,22 @@ +\name{ReadOutputvars} +\alias{ReadOutputvars} +\title{Read 'outputvars.par' to get information about LPJmL output} +\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}}.} +\usage{ReadOutputvars(outputvars.par = NULL, ...)} +\arguments{ + \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. } + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{The function returns a time series of class 'ts'.} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadLPJsim}}} +\examples{ + +# ReadOutputvars() + +} diff --git a/LPJmLmdi/man/ReadPRO.Rd b/LPJmLmdi/man/ReadPRO.Rd new file mode 100644 index 0000000..2251358 --- /dev/null +++ b/LPJmLmdi/man/ReadPRO.Rd @@ -0,0 +1,17 @@ +\name{ReadPRO} +\alias{ReadPRO} +\title{Read *.pro files as produced from GENOUD} +\description{The function is used within OptimizeLPJgenoud} +\usage{ReadPRO(files.pro)} +\arguments{ + \item{files.pro}{file names (*.pro) of genoud optimization results.} +} +\details{No details.} +\value{The function returns a data.frame with number of individual, cost and parameer values} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/RegridLPJinput.Rd b/LPJmLmdi/man/RegridLPJinput.Rd new file mode 100644 index 0000000..84d4d25 --- /dev/null +++ b/LPJmLmdi/man/RegridLPJinput.Rd @@ -0,0 +1,25 @@ +\name{RegridLPJinput} +\alias{RegridLPJinput} +\title{Regrid or subset LPJmL input } +\description{Subsets grid cells or regrids LPJmL input files.} +\usage{RegridLPJinput(files, grid.clm, grid, path.out, overwrite = TRUE, + ...)} +\arguments{ + \item{files}{character vector of CLM or binary file names} + \item{grid.clm}{old grid *.clm file} + \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.} + \item{path.out}{directory where the new files should be saved} + \item{overwrite}{overwrite existing files?} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{The function returns TRUE if the CLM file was created.} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteLPJinput}}} +\examples{ +# no example +} diff --git a/LPJmLmdi/man/Rescue2Df.Rd b/LPJmLmdi/man/Rescue2Df.Rd new file mode 100644 index 0000000..625c333 --- /dev/null +++ b/LPJmLmdi/man/Rescue2Df.Rd @@ -0,0 +1,24 @@ +\name{Rescue2Df} +\alias{Rescue2Df} +\title{Convert a 'rescue' list to a data.frame} +\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).} +\usage{Rescue2Df(rescue.l, lpjpar = NULL, ...)} +\arguments{ + \item{rescue.l}{a list of class "rescue", see \code{\link{CombineRescueFiles}}} + \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)} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{The function returns a data.frame.} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CombineRescueFiles}}} +\examples{ +# files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) +# rescue.l <- CombineRescueFiles(files, remove=FALSE) +# optim.df <- Rescue2Df(rescue.l) +# summary(optim.df) +} diff --git a/LPJmLmdi/man/Rescue2LPJpar.Rd b/LPJmLmdi/man/Rescue2LPJpar.Rd new file mode 100644 index 0000000..99f7e03 --- /dev/null +++ b/LPJmLmdi/man/Rescue2LPJpar.Rd @@ -0,0 +1,34 @@ +\name{Rescue2LPJpar} +\alias{Rescue2LPJpar} +\title{Add information from a 'rescue' list to an 'LPJpar' object} +\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' (see \code{\link{LPJpar}}) object. Then it extracts the best parameter set, the median of the best parameter sets (defined based on dAIC <= 2), and various uncertainty measures and adds them to the 'LPJpar' object.} +\usage{Rescue2LPJpar(rescue.l, lpjpar, ...)} +\arguments{ + \item{rescue.l}{a list of class "rescue" (\code{\link{CombineRescueFiles}}) or alternatively a data.frame as created with \code{\link{Rescue2Df}}.} + \item{lpjpar}{a list of class "LPJpar" (\code{\link{LPJpar}})} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{The function returns the provided 'LPJpar' object with the following additional slots: +\itemize{ +\item{ \code{best} Best parameter set } +\item{ \code{best.median} median of best parameter sets (based on all parameter sets with dAIC <= 2) } +\item{ \code{uncertainty.iqr} uncertainty of parameters as the inter-quartile range of the best parameter sets } +\item{ \code{uncertainty.iqr95} uncertainty of parameters as the central 95\% inter-quantile range (0.975-0.025) of the best parameter sets } +\item{ \code{uncertainty.005.min} lower parameter uncertainty estimate based on the minimum parameter value from all parameter sets for which the cost <= quantile(cost, 0.05) } +\item{ \code{uncertainty.005.max} upper parameter uncertainty estimate based on the maximum parameter value from all parameter sets for which the cost <= quantile(cost, 0.05) } +} } +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CombineRescueFiles}}} +\examples{ +# files <- c(list.files(pattern="rescue.RData", recursive=TRUE), list.files(pattern="rescue0.RData", recursive=TRUE)) +# rescue.l <- CombineRescueFiles(files, remove=FALSE) +# lpjpar2 <- Rescue2LPJpar(rescue.l, lpjpar) +# str(lpjpar2) +# plot(lpjpar2, "ALPHAA", "uncertainty.iqr95") +# plot(lpjpar2, "TMIN_BASE", "uncertainty.iqr95") +} diff --git a/LPJmLmdi/man/RunLPJ.Rd b/LPJmLmdi/man/RunLPJ.Rd new file mode 100644 index 0000000..2b54671 --- /dev/null +++ b/LPJmLmdi/man/RunLPJ.Rd @@ -0,0 +1,36 @@ +\name{RunLPJ} +\alias{RunLPJ} +\title{Run LPJmL from R and get results} +\description{This function calls LPJmL, reads the results of the model run, computes the cost based on the data sets in \code{\link{IntegrationData}} and the defined cost function (in CostMDS), and returns the simulation results. } +\usage{RunLPJ(dpar, lpjpar, which.par.opt, lpjfiles, path = NULL, integrationdata, + xy, newcell = FALSE, name = "LPJmL", lpjcmd = "srun ./bin/lpjml", + plot = FALSE, getresult = FALSE, clean = 1, clean.path = FALSE, + CostMDS = CostMDS.SSE, nkeep = 400, warnings = TRUE)} +\arguments{ + \item{dpar}{vector of scaling factors for each parameter in 'which.par.opt': parameter = dpar * prior (e.g. if dpar is 1, prior parameters are used in the model run). Optimization is performed on these scaling factors} + \item{lpjpar}{data.frame of class \code{\link{LPJpar}} that define LPJ parameter values, ranges, and names} + \item{which.par.opt}{integer vector that indicates which parameters in lpjpar should be optimized} + \item{lpjfiles}{list of class \code{\link{LPJfiles}} that define all LPJ directories, input files, configuration template files} + \item{path}{path for output files of actual model run} + \item{integrationdata}{list of of class \code{\link{IntegrationData}} } + \item{xy}{matrix of grid cell coordinates to run LPJ} + \item{newcell}{calculate new cell and new spinup?} + \item{name}{name of the LPJ run, basic name for all outputs} + \item{lpjcmd}{How you usually run the LPJ model at the console: 'srun ./bin/lpjml' or './bin/lpjml'} + \item{plot}{plot results? see \code{\link{plot.IntegrationData}}} + \item{getresult}{If TRUE, all model results are returned in a LPJsim object and model results are saved. If FALSE, only the cost function value is returned.} + \item{clean}{clean results and temporay configuration and parameter files? 0 = keep everthing; 1 = delete parameter files, conf files and outputs; 2 = clean additionally input files, soil code files and restart} + \item{clean.path}{Delete output directory 'path' in case it already exists before the model run?} + \item{CostMDS}{cost function for multiple data streams} + \item{nkeep}{number of result files to keep. If more are existing, the ones with highest costs will be deleted} + \item{warnings}{print all LPJmL warning messages during optimization?} +} + + + +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/SSE.Rd b/LPJmLmdi/man/SSE.Rd new file mode 100644 index 0000000..8e69fde --- /dev/null +++ b/LPJmLmdi/man/SSE.Rd @@ -0,0 +1,26 @@ +\name{SSE} +\alias{SSE} +\title{Sum-of-squared residuals error} +\description{The function implements the sum-of-squared residuals error as cost function} +\usage{SSE(sim, obs, unc)} +\arguments{ + \item{sim}{vector of simulations} + \item{obs}{vector of observations} + \item{unc}{vector of observation uncertainties} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + +\examples{ + +obs <- rnorm(10, 0, 2) +sim <- obs + rnorm(10, 0.05, 0.01) +unc <- 0.01 +SSE(sim, obs, unc) + +} diff --git a/LPJmLmdi/man/SdW.Rd b/LPJmLmdi/man/SdW.Rd new file mode 100644 index 0000000..45c8eb8 --- /dev/null +++ b/LPJmLmdi/man/SdW.Rd @@ -0,0 +1,23 @@ +\name{SdW} +\alias{SdW} +\title{Weighted standard deviation} +\description{Compute the standard deviation.} +\usage{SdW(x, w = rep(1, length(x)))} +\arguments{ + \item{x}{a vector} + \item{w}{vector of weights} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ObjFct}}} +\examples{ + +x <- 1:5 +sd(x) +SdW(x, w=c(1, 1, 1, 2, 2)) +} diff --git a/LPJmLmdi/man/StandardError.Rd b/LPJmLmdi/man/StandardError.Rd new file mode 100644 index 0000000..e745702 --- /dev/null +++ b/LPJmLmdi/man/StandardError.Rd @@ -0,0 +1,19 @@ +\name{StandardError} +\alias{StandardError} +\title{Compute standard errors from a variance-covariance matrix} +\description{SE = sqrt(diag(vc) * cost^2 / (nobs - npar))} +\usage{StandardError(vc, nobs, cost)} +\arguments{ + \item{vc}{variance-covariance matrix} + \item{nobs}{number of observations} + \item{cost}{cost function value} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/StartingValues.Rd b/LPJmLmdi/man/StartingValues.Rd new file mode 100644 index 0000000..9eb99a5 --- /dev/null +++ b/LPJmLmdi/man/StartingValues.Rd @@ -0,0 +1,19 @@ +\name{StartingValues} +\alias{StartingValues} +\title{Get starting values for genoud from *.pro file} +\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.} +\usage{StartingValues(file.optresult, pop.size = NULL, ...)} +\arguments{ + \item{file.optresult}{genoud *.pro file with optimization results} + \item{pop.size}{population size} + \item{\dots}{further arguments (not used)} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{OptimizeLPJgenoud}} } + diff --git a/LPJmLmdi/man/Texture2Soilcode.Rd b/LPJmLmdi/man/Texture2Soilcode.Rd new file mode 100644 index 0000000..3ebabd5 --- /dev/null +++ b/LPJmLmdi/man/Texture2Soilcode.Rd @@ -0,0 +1,29 @@ +\name{Texture2Soilcode} +\alias{Texture2Soilcode} +\title{Convert soil texture to a LPJ soilcode} +\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".} +\usage{Texture2Soilcode(sand, silt, clay, lpj.soilcodes = c("Cl", "SiCl", + "SaCl", "ClLo", "SiClLo", "SaClLo", "Lo", "SiLo", "SaLo", + "Si", "LoSa", "Sa"), plot = TRUE, ...)} +\arguments{ + \item{sand}{percentage of sand} + \item{silt}{percentage of silt} + \item{clay}{percentage of clay} + \item{lpj.soilcodes}{LPJ soil codes} + \item{plot}{plot soil triangle?} + \item{\dots}{Further arguments (currently not used).} +} +\details{No details.} +\value{The function returns the LPJ soilcode} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadBIN}}} +\examples{ + +# data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) +# WriteBIN(data.sp, file="data.bin") + +} diff --git a/LPJmLmdi/man/Turnover.Rd b/LPJmLmdi/man/Turnover.Rd new file mode 100644 index 0000000..e6bed06 --- /dev/null +++ b/LPJmLmdi/man/Turnover.Rd @@ -0,0 +1,19 @@ +\name{Turnover} +\alias{Turnover} +\title{Calculate turnover time from stock and flux} +\description{Calculates turnover times.} +\usage{Turnover(stock, flux, ...)} +\arguments{ + \item{stock}{stock, e.g. biomass} + \item{flux}{flux, e.g. NPP} + \item{\dots}{further arguments (currently not used)} +} +\details{turnover = stock / flux} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/VarCovMatrix.Rd b/LPJmLmdi/man/VarCovMatrix.Rd new file mode 100644 index 0000000..f3327ad --- /dev/null +++ b/LPJmLmdi/man/VarCovMatrix.Rd @@ -0,0 +1,18 @@ +\name{VarCovMatrix} +\alias{VarCovMatrix} +\title{Compute variance-covariance matrix} +\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.} +\usage{VarCovMatrix(hessian, nms = paste("P", 1:n, sep = ""))} +\arguments{ + \item{hessian}{Hessian matrix} + \item{nms}{names of the parameters (rows and columns in the matrix} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/VarW.Rd b/LPJmLmdi/man/VarW.Rd new file mode 100644 index 0000000..4481771 --- /dev/null +++ b/LPJmLmdi/man/VarW.Rd @@ -0,0 +1,23 @@ +\name{VarW} +\alias{VarW} +\title{Weighted variance} +\description{Compute the weighted variance.} +\usage{VarW(x, w = rep(1, length(x)))} +\arguments{ + \item{x}{a vector} + \item{w}{vector of weights} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ObjFct}}} +\examples{ + +x <- 1:5 +var(x) +VarW(x, w=c(1, 1, 1, 2, 2)) +} diff --git a/LPJmLmdi/man/WriteBIN.Rd b/LPJmLmdi/man/WriteBIN.Rd new file mode 100644 index 0000000..4b34a3b --- /dev/null +++ b/LPJmLmdi/man/WriteBIN.Rd @@ -0,0 +1,25 @@ +\name{WriteBIN} +\alias{WriteBIN} +\title{Write a BIN file from SpatialPointsDataFrame} +\description{The function writes BIN files from a SpatialPointsDataFrame or SpatialPixelsDataFrame. } +\usage{WriteBIN(data.sp, file.bin, size = 1, ...)} +\arguments{ + \item{data.sp}{SpatialPointsDataFrame or SpatialPixelsDataFrame with data} + \item{file.bin}{binary file name with extension *.bin} + \item{size}{The number of bytes per element in the byte stream.} + \item{\dots}{Further arguments (currently not used).} +} +\details{No details.} +\value{The function returns TRUE if the CLM file was created.} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadBIN}}} +\examples{ + +# data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) +# WriteBIN(data.sp, file="data.bin") + +} diff --git a/LPJmLmdi/man/WriteCLM.Rd b/LPJmLmdi/man/WriteCLM.Rd new file mode 100644 index 0000000..3fda0d1 --- /dev/null +++ b/LPJmLmdi/man/WriteCLM.Rd @@ -0,0 +1,32 @@ +\name{WriteCLM} +\alias{WriteCLM} +\title{Write a CLM file from SpatialPointsDataFrame} +\description{The function writes CLM files from a SpatialPointsDataFrame or SpatialPixelsDataFrame. The LPJmL program cru2clm needs to be installed.} +\usage{WriteCLM(data.sp, file.clm, start, nbands, size = 2, scale = 1, + na.replace = -9999, path.lpj = NULL, res = 0.5, ...)} +\arguments{ + \item{data.sp}{SpatialPointsDataFrame or SpatialPixelsDataFrame with data} + \item{file.clm}{CLM file name with extension *.clm} + \item{start}{integer. First year in data.} + \item{nbands}{Number of bands per year.} + \item{size}{The number of bytes per element in the byte stream.} + \item{scale}{Scaling factor to be written to the header of the CLM file. The factor will be not applied to the data.} + \item{na.replace}{integer to replace NA values.} + \item{path.lpj}{path to LPJ installation} + \item{res}{spatial resolution of the grid cells } + \item{\dots}{Further arguments (currently not used).} +} +\details{No details.} +\value{The function returns TRUE if the CLM file was created.} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteLPJinput}}} +\examples{ + +# data.sp <- SpatialPointsDataFrame(lpjinput$grid, as.data.frame(data.m)) +# WriteCLM(data.sp, file="data.clm", start=1901, nbands=12, size=2) + +} diff --git a/LPJmLmdi/man/WriteGrid.Rd b/LPJmLmdi/man/WriteGrid.Rd new file mode 100644 index 0000000..2b9cef4 --- /dev/null +++ b/LPJmLmdi/man/WriteGrid.Rd @@ -0,0 +1,25 @@ +\name{WriteGrid} +\alias{WriteGrid} +\title{Write a *.grid file from a matrix of coordiantes or a SpatialPointsDataFrame} +\description{Writes a grid file for LPJ input data. The functions needs the LPJmL module txt2grid to be installed.} +\usage{WriteGrid(grid, file.grid, ...)} +\arguments{ + \item{grid}{SpatialPointsDataFrame; SpatialPixelsDataFrame, matrix or data.frame with coordinates} + \item{file.grid}{Grid file name} + \item{\dots}{Further arguments (currently not used).} +} +\details{No details.} +\value{The function returns TRUE if the grid file was created.} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteLPJinput}}} +\examples{ + +lon <- c(59.75, 68.25) +lat <- c(61.25, 65.75) +WriteGrid(cbind(lon, lat), "test.grid") + +} diff --git a/LPJmLmdi/man/WriteLPJinput.Rd b/LPJmLmdi/man/WriteLPJinput.Rd new file mode 100644 index 0000000..507e3d8 --- /dev/null +++ b/LPJmLmdi/man/WriteLPJinput.Rd @@ -0,0 +1,26 @@ +\name{WriteLPJinput} +\alias{WriteLPJinput} +\title{Write an object of class 'LPJinput' to CLM files} +\description{The function writes CLM input files for LPJ. } +\usage{WriteLPJinput(lpjinput, files = NULL, path.lpj = NULL, ...)} +\arguments{ + \item{lpjinput}{Object of class 'LPJinput' to be written.} + \item{files}{names of the output CLM or binary files. } + \item{path.lpj}{path to LPJ installation} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} +\value{The function returns TRUE if the CLM file was created.} +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{WriteLPJinput}}} +\examples{ + +# 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))) +# str(lpjinput) +# WriteLPJinput(lpjinput) + +} diff --git a/LPJmLmdi/man/WriteLPJpar.Rd b/LPJmLmdi/man/WriteLPJpar.Rd new file mode 100644 index 0000000..98c39dc --- /dev/null +++ b/LPJmLmdi/man/WriteLPJpar.Rd @@ -0,0 +1,23 @@ +\name{WriteLPJpar} +\alias{WriteLPJpar} +\title{Writes an object of class 'LPJpar' as parameter file or table.} +\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.} +\usage{WriteLPJpar(x, file = "LPJpar", pft.par = NULL, param.par = NULL, + param.only = TRUE, ...)} +\arguments{ + \item{x}{object of class 'LPJpar'} + \item{file}{basic file name for all output files, e.g. name of the optimization experiment} + \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.} + \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.} + \item{param.only}{write only parameters to table (TRUE) or also parameter prior ranges (FALSE)?} + \item{\dots}{further arguments for CheckLPJpar} +} +\details{No details.} +\value{The function returns a data.frame with an overview of the written files} +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{LPJpar}}, \code{\link{CheckLPJpar}} } + diff --git a/LPJmLmdi/man/WriteNCDF4.Rd b/LPJmLmdi/man/WriteNCDF4.Rd new file mode 100644 index 0000000..3391392 --- /dev/null +++ b/LPJmLmdi/man/WriteNCDF4.Rd @@ -0,0 +1,38 @@ +\name{WriteNCDF4} +\alias{WriteNCDF4} +\title{Write NetCDF files} +\description{Writes NetCDF files from rasters and makes sure that meta-information is properly defined.} +\usage{WriteNCDF4(data.l, var.name, var.unit, time = as.Date("2000-01-01"), + var.description = var.name, file = NULL, data.name = NA, + region.name = NA, file.title = var.name, file.description = var.name, + reference = "", provider = "", creator = "", missval = -9999, + scale = 1, offset = 0, compression = 9, overwrite = FALSE)} +\arguments{ + \item{data.l}{a single Raster* object or a list of Raster* objects } + \item{var.name}{vector of variable names} + \item{var.unit}{vector of variable units} + \item{time}{vector of time steps for each layer.} + \item{var.description}{vector of variable descriptions} + \item{file}{file name. If NULL the file name will be created from the variable name and the dimensions of the data.} + \item{data.name}{name of the dataset} + \item{region.name}{name of the region} + \item{file.title}{title of the file} + \item{file.description}{description of the file} + \item{reference}{reference for the dataset} + \item{provider}{dataset provider} + \item{creator}{dataset creator} + \item{missval}{flag for missing/NA values} + \item{scale}{scaling values for the data} + \item{offset}{offset value} + \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.} + \item{overwrite}{overwrite existing file?} +} + + + +\author{Matthias Forkel [aut, cre]} + + + + + diff --git a/LPJmLmdi/man/plot.Cbalance.Rd b/LPJmLmdi/man/plot.Cbalance.Rd new file mode 100644 index 0000000..2b05c0c --- /dev/null +++ b/LPJmLmdi/man/plot.Cbalance.Rd @@ -0,0 +1,36 @@ +\name{plot.Cbalance} +\alias{plot.Cbalance} +\title{Plots a C balance} +\description{The function takes an object of class \code{\link{Cbalance}} and creates time series plots or barplots.} +\usage{\method{plot}{Cbalance}(x, what = NULL, trend = TRUE, baseunit = "PgC", + ylab = NULL, ...)} +\arguments{ + \item{x}{object of class \code{\link{Cbalance}}} + \item{what}{Which variables of C balance to plot? If NULL, sole plots are generated automatically.} + \item{trend}{Compute trends?} + \item{baseunit}{unit of C stocks} + \item{ylab}{labels for y-axis} + \item{\dots}{further arguments (currently not used)} +} + + + +\author{Matthias Forkel [aut, cre]} + + + + +\examples{ + +# with some typical numbers for the global C budget: +cbal <- Cbalance(gpp=123, npp=61, rh=57, firec=2, vegc=400, soilc=2400) +cbal +plot(cbal) + +## using time series:: +#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) +#cbal +#plot(cbal) + + +} diff --git a/LPJmLmdi/man/plot.IntegrationData.Rd b/LPJmLmdi/man/plot.IntegrationData.Rd new file mode 100644 index 0000000..9b4c577 --- /dev/null +++ b/LPJmLmdi/man/plot.IntegrationData.Rd @@ -0,0 +1,22 @@ +\name{plot.IntegrationData} +\alias{plot.IntegrationData} +\title{Plot an object of class IntegrationData} +\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}}.} +\usage{\method{plot}{IntegrationData}(x, ds = 1:length(x), CostMDS = CostMDS.SSE, + fits = "poly3", ...)} +\arguments{ + \item{x}{object of class \code{\link{IntegrationData}}} + \item{ds}{Which data sets in x should be plotted (integer)} + \item{CostMDS}{cost function for multiple data streams} + \item{fits}{Fitting methods that should be used for scatter plots, see \code{\link{MultiFit}}} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{IntegrationData}}} + diff --git a/LPJmLmdi/man/plot.LPJpar.Rd b/LPJmLmdi/man/plot.LPJpar.Rd new file mode 100644 index 0000000..e2b8653 --- /dev/null +++ b/LPJmLmdi/man/plot.LPJpar.Rd @@ -0,0 +1,39 @@ +\name{plot.LPJpar} +\alias{plot.LPJpar} +\title{Plot parameters in 'LPJpar' object.} + +\usage{\method{plot}{LPJpar}(x, par.name = NULL, uncertainty = "uncertainty.005", + unc.change = FALSE, col = NULL, ylim = NULL, xlim = NULL, + which.pft = NULL, if.opt = FALSE, names = FALSE, opt.val = TRUE, + xaxt = "s", add = FALSE, xoff = 0)} +\arguments{ + \item{x}{object of class 'LPJpar'} + \item{par.name}{name(s) of the parameters that should be plotted} + \item{uncertainty}{name of the uncertainty estimate in LPJpar that should be used to plot posterior uncertainties} + \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)} + \item{col}{vector of colours for PFT-specific parameters} + \item{ylim}{limits of the y-axis} + \item{xlim}{limits of the x-axis} + \item{which.pft}{character vector of PFT names that should be plotted. If NULL all } + \item{if.opt}{plot parameters only if optimized (i.e. best) parameters are in LPJpar} + \item{names}{plot PFT names within the plot? } + \item{opt.val}{plot value of optimized parameter?} + \item{xaxt}{x axis type. "n" suppresses the x axis.} + \item{add}{add to existing plot?} + \item{xoff}{offset for adjusting in x-direction} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{LPJpar}}, \code{\link{CheckLPJpar}} } +\examples{ +# plot(lpjpar, par.name="ALBEDO_LEAF_TeBS", uncertainty="uncertainty.iqr95") +# plot(lpjpar, par.name="ALBEDO_LEAF", uncertainty="uncertainty.iqr") +# plot(lpjpar, par.name="LIGHTEXTCOEFF", uncertainty="uncertainty.iqr") +# par(mfrow=c(2,2)) +# plot(lpjpar, par.name=c("ALPHAA", "LIGHTEXTCOEFF", "ALBEDO_LEAF", "ALBEDO_STEM")) +} diff --git a/LPJmLmdi/man/plot.LPJparList.Rd b/LPJmLmdi/man/plot.LPJparList.Rd new file mode 100644 index 0000000..26ad8ec --- /dev/null +++ b/LPJmLmdi/man/plot.LPJparList.Rd @@ -0,0 +1,19 @@ +\name{plot.LPJparList} +\alias{plot.LPJparList} +\title{Plots to compare LPJpar objects} +\description{The function takes a \code{\link{LPJparList}} object and creates a plot to compare optimized parameters} +\usage{\method{plot}{LPJparList}(x, par.name = NULL, ...)} +\arguments{ + \item{x}{object of class 'LPJparList'} + \item{par.name}{name(s) of the parameters that should be plotted} + \item{\dots}{further arguments to \code{\link{plot.LPJpar}} } +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{LPJpar}}, \code{\link{plot.LPJpar}} } + diff --git a/LPJmLmdi/man/plot.LPJsim.Rd b/LPJmLmdi/man/plot.LPJsim.Rd new file mode 100644 index 0000000..ee2f9e1 --- /dev/null +++ b/LPJmLmdi/man/plot.LPJsim.Rd @@ -0,0 +1,30 @@ +\name{plot.LPJsim} +\alias{plot.LPJsim} +\title{Plots a LPJsim object} +\description{The function plots a LPJsim object: monthly, annual time series or map of grid cells} +\usage{\method{plot}{LPJsim}(x, what = "annual", start = NA, end = NA, omit0 = TRUE, + AggFun = AggMeanNULL, ...)} +\arguments{ + \item{x}{an object of class 'LPJsim'} + \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} + \item{start}{first year for time series plot} + \item{end}{last year for time series plot} + \item{omit0}{omit variables from plotting that are only 0?} + \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.} + \item{\dots}{further arguments (currently not used)} +} +\details{No details.} + +\references{No reference.} +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{ReadLPJ2ts}}, \code{\link{ReadLPJsim}}} +\examples{ + +# setwd(path.mylpjresult) +# sim <- ReadLPJ2ts(start=1982, end=2011) +# plot(sim, what="annual") + +} diff --git a/LPJmLmdi/man/plot.rescue.Rd b/LPJmLmdi/man/plot.rescue.Rd new file mode 100644 index 0000000..5c94986 --- /dev/null +++ b/LPJmLmdi/man/plot.rescue.Rd @@ -0,0 +1,24 @@ +\name{plot.rescue} +\alias{plot.rescue} +\title{plot an object of class "rescue" / monitor OptimizeLPJgenoud} +\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)". } +\usage{\method{plot}{rescue}(x, ylim = NULL, xlim = NULL, ylab = "Cost", xlab = "Individuals of genetic optimization", + only.cost = FALSE, ...)} +\arguments{ + \item{x}{a list of class "rescue", see \code{\link{CombineRescueFiles}}} + \item{ylim}{limits of the y-axis of the plot} + \item{xlim}{limits of the x-axis of the plot} + \item{ylab}{label for the y axis} + \item{xlab}{label for the x axis} + \item{only.cost}{plot all integration datasets (TRUE) or only these ones with cost=TRUE} + \item{\dots}{further arguments for \code{\link{plot}}} +} +\details{No details.} + +\references{No reference. } +\author{Matthias Forkel [aut, cre]} + + + +\seealso{\code{\link{CombineRescueFiles}}} + diff --git a/LPJmLmdi_1.0.tar.gz b/LPJmLmdi_1.0.tar.gz new file mode 100644 index 0000000..b4fc978 Binary files /dev/null and b/LPJmLmdi_1.0.tar.gz differ diff --git a/LPJmLmdi_1.1.tar.gz b/LPJmLmdi_1.1.tar.gz new file mode 100644 index 0000000..5703ad7 Binary files /dev/null and b/LPJmLmdi_1.1.tar.gz differ diff --git a/LPJmLmdi_1.2.tar.gz b/LPJmLmdi_1.2.tar.gz new file mode 100644 index 0000000..e4884e7 Binary files /dev/null and b/LPJmLmdi_1.2.tar.gz differ diff --git a/LPJmLmdi_1.3.tar.gz b/LPJmLmdi_1.3.tar.gz new file mode 100644 index 0000000..396727f Binary files /dev/null and b/LPJmLmdi_1.3.tar.gz differ diff --git a/LPJmLmdi_1.31.tar.gz b/LPJmLmdi_1.31.tar.gz new file mode 100644 index 0000000..ef1066f Binary files /dev/null and b/LPJmLmdi_1.31.tar.gz differ diff --git a/LPJmLmdi_overview.ppt b/LPJmLmdi_overview.ppt new file mode 100644 index 0000000..b4097f8 Binary files /dev/null and b/LPJmLmdi_overview.ppt differ diff --git a/MANUAL.pdf b/MANUAL.pdf new file mode 100644 index 0000000..bdc7ce3 Binary files /dev/null and b/MANUAL.pdf differ diff --git a/R.sh b/R.sh new file mode 100644 index 0000000..b845914 --- /dev/null +++ b/R.sh @@ -0,0 +1,13 @@ +module purge +module load R +module load intel/2018.1 +module load netcdf +module load netcdf-c/4.2.1.1/serial +module list +module load udunits +module load json-c/0.13 +module load intel/2018.1 +module load R +unset I_MPI_DAPL_UD_PROVIDER +export R_LIBS_USER=/p/projects/biodiversity/R +R diff --git a/README.md b/README.md index 35a1657..6cec9fc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -# LPJmLmdi LPJmLmdi - model-data integration for the LPJmL dynamic global vegetation model (R package) 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. -Depends: R (>= 2.15.3), raster, plyr, rgenoud, fields, numDeriv, RColorBrewer, quantreg, snow +Depends: R (>= 2.15.3), raster, plyr, rgenoud, fields, numDeriv, RColorBrewer, quantreg, snow \ No newline at end of file diff --git a/slurm_opt.jcf b/slurm_opt.jcf new file mode 100644 index 0000000..0ad0beb --- /dev/null +++ b/slurm_opt.jcf @@ -0,0 +1,29 @@ +#!/bin/bash +#SBATCH --qos=short +#SBATCH --partition=broadwell +#SBATCH --ntasks=5 +#SBATCH --cpus-per-task=2 # for 64GB total +#SBATCH --job-name=LPJmLmdi +#SBATCH --workdir=/p/projects/biodiversity/drueke/LPJmLmdi/LPJmLmdi +##SBATCH --output=outfile.%j.out +##SBATCH --error=outfile.%j.err +#SBATCH --mail-type=end + +module purge +module load R +module load intel/2018.1 +module load netcdf +module load netcdf-c/4.2.1.1/serial +module list +module load udunits +module load json-c/0.13 +module load intel/2018.1 +module load mpi/intel/5.1.3 +module load R +#unset I_MPI_DAPL_UD_PROVIDER +export I_MPI_PMI_LIBRARY=/p/system/slurm/lib/libpmi.so +export R_LIBS_USER=/p/projects/biodiversity/R + +# call R +#R --no-save --file=.R --silent --slave +R CMD BATCH --vanilla inst_gldas/LPJmL-MDI_example_gldas.R ./optim_experiment.Rout