1
function spd = PR670parsespdstr(readStr, S)
2
% PR670parsespdstr - Parses the spectral power distribution string returned by the PR-670.
5
% spd = PR670parsespdstr(readStr)
6
% spd = PR670parsespdstr(readStr, S);
9
% Parse the spectral power distribution string returned by the PR-670. The
10
% results are splined to the desired wavelength sampling defined by the 'S'
14
% readStr (1xN char) - Raw data returned from a meter measurment.
15
% S (1x3) - Wavelength sampling. Default: [380 5 81]
17
if nargin < 2 || isempty(S)
21
% Split up the data delimited by newline characters.
22
C = textscan(readStr, '%s', 'Delimiter', '\n');
25
% Loop over all the data lines and pull out the spectral info. Note that
26
% the first line doesn't contain wavelength data so we toss it.
28
numWavelengths = length(C);
29
if (numWavelengths ~= 201)
30
error('Unexpected native number of wavelength samples for PR-670');
32
spd = zeros(numWavelengths, 1);
35
% Parse the wavelength measurement line. The first element of the
36
% returned cell array will be the wavelength, the second element the
38
D = textscan(C{i}, '%d,%f');
40
wavelengths(i) = D{1};
44
% Convert to our units standard.
46
if (wavelengths(2)-wavelengths(1) ~= 2)
47
error('Unexpected native wavelength sampling for PR-670');
50
% Spline to desired wavelength sampling.
51
startWavelength = wavelengths(1);
52
spacing = wavelengths(2) - wavelengths(1);
53
S0 = [startWavelength, spacing, numWavelengths];
54
spd = SplineSpd(S0, spd, S);