Skip to content

Commit

Permalink
allow for vectors, required in shiny app
Browse files Browse the repository at this point in the history
  • Loading branch information
wincowgerDEV committed Jan 5, 2024
1 parent 2eb67d7 commit 1a92705
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions R/smooth_intens.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,13 @@ calc_window_points <- function(x, ...) {
#' @rdname smooth_intens
#'
#' @export
calc_window_points.default <- function(x, ...) {
stop("object 'x' needs to be of class 'OpenSpecy'")
}

#' @rdname smooth_intens
#'
#' @export
calc_window_points.OpenSpecy <- function(x, wavenum_width = 70){
calc_window_points.default <- function(x, wavenum_width = 70, ...) {
raw_points <- floor(wavenum_width/spec_res(x))

if(raw_points %% 2 == 0){
raw_points <- raw_points - 1
}
if(raw_points > length(x$wavenumber)){
if(raw_points > length(x)){
stop("The wavenum_width must be shorter than the full spectrum.")
}
if(raw_points <= 3){
Expand All @@ -109,6 +103,13 @@ calc_window_points.OpenSpecy <- function(x, wavenum_width = 70){
return(raw_points)
}

#' @rdname smooth_intens
#'
#' @export
calc_window_points.OpenSpecy <- function(x, wavenum_width = 70, ...){
do.call("calc_window_points", list(x = x$wavenumber, wavenum_width = wavenum_width))
}


#' @importFrom signal filter sgolay
.sgfilt <- function(y, p, n, m, abs = F, ...) {
Expand Down

0 comments on commit 1a92705

Please sign in to comment.