function [calcabs calcconcs k]=pka(obsdata, phvector, kguess)
	#	applies a proton dependent speciation model and tries to tease out absorbances based on it
	[k,v,nev]=minimize("pkares",{sort(kguess,'descend'),phvector,obsdata});
	disp("k") #return solution
	disp("fitted k")
	k=sort(abs(k),'descend')
	disp("pK")
	-log10(k)

#	collect solution
	h=phvector;
	k1=[k 0]'; k2=[0 k]';
	f=@(c,h) k1./(k1+h).^2-k2./(k2+h).^2;
#	if (rows(k1)>=2)
		c0=[1-k(1)/(k(1)+h(1)) k(1)/(k(1)+h(1)) zeros(1,rows(k1)-2)]
#	else
#		c0=[1-k(1)/(k(1)+h(1)) k(1)/(k(1)+h(1)) zeros(1,rows(k1)-2)]
#	endif
	calcconcs=lsode(f,c0,h);
	calcabs=pinv(calcconcs)*obsdata;
endfunction
