View source: R/spct.normalize.r
| setNormalized | R Documentation |
Function to write the "normalized" attribute of an existing
generic_spct object.
setNormalized(
x,
norm = FALSE,
norm.type = NA_character_,
norm.factors = NA_real_,
norm.cols = NA_character_,
norm.range = rep(NA_real_, 2),
verbose = getOption("verbose_as_default", default = FALSE)
)
setNormalised(
x,
norm = FALSE,
norm.type = NA_character_,
norm.factors = NA_real_,
norm.cols = NA_character_,
norm.range = rep(NA_real_, 2),
verbose = getOption("verbose_as_default", default = FALSE)
)
x |
a generic_spct object. |
norm |
logical or numeric If |
norm.type |
character Type of normalization applied. |
norm.factors |
numeric The scaling factor(s) so that dividing the spectral values by this factor reverts the normalization. |
norm.cols |
character The name(s) of the columns in |
norm.range |
numeric The wavelength range used for normalization (nm). |
verbose |
logical Flag enabling or silencing informative warnings. |
This function is used internally, although occasionally
users may want to use it to "pretend" that spectral data have not been
normalized. Use normalize() methods to apply a normalization
and simultaneously set the metadata attributes. Function
setNormalized() only saves to the attributes the metadata
corresponding to an already applied normalization. The metadata provides a
trace of the transformations applied to spectral data that makes it
possible to undo the normalization. The metadata is also used in
other by functions in package 'ggspectra' when automatically generating
axis labels.
If norm = FALSE is passed in the call any normalization metadata
present in x are reset and, thus, x marked as not normalized,
without undoing the effect of the normalization.
If x is not a generic_spct object, x is not modified.
The object passed as argument to x is modified by reference by
adding attributes normalized and normalization, unless the
argument passed to x is an anonymous expression. A copy of the
modified x is always returned invisibly, even when setting by
reference fails.
With a single spectrum in x, attribute normalization is set
to a named list, and in the case of multiple spectra in long form, it is
set a named list or named lists, unless norm = FALSE is passed, in
which case the normalization attribute is deleted if already
present. The named list for each spectrum contains the fields:
norm.typecharacter vector of length one, one of "max", "min", "wavelength".
norm.wlnumeric, normalization wavelength in nanometres.
norm.factorsnumeric, multiplier constans used to scale the normalized spectral data.
norm.colscharacter, the name of the columns of x that have been normalized.
norm.rangenumeric vector of length 2, with min and maximum w.length values used to constrain the normalization.
Spectral objects, to allow choice in the trade-off between storage space
and computation effort, can contain multiple columns of spectral data
(e.g., s.e.irrad and s.q.irard), each one with its own
normalization. Only one value is allowed for norm.type, but
norm.wl and norm.factors are vectors of the same length as
norm.cols as their numeric values depend on the unit/base of
expression.
Attribute normalized is set to TRUE unless
norm = FALSE is passed.
Passing a logical as argument to norm is deprecated but
accepted silently for backwards compatibility.
setNormalised() is another name for setNormalized().
Other rescaling functions:
fscale(),
fshift(),
getNormalized(),
getScaled(),
is_normalized(),
is_scaled(),
normalize(),
setScaled()
norm_sun.spct <- normalize(sun.spct, norm = "max")
is_normalized(norm_sun.spct)
# rarely useful: pretend that the spectrum has not been normalized
pretended_sun.spct <- setNormalized(norm_sun.spct, norm = FALSE)
is_normalized(pretended_sun.spct)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.