read.txt.wide.FAST: Parse FAST wide table ground-based spectrometry files

Description Usage Arguments Value Examples

Description

Parse FAST wide table ground-based spectrometry files

Usage

1
read.txt.wide.FAST(file, type = "reflectance", metadata = NULL, sep = ",")

Arguments

file

Path to the spectral data. Wide table format with columns [id, timestamp, spc] and wavelength as spc column names.

type

Reflectance, Irradiance or Radiance units

data

Path to extra data, must have same number of rows as number of spectra

Value

A hyperSpec object

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
26
27
28
29
30
31
32
33
34
# set path to data files
file.path <- system.file("extdata", package = "FASTSpectra")

# parse spectra into hyperSpec object
dn <- read.txt.OceanOptics(files=paste0(file.path,"/*.txt"))

# assign measurement id and type using fieldlog file
logfile <- paste0(file.path,"/fieldlog.csv")
dn <- assign.type(dn, logfile=logfile)

# split into sample and reference
type <- slot(dn,"data")[["type"]]
dn <- split(x=dn, f=type)

# convert samples to spectral radiance [W / sr m2 nm]
cal.rad <- paste0(file.path,"/*.IrradCal")
rad <- rad.corr(dn$SAMP, type="spectral.radiance", cal.DN2RadiantEnergy = cal.rad)
require(hyperSpec)
plot(rad, wl.range=380:850)

# convert references to spectral irradiance relative to 100% reference panel [W / m2 nm]
cal.ref <- paste0(file.path,"/*.ReflCal")
ref <- rad.corr(dn$REF, type="spectral.irradiance", is.REF=TRUE, cal.DN2RadiantEnergy = cal.rad, cal.RRefPanel = cal.ref)
plot(ref, wl.range=380:850)

# calculate reflectance as 'radiance/irradiance'
SHR <- calc.reflectance(reference=ref, sample=rad, logfile=logfile)
plot(SHR, wl.range=380:850)

# write to file
# write.txt.wide.FAST(SHR, paste0(file.path,"/HCRF.spc"), paste0(file.path,"/HCRF-metadata.spc"))

# read txt.wide file
# read.txt.wide.FAST <- function(paste0(file.path,"/HCRF.spc"), type="reflectance", metadata=paste0(file.path,"/HCRF-metadata.spc"))

edwardpmorris/FASTSpectra documentation built on May 15, 2019, 11:03 p.m.