Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix apr #36

Merged
merged 12 commits into from
May 9, 2023
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: soilptf
Type: Package
Title: Estimate soil properties via pedotransferfunctions
Version: 0.5.0.9000
Version: 0.5.1
Authors@R: c(person(given = "Gerard", family = "Ros", email = "[email protected]", role = c("aut","cre")),
person(given = "Kees", family = "van den Dool", email = "[email protected]", role = c("aut")),
person(given = "Sven", family = "Verweij", email = "[email protected]", role = c("aut")),
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ export(sptf_cec72)
export(sptf_cec73)
export(sptf_cec74)
export(sptf_cec75)
export(sptf_cec76)
export(sptf_cec77)
export(sptf_cec78)
export(sptf_cec8)
export(sptf_cec9)
export(sptf_erodibility1)
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog soilptf

## Version 0.5.1 2023-05-09

# Fixed
* NAm and SAm as abbreviation for North and South America causes errors due to confusion with NA, issue #3
* replace `assert_int` with `assert_integer` for years in `sptf_cdec1`, issue #26
* ensure correct CN ratios in `sptf_cdec1`, issue #26

# Changed
* all elements for A_CACO3_MI replaced with A_CACO3_IF, issue #30

# Added
* options for parameter `B_SOILCLASS_USDA` in `sptf_parameters`, issue #23
* add ptfs cec75, cec76 and cec77

## Version 0.5.0 2023-04-29

## Added
Expand Down
5 changes: 2 additions & 3 deletions R/bulkdensity.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

#' Documentation of all possible bulk density pedotransfer function inputs
#'
#' @param A_CACO3_MI (numeric) The calcium carbonate content of the soil (\%)
#' @param A_CEC_CO (numeric) Cation Exchange Capacity (mmol+/kg)
#' @param A_CLAY_MI (numeric) The clay content of the mineral soil fraction (\%).
#' @param A_C_OF (numeric) Organic Carbon Content (g / kg)
#' @param A_C_OF (numeric) Organic Carbon Content (g / kg)
#' @param A_DEPTH (numeric) The depth of the sampled soil layer (m)
#' @param A_DENSITY (numeric) Soil density (g / kg)
#' @param A_H20_T105 (numeric) The volumetric moisture content of the soil (\%)
Expand All @@ -27,7 +26,7 @@
#' @param A_H2O_T105 (numeric) water content measured after drying at 105 degrees (\%)
#'
#' @export
sptf_bd0 <- function(A_CACO3_MI,A_CEC_CO,A_CLAY_MI,A_C_OF,A_DEPTH,A_DENSITY,A_H20_T105,
sptf_bd0 <- function(A_CEC_CO,A_CLAY_MI,A_C_OF,A_DEPTH,A_DENSITY,A_H20_T105,
A_N_RT,A_PH_CC,A_PH_WA,A_SAND_M50,A_SAND_MI,A_SILT_MI,A_SOM_LOI,
B_ALTITUDE,B_ROCKS_FR,B_SLOPE_ASPECT,B_SLOPE_DEGREE,mp_wp,
mp_fc,D_BDS,A_CACO3_IF,A_H2O_T105){return(NULL)}
Expand Down
16 changes: 12 additions & 4 deletions R/cdec.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ sptf_cdec1 <- function(A_C_OF, A_N_RT, years) {

# Check input
arg.length <- max(length(A_N_RT),length(A_C_OF))
checkmate::assert_numeric(A_N_RT, lower = 0, upper = 10000, len = arg.length)
checkmate::assert_numeric(A_N_RT, lower = 0, upper = 20000, len = arg.length)
checkmate::assert_numeric(A_C_OF, lower = 0, upper = 1000, len = arg.length)

# estimate the CN ratio and check for really unrealistic values
cnratio <- A_C_OF *1000 / A_N_RT
checkmate::assert_numeric(cnratio, lower = 1, upper = 100)

# estimate the potential decomposition rate (Vermeulen en Hendriks, 1996)
kpot <- 0.016 - 0.00021 * A_C_OF *1000 / A_N_RT

# estimate carbon decomposition
# estimate carbon decomposition (g / kg lost after x years)
value <- A_C_OF * (1 - exp(-kpot * years))

# return value
Expand All @@ -50,10 +54,14 @@ sptf_cdec2 <- function(A_C_OF, years) {

# Check input
checkmate::assert_numeric(A_C_OF, lower = 0, upper = 1000)
checkmate::assert_int(years,lower = 1)
checkmate::assert_integer(years,lower=1)
checkmate::assert_true(length(years)==1 | length(years)==length(A_C_OF)|(length(A_C_OF)==1 & length(years)>0))

# combine arguments in internal table
dt <- data.table(A_C_OF = A_C_OF,temp = 12)
dt <- data.table(id = 1:length(A_C_OF),
A_C_OF = A_C_OF,
temp = 12,
years = years)

# add correction factor for annual temperature
dt[, cor_temp := ifelse(temp<=-1,0,ifelse(temp<=9,0.1*(temp+1),ifelse(temp<=27,2^((temp-9)/9),4)))]
Expand Down
Loading