Skip to content

Update NEE and LE gap-fill functions#3883

Open
Amedieus wants to merge 18 commits into
PecanProject:developfrom
Amedieus:develop
Open

Update NEE and LE gap-fill functions#3883
Amedieus wants to merge 18 commits into
PecanProject:developfrom
Amedieus:develop

Conversation

@Amedieus
Copy link
Copy Markdown

@Amedieus Amedieus commented Mar 19, 2026

Description

Motivation and Context

Review Time Estimate

  • Immediately
  • Within one week
  • When possible

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • My name is in the list of CITATION.cff
  • I agree that PEcAn Project may distribute my contribution under any or all of
    • the same license as the existing code,
    • and/or the BSD 3-clause license.
  • I have updated the CHANGELOG.md.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Amedieus Amedieus requested a review from mdietze March 20, 2026 00:14
@mdietze mdietze requested review from DongchenZ and ankurdesai March 20, 2026 17:51
@@ -0,0 +1,589 @@
utils::globalVariables(c(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar request to make the function name more specific, such as read_flux_gapfill_covariates

#' }
#'
#' @author Yang Gu
build_sitecov_df <- function(resimet.df,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
build_sitecov_df <- function(resimet.df,
build_fluxnet_sitecov_df <- function(resimet.df,

Comment thread modules/data.land/R/SIPNET_flux_gapfill.R Outdated
#' @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) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread local/sda_runner.R
@@ -0,0 +1,158 @@
# loading libraries
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably want to avoid committing random whitespace changes unless there's an actual reason for them

Comment thread models/sipnet/R/model2netcdf.SIPNET.R Outdated
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 里才崩)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend against committing debugging info

)
}
}
## Delete this
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

for(i in 1:block$constant$YN) {
valueInCompiledNimbleFunction(Cmcmc$samplerFunctions[[samplerNumberOffset+i]], 'toggle', 0)
}
## Revise 2: Delete this
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

if (all(names.sampler %in% names.site.input)) {
input_design <- PEcAn.uncertainty::generate_joint_ensemble_design(settings = settings[[i]],
ensemble_samples = ensemble.samples,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not clear why this line was removed

@github-actions github-actions Bot added the base label May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants