3/8 Distinguish missing and no-flux VPRM cells - #40
Open
Timothy-W-Hilton wants to merge 2 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-
NaNarray withsum()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=1when summing classwise GPP and respiration contributions. The aggregation still ignores an individual missing class when another class contributes a valid value, but returnsNaNwhen 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
3 passed.