eduaguilera / eduaguilera/whep
build_n_percapita() may double-count biological N fixation
@eduaguilera is already working on this.
Since Aug 8, 2026.
- Dominant language
- R
- Stars
- 1
- Forks
- 5
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 183
Description
Problem
The planned SJOS-N build_n_percapita() implementation appears to count biological nitrogen fixation (BNF) twice in the default synthetic_bnf framing.
The coefficient is defined as:
syn_tot_agri_ratio = (109 + 33) / (0.85 * 109)
and the country total is calculated as:
anthropogenic_n_t = synthetic * syn_tot_agri_ratio + bnf
At the calibration values, agricultural synthetic N is 0.85 * 109 = 92.65 Tg N. Multiplying it by the ratio already gives 142 Tg N (109 + 33). Adding the 33 Tg N BNF term again produces 175 Tg N.
Impact
This can inflate:
build_n_percapita()results;- the normalized per-capita nitrogen boundary axis from
build_n_boundary_percapita(); - the SJOS-N scatter output that consumes that axis.
The code is currently on the unpublished SJOS-N work rather than main.
Methodological decision required
Define the intended system boundary and equation before changing the implementation. In particular:
- Does
syn_tot_agri_ratioalready convert agricultural synthetic N to total synthetic + BNF? - Or should synthetic N be scaled independently (for example for its agricultural share) and observed agricultural BNF then added once?
- Should the packaged
food_agri_shareenter this calculation, and at which stage? - Does the gridded
bnfinput represent the same agricultural/system boundary as the Campbell calibration value?
Acceptance criteria
- Document the system boundary and derivation of every scaling factor.
- Count synthetic fixation and BNF exactly once.
- Add a calibration test using
109 Tg synthetic,33 Tg BNF, and the0.85agricultural share, asserting the explicitly chosen expected total. - Add a downstream test for the per-capita and normalized-boundary outputs.
- Update coefficient descriptions and function documentation to match the selected equation.
Evidence
R/n_percapita.R:.n_percapita_anthropogenic()data-raw/sjos_n_coefficients.R:syn_tot_agri_ratio
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.