Description Usage Arguments Details Value Examples
View source: R/Spectra-Methods.R
Spectra
Creates an instance of class Spectra
.
1 |
inDF |
a long-format |
Spectra |
|
Wavelengths |
|
Units |
|
space |
a character or integer holding the
column index in inDF where the spatial coordinates are (if length(space)==2) or where the ID of
the spatial location is (if (length(space)==1). If |
time |
|
endTime |
|
header |
|
... |
other input arguments to be passed to the new() function |
This constructor function uses The function Spectra()
calls spacetime::stConstruct()
that is the constructor of the STIDF
class using an input data.frame
object of long-table format.
length{@Wavelengths}==ncol(@Spectra)
. The default @WavelengthsUnit is nm^-1.
Returns an object of class Spectra
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | fnm = file.path(base::system.file(package = "geoSpectral"),
"test_data","particulate_absorption.csv.gz")
fnm=gsub("\\\\", "/", fnm)
abs = read.table(fnm,sep=",",header=TRUE)
abs$STATION=factor(abs$STATION)
abs[1:2,1:17] #Display only the first 2 rows and first 17 columns if the data frame
lbd = as.numeric(gsub("X","",colnames(abs)[14:514]))
Units="1/m"
colnames(abs)= gsub("X",paste("anap","_",sep=""), colnames(abs))
colnames(abs)= gsub("PRES","DEPTH", colnames(abs))
abs = abs[,c(14:514,1:13)] #Rearrange so that Spectra columns come first
tz<-strsplit(as.character(abs$TIME)," ")[[1]][[3]] #Extract the timezone
abs$TIME = as.POSIXct(as.character(abs$TIME),tz=tz) #Compute the time
#Space and time columns are automatically found in the column names of inDF
myS<-Spectra(abs,Wavelengths=lbd,Units=Units,ShortName="a_nap")
#Space and time columns are explicitly chosen from inDF columns
myS<-Spectra(abs,Wavelengths=lbd, space=c("LONG","LAT"), time="TIME",
Units=Units,ShortName="a_nap")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.