IPCC 2019 Eq. 10.33 (p. 10.85) gives N retained in milk and weight gain in kg N per animal per day. On the same page, IPCC says cattle excretion then uses Eq. 10.31A: Nex = (N intake − N retention) × 365.
The package divides milk retention by 365 twice (R/ghg_emission.R:226). It then uses the result as a fraction of intake (:233).
| Animal | IPCC retention (kg N/d) | Current retention | Fixed retention | Current Nex (kg N/yr) | IPCC Nex, same intake |
|---|---|---|---|---|---|
| Cattle - Cows (improved) | 0.0582 | 0.0002 | 0.0582 | 89.4 | 68.2 |
| Cattle - Steers/heifers (improved) | 0.0098 | 0.0141 | 0.0098 | 49.7 | 43.3 |
| Cattle - Calves | 0.0115 | 0.0141 | 0.0115 | 12.8 | 8.8 |
For the dairy cow, the package's N retention is about 365× too small, so almost all intake N is counted as excreted. That overstates manure N2O and the nitrogen balance. The last column applies IPCC Eq. 10.31A to the package's own N intake, so it isolates the retention error from the intake error in section 1. With the fix, the package matches it exactly (test 02).
--- a/R/ghg_emission.R 2026-09-29 10:30:51
+++ b/R/ghg_emission.R 2026-09-29 10:30:51
@@ -223,14 +223,17 @@
ifelse(livetype_desc== "Pigs - growers" & body_weight %gel% c(40,80),0.024,
ifelse(livetype_desc== "Pigs - growers" & body_weight %gel% c(80,120),0.021,
ifelse(livetype_desc== "Pigs - dry sows/boars",0.021,0))))))),
- n_retained = ifelse(!grepl("Pigs",livetype_desc),ifelse(annual_growth == 0,(annual_milk*(protein_milkcontent/100))/6.38/no_days,((annual_milk*(protein_milkcontent/100))/6.38)+(((annual_growth*(268-(7.03*er_growth/annual_growth)))/1000)/6.25))/no_days,#equation 10.33
+ n_retained = ifelse(!grepl("Pigs",livetype_desc),((annual_milk/no_days)*(protein_milkcontent/100))/6.38+ifelse(annual_growth > 0,(((annual_growth/no_days)*(268-(7.03*er_growth/(annual_growth/no_days))))/1000)/6.25,0),#equation 10.33, kg N/head/day
ifelse(livetype_desc=="Pigs - lactating/pregnant sows",n_gain+n_weaned, #equation 10.33A
ifelse(livetype_desc== "Pigs - growers" | livetype_desc== "Pigs - dry sows/boars",(annual_growth*n_gain),0)))) #equation 10.33C
#Nitrogen excretion rates
n_excretion <- n_retention1%>%
- mutate(n_excretion_rate = n_intake*(1-n_retained)*no_days) #equation 10.31
+ # n_intake is a herd total (ge_intake carries herd_composition); n_retained is per head
+ mutate(n_excretion_rate = ifelse(!grepl("Pigs",livetype_desc),
+ (n_intake-(n_retained*herd_composition))*no_days, #equation 10.31A
+ n_intake*(1-n_retained)*no_days)) #equation 10.31
#################################################################################################################################
#Direct N2O emissions
Rscript reproduce_critical_issues.R 2 using reproduce_critical_issues.R (installs what it needs into its own library and cleaned @ 800d53a). Add CLEANED_FIXES=proposed_fixes.R with proposed_fixes.R for the fixed column.
Comments
Comments are GitHub Discussions on peetmate/cleaned-review; sign in with GitHub to post.