biofilter_toc_once function

Apply biofilter_toc function and output a data frame

Apply biofilter_toc function and output a data frame

This function allows biofilter_toc to be added to a piped data frame. Its output is a data frame with updated TOC, DOC, and BDOC

biofilter_toc_once( df, input_water = "defined_water", ebct = 0, ozonated = TRUE )

Arguments

  • df: a data frame containing a water class column, which has already been computed using define_water_chain. The df may include a column indicating the EBCT or whether the water is ozonated.
  • input_water: name of the column of Water class data to be used as the input for this function. Default is "defined_water".
  • ebct: The empty bed contact time (min) used for the biofilter
  • ozonated: Logical; TRUE if the water is ozonated (default), FALSE otherwise

Returns

A data frame with updated DOC, TOC, and BDOC concentrations.

Details

The data input comes from a water class column, as initialized in define_water_chain.

If the input data frame has column(s) named "ebct" or "ozonated", the function uses those as arguments. Note: The function can use either a column or the direct function arguments, not both.

tidywater functions cannot be added after this function because they require a water class input.

For large datasets, using fn_once or fn_chain may take many minutes to run. These types of functions use the furrr package for the option to use parallel processing and speed things up. To initialize parallel processing, use plan(multisession) or plan(multicore) (depending on your operating system) prior to your piped code with the fn_once or fn_chain functions. Note, parallel processing is best used when your code block takes more than a minute to run, shorter run times will not benefit from parallel processing.

Examples

library(purrr) library(furrr) library(tidyr) library(dplyr) example_df <- water_df %>% define_water_chain() %>% biofilter_toc_once(input_water = "defined_water", ebct = 10, ozonated = FALSE) example_df <- water_df %>% define_water_chain() %>% mutate( ebct = rep(c(10, 15, 20), 4), ozonated = c(rep(TRUE, 6), rep(FALSE, 6)) ) %>% biofilter_toc_once(input_water = "defined_water") # Initialize parallel processing plan(multisession, workers = 2) # Remove the workers argument to use all available compute example_df <- water_df %>% define_water_chain() %>% biofilter_toc_once(input_water = "defined_water", ebct = c(10, 20)) # Optional: explicitly close multisession processing plan(sequential)

See Also

biofilter_toc

  • Maintainer: Sierra Johnson
  • License: Apache License (>= 2) | MIT + file LICENSE
  • Last published: 2025-01-22