-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to
get_SDA_*
/ SOD-like methods (#185)
* get_SDA_property: Vectorizing `property` argument, add argument to get query string * get_SDA_interpretation: Vectorizing `rulename` * get_SDA*: Standardize lower case MUKEY, COKEY, CHKEY, etc. * get_SDA_interpretations: consistent column names for all methods w/ .cleanRuleColumnName() * Demo of bottom_depth logic for weighted average, and comparing column names in results * removing conversion of NULL to 0, why was this in there * get_SDA_interpretation: add not_rated_value argument, default NA_real_ * Update docs Co-authored-by: Dylan Beaudette <[email protected]>
- Loading branch information
1 parent
6b9d08c
commit dea0032
Showing
9 changed files
with
511 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
library(soilDB) | ||
|
||
# WORKS (dominant condition) | ||
get_SDA_property(c("taxsuborder", "taxorder", "tfact"), | ||
method = "dominant condition", | ||
areasymbols = "CA630") | ||
# WORKS (min/max) | ||
get_SDA_property(c("ksat_l", "ksat_r", "ksat_h"), | ||
method = "min", | ||
areasymbols = "CA630") | ||
|
||
# WORKS (weighted average) | ||
get_SDA_property(c("ksat_l", "ksat_r", "ksat_h"), | ||
method = "weighted average", | ||
areasymbols = 'CA630') | ||
|
||
# WORKS (dominant component, numeric -- special case of weighted average) | ||
q <- get_SDA_property( | ||
c("ksat_l", "ksat_r", "ksat_h"), | ||
method = "dominant component (numeric)", | ||
areasymbols = 'CA630', | ||
query_string = TRUE # this just returns the query instead of calling SDA_query | ||
) | ||
# cat(q) | ||
res <- SDA_query(q) | ||
res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
library(soilDB) | ||
|
||
# select a single mukey to check that top and bottom depth and different methods produce stable results | ||
keys <- c(463276) | ||
|
||
s1 <- get_SDA_property(property = 'Available Water Capacity - Rep Value', | ||
method = 'Weighted Average', | ||
mukeys = keys, | ||
top_depth = 0, | ||
bottom_depth = 200) | ||
s2 <- get_SDA_property(property = 'Available Water Capacity - Rep Value', | ||
method = 'Weighted Average', | ||
mukeys = keys, | ||
top_depth = 0, | ||
bottom_depth = 1000) | ||
testthat::expect_equal(s1, s2) | ||
testthat::expect_equal(s1$awc_r, 0.13) | ||
|
||
s3 <- get_SDA_property(property = 'Available Water Capacity - Rep Value', | ||
method = 'Dominant Component (Numeric)', | ||
mukeys = keys, | ||
top_depth = 0, | ||
bottom_depth = 200) | ||
s4 <- get_SDA_property(property = 'Available Water Capacity - Rep Value', | ||
method = 'Dominant Component (Numeric)', | ||
mukeys = keys, | ||
top_depth = 0, | ||
bottom_depth = 1000) | ||
testthat::expect_equal(s3, s4) | ||
testthat::expect_equal(s3$awc_r, 0.18) | ||
|
||
s5 <- get_SDA_interpretation(rulename = 'FOR - Mechanical Planting Suitability', | ||
method = 'Weighted Average', | ||
mukeys = keys) | ||
testthat::expect_equal(s5$rating_FORMechanicalPlantingSuitability, 0.99) | ||
|
||
s6 <- get_SDA_interpretation(rulename = 'FOR - Mechanical Planting Suitability', | ||
method = 'Dominant Component', | ||
mukeys = keys) | ||
testthat::expect_equal(s6$rating_FORMechanicalPlantingSuitability, 0.987) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters