Update NEE and LE gap-fill functions#3883
Conversation
| @@ -0,0 +1,589 @@ | |||
| utils::globalVariables(c( | |||
There was a problem hiding this comment.
I'd strongly recommend agains setting global variables
| #' | ||
| #' @param site.dir character: path to the site information table. | ||
| #' @param n_sites numeric: number of sites to keep from the site table, | ||
| #' the total number of sites is 241. |
There was a problem hiding this comment.
I'd drop this specific number, as it's likely to change in the future
| #' @return character vector of selected site IDs. Example: 'Site ID' CA-ARB | ||
| #' | ||
| #' @author Yang Gu | ||
| read_site_ids <- function(site.dir, n_sites = 40) { |
There was a problem hiding this comment.
Remember that this code is becoming part of the overall PEcAn codebase, and in that context site_id means something different. I'd recommend a slight renaming to include fluxnet in the function name
| #' @return data.frame containing filtered predictor/flux data. | ||
| #' | ||
| #' @author Yang Gu | ||
| read_pred_data <- function(pred.var.dir, site_ids) { |
There was a problem hiding this comment.
similar request to make the function name more specific, such as read_flux_gapfill_covariates
| #' } | ||
| #' | ||
| #' @author Yang Gu | ||
| build_sitecov_df <- function(resimet.df, |
There was a problem hiding this comment.
| build_sitecov_df <- function(resimet.df, | |
| build_fluxnet_sitecov_df <- function(resimet.df, |
Co-authored-by: Michael Dietze <dietze@bu.edu>
| #' @export | ||
| #' @author Shawn Serbin, Michael Dietze | ||
| model2netcdf.SIPNET <- function(outdir, sitelat, sitelon, start_date, end_date, delete.raw = FALSE, revision = NULL, prefix = "sipnet.out", | ||
| overwrite = TRUE, conflict = FALSE) { |
There was a problem hiding this comment.
If this is a local debugging change I'd exclude it from a PR. Probably better to change this through the settings, not through a hard-coded change in the default.
| @@ -0,0 +1,158 @@ | |||
| # loading libraries | |||
There was a problem hiding this comment.
This creates a new high-level folder called "local" without group discussion or a clear definition for what should go in such a folder. I'd recommend git mving this to the SDA inst/ folder for now.d
| @@ -93,31 +121,91 @@ model2netcdf.SIPNET <- function(outdir, sitelat, sitelon, start_date, end_date, | |||
| timestep.s <- 86400 / out_day | |||
|
|
|||
|
|
|||
There was a problem hiding this comment.
you probably want to avoid committing random whitespace changes unless there's an actual reason for them
| output[["litter_N"]] <- sub.sipnet.output$litterN | ||
| } | ||
| if ("n2o" %in% names(sub.sipnet.output)) { | ||
| output[["N2O_flux"]] <- PEcAn.utils::ud_convert(sub.sipnet.output$n2o, "g/m2", "kg/m2") / timestep.s |
There was a problem hiding this comment.
could you explain the proposed changes in file conflict handling?
| if ("mineral_N" %in% names(output)) { | ||
| nc_var[["mineral_N"]] <- ncdf4::ncvar_def("mineral_N", units = "kg N m-2", | ||
| dim = list(lon, lat, t), missval = -999, longname = "Soil mineral nitrogen") | ||
| dim = list(lon, lat, t), missval = -999, longname = "Soil mineral nitrogen") |
There was a problem hiding this comment.
please revert whitespace change so as to avoid long lines
| runid), start.year = lubridate::year(stop.time), end.year = lubridate::year(stop.time), | ||
| variables = c(state.vars, "time_bounds")) | ||
|
|
||
| # 4) 若关键变量缺失,直接给出可读的报错信息(避免在 ud_convert 里才崩) |
There was a problem hiding this comment.
please limit code comments to English
| last <- which(as.Date(real_time) == as.Date(stop.time))[length(which(as.Date(real_time) == | ||
| as.Date(stop.time)))] | ||
|
|
||
| # print("breakpoint3") |
There was a problem hiding this comment.
I'd recommend against committing debugging info
| ) | ||
| } | ||
| } | ||
| ## Delete this |
| for(i in 1:block$constant$YN) { | ||
| valueInCompiledNimbleFunction(Cmcmc$samplerFunctions[[samplerNumberOffset+i]], 'toggle', 0) | ||
| } | ||
| ## Revise 2: Delete this |
| if (all(names.sampler %in% names.site.input)) { | ||
| input_design <- PEcAn.uncertainty::generate_joint_ensemble_design(settings = settings[[i]], | ||
| ensemble_samples = ensemble.samples, | ||
|
|
There was a problem hiding this comment.
not clear why this line was removed
Description
Motivation and Context
Review Time Estimate
Types of changes
Checklist: