pecan
pecan copied to clipboard
Fix(uncertainty): allow explicit MCMC and distribution paths; avoid o…
Title: fix(uncertainty): allow explicit MCMC and distribution paths; avoid overloading pft$outdir as an input
What was fixed or enhanced:
get.parameter.samples()implicitly treatedpft$outdiras an input source for bothpost.distns.Rdataandtrait.mcmc.Rdata. This forced read-only calibration artifacts to be placed/mixed in output directories. The function now supports explicit, per‑PFT input paths and only falls back topft$outdirwhen nothing is provided.
Why the change was necessary:
- To separate immutable input artifacts (posterior distributions and MCMC samples) from workflow outputs and to align with the intent that
pft$outdiris primarily for outputs. This reduces confusion and accidental overwrites and enables using externally curated calibration results without copying them into PEcAn’s output tree.
What exact changes were made:
- Updated
modules/uncertainty/R/get.parameter.samples.Rto:- Accept
posterior.filesas either a vector of distribution files (backward compatible) or a list of lists per PFT with named entriesdistributionand/ormcmc. - If
posterior.files[[i]]$mcmcis provided, load that MCMC directly and skip anypft$outdir/DB fallback; preserve PDA correlation handling. - If
posterior.files[[i]]$distributionis provided, load it directly; otherwise, fall back to the most recentpost.distns.Rdatainpft$outdir, thenprior.distns.Rdata. - Added roxygen comments documenting the new accepted structure while keeping the old behavior working.
- Accept
How it improves the project:
- Decouples input data locations from output directories, reducing accidental mixing of inputs/outputs and enabling cleaner workflows, especially when posteriors are generated offline.
Verification steps:
- Provide explicit paths for a single PFT:
settings <- PEcAn.settings::read.settings('pecan.xml')
posterior.files <- list(list(
distribution = '/path/to/post.distns.Rdata',
mcmc = '/path/to/trait.mcmc.Rdata'
))
PEcAn.uncertainty::get.parameter.samples(settings, ensemble.size = 3, posterior.files = posterior.files)
- Confirm that
samples.Rdatais written undersettings$outdirand that no files are read frompft$outdirwhen explicit paths are provided. - Backward compatibility: call with
posterior.files = NAand confirm previous fallback behavior still works.
Next steps (optional, not included in this PR):
- Consider moving MA/SA output directories to
settings$meta.analysisandsettings$sensitivity.analysisblocks respectively, to fully eliminate the input/output overloading risk.
Modified Files
modules/uncertainty/R/get.parameter.samples.R✅ push
No config or environment files were added.