Learn R Programming

soil.spec (version 2.1.4)

read.opus-method: Reads binary OPUS files containing spectroscopy

Description

Reads binary http://www.bruker.com/products/infrared-near-infrared-and-raman-spectroscopy/opus-software/downloads.html{OPUS} files containing infrared, near infrared and Raman spectroscopy measurements (absorbances) and generates an object of class "SpectraPoints".

Usage

## S3 method for class 'character':
read.opus(file.name, sp = NULL,  
    codes = c("ZFF","RES","SNM","DAT","LWN","FXV","LXV","NPT","MXY","MNY","END","TIM"), 
    plot.spectra = FALSE, print.progress = FALSE, speclib = "ICRAF",
    signif.digit = get("signif.digit", spec.opts), MID, st.wavenumbers = wavenumbers)
## S3 method for class 'list':
read.opus(file.name, \dots)

Arguments

file.name
"character"; file name with extension
sp
"SpatialPoints"; optional spatial object with coordinates of points with same sample ID's in the coordinates slot row names
codes
"character"; default OPUS codes
plot.spectra
"logical"; specifies whether to plot spectral curves every time a new sample is loaded
print.progress
"logical"; specifies whether to print progress
signif.digit
"integer"; number of significant digits
speclib
"character"; specifies which spectral library to base data points
MID
"character"; metadata ID
st.wavenumbers
"data.frame"; standard wavenumbers with band names and upper / lower limits (usually predefined)
...
other optional arguments

Details

This function will read OPUS files from Bruker Optics' Alpha, MPA and Tensor-27 spectrometers. A choice for the type of spectral library to be created from the data tables created is done. To match data points to ICRAF's spectral library set speclib = "ICRAF", otherwise to create own spectral library based on OPUS files being converted set speclib="New".

References

  • http://www.bruker.com/products/infrared-near-infrared-and-raman-spectroscopy/opus-software/downloads.html{Bruker Coorporation Guide for Infrared Spectroscopy}

See Also

SpectraPoints-class, predict.SpectraPoints, wavenumbers

Examples

Run this code
## Original binary Opus files:
pth = system.file(package = "soil.spec")
lst <- as.list(list.files(path=pth, pattern="*.0$", full.names=TRUE))
file.info(lst[[1]])
xx <- read.opus(lst)
str(xx)
## predict pH
data(m.PHIHOX)
s.xx <- predict(xx, model = m.PHIHOX, prob. = .75)
s.xx
## Note: duplicate samples get unique name by default

## predict all standard soil properties:
nm <- get("attributes", spec.opts)
nm
pr.lst <- NULL
for(k in 1:length(nm)){
  data(list=paste("m.", nm[k], sep=""))
  try( pr.lst[[k]] <- predict(xx, variable=nm[k], 
  model = get(paste("m.", nm[k], sep="")), prob. = .75) )
}
pr <- do.call(cbind, pr.lst)
str(pr)

Run the code above in your browser using DataLab