This function finds all peaks (local maxima) in a spectrum, using a user
provided size threshold relative to the tallest peak (global maximum) bellow
which found peaks are ignored—i.e., not included in the returned value. This
is a wrapper built on top of function peaks()
from package 'splus2R'.
Arguments
- x
numeric vector
- ignore_threshold
numeric Value between 0.0 and 1.0 indicating the relative size compared to tallest peak threshold below which peaks will be ignored. Negative values set a threshold so that the tallest peaks are ignored, instead of the shortest.
- span
integer A peak is defined as an element in a sequence which is greater than all other elements within a window of width
span
centered at that element. UseNULL
for the global peak.- strict
logical If
TRUE
, an element must be strictly greater than all other values in its window to be considered a peak.- na.rm
logical indicating whether
NA
values should be stripped before searching for peaks.
Value
A logical vector of the same length as x
. Values that are
TRUE
correspond to local peaks in the data.
Note
This function is a wrapper built on function
peaks
from splus2R and handles non-finite
(including NA
) values differently than splus2R::peaks
,
instead of giving an error they are replaced with the smallest finite value
in x
.
See also
Other peaks and valleys functions:
find_spikes()
,
get_peaks()
,
peaks()
,
replace_bad_pixs()
,
spikes()
,
valleys()
,
wls_at_target()
Examples
with(sun.data, w.length[find_peaks(s.e.irrad)])
#> [1] 315 317 321 327 330 332 335 340 343 345 347 350 354 360 364 366 370 378
#> [19] 381 385 387 391 395 402 404 409 412 414 416 419 421 426 433 436 442 444
#> [37] 448 451 457 461 464 466 468 472 475 478 480 482 488 490 493 495 499 503
#> [55] 506 509 512 516 518 522 525 529 531 536 538 545 547 550 552 555 558 561
#> [73] 563 565 568 570 573 577 582 587 591 594 597 600 605 608 612 615 619 621
#> [91] 627 629 633 635 638 642 651 653 662 668 674 688 692 697 704 709 712 722
#> [109] 727 730 734 741 744 747 751 754 762 771 774 777 779 782 785 792 794 798