A method and an apparatus for increasing the accuracy of a spectrometer system corrects for light source quality, exposure time, distortion in y direction, distortion in x direction, temperature dependence, pixel alignment variability, dark pixels, bad pixels, pixel read noise, and pixel dark current noise. The method and apparatus produces an algorithm for optimizing spectral data and for measuring a sample within the spectrometer system using the optimization algorithm. The spectrometer apparatus comprises a composite external light source, a source light collector, an illumination light structuring component, a sample, a sample light collector, a spectrometer light structuring component, a light dispersing engine, photo detectors, an electrical signal converter, a data preprocessing unit, and a data analyzer. The method and apparatus can include a corrected photo detector algorithm, sample illumination correction algorithm, LDE-PD alignment procedure, SLSC-LDE alignment procedure, distortion correction matrix, and an algorithm for optimizing of spectral data.