Skip to content

Commit

Permalink
Adapt to be used for multi-solute definition
Browse files Browse the repository at this point in the history
  • Loading branch information
mrustl committed Jun 27, 2024
1 parent 55909fd commit ced3151
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion R/prepare_atmosphere_input.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ prepare_atmosphere_input <- function(
)
{
required_parameters <- get_atmosphere_headers()
n_solutes_per_run <- 12
optional_parameters <- sapply(2:n_solutes_per_run, function(i) {
c(sprintf("cTop%d", i), sprintf("cBot%d", i))
}) %>% as.vector()



is_given <- required_parameters %in% names(inputs)
is_given_optional <- optional_parameters %in% names(inputs)
has_default <- required_parameters %in% names(defaults)

if (any(is_missing <- !is_given & !has_default)) {
Expand All @@ -44,7 +51,9 @@ prepare_atmosphere_input <- function(

dplyr::bind_cols(
inputs[, required_parameters[is_given], drop = FALSE],
inputs[, optional_parameters[is_given_optional], drop = FALSE],
defaults[, required_parameters[!is_given & has_default], drop = FALSE]
) %>%
dplyr::select(tidyselect::all_of(required_parameters))
dplyr::select(tidyselect::all_of(required_parameters),
tidyselect::all_of(optional_parameters[is_given_optional]))
}

0 comments on commit ced3151

Please sign in to comment.