Skip to content

Commit

Permalink
1. Add full @param descriptions for adjust.biomass.LPJGUESS, `AbvGr…
Browse files Browse the repository at this point in the history
…ndWood`, `TotalCarbon`;

2. Fix the hard code `npatches <- 5` in `read_state.R`
  • Loading branch information
yinghaoSunn committed Feb 25, 2025
1 parent a25c556 commit a20561f
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 26 deletions.
10 changes: 5 additions & 5 deletions models/lpjguess/R/adjust.biomass.LPJGUESS.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
##' adjustments to the litter pools.
##'
##' @param individual A nested list which encapsulates an LPJ-GUESS 'Individual' as read from a binary state file
##' @param rel.change A numeric by which to scale the density and C and N pools
##' @param biomass.inc A numeric value specifying the biomass increment to be applied.
##' @param sla The SLA (specific leaf area) (per PFT parameter)
##' @param k_latosa The leaf area to sapwood area ratio (per PFT parameter)
##' @param k_allom2,k_allom3, Allometry coefficients (per PFT parameters)
##' @param wooddens Wood density (kgC/m^2) (per PFT parameter)
##' @param crownarea_max Maximum allowed crown area (m^2) (per PFT parameter)
##' @param lifeform An integer code for the lifeform of this individual (cohort): 1 = Tree, 2 = Grass
##' @param k_latosa The leaf area to sapwood area ratio (per PFT parameter)
##' @param k_allom2,k_allom3, Allometry coefficients (per PFT parameters)
##' @param trace Logical; if TRUE, prints details of biomass adjustment process.
##'
##' The changes in C pools are determined by the allocation. The changes in the N pools are designed to
##' maintain the pre-exisiing C:N ratios, so N is just scaled using the updated C with the initial C:N ratio.
Expand All @@ -27,7 +27,7 @@
##' @keywords internal
##' @return the scaled 'individual' (the initial nested list with update values)
##' @author Matthew Forrest
adjust.biomass.LPJGUESS <- function(individual, biomass.inc, sla, wooddens, lifeform, k_latosa, k_allom2, k_allom3, trace = TRUE){
adjust.biomass.LPJGUESS <- function(individual, biomass.inc, sla, wooddens, lifeform, k_latosa, k_allom2, k_allom3, trace = TRUE){

# dummy input values to the allocation function below
# note that they are not actually updated by the function, the updated values are in the returned list
Expand Down
8 changes: 4 additions & 4 deletions models/lpjguess/R/read_state.R
Original file line number Diff line number Diff line change
Expand Up @@ -480,10 +480,10 @@ read_binary_LPJGUESS <- function(outdir, version = "PalEON"){
paramh_name <- paste0("parameters.", version, ".h")
paramh_in <- readLines(con = system.file(paramh_name, package = "PEcAn.LPJGUESS"), n = -1)

### these are the values read from params.ins, passed to this fcn
#paramsins <- readLines(file.path(rundir, "params.ins"), n = -1)
#npatches <- as.numeric(gsub(".*([0-9]+).*$", "\\1", paramsins[grepl("npatch", paramsins, fixed = TRUE)]))
npatches <- 5
## these are the values read from params.ins, passed to this fcn
paramsins <- readLines(file.path(rundir, "params.ins"), n = -1)
npatches <- as.numeric(gsub(".*([0-9]+).*$", "\\1", paramsins[grepl("npatch", paramsins, fixed = TRUE)]))
#npatches <- 5

######################################
## read meta.bin
Expand Down
20 changes: 16 additions & 4 deletions models/lpjguess/R/update.state.LPJGUESS.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
##' Calculate Above Ground Woody Biomass

##' @title AbvGrndWood
##'
##' @description Calculates the above-ground woody biomass of an LPJ-GUESS individual.
##'
##' @param individual A nested list representing an LPJ-GUESS individual from a binary state file.
##' @param include.debt Logical; if TRUE, includes carbon mass debt in the calculation.
##'
##' @return A numeric value representing the above-ground woody biomass (kgC/m²).
##' @keywords internal
AbvGrndWood <- function(individual, include.debt = TRUE){

Expand All @@ -15,8 +21,14 @@ AbvGrndWood <- function(individual, include.debt = TRUE){

}

##' Calculate Above Ground Woody Biomass

##' @title TotalCarbon
##'
##' @description Calculates the total carbon content of an LPJ-GUESS individual.
##'
##' @param individual A nested list representing an LPJ-GUESS individual from a binary state file.
##' @param include.debt Logical; if TRUE, includes carbon mass debt in the calculation.
##'
##' @return A numeric value representing the total carbon content (kgC/m²).
##' @keywords internal
TotalCarbon <- function(individual, include.debt = TRUE){

Expand Down
12 changes: 10 additions & 2 deletions models/lpjguess/man/AbvGrndWood.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions models/lpjguess/man/TotalCarbon.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions models/lpjguess/man/adjust.biomass.LPJGUESS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a20561f

Please sign in to comment.