Skip to content

Commit

Permalink
Merge pull request #19 from springgbv/yuki_verslemping
Browse files Browse the repository at this point in the history
adjust lookup table to calculate cor.A_OS_GV
  • Loading branch information
SvenVw authored Oct 10, 2019
2 parents 275e50d + 38a29d6 commit 41605a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Fixed
* Fixed typo if mais in `ind_managment`
* Fixed test for winderodibility
* Use the correct correction factor in `calc_sealing_risk` #19

## Version 0.8.0 2019-08-02
### Added
Expand Down
4 changes: 2 additions & 2 deletions R/sealing.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ calc_sealing_risk <- function(A_CLAY_MI, A_OS_GV) {
dt[is.na(value), value.A_CLAY_MI := fun.A_CLAY_MI(A_CLAY_MI)]

# Create organic matter correction function and calculate correction for A_OS_GV
fun.cor.A_OS_GV <- approxfun(x = df.lookup$value.A_CLAY_MI, y = df.lookup$cor.A_OS_GV, rule = 2)
dt[is.na(value), cor.A_OS_GV := fun.cor.A_OS_GV(value.A_CLAY_MI)]
fun.cor.A_OS_GV <- approxfun(x = df.lookup$A_CLAY_MI, y = df.lookup$cor.A_OS_GV, rule = 2)
dt[is.na(value), cor.A_OS_GV := fun.cor.A_OS_GV(A_CLAY_MI)]

# Calculate the value
dt[is.na(value), value := value.A_CLAY_MI + cor.A_OS_GV * A_OS_GV]
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-sealing.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ test_that("calc_sealing works", {
A_CLAY_MI = 20,
A_OS_GV = 5
),
expected = 8.625,
expected = 8.4375,
tolerance = 0.001
)
expect_equal(
calc_sealing_risk(
A_CLAY_MI = c(25, 20),
A_OS_GV = c(1.5, 8)
),
expected = c(8.6, 10.5),
expected = c(8.6, 10.2),
tolerance = 0.001
)
})
Expand Down

0 comments on commit 41605a6

Please sign in to comment.