eduaguilera / eduaguilera/whep

build_n_percapita() may double-count biological N fixation

Open
#409 2 comments 0 reactions 1 assignee View on GitHub

@eduaguilera is already working on this.

Since Aug 8, 2026.

area:nitrogen bug needs-expert priority:medium
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_ratio already 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_share enter this calculation, and at which stage?
  • Does the gridded bnf input 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 the 0.85 agricultural 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.