28 abr 2015

Centered spectra vs. Std Spectrum



In my last post I added a video, with the idea of the centered spectra. The video is in Spanish, but I hope you can follow the script with R. 
The idea of this post is overplot the centered spectra with the standard deviation spectrum which also explain the wavelengths of the spectrum which has more variation. The script has to consider that we have two scales, so I put one on the left (centered spectra) and on the right the scale for the standard deviation spectra. We can see that the zone of variation matches.
NIR.mc<-scale(gasoline$NIR,center=TRUE,scale=FALSE)
matplot(wavelengths,t(NIR.mc),type="l",lty=1,
        col="blue",col.axis="blue",
        xlab="wavelength",ylab="log 1/R",
        main="Centered Spectra + STD Spectrum")
par(new=T)
#The standard deviation spectrum for gasoline$NIR is:
NIR.sd<-apply(gasoline$NIR,2,sd)
matplot(wavelengths,NIR.sd,type="l",lty=1,lwd=4,col="red",
        xlab="wavelength",ylab="log 1/R",
        axes=FALSE)
axis(4,col.axis="red")

No hay comentarios:

Publicar un comentario