Skip to content

Commit

Permalink
Temporarily dissable custom_eqn (#29).
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolepore committed Mar 22, 2019
1 parent 62838e6 commit eadae46
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 233 deletions.
17 changes: 12 additions & 5 deletions R/allo_find.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,24 @@ allo_find_memoised <- memoise::memoise(allo_find_impl)
#' dbh_unit = "cm",
#' bms_unit = "g",
#' dbh_min_mm = 0,
#' dbh_max_mm = Inf
#' dbh_max_mm = Inf,
#' is_generic = FALSE
#' )
#'
#' class(as_eqn(your_equations))
#'
#' allo_find(census_species, custom_eqn = as_eqn(your_equations))
#'
#' census_species %>%
#' allo_find(custom_eqn = as_eqn(your_equations))
#' # FIXME: https://github.com/forestgeo/fgeo.biomass/issues/29
#' try(allo_find(census_species, custom_eqn = as_eqn(your_equations)))
#' @family constructors
allo_find <- function(data, custom_eqn = NULL) {
if (!is.null(custom_eqn)) {
warn(glue("
Ignoring `custom_equaiton`.
See https://github.com/forestgeo/fgeo.biomass/issues/29
"))
}
custom_eqn <- NULL

inform("Assuming `dbh` in [mm] (required to find dbh-specific equations).")
warn_odd_dbh(data$dbh)
allo_find_memoised(data, custom_eqn = custom_eqn)
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
prefer_false <- function(x) {
stopifnot(is.logical(x))

if (all(x[!is.na(x)])) {
x
} else {
Expand Down
41 changes: 0 additions & 41 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -118,47 +118,6 @@ with_biomass %>%
arrange(desc(total_biomass))
```

### Providing custom equations

If we have our own equations, we can create an `equations`-like dataset and use it. `as_eqn()` helps us to create such a dataset: It ensures that our data has the correct structure.

```{r, error=TRUE}
# Checks that the structure of your data isn't terriby wrong
# BAD
as_eqn("really bad data")
as_eqn(data.frame(1))
# GOOD
custom_equations <- tibble::tibble(
equation_id = c("000001"),
site = c("scbi"),
sp = c("paulownia tomentosa"),
eqn = c("exp(-2.48 + 2.4835 * log(dbh))"),
eqn_type = c("mixed_hardwood"),
anatomic_relevance = c("total aboveground biomass"),
dbh_unit = "cm",
bms_unit = "g",
dbh_min_mm = 0,
dbh_max_mm = Inf,
)
class(as_eqn(custom_equations))
```

We can now use the argument `custom_eqn` to pass our custom equations to `allo_find()`.

```{r}
allo_find(census_species, custom_eqn = as_eqn(custom_equations))
```

This is what the entire workflow looks like:

```{r}
census_species %>%
allo_find(custom_eqn = as_eqn(custom_equations)) %>%
allo_evaluate()
```

### Issues

Our progress is recorded in this [Kanban project board](https://github.com/forestgeo/allodb/projects/4). Because we still don't support some features, the the biomass result currently is invalid and excludes some trees.
Expand Down
Loading

0 comments on commit eadae46

Please sign in to comment.