-
Notifications
You must be signed in to change notification settings - Fork 314
Refactor the baseline Validation Pipeline to align with GSoC Architecture #4017
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
Merged
dlebauer
merged 35 commits into
PecanProject:develop
from
ayushman1210:gsoc/phase2-architecture
Jul 2, 2026
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
7df98d9
feat(benchmark): add run_benchmark MVP with alignment, metrics, and t…
anshul23102 b2731cd
feat(benchmark): add tests and update README with quickstart
anshul23102 6769cf9
docs(benchmark): add roxygen man page for run_benchmark
anshul23102 f2aa206
docs(benchmark): add man pages and update NAMESPACE
anshul23102 d53d372
fix(benchmark): fix NAMESPACE export and run_benchmark.Rd usage format
anshul23102 d56416b
fix(benchmark): use multi-line usage format and fix author name
anshul23102 4df7daf
refactor(benchmark): dataframe-first API, add bm_validate/compute_met…
anshul23102 bac2138
docs(benchmark): add man pages for bm_validate, compute_metrics, plot…
anshul23102 1a77447
fix(benchmark): use .data$ in aes() to fix R CMD check NOTE
anshul23102 0887a47
Phase 2: Refactor benchmark pipeline and add data intake API
ayushman1210 403a564
Merge branch 'develop' into gsoc/phase2-architecture
ayushman1210 954b123
Merge branch 'develop' into gsoc/phase2-architecture
ayushman1210 a96665d
Merge branch 'develop' into gsoc/phase2-architecture
ayushman1210 4b6baef
Merge branch 'develop' into gsoc/phase2-architecture
ayushman1210 760c455
Merge branch 'develop' into gsoc/phase2-architecture
ayushman1210 e24195b
used baseR findInterval() funct
ayushman1210 3877574
Merge branch 'develop' into gsoc/phase2-architecture
ayushman1210 67d3f33
Address maintainer review comments for validation framework PR
ayushman1210 4eaf221
Expand dataframe passthrough and add PMU/Coverage metrics
ayushman1210 d5f38d7
Merge branch 'develop' into gsoc/phase2-architecture
ayushman1210 f7e0c99
Refactor Phase 2: Standardize Roxygen docs and integrate NetCDF loade…
ayushman1210 014fb3e
update namespace
divine7022 e1edfbe
update align_by_time.Rd
divine7022 09ac45a
update compute_metrics.Rd
divine7022 00e9c7d
update load_x_netcdf.Rd
divine7022 d97792d
plot_time_series.Rd
divine7022 1cbeec9
add metric_Coverage.Rd
divine7022 98d7eac
metric_PMU.Rd
divine7022 e627d97
add pecan_metric_registry.Rd
divine7022 21d749f
add register_metric.Rd
divine7022 756ec13
update load_x_netcdf.Rd
divine7022 0df39d7
update docker depends
divine7022 dc4eecd
add yaml to desc
divine7022 33ab7f9
Merge remote-tracking branch 'origin/develop' into gsoc/phase2-archit…
divine7022 656e298
remove hand edited load_x_netcdf.Rd and auto gen
divine7022 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| #' Load and standardize arbitrary tabular data using a YAML mapping configuration | ||
| #' | ||
| #' @param data.path character, file path to the tabular data (e.g. .csv) | ||
| #' @param mapping.path character, file path to the YAML mapping configuration | ||
| #' @return A standardized data frame with column names mapped to PEcAn standard vocabulary | ||
| #' @export | ||
| #' @importFrom yaml read_yaml | ||
| #' @importFrom dplyr rename | ||
| load_and_map_data <- function(data.path, mapping.path) { | ||
| # Load the YAML mapping first to know which variables we need | ||
| # The YAML should look like: | ||
| # variables: | ||
| # airT: TA_F | ||
| # NEE: NEE_PI | ||
| mapping <- yaml::read_yaml(mapping.path) | ||
|
|
||
| if (is.null(mapping$variables)) { | ||
| PEcAn.logger::logger.severe("YAML mapping must contain a 'variables' section.") | ||
| } | ||
|
|
||
| # Create a named vector for dplyr::rename (new_name = old_name) | ||
| rename_vector <- unlist(mapping$variables) | ||
| required_vars <- unname(rename_vector) | ||
|
|
||
| # Load the raw data based on file extension | ||
| if (grepl("\\.nc$", data.path, ignore.case = TRUE)) { | ||
| # If NetCDF, we only load the variables requested in the YAML mapping | ||
| # Assuming standard NA string representations for now, can be expanded via YAML | ||
| dat <- load_x_netcdf(data.path, format = list(na.strings = c("-9999", "-9999.0", "NA")), site = NULL, vars = required_vars) | ||
| } else { | ||
| # Default to CSV | ||
| dat <- utils::read.csv(data.path, as.is = TRUE, check.names = FALSE) | ||
| } | ||
|
|
||
| # Only rename columns that exist in the raw data | ||
| valid_renames <- rename_vector[rename_vector %in% colnames(dat)] | ||
|
|
||
| # Apply renaming | ||
| if (length(valid_renames) > 0) { | ||
| # dplyr::rename syntax expects: rename(df, new_name = old_name) | ||
| # Using tidy evaluation with !!! | ||
| dat <- dplyr::rename(dat, !!!valid_renames) | ||
| } else { | ||
| PEcAn.logger::logger.warn("No matching columns found in the dataset to map.") | ||
| } | ||
|
|
||
| return(dat) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #' @name metric_Coverage | ||
| #' @title Prediction Interval Coverage | ||
| #' @export | ||
| #' @param dat dataframe with columns `model_q025` and `model_q975` | ||
| #' @param ... ignored | ||
| #' @return A numeric value representing the fraction of observations that fall within the 95% prediction interval. | ||
| #' @details | ||
| #' Measures the fraction of observations that fall within the model's | ||
| #' stated 95% prediction interval. | ||
|
|
||
| metric_Coverage <- function(dat, ...) { | ||
| if (!"model_q025" %in% names(dat) || !"model_q975" %in% names(dat)) { | ||
| PEcAn.logger::logger.severe("Metric Coverage requires 'model_q025' and 'model_q975' columns in the dataset.") | ||
| } | ||
|
|
||
| PEcAn.logger::logger.info("Metric: Prediction Interval Coverage") | ||
|
|
||
| valid <- !is.na(dat$obvs) & !is.na(dat$model_q025) & !is.na(dat$model_q975) | ||
| covered <- dat$obvs[valid] >= dat$model_q025[valid] & dat$obvs[valid] <= dat$model_q975[valid] | ||
|
|
||
| return(mean(covered)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #' @name metric_PMU | ||
| #' @title Predictive Model Uncertainty (PMU) | ||
| #' @export | ||
| #' @param dat dataframe with columns `obs_se` and `obs_n` | ||
| #' @param ... ignored | ||
| #' @return A numeric value representing the pooled measurement uncertainty. | ||
| #' @details | ||
| #' Calculates the pooled measurement uncertainty. | ||
| #' Requires `obs_se` (standard error) and `obs_n` (replicate counts) in the observation data. | ||
|
|
||
| metric_PMU <- function(dat, ...) { | ||
| if (!"obs_se" %in% names(dat) || !"obs_n" %in% names(dat)) { | ||
| PEcAn.logger::logger.severe("Metric PMU requires 'obs_se' and 'obs_n' columns in the dataset.") | ||
| } | ||
|
|
||
| PEcAn.logger::logger.info("Metric: Predictive Model Uncertainty (PMU)") | ||
|
|
||
| # Calculate pooled standard error | ||
| # Formula: sqrt(sum(SE^2 * n) / sum(n)) | ||
| valid <- !is.na(dat$obs_se) & !is.na(dat$obs_n) | ||
|
|
||
| se2_n <- (dat$obs_se[valid]^2) * dat$obs_n[valid] | ||
| pooled_var <- sum(se2_n) / sum(dat$obs_n[valid]) | ||
|
|
||
| return(sqrt(pooled_var)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.