9 feb 2015

Moving average correction

It can happen that even acquiring enough subscans the spectra is still noisy, due to certain sample presentation limitations, so we can apply another technique to reduce the noise, the one called “moving average”. With this technique we select a window size (in this case 11) and the absorbance average of the 11 data points is given to the middle one. After we move one data point to the right and continue with the processing. Is for this reason that, in this case, we truncate the spectrum 5 points at the beginning and 5 points at the end.
See the results following this script:

library(prospectr)
X.movav<-movav(X.noisy,11)                            
plot(colnames(X),X.noisy[1,],type="l",col="red",
+ xlim=c(1100,2500),ylim=c(0.28,0.38),
+ xlab="wavelength",ylab="absorbance")
par(new=TRUE)
plot(colnames(X.movav),X.movav[1,],type="l",lwd=2,
+ xlim=c(1100,2500),ylim=c(0.28,0.38),
+ xlab="wavelength",ylab="absorbance",col="blue")
legend("topleft",legend=c("moving average","raw"),
+ lty=c(1,1),col=1:2)
 
Follow this tutorial
Previous posts:
 

No hay comentarios:

Publicar un comentario