Functions to read the "normalized" and "normalization" attributes of an existing generic_spct object.
Usage
getNormalized(x, .force.numeric = FALSE)
getNormalised(x, .force.numeric = FALSE)
getNormalization(x)
getNormalisation(x)Value
For objects containing a single spectrum, getNormalized()
returns a logical value, and exceptionally for objects created with
'photobiology' (< 0.10.8), a numeric value (normalization wavelength
expressed in nanometres). A character value for objects created with
'photobiology' (< 0.x.x). For collections of spectra and multiple spectra
in long form, a named list, with one logical member for each spectrum is
returned. If x is not a generic_spct object, NA is
returned with a warning.
For objects containing a single spectrum, getNormalization() returns
a list with five fields: norm.type, norm.wl,
norm.factors, norm.cols, norm.range. For collections
of spectra, a named list of lists, with one member list for each member of
the collection of spectra is returned. Objects created with versions of
package 'photobiology' (< 0.10.8) are lacking the detailed normalization
metadata, in which case getNormalized() must be used to detect
normalization. See setNormalized() for the values stored in
the fields. If x is not a generic_spct object, a named list
with all fields set to NA is returned with a warning.
Details
In some computations spectral data that have been normalized need to
be handled differently than data expressed in original units. Method
getNormalized() makes it possible to query if a
generic_spct or generic_mspct object or objects of derived
classes contain data expressed in true physical units or normalized.
Method getNormalization() retrieves from objects storing spectral
data, metadata that trace previously applied normalizations, making it
possible to revert the effect of earlier normalizations. The metadata are
also used when printing and plotting the spectra.
Note
While method getNormalized() returns in some cases numeric
values or possibly even character values if stored in attribute
normalized, is_normalized() always returns a logical value
and can be safely used in conditional code clauses.
getNormalised() is another name for getNormalized().
getNormalisation() is another name for getNormalization().
See also
Other rescaling functions:
fscale(),
fshift(),
getScaled(),
is_normalized(),
is_scaled(),
normalize(),
setNormalized(),
setScaled()
Examples
getNormalized(sun.spct)
#> [1] FALSE
str(getNormalization(sun.spct))
#> List of 5
#> $ norm.type : chr NA
#> $ norm.wl : num NA
#> $ norm.factors: num NA
#> $ norm.cols : chr NA
#> $ norm.range : num [1:2] NA NA
norm_sun.spct <- normalize(sun.spct)
is_normalized(norm_sun.spct)
#> [1] TRUE
getNormalized(norm_sun.spct)
#> [1] TRUE
str(getNormalization(norm_sun.spct))
#> List of 5
#> $ norm.type : chr [1:2] "max" "max"
#> $ norm.wl : num [1:2] 451 531
#> $ norm.factors: num [1:2] 1.22 2.96e+05
#> $ norm.cols : chr [1:2] "s.e.irrad" "s.q.irrad"
#> $ norm.range : num [1:2] 280 800
str(getNormalization(e2q(norm_sun.spct)))
#> List of 5
#> $ norm.type : chr "max"
#> $ norm.wl : num 531
#> $ norm.factors: num 296300
#> $ norm.cols : chr "s.q.irrad"
#> $ norm.range : num [1:2] 280 800
norm_gel.spct <- normalize(yellow_gel.spct)
is_normalized(norm_gel.spct)
#> [1] TRUE
getNormalized(norm_gel.spct)
#> [1] 768
str(getNormalization(norm_gel.spct))
#> List of 5
#> $ norm.type : chr "max"
#> $ norm.wl : num 768
#> $ norm.factors: num 1.11
#> $ norm.cols : chr "Tfr"
#> $ norm.range : int [1:2] 190 800
getNormalization(T2Afr(norm_gel.spct))
#> $norm.type
#> [1] "max" "max"
#>
#> $norm.wl
#> [1] 768 196
#>
#> $norm.factors
#> [1] 1.108911 1.086968
#>
#> $norm.cols
#> [1] "Tfr" "Afr"
#>
#> $norm.range
#> [1] 190 800
#>
getNormalization(any2A(norm_gel.spct))
#> $norm.type
#> [1] "max" "max"
#>
#> $norm.wl
#> [1] 768 367
#>
#> $norm.factors
#> [1] 1.108911 0.200000
#>
#> $norm.cols
#> [1] "Tfr" "A"
#>
#> $norm.range
#> [1] 190 800
#>
norm_sun_evening.mspct <- normalize(sun_evening.mspct[1:3])
str(is_normalized(norm_sun_evening.mspct))
#> List of 3
#> $ time.01: logi TRUE
#> $ time.02: logi TRUE
#> $ time.03: logi TRUE
#> - attr(*, "comment")= chr "Applied function: 'is_normalized'.\n"
str(getNormalized(norm_sun_evening.mspct))
#> List of 3
#> $ time.01: num 451
#> $ time.02: num 451
#> $ time.03: num 451
#> - attr(*, "comment")= chr "Applied function: 'getNormalized'.\n"
str(getNormalization(norm_sun_evening.mspct))
#> List of 3
#> $ time.01:List of 5
#> ..$ norm.type : chr "max"
#> ..$ norm.wl : num 451
#> ..$ norm.factors: num 13.3
#> ..$ norm.cols : chr "s.e.irrad"
#> ..$ norm.range : num [1:2] 290 1000
#> $ time.02:List of 5
#> ..$ norm.type : chr "max"
#> ..$ norm.wl : num 451
#> ..$ norm.factors: num 13.7
#> ..$ norm.cols : chr "s.e.irrad"
#> ..$ norm.range : num [1:2] 290 1000
#> $ time.03:List of 5
#> ..$ norm.type : chr "max"
#> ..$ norm.wl : num 451
#> ..$ norm.factors: num 13.9
#> ..$ norm.cols : chr "s.e.irrad"
#> ..$ norm.range : num [1:2] 290 1000
#> - attr(*, "comment")= chr "Applied function: 'getNormalization'.\n"
