-- calculates a relative spectra
create or replace function createRelavieSpectra(spectra float8[]) returns float8[] AS $$
DECLARE
result float8[1000];
array_len int;
maxValue float8 := 0;
BEGIN
array_len = array_upper(spectra,1);
for i in 1 .. array_len
LOOP
IF spectra[i] is not null and spectra[i] > maxValue
THEN
maxValue := spectra[i];
END IF;
END LOOP;
for i in 1 .. array_len
LOOP
if spectra[i] is not null
then
result[i] := spectra[i]/maxValue * 100;
end if;
END LOOP;
RETURN result;
END;
$$ LANGUAGE plpgsql;
April + May
6 years ago
No comments:
Post a Comment