Skip to content

Commit

Permalink
completed forcing variable checks to avoid bug when netrad is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
stineb committed Aug 8, 2024
1 parent 31e69d3 commit b24963b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions R/run_pmodel_f_bysite.R
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ run_pmodel_f_bysite <- function(
"temp",
"rain",
"vpd",
"ppfd",
"netrad",
"fsun",
"snow",
"co2",
"fapar",
Expand Down Expand Up @@ -282,7 +285,7 @@ run_pmodel_f_bysite <- function(
}

# Check model parameters
if( sum( names(params_modl) %in% c('kphio', 'kphio_par_a', 'kphio_par_b',
if ( sum( names(params_modl) %in% c('kphio', 'kphio_par_a', 'kphio_par_b',
'soilm_thetastar', 'soilm_betao',
'beta_unitcostratio', 'rd_to_vcmax',
'tau_acclim', 'kc_jmax')
Expand All @@ -302,13 +305,13 @@ run_pmodel_f_bysite <- function(
in_netrad <- FALSE # net radiation is currently ignored as a model forcing, but is internally simulated by SPLASH.

# Check if fsun is available
if(! (in_ppfd & in_netrad)){
if (! (in_ppfd & in_netrad)){
# fsun must be available when one of ppfd or netrad is missing
if(any(is.na(forcing$fsun))) continue <- FALSE
if (any(is.na(forcing$fsun))) continue <- FALSE
}
}

if(continue){
if (continue){

# convert to matrix
forcing <- as.matrix(forcing)
Expand Down
1 change: 1 addition & 0 deletions vignettes/pmodel_use.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,4 @@ ggplot(data = df_gpp_plot) +
```

For details on the optimization settings we refer to the manuals of [GenSA](https://cran.r-project.org/package=GenSA) and [BayesianTools](https://github.com/florianhartig/BayesianTools).

0 comments on commit b24963b

Please sign in to comment.