Skip to content

Commit

Permalink
Specify default directly in sensmodel arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo committed Feb 20, 2021
1 parent 8b39caf commit 11ecb6e
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions R/sensmodel.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@


sensmodel <- function(peaksens, range = c(300, 700), lambdacut = NULL, Bmid = NULL,
oiltype = NULL, beta = TRUE, om = NULL, integrate = TRUE, sensnames = NULL) {
oiltype = NULL, beta = TRUE, om = NULL, integrate = TRUE, sensnames = paste0("lmax", peaksens)) {
if (!is.null(lambdacut)) {
if (is.null(Bmid) & is.null(oiltype)) stop("Bmid or oiltype must be included when including a lambdacut vector", call. = FALSE)
if (length(lambdacut) != length(peaksens)) stop("lambdacut must be same length as peaksens", call. = FALSE)
Expand Down Expand Up @@ -158,20 +158,13 @@ sensmodel <- function(peaksens, range = c(300, 700), lambdacut = NULL, Bmid = NU

sensecurves <- as.data.frame(sensecurves)

if (!is.null(sensnames)) {
if (length(sensnames) != length(sensecurves)) {
message("The length of argument 'sensnames' does not equal the number of curves specified by 'peaksens'. Reverting to default names.")
sensnames <- NULL
} else {
names(sensecurves) <- sensnames
}
}

if (is.null(sensnames)) {
names(sensecurves) <- paste0("lmax", peaksens)
if (length(sensnames) != length(sensecurves)) {
message("The length of argument 'sensnames' does not equal the number of curves specified by 'peaksens'. Reverting to default names.")
sensnames <- paste0("lmax", peaksens)
} else {
names(sensecurves) <- sensnames
}


sensecurves <- cbind(wl, sensecurves)

class(sensecurves) <- c("sensmod", "rspec", "data.frame")
Expand Down

0 comments on commit 11ecb6e

Please sign in to comment.