Code covered by the BSD License  

Highlights from
Avantes to Matlab

image thumbnail

Avantes to Matlab

by

 

11 Jun 2012 (Updated )

Read spectral data from Avantes USB2 spectrometer files

Reading spectra from Avantes binary files (demonstration)

Reading spectra from Avantes binary files (demonstration)

By Kotya Karapetyan, kotya.karapetyan@gmail.com, 2011--2012.

Thanks to Avantes BV (http://www.avantes.com) for providing me with detailed description of their binary format.

In my programs I normally use a term scan for a spectrum, to emphasise the technicality of what's written into a file. A spectrum is something physical, data in a file is something technical. Besides, spectrometer devices are usually scanning, either mechanically, like an optical spectrum analyser, or electronically, like a CCD-based spectrometer.

Add parent folder with functions. Note: I recommend adding the folder with these functions to your path whenever you need them using a Matlab shortcut, see http://blogs.mathworks.com/community/2007/03/29/shortcuts-for-commonly-used-code/.

addpath('..')

Read all Avantes files (any type of measurement, both binary and ASCII files) in the current directory

scans = avantesSpectrumRead;
NEW0001.RCM. 21 files to go
NEW0001.ROH. 20 files to go
NEW0002.RCM. 19 files to go
NEW0002.ROH. 18 files to go
NEW0003.RCM. 17 files to go
NEW0003.ROH. 16 files to go
NEW0004.RCM. 15 files to go
NEW0004.ROH. 14 files to go
NEW0005.RCM. 13 files to go
NEW0005.ROH. 12 files to go
NEW0006.RCM. 11 files to go
NEW0006.ROH. 10 files to go
NEW0007.RCM. 9 files to go
NEW0007.ROH. 8 files to go
NEW0008.RCM. 7 files to go
NEW0008.ROH. 6 files to go
NEW0009.RCM. 5 files to go
NEW0009.ROH. 4 files to go
NEW0010.RCM. 3 files to go
NEW0010.ROH. 2 files to go
demo.m. 1 files to go
Time: 1 s

Display overview information

fprintf('\nSpectra read: %g\n', numel(scans));
fprintf('First spectrum taken %s\n', datestr(scans(1).timeEnd, 31))
fprintf('Last spectrum taken %s\n', datestr(scans(end).timeEnd, 31))
fprintf('Spectra times:\n')
datestr([scans(:).timeEnd], 31)
fprintf('Device S/N: %s\n', scans(1).spectrometerName);
fprintf('Number of pixels: %g\n', numel(scans(1).signal));
fprintf('Wavelength range: %g...%g nm\n', scans(1).wvl(1), scans(1).wvl(end));
Spectra read: 10
First spectrum taken 2011-08-18 20:19:55
Last spectrum taken 2011-08-18 20:23:54
Spectra times:

ans =

2011-08-18 20:19:55
2011-08-18 20:23:50
2011-08-18 20:23:50
2011-08-18 20:23:51
2011-08-18 20:23:51
2011-08-18 20:23:52
2011-08-18 20:23:52
2011-08-18 20:23:53
2011-08-18 20:23:53
2011-08-18 20:23:54

Device S/N: 1103217U1
Number of pixels: 1608
Wavelength range: 171.326...1100.42 nm

Plot one spectrum, chosen by time

s = getScansByTime(scans, '20:19:55');
plot(s.wvl, s.signal);
title(sprintf('Comment in file: %s', s.comment))
xlabel('Wavelength, nm')
ylabel('Signal, counts')
xlim([scans(1).wvl(1), scans(1).wvl(end)])
grid on
getScansByTime: First scan at 2011-08-18 20:19:55

Contact us