spectra-factory
Implement a spectra calculator according to the design algorithm. Here's some helpful code (JS):
_this.getSdSpectra = function (calculation) {
var i,
result,
sd1,
sds,
sdSpectra,
t1,
tHat,
tl,
tn;
result = _this.getResult(calculation);
sds =_this.getSds(calculation);
sd1 = _this.getSd1(calculation);
if (sd1 > sds) {
sds = sd1;
}
tl = result.get('tl');
sdSpectra = [];
i = 1;
t1 = sd1 / sds;
sdSpectra.push([0, 0.4 * sds]);
sdSpectra.push([0.2 * t1, sds]);
sdSpectra.push([t1, sds]);
tHat = +(t1.toFixed(1));
tn = 0.05 + tHat;
while (tn < 2.0) {
tn = (0.05 * i) + tHat;
sdSpectra.push([tn, sd1/tn]);
i += 1;
}
result.set({
'sdSpectrum': sdSpectra
});
return sdSpectra;
};