Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0300aeb
feat: uncertainty analysis quarto notebook
AritraDey-Dev Jul 13, 2025
3f84625
correct pecan.xml path
AritraDey-Dev Jul 13, 2025
5f53a2e
fix: setings path
AritraDey-Dev Jul 13, 2025
e75b1f4
add additional instructions on ensemble analysis
AritraDey-Dev Jul 13, 2025
e836f28
set ensemble run no to 50 for customization
AritraDey-Dev Jul 13, 2025
b94022e
added pecan.xml for example
AritraDey-Dev Jul 13, 2025
122ef77
updated changelog.md
AritraDey-Dev Jul 13, 2025
846dd5a
Merge branch 'develop' into quarto-ensemble-sensivity
dlebauer Jul 16, 2025
ad8ee17
feat: uncertainty analysis quarto notebook
AritraDey-Dev Jul 13, 2025
e9559ad
correct pecan.xml path
AritraDey-Dev Jul 13, 2025
30c1d3d
fix: setings path
AritraDey-Dev Jul 13, 2025
9c775c6
add additional instructions on ensemble analysis
AritraDey-Dev Jul 13, 2025
70eb78b
set ensemble run no to 50 for customization
AritraDey-Dev Jul 13, 2025
798f937
added pecan.xml for example
AritraDey-Dev Jul 13, 2025
fecc9ef
fix conflicts in changelog
AritraDey-Dev Sep 30, 2025
eca8ef7
fix pecan.xml
AritraDey-Dev Aug 26, 2025
d462fe7
added changes from demo1 in uncertainty analysis
AritraDey-Dev Aug 26, 2025
6a094b6
fixed a general path fordemo outdir
AritraDey-Dev Aug 26, 2025
253d3ec
Added a new section to the uncertainty analysis tutorial to visualiz…
AritraDey-Dev Oct 2, 2025
e386161
fixed results in plots
AritraDey-Dev Oct 2, 2025
7c13053
separate plot all the analysis
AritraDey-Dev Oct 4, 2025
2be4065
added back the section after 13
AritraDey-Dev Oct 4, 2025
1f9f0a2
fix: resolve conflicts in changelog
AritraDey-Dev Oct 4, 2025
e081921
fix numbering of the blocks
AritraDey-Dev Oct 4, 2025
44d39ae
merge
dlebauer Oct 7, 2025
b39c68e
Demo 2 streamline introduction (referring back to Demo 1) and clarify…
dlebauer Oct 7, 2025
6be59f8
Merge branch 'dlebauer-PR3570_updates' into quarto-ensemble-sensivity
AritraDey-Dev Oct 8, 2025
26d3369
fix: numbering of the code blocks
AritraDey-Dev Oct 8, 2025
ef7a38e
Merge branch 'develop' into quarto-ensemble-sensivity
AritraDey-Dev Oct 8, 2025
52f8a68
fix: add pdf files of uncertainty notebook to gitignore
AritraDey-Dev Oct 9, 2025
5994051
Merge branch 'PecanProject:develop' into quarto-ensemble-sensivity
AritraDey-Dev Oct 9, 2025
c0aeb50
fix documentation of demo 2
AritraDey-Dev Oct 13, 2025
4455803
migrating content from original demos to uncertainty.qmd and run_peca…
dlebauer Oct 15, 2025
4d483c4
Update documentation/tutorials/Demo_02_Uncertainty_Analysis/uncertain…
AritraDey-Dev Oct 16, 2025
31b8046
fix spacing
AritraDey-Dev Oct 16, 2025
09fa53c
Merge pull request #8 from dlebauer/quarto-ensemble-sensivity
AritraDey-Dev Oct 21, 2025
4682f82
migrate pecan outputs block from demo 1 to demo 2
AritraDey-Dev Oct 21, 2025
0a9957f
add changes in demo 2
AritraDey-Dev Oct 21, 2025
123c628
- Remove description of trait data and meta-analysis from uncertainty…
dlebauer Nov 11, 2025
0e54cb2
add self as co-author
dlebauer Nov 11, 2025
4193a99
Merge pull request #10 from dlebauer/uncertainty_demo_update
AritraDey-Dev Nov 15, 2025
b6a06c7
fix pft outdir path
AritraDey-Dev Nov 20, 2025
cf80986
Update CHANGELOG.md
AritraDey-Dev Nov 20, 2025
7ac3aa5
Update documentation/tutorials/Demo_02_Uncertainty_Analysis/uncertain…
AritraDey-Dev Nov 20, 2025
e3b2834
Update documentation/tutorials/Demo_02_Uncertainty_Analysis/uncertain…
AritraDey-Dev Nov 20, 2025
2d6c85a
Update documentation/tutorials/Demo_02_Uncertainty_Analysis/uncertain…
AritraDey-Dev Nov 20, 2025
fbf778b
Update documentation/tutorials/Demo_02_Uncertainty_Analysis/uncertain…
AritraDey-Dev Nov 20, 2025
22f5069
Update documentation/tutorials/Demo_02_Uncertainty_Analysis/uncertain…
AritraDey-Dev Nov 20, 2025
97c15b9
fix: output directory structure
AritraDey-Dev Nov 20, 2025
52e8db3
Update CHANGELOG.md
AritraDey-Dev Nov 22, 2025
628f626
allow multi variable outputs for ensemble analysis
AritraDey-Dev Nov 22, 2025
45553d2
change naming for outputs
AritraDey-Dev Nov 22, 2025
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,6 @@ contrib/modellauncher/modellauncher
# Ignore any folder named demo_outdir (Quarto notebook outputs)
**/demo_outdir/
dbfiles/
**/temperate.coniferous/
*.sensitivity.analysis.*.pdf
*.variance.decomposition.*.pdf
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ section for the next release.
- Directory structure for PEcAn Quarto notebooks under `pecan/documentation/tutorials/Demo_1_Basic_Run`
- Support for inspecting and plotting NetCDF output variables within the notebook workflow.
- added support for soil temperature, relative humidity, soil moisture, and PPFD downscaling to `met_temporal_downscale.Gaussian_ensemble`
- The PEcAn uncertainty analysis tutorial ("Demo 2") has been updated and reimplemented as a Quarto notebook at `documentation/tutorials/Demo_02_Uncertainty_Analysis/uncertainty.qmd`. (#3570)

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ authors:
affiliation: Boston University Software & Application Innovation Lab(SAIL)
- given-names: Akash BV
affiliation: CMR Institute of Technology, Bengaluru
- given-names: Aritra Dey
affiliation: National Institute of Technology, Tiruchirappalli

preferred-citation:
type: article
Expand Down
67 changes: 67 additions & 0 deletions documentation/tutorials/Demo_02_Uncertainty_Analysis/pecan.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<pecan>
<info>
<notes/>
<userid>-1</userid>
<username/>
<date>2025-06-19-15-34-01</date>
</info>
<outdir>demo_outdir</outdir>
<pfts>
<pft>
<name>temperate.coniferous</name>
<posterior.files>pft/temperate.coniferous/prior.distns.Rdata</posterior.files>
<outdir>pft/temperate.coniferous</outdir>
</pft>
</pfts>
<ensemble>
<size>50</size>
<variable>NPP</variable>
<samplingspace>
<parameters>
<method>halton</method>
</parameters>
</samplingspace>
<start.year>2004</start.year>
<end.year>2004</end.year>
</ensemble>
<sensitivity.analysis>
<quantiles>
<sigma>-1</sigma>
<sigma>1</sigma>
</quantiles>
<variable>NPP</variable>
<start.year>2004</start.year>
<end.year>2004</end.year>
</sensitivity.analysis>
<model>
<type>SIPNET</type>
<revision>1.3.0</revision>
<delete.raw>FALSE</delete.raw>
<binary>demo_outdir/sipnet</binary>
</model>
<run>
<site>
<met.start>2004/01/01</met.start>
<met.end>2004/12/31</met.end>
<name>Niwot Ridge Forest/LTER NWT1 (US-NR1)</name>
<lat>40.0329</lat>
<lon>-105.546</lon>
</site>
<inputs>
<met>
<source>AmerifluxLBL</source>
<output>SIPNET</output>
<username>Aritra_2004</username>
<path>
<path1>dbfiles/AMF_US-NR1_BASE_HH_23-5.2004-01-01.2004-12-31.clim</path1>
</path>
</met>
</inputs>
<start.date>2004/01/01</start.date>
<end.date>2004/12/31</end.date>
</run>
<host>
<name>localhost</name>
</host>
</pecan>
Binary file not shown.
555 changes: 555 additions & 0 deletions documentation/tutorials/Demo_02_Uncertainty_Analysis/uncertainty.qmd

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion documentation/tutorials/Demo_1_Basic_Run/download_sipnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if (os == "Linux") {
PEcAn.logger::logger.error("Unsupported operating system: ", os)
}

demo_outdir <- here::here("documentation/tutorials/Demo_1_Basic_Run/demo_outdir")
demo_outdir <- file.path("demo_outdir")
dest_path <- file.path(demo_outdir, "sipnet")
if (!dir.exists(demo_outdir)) {
# using if(!dir.exists) instead of `showWarnings = FALSE`
Expand Down
82 changes: 54 additions & 28 deletions documentation/tutorials/Demo_1_Basic_Run/run_pecan.qmd
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
---
title: "Running Ecosystem Simulations Using PEcAn"
author: "Aritra Dey"
author:
- "Aritra Dey"
- "David LeBauer"
format:
pdf:
toc: true
number-sections: false
number-sections: true
fig-width: 10
fig-height: 6
fig-dpi: 300
---

# 1. Introduction {#introduction}
# Introduction {#introduction}

Welcome to this PEcAn workflow notebook! This notebook will guide you through running an ecosystem model using PEcAn's programmatic interface.

## 1.1 What Is PEcAn?
## What Is PEcAn?

PEcAn (Predictive Ecosystem Analyzer) is a scientific workflow system designed to make ecosystem modeling more transparent, repeatable, and accessible. It helps researchers:

Expand All @@ -23,7 +25,7 @@ PEcAn (Predictive Ecosystem Analyzer) is a scientific workflow system designed t
- Compare model predictions with observations
- Share and reproduce scientific workflows

## 1.2 What This Notebook Does
## What This Notebook Does

This notebook demonstrates how to:

Expand All @@ -43,7 +45,7 @@ This run is based on a study by [Moore et. al. (2007)](https://doi.org/10.1016/j



## 1.3 Prerequisites
## Prerequisites

Before running this notebook, make sure you have:

Expand All @@ -62,7 +64,7 @@ install.packages('PEcAn.all')

- A valid `pecan.xml` configuration file or use the example provided: `pecan/documentation/tutorials/Demo_1_Basic_Run/pecan.xml`

## 1.4 How to Use This Notebook
## How to Use This Notebook

1. Each section is clearly marked with a heading
2. Code chunks are provided with explanations
Expand All @@ -73,15 +75,15 @@ install.packages('PEcAn.all')

This demo illustrates how to run a basic PEcAn workflow using an R-based Quarto notebook. It will cover loading settings, writing model configuration files, and running model simulations. This approach provides a programmatic alternative to the web-based PEcAn interface for executing ecosystem models.

# 2. Session Info
# Session Info

This section prints your R session information for reproducibility. Having this information at the beginning helps with debugging even if the notebook encounters errors later.

```{r version-info}
PEcAn.all::pecan_version()
```

# 3. Install SIPNET v1.3.0
# Install SIPNET v1.3.0

If you haven't already installed the SIPNET binary, you can do so by running the following code. This will download the SIPNET binary to `demo_outdir/sipnet` and make it executable.

Expand All @@ -98,7 +100,7 @@ source(

> Note: You can find the most recent version of the SIPNET binary at: [SIPNET GitHub Releases](https://github.com/PecanProject/sipnet/releases), but this notebook is designed to work with SIPNET v1.3.0.

# 4. Load PEcAn Packages
# Load PEcAn Packages

First, we need to load the PEcAn R packages. These packages provide all the functions we'll use to run the workflow.

Expand All @@ -107,7 +109,7 @@ First, we need to load the PEcAn R packages. These packages provide all the func
library("PEcAn.all")
```

# 5. Load PEcAn Settings File
# Load PEcAn Settings File

PEcAn uses an XML-based settings file (pecan.xml) to configure model runs. This file defines key information about the run including: PFT(s), site location, time period of the run, the location of input files and where outputs will be saved. Other settings outside the scope of this demo include the types of analyses that will be performed, how to connect to a database, and how to run it on a high performance computing cluster (we are using the default single model run on a single computer).

Expand All @@ -122,7 +124,7 @@ This is how PEcAn loads the settings file:
settings_path <- here::here("documentation/tutorials/Demo_1_Basic_Run/pecan.xml")
```

# 6. Prepare and Validate Settings
# Prepare and Validate Settings

After specifying the path to the `pecan.xml` file, the next step involves reading and preparing these settings. PEcAn provides utilities to process and validate the configurations before execution begins.

Expand All @@ -137,7 +139,7 @@ settings <- PEcAn.settings::read.settings(settings_path)
settings <- PEcAn.settings::prepare.settings(settings)
```

# 7. Explore the Settings Object
# Explore the Settings Object

Once the settings have been read and prepared, it is useful to inspect the structure of the `settings` object. This object is an R list containing all parameters and configurations for the PEcAn workflow.

Expand Down Expand Up @@ -165,7 +167,7 @@ settings$info <- list(

Editing the more interesting settings to change the PFT (`settings$pfts`) or extend the run (`settings$run$end.date`) is beyond the scope of this demo. You _could_ change the pft or the end date, but you would need a new file containing parameters for that PFT (`settings$pfts$pft$posterior.files`), or a climate file (`settings$run$met$path$path1`) that extends to the desired simulation period.

# 8. Create Output Directory
# Create Output Directory

Before running the workflow, we need to ensure that the output directory specified in the settings exists. This directory will store all the model outputs, configuration files, and results from the simulation.

Expand All @@ -175,9 +177,28 @@ Before running the workflow, we need to ensure that the output directory specifi
dir.create(settings$outdir, recursive = TRUE, showWarnings = FALSE)
```

# 9. Write Model Configuration Files

This step generates the model-specific configuration files that will be used to run the ecosystem model. The process involves:
The directory structure created by PEcAn for this demo run will look like this:

```
demo_outdir/ # Root output directory
├── run/ # Configuration & execution metadata
│ ├── runs.txt # List of run IDs (one per model realization)
│ ├── <runid>/ # Model-specific config copies (sometimes)
│ └── config.* # Generated model configs (e.g., SIPNET)
├── out/ # Raw model outputs by run ID
│ └── <runid>/ # E.g., daily or sub-daily SIPNET output files
```

The root output directory is defined here as `demo_outdir/` by `settings$outdir`. This directory contains log and record files from the PEcAn workflow. They provide a detailed record of how data was generated and are key components of the analysis metadata and provenance. These can be useful for debugging as well as for downstream analysis.

Key subdirectories include `run/` and `out/` that contain files used to configure and run the model, files generated by the underlying ecosystem model, and PEcAn standard outputs used in downstream analyses. These are described in subsequent sections.

Additional outputs include logs, a `STATUS` file that records the steps of the workflow along with timestamps and whether each step was successful, and a copy of the `pecan.*.xml` file.

# Write Model Configuration Files

This step generates the model-specific configuration files and scripts that will be used to run the ecosystem model. The process involves:

1. Disabling database write operations because we are not using a database
2. Generating SIPNET configuration files using the `runModule.run.write.configs()` function.
Expand All @@ -187,7 +208,7 @@ settings$database <- NULL # Disable database operations for this demo
settings <- PEcAn.workflow::runModule.run.write.configs(settings)
```

# 10. Run Model Simulations and Fetch Results
# Run Model Simulations and Fetch Results

This section executes the actual model simulations and retrieves the results. The process is managed by PEcAn's workflow system, which handles the execution of your chosen ecosystem model.

Expand All @@ -197,14 +218,18 @@ This section executes the actual model simulations and retrieves the results. Th
PEcAn.workflow::runModule_start_model_runs(settings)
```

# 11. Extract Model Results and Prepare for Analysis

This step generates raw model outputs in model-specific format (in this case, `sipnet.out`) as well as log files.

# Extract Model Results and Prepare for Analysis

After the model simulation completes, we need to extract the results and prepare them for analysis. This involves:

1. Reading the run ID
2. Setting up output paths
3. Defining time period
4. Loading model output
5. Convert to a standard format

```{r get-plot-vars}
runid <- as.character(read.table(paste(settings$outdir, "/run/", "runs.txt", sep = ""))[1, 1]) # Note: if you are using an xml from a run with multiple ensembles this line will provide only the first run id
Expand All @@ -223,7 +248,9 @@ model_output <- PEcAn.utils::read.output(
available_vars <- names(model_output)[!names(model_output) %in% c("posix", "time_bounds")]
```

# 12. Display Available Model Variables
Running this code will convert model specific output files into a standardized netCDF ([year].nc) that can be downloaded for visualization and analysis (R, Matlab, ncview, panoply, etc). This is a key step, because this standardization enables PEcAn to apply downstream analyses to outputs from different ecosystem models.

# Display Available Model Variables

This section shows all the variables that are available in the model output. These variables represent different ecosystem processes and states that the model has simulated.

Expand All @@ -246,11 +273,11 @@ vars_df$Description[is.na(vars_df$Description)] <- "(No description available)"
knitr::kable(vars_df, caption = "Model Output Variables and Descriptions")
```

# 13. Visualize Model Results
# Visualize Model Results

This section provides examples of how to create time series plots of different model variables. The examples cover various ecosystem processes including carbon fluxes, carbon pools, water variables, and structural variables like Leaf Area Index (LAI).

## 13.1 Plot Carbon Fluxes
## Plot Carbon Fluxes

```{r plot-carbon-fluxes}
# Plot Gross Primary Productivity (GPP) and Net Primary Productivity (NPP)
Expand All @@ -265,7 +292,7 @@ lines(model_output$posix, model_output$NPP, col = "blue")
legend("topright", legend = c("GPP", "NPP"), col = c("green", "blue"), lty = 1)
```

## 13.2 Plot Carbon Pools
## Plot Carbon Pools

```{r plot-carbon-pools}
# Plot Total Live Biomass and Total Soil Carbon
Expand All @@ -280,7 +307,7 @@ lines(model_output$posix, model_output$TotSoilCarb, col = "brown")
legend("topright", legend = c("Total Live Biomass", "Total Soil Carbon"), col = c("darkgreen", "brown"), lty = 1)
```

## 13.3 Plot Water Variables
## Plot Water Variables

```{r plot-water-variables}
# Plot Soil Moisture and Snow Water Equivalent
Expand All @@ -295,7 +322,7 @@ lines(model_output$posix, model_output$SWE, col = "lightblue")
legend("topright", legend = c("Soil Moisture", "Snow Water Equivalent"), col = c("blue", "lightblue"), lty = 1)
```

## 13.4 Plot LAI and Biomass
## Plot LAI and Biomass

```{r plot-lai-biomass}
# Plot Leaf Area Index (LAI) and Above Ground Wood
Expand All @@ -310,13 +337,13 @@ lines(model_output$posix, model_output$AbvGrndWood, col = "brown")
legend("topright", legend = c("LAI", "Above Ground Wood"), col = c("darkgreen", "brown"), lty = 1)
```

# 14. Conclusion
# Conclusion

This notebook demonstrated how to set up, run, and analyze a PEcAn ecosystem model workflow programmatically. You can now modify parameters, try different models, or extend the analysis as needed.

Try editing the `pecan.xml` file. Give it a new name and update the **settings_path** variable at the beginning of this Demo to point to the new file. See how the changes affect the model output!

# 15. Clean Up Workflow Output (Optional)
# Clean Up Workflow Output (Optional)

If you want to remove all files and directories created by this workflow and start fresh, you can run the following code. This will delete the entire output directory specified in your settings. **Use with caution!**

Expand All @@ -326,10 +353,9 @@ If you want to remove all files and directories created by this workflow and sta
# fs::dir_delete(settings$outdir)
```

# 16. Session Info
# Session Info
This section prints your R session information for reproducibility.

```{r session-info}
sessionInfo()
```

Loading