Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groundwork luluc (Biomee) #277

Draft
wants to merge 44 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bf3fc83
Implement dummy LULUC data structures
Dec 12, 2024
b291292
- Reworked internal data structures as groundwork for LULUC.
Dec 13, 2024
17efa3d
Merge branch 'master' into preparation_luluc
marcadella Dec 13, 2024
cd5ef56
Fix doc
Dec 13, 2024
a7c1929
Fix doc
Dec 13, 2024
f5db742
Wraper cleanup
Dec 13, 2024
3e8dfad
Simplify interface (init_soil)
Dec 16, 2024
8369003
Simplify interface (params_tile)
Dec 16, 2024
54e30b8
Simplify interface (params_species)
Dec 16, 2024
6f15d42
Add name to init_lu
Dec 16, 2024
9c018ea
Fix doc
Dec 16, 2024
c1ef978
Remove unused code
Dec 17, 2024
3f0110a
Simplify interface
Dec 17, 2024
2ac4016
Fix doc
Dec 17, 2024
c3d3e19
Minor
Dec 17, 2024
596b5be
Implement LULUC outputs
Dec 17, 2024
c9559ff
Fix issue with parallel run (due to flattening of arrays of dim 1) an…
Dec 18, 2024
e170e8d
Fix doc and make deprecated falgs less verbose.
Dec 19, 2024
f0d9bb1
Fix issue with runread_biomee not being able to deal with missing col…
Dec 19, 2024
687e4a5
Fix unit test hanging because spinup was engaged.
Dec 19, 2024
a85c6cb
Split sofun_r in two separate modules
Dec 19, 2024
657173e
Major refactoring:
Dec 19, 2024
6554b32
Fix test being verbose.
Dec 19, 2024
08ee685
Fix broken biomee p-model test
Dec 19, 2024
d668b70
Protect state from alteration in biosphere_annual
Dec 19, 2024
c6cbf8b
Remove unused code in get_steering
Jan 6, 2025
3657355
Code refactoring:
Jan 6, 2025
a686cfd
Implement outer loop for LULUC (so far, no effect on the pools)
Jan 6, 2025
943ef05
fixup! Implement outer loop for LULUC (so far, no effect on the pools)
Jan 6, 2025
30bd8f8
Add year in land use output, and fill in spinup too.
Jan 6, 2025
f5e4363
Add site info to myinterface to quiet down compile warning
Jan 6, 2025
cd67858
Add one vegn tile per LU, keeping memory separated for each.
Jan 7, 2025
4699699
Minor: cleanup units and initializations
Jan 7, 2025
a47212c
Minor: some more cleanup
Jan 7, 2025
a9574ca
Refactoring: use myinterface to get parameters rather than copying th…
Jan 7, 2025
77e0e12
Refactoring: minor clean-up (removed unused function reset_vegn_initial)
Jan 8, 2025
4e13ad9
Refactoring: minor clean-up
Jan 8, 2025
e86dcaf
Refactoring: minor clean-up
Jan 8, 2025
783339b
Factorize diagnostics out of cohorts
Jan 8, 2025
089d8f8
Removed flag update_annualLAImax as implementation was mutating param…
Jan 8, 2025
ed45512
Update news
Jan 9, 2025
3a39dc7
Refactoring: use function do generate derived variables rather using …
Jan 9, 2025
08591f8
Refactoring: factorize fast_fluxes in cohort
Jan 9, 2025
a03df9f
Refactoring: move cohort type to its own file. Functionalize in prepa…
Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

* new BiomeE behavior to recycle last year of forcing if requested simulation time span (`nyeartrend`) is longer than
available forcing data
* Breaking change: biomee drivers' `init_cohort$init_n_cohorts` column has been phased out and must not be present in
* Breaking changes in biomee drivers
* `init_cohort$init_n_cohorts` column has been phased out and must not be present in
drivers to protect against data corruption.
* `update_annualLAImax` flag was removed and the behavior is now slightly altered since `LAImax` and `underLAImax` are set and kept constant at the start of the simulation:
* `LAImax` takes value `max(LAI_light, 0.5)`
* `underLAImax` takes value `min(LAImax, 1.2)`

# rsofun v5.0.0

Expand Down
18 changes: 3 additions & 15 deletions R/cost_likelihood_biomee.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cost_likelihood_biomee <- function(
){

# predefine variables for CRAN check compliance
GPP <- LAI <- Density12 <- plantC <- error <- NULL
GPP <- LAI <- Density12 <- plantC <- NULL

# Add changed model parameters to drivers, overwriting where necessary.
drivers$params_species[[1]]$phiRL[] <- par[1]
Expand All @@ -65,21 +65,9 @@ cost_likelihood_biomee <- function(
parallel = FALSE
)

# did we spin up
spin_up <- drivers$params_siml[[1]]$spinup

# drop spinup years if activated
# see below
if (spin_up){
spin_up_years <- drivers$params_siml[[1]]$spinupyears + 1
} else {
spin_up_years <- 0
}

# Aggregate variables from the model df taking the last 500 yrs
# if spun up
# Aggregate variables from the model df taking the last 50 yrs (up to)
df <- df$data[[1]]$output_annual_tile |>
utils::tail(500 - spin_up_years) |>
utils::tail(50) |>
dplyr::summarise(
GPP = mean(GPP),
LAI = stats::quantile(LAI, probs = 0.95, na.rm=TRUE),
Expand Down
26 changes: 11 additions & 15 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,14 @@
#' \item{params_siml}{Simulation parameters as a data.frame, including
#' the following data:
#' \describe{
#' \item{spinup}{Flag indicating whether this simulation does spin-up.}
#' \item{spinupyears}{Number of spin-up years.}
#' \item{spinup}{Flag indicating whether this simulation does spin-up (deprecated).}
#' \item{spinupyears}{Number of spin-up years. Set to 0 for no spinup.}
#' \item{recycle}{Number of first N years of forcing data.frame that are recycled for spin-up.}
#' \item{firstyeartrend}{Year of first transient year (AD) (optional). Is only used to set years in output data frames. Defaults to 0 if not provided.}
#' \item{nyeartrend}{Number of transient years (optional). Determines the length of simulation output after spin-up. Defaults to number of years contained in the forcing data. (If longer than forcing data, last year of forcing is repeated until the end (spin-down).)}
#' \item{steps_per_day}{Time resolution of the forcing (day-1).}
#' \item{do_U_shaped_mortality}{Flag indicating whether U-shaped
#' mortality is used.}
#' \item{update_annualLAImax}{Flag indicating whether updating
#' LAImax according to mineral N in soil.}
#' \item{do_closedN_run}{Flag indicating whether doing N closed
#' runs to recover N balance enforcing 0.2 kg N m-2 in the inorganic N pool.}
#' \item{code_method_photosynth}{String specifying the method of photosynthesis
Expand Down Expand Up @@ -285,7 +283,7 @@
#' \item{betaOFF}{Critical soil moisture for phenology offset.}
#' \item{seedlingsize}{Initial size of seedlings, in kg C per individual.}
#' \item{LNbase}{Basal leaf N per unit area, in kg N m\eqn{^{-2}}.}
#' \item{lAImax}{Maximum crown LAI (leaf area index).}
#' \item{lAImax}{Maximum crown LAI (leaf area index) (not used, see LAI_light).}
#' \item{Nfixrate0}{Reference N fixation rate (kg N kg C\eqn{^{-1}} root).}
#' \item{NfixCost0}{Carbon cost of N fixation (kg C kg N\eqn{^{-1}}).}
#' \item{phiCSA}{Ratio of sapwood area to leaf area.}
Expand Down Expand Up @@ -356,16 +354,14 @@
#' Dataset. https://doi.org/10.18140/FLX/1440134
"biomee_validation"

#' rsofun BiomeE (P-model) output data
#'
#' Example output dataset from a BiomeE-model run (p-model)
#' See \code{\link{run_biomee_f_bysite}} for a detailed
#' description of the outputs.
"biomee_p_model_output"

#' rsofun BiomeE (gs_leuning) output data
#'
#' Example output dataset from a BiomeE-model run (gs_leuning)
#' See \code{\link{run_biomee_f_bysite}} for a detailed
#' description of the outputs.
#' Example output dataset from a BiomeE-model run using divers \code{\link{biomee_gs_leuning_drivers}}
#' See \code{\link{run_biomee_f_bysite}} for a detailed description of the outputs.
"biomee_gs_leuning_output"

#' rsofun BiomeE (P-model) output data
#'
#' Example output dataset from a BiomeE-model run using divers \code{\link{biomee_p_model_drivers}}
#' See \code{\link{run_biomee_f_bysite}} for a detailed description of the outputs.
"biomee_p_model_output"
Loading
Loading