Skip to content

Commit

Permalink
Adapt to accept data.frame as c_tops
Browse files Browse the repository at this point in the history
  • Loading branch information
mrustl committed Jul 1, 2024
1 parent 9de50de commit 32c0130
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion R/prepare_atmosphere.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,24 @@ prepare_atmosphere <- function(
conc_irrig_clearwater = conc_irrig_clearwater,
conc_rain = conc_rain)

n_conc <- sapply(conc_paras, length)

is_vector <- sapply(conc_paras, is.vector)

n_conc <- sapply(seq_along(conc_paras), function(i) { if(is_vector[i]) {
length(conc_paras[[i]])
} else {
if(is.data.frame(conc_paras[[i]])) {
stopifnot(nrow(conc_paras[[i]]) == nrow(atm))
stopifnot(ncol(conc_paras[[i]]) <= 10)
ncol(conc_paras[[i]])
} else {
stop("unsupported data type")
}
}
})

names(n_conc) <- names(conc_paras)


if (sum(n_conc > 1) > 1) {
if(all(n_conc[n_conc > 1] != n_conc[n_conc > 1][1])) {
Expand Down

0 comments on commit 32c0130

Please sign in to comment.