function [calcabs calcconcs]=opa(obsdata, ncomp)
% module description
% 	orthogonal projection approach (opa) - compares vectors in an ensemble and calculates
%	 the space they construct. The more orthogonal the vectors are - and thus different 
%	to each-other - the bigger the space they construct.
%
% variables:
% 	input - obsdata: observed and trimmed data, ncomp: number of components used in fit, 
%	temp -  dissimily: a measure of the dissimilarity of the ensemble of vectors in vectorensemble,
%	 	whichindex: the position in the array where maxvalue is found, maxvalue: the largest value in the array
%	output - absvectors: calculated pure-compound spectra (see calcabs in other modules)
% tokens: sqrt, sum, dot, rows, size, max
	disp('opa')
	tmp_obsdata=size(obsdata);%another ugly matlab hack
	
	absvectors=mean(obsdata)'./sqrt(sum(dot(obsdata,obsdata)));
	dissimilarity=zeros(1,tmp_obsdata(1));
	
	for n=1:ncomp
		size(absvectors);
		n;
		for m=1:tmp_obsdata(1)
			vectorensemble=[absvectors obsdata(m,:)']';
			dissimily(1,m)=det(vectorensemble*vectorensemble');
		end

		[maxvalue whichindex]=max(dissimily);

		if (n==1)
			absvectors=(obsdata(whichindex,:)'./sqrt(sum(dot(obsdata(whichindex,:),obsdata(whichindex,:)'))));
		else
			absvectors=[absvectors (obsdata(whichindex,:)'./sqrt(sum(dot(obsdata(whichindex,:),obsdata(whichindex,:)'))))];
		end
	end
	calcabs=absvectors';
	calcconcs=obsdata*transpose(calcabs);
end
