Skip to content

Commit

Permalink
Merge pull request #158 from AgroCares/fix-spelling
Browse files Browse the repository at this point in the history
Release/v2.0.1
  • Loading branch information
SvenVw authored Apr 13, 2022
2 parents bf5c240 + 7399a25 commit 6618d32
Show file tree
Hide file tree
Showing 310 changed files with 2,085 additions and 22,351 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
^DEV$
^\.github$
^codecov\.yml$
^LICENSE
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.Rhistory
.RData
.Ruserdata
.Renviron
.Rproj
inst/doc
doc
Meta
Expand Down
15 changes: 8 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
Package: OBIC
Type: Package
Title: Calculate the Open Bodem Index (OBI) score to evaluate the soil quality of agricultural fields
Version: 2.0.0
Title: Calculate the Open Bodem Index (OBI) Score
Version: 2.0.1
Authors@R: c(
person("Sven", "Verweij", email = "[email protected]", role = c("aut","cre")),
person("Gerard", "Ros", email = "[email protected]", role = "aut"),
person("Yuki", "Fujita", email = "[email protected]", role = "aut"),
person("Brent", "Riechelman", email = '[email protected]', role = "aut"),
person("Job", "de Pater", email = "[email protected]", role = "ctb"),
person("Yuki", "Fujita", email = "[email protected]", role = "ctb"),
person("Brent", "Riechelman", email = '[email protected]', role = "ctb"),
person("Nutriënten Managment Instituut", email = "[email protected]", role = "cph"))
Description: The Open Bodem Index (OBI) is a method to evaluate the quality of soils of agricultural fields in The Netherlands and the sustainability of the current agricultural practices.
The OBI score is based on four main criteria: chemical, physical, biological and management, which consist of more than 21 indicators.
By providing results of a soil analysis and management info the OBIC package can be use to calculate he scores, indicators and derivatives that are used by the OBI.
More information about the Open Bodem Index can be found at https://www.openbodemindex.nl/.
By providing results of a soil analysis and management info the 'OBIC' package can be use to calculate he scores, indicators and derivatives that are used by the OBI.
More information about the Open Bodem Index can be found at <https://www.openbodemindex.nl/>.
Depends:
R (>= 3.5.0)
Imports:
checkmate,
data.table
License: GPL-3 | file LICENSE
License:
GPL-3
URL: https://github.com/AgroCares/Open-Bodem-Index-Calculator
BugReports: https://github.com/AgroCares/Open-Bodem-Index-Calculator/issues
Encoding: UTF-8
Expand Down
64 changes: 32 additions & 32 deletions DEV/scripts/ppr_maatregel.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@
cols <- colnames(m.obic)[grepl('melk',colnames(m.obic))]
m.obic[,(cols) := lapply(.SD,function(x) fifelse(is.na(x),0,x)),.SDcols = cols]

# overwrite name
setnames(m.obic, "Bodemfunctie / indicator",'m_soilfunction')

# check if there is missing data for any indicator
load('dev/column_description_obic.RData')
column_description.obic <- readRDS('dev/data/column_description_obic.rds')
cols <- column_description.obic[grepl('^I_C_|^I_P_|^I_B_',column),column]

# make temporary data.table with for each unknown indicator a zero impact measure
cols <- cols[!cols %in% unique(m.obic$OBICvariable)]
ind.miss <- CJ(maatregel_nr = 1:max(m.obic$maatregel_nr), OBICvariable = cols)
ind.add <- merge(unique(m.obic[,c(1:3,5:6)]),ind.miss,by='maatregel_nr')
ind.miss <- merge(ind.miss,
column_description.obic[,.(OBICvariable = column,m_soilfunction = description_nl)],
by = 'OBICvariable')
ind.add <- merge(ind.miss,unique(m.obic[,.(maatregel_nr,omschrijving,Prio_M,Order)]),
by='maatregel_nr')

# add missing columns with value 0, and a tresshold value of 0.5
cols <- colnames(m.obic)[grepl('melk|groente|akker|boom|klei|veen|zand|loss|Ef',colnames(m.obic))]
Expand Down Expand Up @@ -93,38 +100,31 @@
# setkey
setkey(m.obic,indicator,m_sector,m_soiltype)

# update april 2021

# I_P_MS is splitted into droughtstress and wetness stress separately
m1.copy <- m.obic[indicator=='I_P_MS'][,indicator := 'I_P_DS']
m2.copy <- m.obic[indicator=='I_P_MS'][,indicator := 'I_P_WS']

# add to m.obic
m.obic <- rbind(m.obic[!indicator=='I_P_MS'],m1.copy,m2.copy)



# update september 2021

# add workability, assuming similar impacts on workability as on wetness stress
m2.copy <- m.obic[indicator=='I_P_WS'][,indicator := 'I_P_WO']

# add to m.obic
m.obic <- rbind(m.obic,m2.copy)

# setkey
setkey(m.obic,indicator,m_sector,m_soiltype)

# update august 2021

# I_P_WO is added to with dummy values to prevent error
m1.copy <- m.obic[indicator=='I_P_DS'][,indicator := 'I_P_WO'][,c('m_effect','m_applicability') := 0]
# update march 2022

# there where three OBIC indicators added, now with default "no impact
# these include: I_B_NEM, I_P_DS, I_P_WS and I_P_WO

# drought stress and wetness stress: all measures for original moisture stress are applicable
# and moisture stress can be deleted
m1.copy <- m.obic[indicator=='I_P_MS'][,indicator := 'I_P_DS']
m2.copy <- m.obic[indicator=='I_P_MS'][,indicator := 'I_P_WS']

# add to m.obic
m.obic <- m.obic[!indicator %in% c('I_P_DS','I_P_WS','I_P_MS')]
m.obic <- rbind(m.obic,m1.copy,m2.copy)

# add workability, assuming similar impacts on workability as on wetness stress
m1.copy <- m.obic[indicator=='I_P_WS'][,indicator := 'I_P_WO']
m.obic <- rbind(m.obic[!indicator == 'I_P_WO'],m1.copy)

# add to m.obic
m.obic <- rbind(m.obic,m1.copy)
# setkey
setkey(m.obic,indicator,m_sector,m_soiltype)

# setkey
setkey(m.obic,indicator,m_sector,m_soiltype)
# test
if(length(m.obic[,.N,by=.(indicator)][,unique(N)]) != 1){
print("warning, there are differences in the number of indicators. that should not be possible. please check")
}

# rename to recom.obic
recom.obic <- m.obic
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export(ind_pmn)
export(ind_potassium)
export(ind_resistance)
export(ind_sealing)
export(ind_sulfur)
export(ind_sulpher)
export(ind_waterretention)
export(ind_waterstressindex)
Expand Down
66 changes: 45 additions & 21 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# OBIC 2.0.1 2022-03-26
### Changed
* The function `ind_sulpher` is renamed to `ind_sulfur` in documentation

### Added
* all functions are extended with `examples` and `return`

### Changed
* standardize output variables of pedotransfer parameters Wosten

### Fixed
* Fixes many spelling errors in the documentation
* Set title in `decription` to title case
* Fix links to external websites
* Fix duplicated indicator in recom.obic (in dev/ppr_maatregel.r), issue #164
* Fix setorder after merge in calc_n_effieciency
* Fix setorder after merge in calc_som_balance

### Removed
* Removes `/docs` as the documentation website is now automatically generated by GitHub Actions

### Deprecated
* The function `ind_sulpher` is deprecated due to renaming

# OBIC 2.0.0 2022-01-11
## Added
* Add `ppr_bouwplan_tables.R` in dev/scripts
Expand All @@ -18,7 +42,7 @@
* Add table `weather.obic` with monthly mean precipitation, temperature and evaporation
* Add table `crops.makkink` with mean Makkink factors per crop type
* Add table `nema.crop.rot.obic` added with crop sensitivity for nematodes
* Add table `nema.obic` with treshold values per species
* Add table `nema.obic` with threshold values per species
* Add GitHub Action to run R-CMD-Check for changes on `master` and `development`
* Add coverage of unit tests

Expand Down Expand Up @@ -80,7 +104,7 @@
## Changed
* I_M_* and I_*_BCS indicators for management measures and BCS are removed, issue #126
* values -999 are replaced by NA
* column_descriptons_obic.Rdata is updated
* column_descriptions_obic.Rdata is updated
* weight.obic is updated


Expand All @@ -98,7 +122,7 @@
* preparation nema.obic in dev
* preparation season.obic in dev
* obic_field is added to run obic score for one field
* ppr_column_description plus column_descriptons_obic.Rdata
* ppr_column_description plus column_descriptions_obic.Rdata
* ppr_maatregel plus recom_obic.Rdata
* ppr_weights plus weights.obic
* I_P_DS and I_P_WS added (drought and wetness stress separately)
Expand All @@ -113,11 +137,11 @@
* PBI input is flexible for both grassland and arable
* calculation SLV updated
* update element_names for A_P_CC, A_P_AL in phosphate_availability.R
* update element_names for A_S_RT, A_SOM_LOI, B_AER_CBS, B_SOILTYPE_AGR in sulpher.R
* update element_names for A_S_RT, A_SOM_LOI, B_AER_CBS, B_SOILTYPE_AGR in sulfur.R
* update element_names for B_GWL_CLASS in wateravailability.R
* update element_names for B_GWL_CLASS and B_AER_CBS in nretention.R
* correct weighing for S_C_A
* all element names are updated to english ones
* all element names are updated to English ones
* weighing for score calculated is changed into a more generic approach
* structure for running obi is changed into one function
* weights.obic is extended and used to distinguish for relevant/non-relevant indicators
Expand All @@ -143,7 +167,7 @@
* Range of `D_P_DU` is set between 0 and 1

## Fixed
* Fixed the use of `B_LG_CBS` at sulphur
* Fixed the use of `B_LG_CBS` at sulfur
* `ID` can now also be character and does not have to be numeric #66


Expand All @@ -154,17 +178,17 @@
## Changed
* Optimal pH values of grassland are now the middle value of the class `good` #55
* pF of field capacity is changed from 2.2 to 2.0 #53
* Bulk density in the default PTF is now aggregated into 1 continous function #53
* Bulk density in the default PTF is now aggregated into 1 continuous function #53
* Parameters of evaluation for PAW are adjusted #53
* Parameters for the evaluation of sealing are adjusted #57
* Changes the formula to calculate nitrogen leaching and run-off #58
* Parameters for the evaluation of nretention are adjusted #58
* Paramaters and funs for CEC are updated and split for soil fertility and aggregate stability #59
* parameters and funs for CEC are updated and split for soil fertility and aggregate stability #59
* Parameters for the evaluation of Cu availability are adjusted #59
* potassium index is multiplied so that the evaluation is equal for grass and maize #60

## Fixed
* Improved the function for crumbleability to match the factsheet #54 #56
* Improved the function for crumbleability to match the fact sheet #54 #56
* Fix error in calc_potassium_availability #59

# OBIC 0.10.0 2019-12-13
Expand All @@ -184,30 +208,30 @@
* new table with weighing factors included 'weight.obic' #32
* weighing factors updated in obic_indicators.R #32
* Improved the zinc indicator function #39
* The evaluation function for sulphur on maize and grass is updated #40
* The evaluation function for sulfur on maize and grass is updated #40
* The management function is improved, especially for maize #38
* The maximum score of `ind_management` is adjusted #38
* The parameter values for sulphur on arable land is adjusted #41
* The parameter values for sulfur on arable land is adjusted #41
* The optimal pH for grassland depends now on organic matter content and presence of clover #42
* The score aggragation is now 60% average of last 4 years and 40% of older years #31
* The score aggregation is now 60% average of last 4 years and 40% of older years #31
* The maximum value for `D_CR` is limited to 10 #47
* The parameters for the evaluation for `I_C_K` is set to the same as grassland #51
* The evaluation for `I_C_N` is now split into grassland and arable land #50
* Set lifecyle status to `maturing`
* The evaluation of `I_C_MG` is adjusted according to factsheet
* Set lifecycle status to `maturing`
* The evaluation of `I_C_MG` is adjusted according to fact sheet

## Fixed
* Preprocessing, indicators and scores make use of internal copy of the table now rather than referencing to an object outside the scope of the function
* Fixed the droughtstress, wetnessstress and waterstress values for GtI in `waterstress.obic`
* Fixed the drought stress, wetness stress and water stress values for GtI in `waterstress.obic`
* For grasslands on peat pr clay, the `D_MG` is now scaled #51
* Limit `D_SLV` between -30 and 250

# OBIC 0.9.0 2019-10-22
## Changed
* The uppper limit for `D_BCS` is increased from 40 to 50
* The upper limit for `D_BCS` is increased from 40 to 50
* Switch on crumbleability
* For `calc_phosphate_availability` the category `arable` is added for the crop categories
* Changed evaluation of sulphur for arable fields #26
* Changed evaluation of sulfur for arable fields #26

## Fixed
* Fixed typo if mais in `ind_managment`
Expand All @@ -222,7 +246,7 @@
## Added
* Adds index and evaluation of the BodemConditieScore
* Adds potassium to main functions
* Adds a random recommondation to the output
* Adds a random recommendation to the output

## Changed
* The upper limit for `A_MN_CC` is increased from 20000 to 30000
Expand All @@ -231,12 +255,12 @@
## Fixed
* The indicator of pH had the wrong direction
* Removed the minus sign before `ind_zinc`
* The function `calc_potassium_availability` containted a wrong column name for `A_PH_CC`
* The function `calc_potassium_availability` contained a wrong column name for `A_PH_CC`
* Some unknown situations at `calc_potassium_availability` have now the same values as comparable situations. This should be looked at later

# OBIC 0.7.0 2019-08-02
## Added
* Adds index and evaluation of waterretention paramaters
* Adds index and evaluation of waterretention parameters
* Adds index and evaluation of water related yield stress
* Adds index and evaluation of metals (Zn and Cu)
* Adds index and evaluation of microbial activity (PMN)
Expand Down Expand Up @@ -264,7 +288,7 @@

# OBIC 0.4.0 2019-07-26
## Added
* The existing functions for pH, P, N, crumbleability, sealing and resistance are intergrated into `obic()`
* The existing functions for pH, P, N, crumbleability, sealing and resistance are integrated into `obic()`

## Changed
* The column name `brp` is changed to `B_LU_BRP`
Expand Down
3 changes: 0 additions & 3 deletions Open-Bodem-Index-Calculator.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace

QuitChildProcessesOnExit: Yes
DisableExecuteRprofile: Yes

SpellingDictionary: nl_NL
20 changes: 17 additions & 3 deletions R/bodemconditiescore.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' This function calculates the BodemConditieScore given input from manual observations made in the field.
#' The individual parameters are scored in three classes: poor (0), neutral (1) or good (2)
#' More information on this test can be found \href{http://mijnbodemconditie.nl/}{here}
#' More information on this test can be found \href{https://mijnbodemconditie.nl/}{here}
#'
#'
#' @param B_LU_BRP (numeric) The crop code from the BRP
Expand All @@ -20,13 +20,20 @@
#' @param A_CC_BCS (integer) The crop cover on the surface (score 0-1-2)
#' @param type (character) Define output of the function. Options: score (integrated score) and indicator (score per indicator)
#'
#' @references \href{http://mijnbodemconditie.nl/}{mijnbodemconditie.nl}
#' @references \href{https://mijnbodemconditie.nl/}{mijnbodemconditie.nl}
#'
#' @import data.table
#'
#' @examples
#' calc_bcs(B_LU_BRP = 265, B_SOILTYPE_AGR = 'dekzand', A_SOM_LOI = 3.5, D_PH_DELTA = 0.4,
#' A_EW_BCS = 1, A_SC_BCS = 1, A_GS_BCS = 1, A_P_BCS = 1, A_C_BCS = 1, A_RT_BCS =1, A_RD_BCS = 1,
#' A_SS_BCS = 1, A_CC_BCS = 1)
#'
#' @return
#' A visual soil assessment score derived from field observations driven by organic matter content and soil structure properties. Returns a numeric value.
#' @export
calc_bcs <- function(B_LU_BRP,B_SOILTYPE_AGR,A_SOM_LOI, D_PH_DELTA,
A_EW_BCS = NA, A_SC_BCS = NA, A_GS_BCS = NA, A_P_BCS = NA, A_C_BCS = NA, A_RT_BCS =NA, A_RD_BCS = NA,
A_EW_BCS = NA, A_SC_BCS = NA, A_GS_BCS = NA, A_P_BCS = NA, A_C_BCS = NA, A_RT_BCS = NA, A_RD_BCS = NA,
A_SS_BCS = NA, A_CC_BCS = NA,
type = 'score'
) {
Expand Down Expand Up @@ -153,6 +160,13 @@ calc_bcs <- function(B_LU_BRP,B_SOILTYPE_AGR,A_SOM_LOI, D_PH_DELTA,
#'
#' @param D_BCS (numeric) The value of BCS calculated by \code{\link{calc_bcs}}
#'
#' @examples
#' ind_bcs(D_BCS = 12)
#' ind_bcs(D_BCS = c(12,18,26,30))
#'
#' @return
#' The evaluated score for the Visual Soil Assessment. A numeric value between 0 and 50.
#'
#' @export
ind_bcs <- function(D_BCS) {

Expand Down
8 changes: 8 additions & 0 deletions R/bulk_density.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
#'
#' @import data.table
#'
#' @examples
#' calc_bulk_density(B_SOILTYPE_AGR = 'zeeklei', A_SOM_LOI = 6.5, A_CLAY_MI = 28)
#' calc_bulk_density(B_SOILTYPE_AGR = 'dekzand', A_SOM_LOI = 3.5)
#' calc_bulk_density(B_SOILTYPE_AGR = c('dekzand','rivierklei'), A_SOM_LOI = c(3.5,8.5))
#'
#' @return
#' The bulk density of an arable soil (kg / m3). A numeric value.
#'
#' @export
calc_bulk_density <- function(B_SOILTYPE_AGR, A_SOM_LOI, A_CLAY_MI = NULL) {

Expand Down
Loading

0 comments on commit 6618d32

Please sign in to comment.