Theory
Spectroscopy
Matter and radiation
Spectroscopy is based on the interaction of matter with electromagnetic or other radiation. Different types of radiation have different effects, see figure.

Near Infrared Spectroscopy
Near infrared (NIR) radiation is the radiation arising from vibration of molecular bonds of C-H, O-H and N-H in the spectral range between 780-2500 nm (12820-4000 cm-1). The method is therefore very useful for measuring in organic and biological systems. Food science, pharmacy, clinical measurement, forestry, environmental measurement, food industry, pharmaceutical etc.
NIR radiation enters very deep into some samples, enabling versatile sample presentation systems. NIR spectroscopic measurement can be done in the transmission and reflection mode, but also in transflection, attenuated total reflection, diffuse reflection, using fiber optic probes etc.
NIR measurements are a non destructive and very fast (less than one minute). No chemicals are needed and sample preparation is nonexistent to minimal. NIR is therefore often used in industrial process for continuous process control.
Chemometrics
Sampling
To be able to get correct information from your analysis it is important that the sample analyzed is representative for the population studied. This can be accomplished with different methods such as homogenization in all kinds of blenders, grinding, cutting up, quartering, riffleboxes, and fraction collectors. Sometimes homogenization is not possible and then fractionation may be necessary: e.g. sieving, centrifugation, filtering. Even when care is taken to do the sampling correctly, the sampling error may exceed the measurement error.
When sampling is performed in space or time semivariogram may be used. This gives information where in space or time the next sample should be taken ideally, so that autocorrelation between samples can be avoided.
Design
To be able to systematically extract the maximum amount of information from an experiment on a chemical or biological system experimental design is needed. When designing an experiment it is important to figure out which of many possible factors has an influence on the system.
These factors can be tested at a number of levels. Typical factors could be:
x1: temperature x2: pressure and x3: concentration of a catalyst

Illustration of a factorial design in three factors
Responses (y) are measured for each corner of the above cube. Sometimes the responses need to be maximized e.g. quality of a food product or minimized e.g. an emission from a process or held constant at a fixed level. An equation can explain the relationship between the factor settings and the responses. The coefficients of this equation can be interpreted in size e.g. in a bar plot.

Illustration of a coefficient plot for the responses. The coefficients pH, tim and the interaction temp x pH are the most influential ones. Small coefficients signify that the factor can be ignored.
A screening design are used to answers the question: which of the chosen factor is very important, slightly important or not important?
After this a response surface design is often made. The result of such a design is a response surface y = f(x1,x2,x3, x4). The response surface can show maxima, minima or fixed levels.

Illustration of a response surface in two factors and one response. If a maximum is needed, the upper right corner gives the settings to achieve this value and also the value that can be obtained.
Multivariate data analysis
Multivariate data analysis should be used when analyzing data that contain several variables. NIR spectra that often consist of hundreds or thousands of variables should therefore be analyzed in a multivariate way. Before analysis the data are gathered in a matrix, X.
NIR spectra often contain unwanted information such as scatter and baseline shift. To reduce the unwanted information pretreatment are often used before analysis. Pretreatments commonly applied to NIR-data are Multiplicative scatter correction (MSC), Standard normal variate (SNV) and Savitzky-Golay. Mean-centering is also used and weighting the variables is a possible option.
Principal Component Analysis (PCA) or Partial least squares (PLS) regression are important Multivariate techniques for NIR.
Principal Component Analysis (PCA)
PCA decomposes multidimensional matrices, X, in a few orthogonal principal component PC’s and a residual matrix, E. This is without losing significant information. The PC’s consist of scores, T, and loadings, P.
X=TP’ + E= t1p1’ + t1p1’ +…. + tnpn’ + E
The score matrix, T, contains information about how observations relate to each other. By plotting different score vectors against each other in score scatter plot for example t1/t2 or t1/t3 groups and outliers can be seen.
In loading plots it can be seen which variables are responsible to the groups and outliers found in scores. Loadings can be plotted against each other in a loading scatter plot for example p1/p2 or in a loading line plot where a score vector is plotted against wavenumbers or measurement order.
Partial Least Squares (PLS) regression
PLS is a regression method that fits a model between a matrix X (e.g. NIR spectra) and a response variable y (e.g. protein content of the samples in X):
y = Xb + e
PLS is a component based method that can be used to find a proper value of b that keeps e small and enables prediction of new samples.
ynew = Xnewb
Biological wastewater treatment
Waste water must be treated before entering the environment and the reason is that the content of N, P and organics must be reduced according to the regulations. There are a number of biological methods and technical constructions to apply. Biologically there are two conventional methods , either with anaerobic or ananaerobic process In the aerobic, active sludge, method, the aerobic bacteria consume the soluble organic material and the carbon is either fixed in a bacterial biomass that can sediment and built up a sludge or emitted from the system as C02 as a result of the metabolic activity. The active sludge method in different technical configurations has been in practice for a long time and is used in both industrial and municipal plants. The problems with the management of an aerobic plant is usually linked to a variation in the incoming organic load, an overload of th system or sometimes due to toxic substances.
An anaerobic treatment leads to a conversion of organic materials to gases, mostly CH4 and some CO2 and H2. This process occurs in an anaerobic environment and is mediated by a number of bacteria and archaebacterial. The bacterial and chemical processes are more complex than in an aerobic basin but has the advantage of producing energy in terms of a combustible gas, CH4. Anaerobic systems are generally sensitive to disturbances due to for ex an organic overload of the system or variations in the chemical composition in inflowing materials that may alter the delicate balance in the bacterial population.
Electrochemical wastewater treatment
In comparison to chemical treatment electrolytic wastewater treatment is not very common. However, the technique is convenient and may become competitive to produce high quality water. In the present project the combination of electro-coagulation (EC) and electro-flotation (EF) to the treatment of wastewater will be tested. Operating parameters such as current density eelctrolyte concentration, time will be optimised with multivariate techniques. In electrocoagulation the coagulant is generated in situ by electrolytic oxidation of an anode of appropriate material. Cations are formed such as Al 3+ and/or Fe2+. These cations will attract negatively charged particles especially the bacteria, causing coagulation and sometimes sedimentation. This technique is reported to be more effective for removal of COD than conventional coagulation and sedimentation processes. The coagulated flocs are then transferred to an electroflotation vesselElectroflotation is a method that uses electrically generated hydrogen and oxygen gas bubbles to lift the coagulate to the surface of the aquoues phase in the reaction vessel. The size of the gas bubbles are dependent of electrode material and pH.