-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* separating app and package vignettes. * update sig_noise and other docs * change transmittance to natural log, log10 is too agressive. * default smoothing set to optimal. * add and update tests * allow `make_rel()` to accept OpenSpecy objects * bug discoved, `smooth_intens()` can't handle NA's * force conform wavenumbers to stay inbounds * better names for plot. def_features when 1 pixel features present. more sop. * add funders, docs, update functions for consistency. * remove unused images * discovered that := can override the original data if we aren't careful. * Add methods to convert OpenSpecy objects to tables * Add ordering to `match_spec()` * Prep for CRAN submission * Submission 🥳 --------- Co-authored-by: Zacharias Steinmetz <git@zsteinmetz.de>
- Loading branch information
1 parent
3c25673
commit 3efca61
Showing
84 changed files
with
2,185 additions
and
2,029 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Version: 1.0.0 | ||
Date: 2023-09-01 14:53:15 UTC | ||
SHA: 1924ab057e7bd36723eccdd4649204fef0b2366c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#' @rdname make_rel | ||
#' @title Make spectral intensities relative | ||
#' | ||
#' @description | ||
#' \code{make_rel()} converts intensities \code{x} into relative values between | ||
#' 0 and 1 using the standard normalization equation. | ||
#' If \code{na.rm} is \code{TRUE}, missing values are removed before the | ||
#' computation proceeds. | ||
#' | ||
#' @details | ||
#' \code{make_rel()} is used to retain the relative height proportions between | ||
#' spectra while avoiding the large numbers that can result from some spectral | ||
#' instruments. | ||
#' | ||
#' @param x a numeric vector or an \R OpenSpecy object | ||
#' @param na.rm logical. Should missing values be removed? | ||
#' @param \ldots further arguments passed to \code{make_rel()}. | ||
#' | ||
#' @return | ||
#' \code{make_rel()} return numeric vectors (if vector provided) or an | ||
#' \code{OpenSpecy} object with the normalized intensity data. | ||
#' | ||
#' @examples | ||
#' make_rel(c(-1000, -1, 0, 1, 10)) | ||
#' | ||
#' @author | ||
#' Win Cowger, Zacharias Steinmetz | ||
#' | ||
#' @seealso | ||
#' \code{\link[base]{min}()} and \code{\link[base]{round}()}; | ||
#' \code{\link{adj_intens}()} for log transformation functions; | ||
#' \code{\link{conform_spec}()} for conforming wavenumbers of an | ||
#' \code{OpenSpecy} object to be matched with a reference library | ||
#' | ||
#' | ||
#' @export | ||
make_rel <- function(x, ...) { | ||
UseMethod("make_rel") | ||
} | ||
|
||
#' @rdname make_rel | ||
#' | ||
#' @export | ||
make_rel.default <- function(x, na.rm = FALSE, ...) { | ||
r <- range(x, na.rm = na.rm) | ||
|
||
return((x - r[1]) / (r[2] - r[1])) | ||
} | ||
|
||
#' @rdname make_rel | ||
#' | ||
#' @export | ||
make_rel.OpenSpecy <- function(x, na.rm = FALSE, ...) { | ||
x$spectra <- x$spectra[, lapply(.SD, make_rel, na.rm = na.rm, ...)] | ||
|
||
return(x) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.