data.land: prepare_pools fails to calculate woody biomass from TotLivBiom when AbvGrndWood is present without coarse roots
I maintainer di solito rispondono entro 1 giorno
@coder-Yash886 ci sta già lavorando.
Dal 14/11/2026.
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 82/100
Direzione di ricerca
Leggi la catena condizionale intorno alle righe 90-96 di modules/data.land/R/prepare_pools.R, poi riproduci con pool_ic_list2netcdf() e prepare_pools() come nel report per confermare che $wood è NULL nel Caso 1. La modifica consiste nel proteggere il ramo AbvGrndWood con is.valid(coarse.roots) in modo che venga raggiunto il ramo TotLivBiom. Fatto quando l'esempio del Caso 1 restituisce $wood = 8 e i test del pacchetto sotto modules/data.land/tests continuano a passare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
In PEcAn.data.land::prepare_pools(), there is a control-flow bug when attempting to calculate the initial woody biomass pool (IC.params[["wood"]]).
Lines 90–96 of modules/data.land/R/prepare_pools.R:
} else if (is.valid(AbvGrndWood)) {
if (is.valid(coarse.roots)) {
IC.params[["wood"]] <- (AbvGrndWood + coarse.roots)
} else {
PEcAn.logger::logger.error("prepare_pools can't calculate total woody biomass with only AbvGrndWood; checking for total biomass.")
}
} else if (is.valid(TotLivBiom) && is.valid(leaf) && is.valid(fine.roots)) {
wood <- (TotLivBiom - leaf - fine.roots)
When an IC file contains TotLivBiom, leaf_carbon_content, fine_root_carbon_content, and AbvGrndWood (but lacks coarse_root_carbon_content):
- Execution enters
else if (is.valid(AbvGrndWood))at line 90. - Because
coarse.rootsis not valid, it hits theelseblock at line 94, which logs:
"prepare_pools can't calculate total woody biomass with only AbvGrndWood; checking for total biomass." - However, because the total biomass check is an
else if (is.valid(TotLivBiom)...)at line 96, it is mutually exclusive withelse if (is.valid(AbvGrndWood)). - As a result, the code exits the conditional chain without ever checking
TotLivBiom, leaving$woodcompletely uncalculated (NULL), despite having all necessary data to compute it (TotLivBiom - leaf - fine.roots).
Paradoxically, removing AbvGrndWood from the IC file causes prepare_pools() to calculate $wood successfully, but supplying AbvGrndWood causes the calculation to fail.
Steps to Reproduce
Run the following in R:
out <- tempdir()
# Case 1: Input file with TotLivBiom, leaf, fine roots, AND AbvGrndWood (no coarse roots)
list(
vals = list(leaf_carbon_content = 1, fine_root_carbon_content = 1, TotLivBiom = 10, AbvGrndWood = 5),
dims = list(time = 1)
) |> PEcAn.data.land::pool_ic_list2netcdf(outdir = out, siteid = 1)
PEcAn.data.land::prepare_pools(file.path(out, "IC_site_1.nc"), constants = list())
# 2026-11-14 15:28:19 ERROR [PEcAn.data.land::prepare_pools] :
# prepare_pools can't calculate total woody biomass with only AbvGrndWood; checking for total biomass.
# $leaf
# [1] 1
# $fine.roots
# [1] 1
# Note: $wood is NULL / missing!
# Case 2: Exact same input file, but omitting AbvGrndWood
list(
vals = list(leaf_carbon_content = 1, fine_root_carbon_content = 1, TotLivBiom = 10),
dims = list(time = 1)
) |> PEcAn.data.land::pool_ic_list2netcdf(outdir = out, siteid = 2)
PEcAn.data.land::prepare_pools(file.path(out, "IC_site_2.nc"), constants = list())
# $leaf
# [1] 1
# $wood
# [1] 8
# $fine.roots
# [1] 1
Expected Behavior
When AbvGrndWood is provided without coarse.roots, prepare_pools should fall through to check TotLivBiom (as indicated by the log message "checking for total biomass.") and compute $wood = TotLivBiom - leaf - fine.roots (yielding 8 in the example above).
Proposed Fix
Change line 90 so that the AbvGrndWood branch only matches when both AbvGrndWood and coarse.roots are valid, allowing the TotLivBiom branch to be evaluated when coarse.roots is missing:
- } else if (is.valid(AbvGrndWood)) {
- if(is.valid(coarse.roots)){
- IC.params[["wood"]] <- (AbvGrndWood + coarse.roots)
- } else{
- PEcAn.logger::logger.error("prepare_pools can't calculate total woody biomass with only AbvGrndWood; checking for total biomass.")
- }
+ } else if (is.valid(AbvGrndWood) && is.valid(coarse.roots)) {
+ IC.params[["wood"]] <- (AbvGrndWood + coarse.roots)
- Lingua principale
- R
- Stelle
- 246
- Fork
- 322
- Merge medio
- 4g 15h
- PR unite (30g)
- 15
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PecanProject/pecan
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
PecanProject/pecan#4255 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
doi_to_product_name() errors for an unknown DOI instead of reaching its "Unknown DOI" fallbackAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
PecanProject/pecan#4254 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
PecanProject/pecan#4253 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Annual NetCDF merge writes values to the wrong ensemble members and timestepsForse già presa @ANAMASGARD l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
PecanProject/pecan#4251 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
PecanProject/pecan#4236 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di PecanProject/pecan
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
OHDSI/PhenotypeR#728 ·
-
DataSet inherits from DotNetWrapper but has no .NET pointer, so NetObject methods failForse già presa @PavelBal l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Open-Systems-Pharmacology/OSPSuite-R#2076 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
rfordatascience/tidytuesday#1105 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Huber-group-EMBL/remart#17 · 1 commento ·
-
teaching-followup
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
Openscapes/kyber#197 ·