ozonate_bromate_chain function

Apply ozonate_bromate within a data frame and output a column of water class to be chained to other tidywater functions

Apply ozonate_bromate within a data frame and output a column of water class to be chained to other tidywater functions

This function allows ozonate_bromate to be added to a piped data frame. Its output is a water class, and can therefore be used with "downstream" tidywater functions. The bro3 slot will be updated.

ozonate_bromate_chain( df, input_water = "defined_water", output_water = "ozonated_water", dose = 0, time = 0, model = "Ozekin" )

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 named for the applied ozone dose (dose), and a column for time in minutes.
  • input_water: name of the column of water class data to be used as the input for this function. Default is "defined_water".
  • output_water: name of the output column storing updated parameters with the class, water. Default is "ozonated_water".
  • dose: Applied ozone dose (mg/L as O3). Results typically valid for 1-10 mg/L, but varies depending on model.
  • time: Reaction time (minutes). Results typically valid for 1-120 minutes, but varies depending on model.
  • model: Model to apply, defaults to "Ozekin". One of c("Ozekin", "Sohn", "Song", "Galey", "Siddiqui")

Returns

A data frame containing a water class column with updated bro3.

Details

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

If the input data frame has a dose column (dose) or time column (time), the function will use those columns. Note: The function can only take dose and time inputs as EITHER a column or as function arguments, not both.

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 %>% mutate(br = 50) %>% define_water_chain() %>% ozonate_bromate_chain(dose = 4, time = 8) example_df <- water_df %>% mutate(br = 50) %>% define_water_chain() %>% mutate( dose = c(seq(.5, 3, .5), seq(.5, 3, .5)), time = 30 ) %>% ozonate_bromate_chain() example_df <- water_df %>% mutate(br = 80) %>% define_water_chain() %>% mutate(time = 8) %>% ozonate_bromate_chain( dose = 6, model = "Sohn" ) # Initialize parallel processing plan(multisession, workers = 2) # Remove the workers argument to use all available compute example_df <- water_df %>% mutate(br = 50) %>% define_water_chain() %>% ozonate_bromate_chain(dose = 4, time = 8) # Optional: explicitly close multisession processing plan(sequential)

See Also

ozonate_bromate

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