wl2i: Conversion between Wavelength and Spectra Matrix Column Index...

Description Usage Arguments Details Value Author(s) Examples

Description

If wavelength is numeric, each of its elements is converted to the respective index. Values outside the range of x@wavelength become NA.

Usage

1
2
3
wl2i(x, wavelength = stop("wavelengths are required."))

i2wl(x, i)

Arguments

x

a hyperSpec object

wavelength

the wavelengths to be converted into column indices, either numeric or a formula, see details.

i

the column indices into the spectra matrix for which the wavelength is to be computed

Details

If the range is given as a formula (i.e. start ~ end, a sequence

index corresponding to start : index corresponding to end

is returned. If the wavelengths are not ordered, that may lead to chaos. In this case, call orderwl first.

Two special variables can be used: min and max, corresponding to the lowest and highest wavelength of x, respectively.

start and end may be complex numbers. The resulting index for a complex x is then

index (Re (x)) + Im (x)

Value

A numeric containing the resulting indices for wl2i

i2wl returns a numeric with the wavelengths

Author(s)

C. Beleites

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
flu
wl2i (flu, 405 : 407)
wl2i (flu, 405 ~ 407)

## beginning of the spectrum to 407 nm
wl2i (flu, min ~ 407)

## 2 data points from the beginning of the spectrum to 407 nm
wl2i (flu, min + 2i ~ 407)

## the first 3 data points
wl2i (flu, min ~ min + 2i)

## from 490 nm to end of the spectrum
wl2i (flu, 490 ~ max)

## the last 8 data points
wl2i (flu, max - 7i ~ max)

## get 450 nm +- 3 data points
wl2i (flu, 450 - 3i ~ 450 + 3i)

wl2i (flu, 300 : 400) ## all NA:
wl2i (flu, 600 ~ 700) ## NULL: completely outside flu's wavelength range
i2wl (chondro, 17:20)

Example output

Loading required package: lattice
Loading required package: grid
Loading required package: ggplot2
Package hyperSpec, version 0.99-20180627

To get started, try
   vignette ("hyperspec")
   package?hyperSpec 
   vignette (package = "hyperSpec")

If you use this package please cite it appropriately.
   citation("hyperSpec")
will give you the correct reference.

The project homepage is http://hyperspec.r-forge.r-project.org


hyperSpec object
   6 spectra
   3 data columns
   181 data points / spectrum
wavelength: lambda/nm [numeric] 405.0 405.5 ... 495 
data:  (6 rows x 3 columns)
   1. spc: I[fl]/"a.u." [matrix181] 27.15000 66.80133 ... 294.6495 
   2. filename: filename [character] rawdata/flu1.txt rawdata/flu2.txt ... rawdata/flu6.txt 
   3. c: c / (mg / l) [numeric] 0.05 0.10 ... 0.3 
[1] 1 3 5
[1] 1 2 3 4 5
[1] 1 2 3 4 5
[1] 3 4 5
[1] 1 2 3
 [1] 171 172 173 174 175 176 177 178 179 180 181
[1] 174 175 176 177 178 179 180 181
[1] 88 89 90 91 92 93 94
  [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
 [26] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
 [51] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
 [76] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[101] NA
NULL
[1] 666 670 674 678

hyperSpec documentation built on May 2, 2019, 5:45 p.m.