Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
43 changes: 36 additions & 7 deletions analysis/legacy-params.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,30 @@ legacy_indicator_symbols <- c(
prepare_raw = "prepare.raw", convert_percent = "convert.percent", logit = "logit",
remove_zero_cover_plots = "remove.zero.cover.plots", scale_abundance = "scale.abund",
td_multiplier = "td.multiplier", td_multiplier_omit = "td.multiplier.omit",
exclude_exotics = "exclude.exotics", na_to_zero = "NA.TO.ZERO"
exclude_exotics = "exclude.exotics", na_to_zero = "NA.TO.ZERO",
multiplier = "ei.multiplier", normalize_area_m2 = "normalize.m2"
)

legacy_project_params <- function(config) {
values <- config[names(legacy_project_symbols)]
names(values) <- unname(legacy_project_symbols)
active <- unlist(config$active_indicators, use.names = FALSE)
active <- as.character(unlist(config$active_indicators, use.names = FALSE))
if (config$td_only) active <- "TD"
values$EI.vec <- active
values$EI.F.GROUPS <- cbind(
EI = active,
f.group = unname(unlist(config$indicator_groups[active]))
f.group = as.character(unlist(config$indicator_groups[active], use.names = FALSE))
)
values$df.EI.FG <- as.data.frame(values$EI.F.GROUPS)
values$EI.list <- data.frame(fname = active)
values$EI.agg.list <- data.frame(fname = unlist(config$aggregate_indicators, use.names = FALSE))
values$EI.agg.list <- data.frame(
fname = as.character(
unlist(
config$aggregate_indicators,
use.names = FALSE
)
)
)
nodata <- unlist(config$vegetation_without_data, use.names = FALSE)
values$veg.nodata <- if (length(nodata)) nodata else ""
values$ei.params <- function(ei_code) {
Expand All @@ -117,10 +125,17 @@ legacy_project_params <- function(config) {
if (is.null(parameters$td.multiplier)) parameters$td.multiplier <- NA
omit <- unlist(parameters$td.multiplier.omit, use.names = FALSE)
parameters$td.multiplier.omit <- if (length(omit)) omit else ""
parameters$ei.data.type <- if (ei_code %in% c("SR", "TD")) config$data_type else "cover"
parameters$ei.data.type <- if (!is.null(settings$data_type)) {
settings$data_type
} else if (ei_code %in% c("SR", "TD", "TS")) {
config$data_type
} else {
"cover"
}
inputs <- c(
SR = "speciesCover", TD = "speciesCover", PCGF = "coverByGrowthForm",
GC = "groundCover", PCESS = "exoticCoverByStratum"
SR = "speciesCover", TD = "speciesCover", TS = "speciesCover", PCGF = "coverByGrowthForm",
GC = "groundCover", PCESS = "exoticCoverByStratum", PCES = "exoticCoverByStratum",
BA = "speciesStems", ASC = "speciesStems"
)
parameters$df.input <- if (parameters$ei.data.type == "ind") {
"speciesStems"
Expand All @@ -139,5 +154,19 @@ legacy_project_params <- function(config) {
names(parameters) <- unname(symbols)
c(list(land.cover = land_cover), parameters)
}
if (!is.null(config$stem_sampling)) {
values$dbh.ba.scaled <- function(dbh, target_area_m2 = NULL) {
sampling <- config$stem_sampling
if (is.null(target_area_m2)) target_area_m2 <- 10000
dplyr::case_when(
dbh >= sampling$min_dbh_cm & dbh < sampling$split_dbh_cm ~
pi * ((dbh / 2)^2) / 10000 * target_area_m2 / sampling$small_plot_area_m2,
dbh >= sampling$split_dbh_cm ~
pi * ((dbh / 2)^2) / 10000 * target_area_m2 / sampling$large_plot_area_m2,
is.na(dbh) ~ NA,
.default = NA
)
}
}
values
}
2 changes: 1 addition & 1 deletion analysis/legacy.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ prepare_legacy_environment <- function(context = NULL, config = list(), seed = N
run_env$VQA_COMMON_PARAMS <- legacy_common_params(
if (is.null(context)) load_default_params() else config
)
if (!is.null(context) && identical(project, "vqa-demo1")) {
if (!is.null(context) && project %in% c("vqa-demo1", "vqa-demo2")) {
run_env$VQA_PROJECT_PARAMS <- legacy_project_params(config)
}
sys.source("params.R", envir = run_env, toplevel.env = run_env)
Expand Down
2 changes: 0 additions & 2 deletions data/vqa-demo1-min/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ active_indicators:
- PCGF
- GC
- PCESS
indicator_defaults:
scale_abundance: yes
source_plot_data_filename: vqa-demo1_data.accdb
40 changes: 25 additions & 15 deletions data/vqa-demo2-min/params.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
project: vqa-demo2-min

# Validation-only manifest for now.
# This is a declarative subset of params/params.vqa-demo2.R.
data_type: mixed
qh_method: empirical
td_only: false
include_plots_nodata: true

active_indicators:
- SR
- TS
- PCES
- PCGF
- BA
- ASC

bootstrap_reps: 10
min_plots: 4
omit_quality_hectares: false
functional_group_group_by: indicator_group
functional_group_method: generalized_mean
overall_quality_method: mixed
nodata_sd: 4
aggregate_indicators: [PCGF, ASC]
active_indicators: [SR, TS, PCES, PCGF, BA, ASC]
source_plot_data_filename: Demo_data_main.xlsx
indicator_settings:
SR:
data_type: cover
test_tail: both
ASC:
distribution: gamma
stem_sampling:
min_dbh_cm: 2.5
split_dbh_cm: 10
small_plot_area_m2: 48
large_plot_area_m2: 192
assessments:
offset_baseline:
active_indicators: []
aggregate_indicators: []
qh_method: assume.0
source_plot_data_filename: Demo_data_offsets.xlsx
offset_current:
source_plot_data_filename: Demo_data_offsets.xlsx
25 changes: 19 additions & 6 deletions docs/common-config-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ counts as a consumer because it decides which calculations or outputs run.

## Project analysis configuration

Demo 1 uses root defaults plus `data/vqa-demo1-min/params.yaml` for both assessments.
Both demo projects use root defaults plus their project `params.yaml` files.
`legacy_project_symbols` and `legacy_indicator_symbols` in `analysis/legacy-params.R`
map resolved settings to script parameters. The adapter derives indicator lists, groups,
input filenames, and the `ei.params()` and `nmds.params()` functions from that configuration.
Expand All @@ -89,23 +89,36 @@ input filenames, and the `ei.params()` and `nmds.params()` functions from that c
| `figure_type`, `plot_legends`, `legend_no_focal_benchmark`, `show_sample_sizes`, `legend_combined`, `plot_dists_fitted_grouped_rescaled`, `plot_dists_fitted_rescaled` | Distribution figures. |
| `indicator_defaults`, `indicator_settings`, `nmds`, `pcess_herbs_only`, `vegetation_without_data` | Indicator scripts, NMDS fitting, and workbook indicator metadata. |
| `min_plots`, `legacy_summary_area_ha`, `source_plot_data_filename`, `missing_exotic_status_assume_native` | Workbook metadata and preprocessing summaries. |
| `stem_sampling` and indicator `normalize_area_m2` | Basal-area normalization using the sampled area for each DBH size class. |

Both demo 1 assessments share the same settings. Their input tables determine the
assessment differences. Root defaults contain application settings and indicator
definitions; project YAML supplies data type, bootstrap count, aggregation choices,
aggregate indicators, herbs-only exotic cover, and abundance scaling.
aggregate indicators, and herbs-only exotic cover. Abundance scaling is a shared default,
with a separate setting for taxonomic distance.

Demo 2 analysis settings are supplied by `params/params.vqa-demo2.R`. Standalone commands
such as `import.R` and `qh.net.R` load project parameter scripts through `params.R`.
Callable demo 1 analysis supplies resolved project settings directly to that wrapper.
Demo 2 uses mixed data: species richness selects cover observations, taxonomic similarity
uses the project data type, and basal area and abundance by size class select stem records.
Basal area uses configured DBH sampling geometry; abundance by size class counts individuals
from standardized stem records. Indicator settings select the distributions, transformations,
and handling of missing observations.

The `offset_baseline` override explicitly selects `assume.0`, with no active or aggregate
indicators. Other assessments use empirical quality. Source-data labels for the offset
assessments are explicit overrides. Analysis settings do not depend on assessment-name
patterns. Baseline/offset relationships for net-quality calculations are not read by the
assessment analysis workflow.

Standalone commands such as `import.R` and `qh.net.R` load project parameter scripts through
`params.R`. Callable analysis supplies resolved project settings directly to that wrapper.

## Runtime and file conventions

Runtime arguments select the data root, assessment, and seed. Analysis operations reset
RNG seeds individually; NMDS has its own seed settings. Paths, input and output filenames,
and indicator lists are constructed in code. `params.R` defines application file conventions.

Raw filenames, import filters, include-file replacement, taxonomy/TNRS settings, and
Raw-data loading, import filters, include-file replacement, taxonomy/TNRS settings, and
net-quality calculations are separate from assessment analysis. Parameters such as
`allow.discrete`, `plot.mean`, `remove.grid`, and `VQA.XLS.NO.AREA` have no reads in the
active scripts and are retained for standalone caller compatibility.
Expand Down
38 changes: 37 additions & 1 deletion params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ indicator_defaults:
convert_percent: no
logit: no
remove_zero_cover_plots: no
scale_abundance: no
scale_abundance: yes
td_multiplier: ~
td_multiplier_omit: []
exclude_exotics: no
na_to_zero: yes
multiplier: 1
normalize_area_m2: false
indicator_settings:
SR:
name: Species Richness
Expand Down Expand Up @@ -119,12 +121,45 @@ indicator_settings:
has_stratum: yes
test_tail: upper
benchmark_value: 0
TS:
name: Taxonomic Similarity
distribution: Bet
quality_method: empirical
has_stratum: no
test_tail: lower
PCES:
name: Percent Cover Exotic Species
distribution: Bet
quality_method: fixed
has_stratum: no
test_tail: upper
benchmark_value: 0
BA:
name: Basal Area (m2/ha)
distribution: gamma
quality_method: empirical
has_stratum: no
test_tail: both
data_type: ind
normalize_area_m2: 10000
ASC:
name: Abundance by Size Class
distribution: NBin
quality_method: empirical
has_stratum: yes
test_tail: both
data_type: ind
na_to_zero: no
indicator_groups:
SR: composition
TD: composition
PCGF: structure
GC: function
PCESS: integrity
TS: composition
PCES: integrity
BA: structure
ASC: structure
nmds:
verbose: no
seed_enabled: yes
Expand All @@ -133,3 +168,4 @@ nmds:
dimensions: 3
max_iterations: 200
missing_exotic_status_assume_native: true
pcess_herbs_only: false
9 changes: 8 additions & 1 deletion pipeline/params.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ validate_params_schema <- function(params) {

validate_analysis_params <- function(params) {
validate_params_schema(params)
if (isTRUE(params$project %in% c("vqa-demo1", "vqa-demo1-min"))) {
if (isTRUE(params$project %in% c("vqa-demo1", "vqa-demo1-min", "vqa-demo2", "vqa-demo2-min"))) {
active <- unlist(params$active_indicators, use.names = FALSE)
if ((identical(params$qh_method, "empirical") && !length(active)) ||
!all(active %in% names(params$indicator_settings)) ||
Expand All @@ -58,6 +58,13 @@ validate_analysis_params <- function(params) {
call. = FALSE
)
}
if (code == "BA" && !isFALSE(settings$normalize_area_m2) && is.null(params$stem_sampling)) {
stop("Basal-area normalization requires stem sampling geometry.", call. = FALSE)
}
}
if (!is.null(params$stem_sampling) &&
params$stem_sampling$min_dbh_cm >= params$stem_sampling$split_dbh_cm) {
stop("The stem diameter split must exceed the minimum measured diameter.", call. = FALSE)
}
}
invisible(TRUE)
Expand Down
Loading
Loading