## 8 feb. 2015

### Subscans and Scan concept

This post is part of a new tutotial to practice "Chemometrics with R", you can read the first part of the tutorial in the post " Adding Noise to the spectra".                                          ".

Continuing with the tutorial, and using the NIRsoil spectra, this time I want to explain the concept of “Scan” and “Subscan”, being a Scan an average of certain number of Subscans (normally 32).
One subscan is normally noisy, and it is acquired, after a grating or an interferometer moves a complete cycle once, but normally we configure the software to take more scans and to get an average (can be 32 in the case of a grating instrument). After that we get an average of the 32 as the spectrum of the sample.
Every subscan is quite noisy, but because the noise is random, the average is much less noisy.
Let´s check with this simulation:

#We take one spectrum and repeated 32 times
subscan<-X[1,]
subscans<-rep(subscan,32)
subscans<-matrix(subscans,nrow=32,byrow=TRUE)
wavelength<-seq(1100,2498,by=2)
#Now we add different spectra noise to each
noise32<-noise[1:32,]
subscans<-subscans + noise32
matplot(wavelength,t(subscans),type="l",
+ xlab="wavelength",ylab="absorbance")

See in the figure the 32 subscans overplotted

#Now let´s do the average to get just one scan, the one we will use #as representative of the sample
subscan.avg<-as.matrix(colMeans(subscans))
matplot(wavelength,subscan.avg,type="l",
+ xlab="wavelength",ylab="absorbance")