- Agustin.Lobo@geo3bcn.csic.es
- 20230726
- 20230721 Lab spectra acquired with Valentin
- FS3, optic fiber + 8º forelens and ASD PROLAMP illuminator
require(ggplot2)
require(plotly)
library(RColorBrewer)
library(plyr)
require(prospectr)
#library(soilspec)
#NOTE: there is also asdreader::get_spectra() (see EspCrater_FS3_nb.Rmd)
# > getwd()
# [1] "/media/alobo/DecepNTFS2/HSI_Lab/Testllum_20230717/Rtestllum_20230717"
dirRSpect <- "/home/alobo/owncloudRSpect/RSpect"
dirdat <- "../EspCrater_HandSamples/FS3/EspCraterSamples20230721"
1. Reading data
#inital list of files and times to sort them and write csv:
#f <- list.files(dirdat, patt=glob2rx("*.asd"))
#ft <- file.mtime(file.path(dirdat,f))
#df <- data.frame(file=f, time=ft)
#df <- df[order(df$time),]
#head(df)
#write.csv(df, file=file.path(dirdat,"labNoprobe20230717.csv"))
#"labNoprobe20230717.csv" edited in LibreOffice Calc
f <- read.csv(file.path(dirdat,"labNoprobe20230717.csv"), stringsAsFactors = FALSE)
f$ID <- paste(f$sample,f$point,f$replicate, sep="_")
3. Reflectance Spectra
#glabnoprobe <- ggplot(data=d.lf[d.lf$sample!="backg",],
# aes(label1=ID,label2=point, label3=replicate)) +
# geom_line(aes(x=w, y=sc, color=sample, group=file), linewidth=0.3) +
# xlab("Wavelength") + ylab("Reflectance") +
# theme(legend.position="none") +
# ggtitle("Espai Crater: lab (optic fiber) Reflectance spectra")
# #scale_color_brewer(palette = "Set1")
#d.lf is too large. We average replicates
a <- ddply(d.lf,c("sample", "point","w"), summarise, sc = mean(sc))
a$ID <- paste0(a$sample,"_",a$point)
d.lf <- a
glabnoprobe <- ggplot(data=d.lf[d.lf$sample!="backg",],
aes(label1=ID,label2=point)) +
geom_line(aes(x=w, y=sc, color=sample), linewidth=0.3) +
xlab("Wavelength") + ylab("Reflectance") +
theme(legend.position="none") +
ggtitle("Espai Crater: lab (optic fiber) Reflectance spectra")
ggplotly(glabnoprobe + facet_wrap(~sample))