Skip to content

3/8 Distinguish missing and no-flux VPRM cells - #40

Open
Timothy-W-Hilton wants to merge 2 commits into
tglauch:mainfrom
Timothy-W-Hilton:fix-vprm-flux-missing-and-NaN-handling
Open

3/8 Distinguish missing and no-flux VPRM cells#40
Timothy-W-Hilton wants to merge 2 commits into
tglauch:mainfrom
Timothy-W-Hilton:fix-vprm-flux-missing-and-NaN-handling

Conversation

@Timothy-W-Hilton

Copy link
Copy Markdown

Distinguish missing and no-flux VPRM cells

Summary

Distinguish genuinely missing model results from cells with no flux-capable land-cover fraction when aggregating GPP and respiration across VPRM classes.

Why

By default, xarray reduces an all-NaN array with sum() to zero. In VPRM, that could turn an all-missing stack of landcover-classwise GPP or respiration terms into a physically meaningful-looking zero. The resulting NEE could therefore appear valid even though a required model input was missing.

For example, a cloud-obscured EVI value can make every classwise GPP term missing. Likewise, a missing respiration temperature input (tcorr) can make every classwise respiration term missing. Neither condition should be reported as zero biological flux. Conversely, a cell whose fractional land cover contains no flux-capable class is structurally a zero-flux cell, not a missing-data cell.

Change

Use xarray's skipna=True, min_count=1 when summing classwise GPP and respiration contributions. The aggregation still ignores an individual missing class when another class contributes a valid value, but returns NaN when no valid contribution exists.

For fractional (two-dimensional) land-cover inputs, calculate the combined coverage of all flux-capable classes. Explicitly set GPP and NEE to zero only where that coverage is zero. Thus an active cell with missing EVI remains NaN, whereas an ocean, desert, or other no-flux cell is reported as zero.

Validation

  • Added a regression test confirming that missing EVI keeps GPP and NEE missing rather than converting GPP to zero.
  • Added a regression test confirming that missing respiration temperature keeps NEE missing rather than converting respiration to zero.
  • Added a regression test confirming that an all-no-flux cell is zero while an adjacent active cell with missing EVI remains missing.
  • Focused test suite: 3 passed.

Timothy W. Hilton added 2 commits August 15, 2026 14:33
Use xarray’s skipna=True, min_count=1 when summing classwise GPP and
respiration contributions, so an all-missing stack remains missing
rather than being silently converted to zero. Add regression coverage
showing that missing EVI preserves missing GPP and NEE, while missing
temperature correction preserves missing respiration and therefore
missing NEE.
Calculate the combined coverage of flux-capable fractional land-cover
classes and explicitly set GPP and NEE to zero only where that coverage
is zero. This preserves missing (that is, NaN) outputs for active cells
with unavailable inputs while correctly assigning cells containing only
no-flux classes a (physically meaningful) 0.0 flux; add a two-cell
regression test covering both cases.
@Timothy-W-Hilton Timothy-W-Hilton changed the title Distinguish missing and no-flux VPRM cells 3/8 Distinguish missing and no-flux VPRM cells Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant