Spectra: Constructor function for the class 'Spectra'.

Description Usage Arguments Details Value Examples

View source: R/Spectra-Methods.R

Description

Spectra Creates an instance of class Spectra.

Usage

1
Spectra(inDF, Spectra, Wavelengths, Units, space, time, endTime, header, ...)

Arguments

inDF

a long-format data.frame containing LAT,LON and TIME columns as well as Ancillary data. See stConstruct for more information on long DF format.

Spectra

matrix containing spectral data. Channels are in columns, observations are in rows. If Spectra is missing, the first length(Wavelengths) columns of inDF will be taken as spectral data.

Wavelengths

numeric vector containing wavelengths of spectral channels.

Units

character defining the units of the wavelengths.

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 space is not provided, inDF columns are searched to match one of the following : LAT,lat,latitude,LATITUDE,LON,LONG,lon,long,longitude,LONGITUDE If LAT & LON are not found, they set the dummy value of 1.

time

character or integer indicating the column in inDF containing POSIXct TIME data values. if time is missing, it is set the dummy integer sequential vector of 1:nrow(Spectra).

endTime

character or integer indicating the column in inDF containing POSIXct ENDTIME data values. If the temporal measurements are performed over an interval, time and endtime contain the time for the start and end of intervals respectively. If the temporal measurements are performed over a time-instance, then endTime==TIME. If endTime is not provided, inDF columns are searched to match ENDTIME. If none found, then it is assumed that data are time-instance measurements. For more information, see the documentation of spacetime.

header

SpcHeader object containing metadata

...

other input arguments to be passed to the new() function

Details

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.

Value

Returns an object of class Spectra.

Examples

 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")

PranaGeo/geoSpectral documentation built on Feb. 21, 2020, 10:22 a.m.