Skip to content

Commit 0f0de9d

Browse files
committed
Add PEcAn-to-ILAMB GeoTIFF conversion pipeline (GH-4019)
Adds a Python pipeline in PEcAn.benchmark to convert downscaled SDA reanalysis GeoTIFF ensemble maps into ILAMB-compatible CF-1.8 netCDF for cVeg, cSoil, mrsol, and lai, with unit conversions and 13 unit tests.
1 parent e52c594 commit 0f0de9d

6 files changed

Lines changed: 542 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ For more information about this file see also [Keep a Changelog](http://keepacha
99
## Unreleased
1010

1111
### Added
12+
- Added `inst/ilamb/` pipeline in PEcAn.benchmark to convert downscaled SDA reanalysis GeoTIFFs into ILAMB-compatible CF netCDF for carbon-cycle benchmarking (#4019).
1213
- Added PEcAn.PEPRMT model, including a demo run with example data
1314
- Add `format_try_for_ma()` and `try_trait_mapping()` to `PEcAn.data.remote` to convert trait data from the external TRY database into the tabular format required by the PEcAn meta-analysis module (#3717).
1415
- Add function `qsub_sda()` for submitting SDA batch jobs by splitting a large number of sites into multiple small groups of sites (#3634).

CITATION.cff

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ authors:
3030
- given-names: David LeBauer
3131
affiliation: University of Arizona
3232
orcid: 'https://orcid.org/0000-0001-7228-053X'
33+
- given-names: Tejas Dahiya
3334
- given-names: Michael Dietze
3435
orcid: 'https://orcid.org/0000-0002-2324-2518'
3536
affiliation: Boston University

modules/benchmark/NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# PEcAn.benchmark 1.7.5.9000
22

3+
## Added
4+
5+
* Added Python pipeline (`inst/ilamb/`) to convert PEcAn SDA reanalysis GeoTIFFs to ILAMB-compatible CF netCDF (cVeg, cSoil, mrsol, lai) with unit tests (#4019).
6+
37
## Fixed
48

59
* `metric_PPMC()`: added `use = "pairwise.complete.obs"` to `stats::cor()` so the Pearson correlation is computed on available pairs rather than returning `NA` whenever any observation is missing. This matches the behaviour of `metric_cor()` in the same package.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# PEcAn-to-ILAMB Conversion
2+
3+
Converts PEcAn SDA carbon reanalysis outputs (downscaled GeoTIFF ensemble maps)
4+
into ILAMB-compatible CF-convention netCDF files for benchmarking against
5+
TRENDY, CMIP, and observational datasets.
6+
7+
## Overview
8+
9+
The PEcAn North American carbon reanalysis (Zhang et al. 2026) provides
10+
downscaled 1 km ensemble maps of four state variables. This tool reads those
11+
GeoTIFFs, computes the ensemble mean, coarsens to ILAMB's default 0.5 degree
12+
resolution, applies unit conversions, and writes CF-1.8 compliant netCDF that
13+
ILAMB can ingest directly.
14+
15+
## Input
16+
17+
GeoTIFF ensemble maps organized as:
18+
19+
```
20+
<input_dir>/<year>/<variable>_<year>/ensemble_<n>_<year>_<variable>.tiff
21+
```
22+
23+
- 13 years (2012-2024), annual snapshots fixed to July 15
24+
- 4 variables, 100 ensemble members each
25+
- 1 km resolution (9360 x 19080), EPSG:4326
26+
27+
## Variable mapping and unit conversions
28+
29+
| PEcAn variable | CMOR name | Source units | Conversion | ILAMB units |
30+
|----------------|-----------|--------------|------------|-------------|
31+
| AbvGrndWood | cVeg | Mg C ha-1 | x 0.1 | kg m-2 |
32+
| TotSoilCarb | cSoil | kg C m-2 | none | kg m-2 |
33+
| SoilMoistFrac | mrsol | vol. percent | x 9.98 | kg m-2 |
34+
| LAI | lai | m2 m-2 | none | m2 m-2 |
35+
36+
**Aboveground biomass** is already a carbon density (Mg C ha-1), so the
37+
conversion to kg m-2 is purely unit scaling: 1 Mg ha-1 = 0.1 kg m-2.
38+
39+
**Soil moisture** is volumetric water content expressed as percent over the
40+
0-100 cm root zone. Conversion to mass per area:
41+
42+
```
43+
kg m-2 = percent / 100 x 1.0 m depth x 998 kg/m3 = percent x 9.98
44+
```
45+
46+
The 0-100 cm root-zone depth was confirmed with the dataset author
47+
(D. Zhang, pers. comm.), and matches the depth span of the ILAMB Wang2021
48+
soil-moisture benchmark (0-10, 10-30, 30-50, 50-100 cm layers).
49+
50+
## Output
51+
52+
CF-1.8 compliant netCDF on a 0.5 degree regular grid (156 x 318) covering the
53+
North American study area (7-85N, 179-20W):
54+
55+
- `<output_dir>/<cmor_name>/<cmor_name>_<year>.nc` (one file per year)
56+
- `<output_dir>/<cmor_name>.nc` (merged multi-year file)
57+
58+
Latitude is monotonically increasing (south to north); coordinates are rounded
59+
to 0.01 degrees; time is encoded as days since 1850-01-01 with full-year
60+
bounds.
61+
62+
## Usage
63+
64+
```bash
65+
module load python3 gcc/13.2.0
66+
export PATH=$HOME/.local/bin:$PATH
67+
68+
# Convert all variables, all years
69+
python convert_geotiff_to_ilamb.py \
70+
--input_dir /path/to/NA_SDA_maps_zipped \
71+
--output_dir /path/to/output
72+
73+
# Single variable / year range
74+
python convert_geotiff_to_ilamb.py --variables AbvGrndWood --years 2014 2014
75+
76+
# Skip the merge step
77+
python convert_geotiff_to_ilamb.py --skip-merge
78+
```
79+
80+
On an HPC system, reading 100 full-resolution members per variable exceeds
81+
interactive CPU limits; submit the full run as a batch job.
82+
83+
## Testing
84+
85+
```bash
86+
pytest test_convert.py -v
87+
```
88+
89+
13 tests cover file existence, CMOR variable naming, all four unit
90+
conversions, output grid shape, CF-1.8 compliance, latitude direction,
91+
spatial coverage, chronological multi-year merging, and ILAMB `ModelResult`
92+
loading. Set `ILAMB_OUTPUT_DIR` to point the tests at your output directory.
93+
94+
## Dependencies
95+
96+
`numpy`, `xarray`, `rasterio`, `netCDF4`, and `ILAMB` (for the loading test).
97+
98+
## Notes
99+
100+
- Fluxes (GPP, NEE) are not included; the downscaled product covers only the
101+
four state variables above. Flux benchmarking will draw from the raw SDA
102+
netCDF outputs in a later contribution.
103+
- A known structural discontinuity exists in the underlying LandTrendr input
104+
around 2017-2018 (see the ORNL DAAC documentation); it is preserved as-is in
105+
the converted output rather than adjusted here.

0 commit comments

Comments
 (0)