Skip to content

fix(SIPNET): apply plantStorageNInit default conditionally (#4114) - #4117

Open
coder-Yash886 wants to merge 4 commits into
PecanProject:developfrom
coder-Yash886:fix/plantStorageNInit-conditional-4114
Open

coder-Yash886 wants to merge 4 commits into
PecanProject:developfrom
coder-Yash886:fix/plantStorageNInit-conditional-4114

Conversation

@coder-Yash886

@coder-Yash886 coder-Yash886 commented Sep 18, 2026 •

Copy link
Copy Markdown

Closes #4114

What Changed

1. inst/template.param_v2 — Static default value set to 5.0

Changed plantStorageNInit from 0.0 → 5.0 g N m⁻². This value (derived from the Niwot-specific template: plantWoodInit = 30000 g C m⁻² → ~5.04 g N m⁻²) ensures the first leafon event is not suppressed when the nitrogen cycle is active, without requiring any computation inside write.config.

2. R/write.configs.SIPNET.R — Dropped dynamic unconditional overwrite

  • Removed the dynamic computed override of plantStorageNInit that previously overwrote template values unconditionally (violating the pattern used by all other parameters in write.config.SIPNET).
  • Added has_n_cycle = rev_str == "v2" to the caps list (suggested by @infotroph) — replacing the implicit and misleading "plantStorageNInit" %in% param[, 1] check.
  • Added proper IC precedence handling for plantStorageNInit via both the IC argument and poolinitcond, including explicit zero values.
  • Added plantStorageNInit support via trait.values for v2.

3. tests/testthat/test-write.config.SIPNET.R — Cleaned up + new tests

  • Removed unnecessary events file construction from the existing test.
  • Added a new test covering:
    • Template default 5.0 is preserved when no IC is provided.
    • IC = 0 (intentional nitrogen-limited start) is respected.
    • IC = 12.5 (explicit non-zero) is respected.

4. man/write.config.SIPNET.Rd — Documented precedence

Added a Parameter precedence section explaining the override order:
template → defaults$constants → trait.values → IC/poolinitcond (highest, including explicit zero).

@coder-Yash886
coder-Yash886 force-pushed the fix/plantStorageNInit-conditional-4114 branch from 9e48e89 to 7c9825e Compare September 18, 2026 12:39
@coder-Yash886

Copy link
Copy Markdown
Author

@dlebauer Please review the Pr When you have free time

Comment thread models/sipnet/R/write.configs.SIPNET.R Outdated
Comment thread models/sipnet/R/write.configs.SIPNET.R Outdated
Comment thread models/sipnet/R/write.configs.SIPNET.R Outdated
Comment thread models/sipnet/R/write.configs.SIPNET.R Outdated
@coder-Yash886
coder-Yash886 force-pushed the fix/plantStorageNInit-conditional-4114 branch from 59bae89 to 3f187af Compare September 19, 2026 02:14
@coder-Yash886

coder-Yash886 commented Sep 19, 2026 •

Copy link
Copy Markdown
Author

@divine7022 @infotroph @dlebauer I have addressed all your comments Please Review the PR when you have free time

@S1DDHEY

S1DDHEY commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

@coder-Yash886 run make document and push again. CI fails coz the .Rd files are out-of-sync.

@divine7022 divine7022 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coder-Yash886 thanks for turning this round quickly!

CI fails isn't only .Rd sync that @S1DDHEY flagged; devtools::document
will fix that one, but test file also doesn't pass. the new plantStorageNInit precedence in v2 test matches on the literal string plantStorageNInit 5.0 while the writer emits plantStorageNInit 5, and carbon-limited leaf flush block is still have the computed behaviour this PR removes

not blocking -- update News.md and it still describe the computed default

Comment thread models/sipnet/tests/testthat/test-write.config.SIPNET.R Outdated
Comment thread models/sipnet/tests/testthat/test-write.config.SIPNET.R Outdated
Comment thread models/sipnet/R/write.configs.SIPNET.R
@divine7022

divine7022 commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

plantStorageNInit here is sipnet parameter name rather than a standard_vars one, so this branch only fires for a hand built poolinitcond file. meanwhile soil_organic_nitrogen_content is standard var that read from the IC nc, it's not in this list. fine by me if the sipnet name is what you agreed on, but #4116 is going to add the soil and litter side and it'd be good if the two don't end up on different naming conventions
please consider soil side (soilOrgNInit) too

@coder-Yash886

Copy link
Copy Markdown
Author

@divine7022 @dlebauer Changes addressed Please review the Pr when you have free time

@infotroph infotroph left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posting some comments I had started before your last commit, with apologies if you resolved / changed these already.

Comment thread models/sipnet/NEWS.md Outdated
@infotroph

infotroph commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

it'd be good if the two don't end up on different naming conventions

@divine7022 I don't know of any documented names for storage pools in the existing standard vars, so I'd say the choice is between "make up something that looks similar" (plant_organic_nitrogen_storage_content?) and "use the Sipnet name so it's clear exactly what we meant it to be used for" (plantStorageNInit).

I lean weakly[*] toward the former today, but will go along with what you like. The existing IC.nc names are such a mess that I don't think we can make it worse here -- I mean look at this, we have camelcase and snake case AND spaces! 😉

ic_ncvars_to_try <- c(
        "nee",
        "SoilMoistFrac",
        "SWE",
        "date_of_budburst",
        "date_of_senescence",
        "Microbial Biomass C"
      )

[*] So weakly I came back to edit my vote after posting...

@coder-Yash886

coder-Yash886 commented Sep 23, 2026 •

Copy link
Copy Markdown
Author

@divine7022 @infotroph @dlebauer Please review the pr

@coder-Yash886

Copy link
Copy Markdown
Author

@dlebauer @divine7022 Sir please review the Pr

@coder-Yash886
coder-Yash886 force-pushed the fix/plantStorageNInit-conditional-4114 branch from 6a85923 to 5da8cc2 Compare October 7, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

apply the computed plantStorageNInit default conditionally

4 participants