diff --git a/DESCRIPTION b/DESCRIPTION index 5d13509d..13f98fd7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: OBIC Type: Package Title: Calculate the Open Bodem Index (OBI) Score -Version: 3.0.0 +Version: 3.0.1 Authors@R: c( person(given = "Sven", family = "Verweij", @@ -27,7 +27,7 @@ Authors@R: c( family = "van den Dool", email = 'kees.vandendool@nmi-agro.nl', role = "aut", - comment = c(ORCHID = '0009-0003-8963-2556')), + comment = c(ORCID = '0009-0003-8963-2556')), person(given = "Job", family = "de Pater", email = "job.depater@nmi-agro.nl", diff --git a/NEWS.md b/NEWS.md index 43cef0a2..e670b1f5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# OBIC 3.0.1 2023-11-24 +## Fixed +* Fixes calculation of N surplus used for I_H_NGW and I_H_NSW + # OBIC 3.0.0 2023-10-16 ## Added * Add `calc_permeability` for calculating top soil permeability diff --git a/R/nitrogen_efficiency.R b/R/nitrogen_efficiency.R index 15962818..7e4545d6 100644 --- a/R/nitrogen_efficiency.R +++ b/R/nitrogen_efficiency.R @@ -132,7 +132,7 @@ calc_n_efficiency <- function(B_LU_BRP, B_SOILTYPE_AGR, B_GWL_CLASS, B_AER_CBS, dt[,catchcrop := fifelse(M_GREEN, 75,0)] # Calculate deviation from N surplus - dt[,n_sp := max(0,((1 - NUE * cf_pkph) * n_app) - catchcrop)] + dt[,n_sp := pmax(0,((1 - NUE * cf_pkph) * n_app) - catchcrop)] # compute (potential and soil derived) N leaching to groundwater D_NGW (mg NO3/L) dt[, D_NLEACH := nf * n_sp] diff --git a/tests/testthat/test-nitrogen_efficiency.R b/tests/testthat/test-nitrogen_efficiency.R index d4d419d8..7c56b36e 100644 --- a/tests/testthat/test-nitrogen_efficiency.R +++ b/tests/testthat/test-nitrogen_efficiency.R @@ -13,7 +13,7 @@ test_that("test whether calc_nitrogen_efficiency works", { B_FERT_NORM_FR = c(1,1,1,0.8), leaching_to = 'gw' ), - expected = c(10.00, 11.25, 10.00, 10.00), + expected = c(3.92, 7.20, 10.00, 0.96), tolerance = 0.01 ) @@ -31,7 +31,7 @@ test_that("test whether calc_nitrogen_efficiency works", { B_FERT_NORM_FR = c(1,0.8,1,1), leaching_to = 'gw' ), - expected = c(1.90,2.09,1.90,1.90), + expected = c(0.0, 0.0, 1.9, 0.0), tolerance = 0.01 )