
function dataOut = calc_pH(calCoeffs,T,V1)

% -- 
% Jeff Sevadjian
% Research Technician
% Monterey Bay Aquarium Research Institute
% 7700 Sandholdt Rd
% Moss Landing, CA 95039, USA
% ph: +1 831-775-1888

% Calculates pH [total scale] from Durafet voltage

% Inputs:
%  calCoeffs are [de-amp slope, de-amp intercept, E0, Ts]
%  T is CTD temperature [C]
%  V1 is pH voltage [V]

% Constants:
 R = 8.31451; %gas constant (J mol-1 K-1)
 F = 96487; %converts between Coulombs and Faradays

%convert pH voltage to pH
 pHdaV = V1*calCoeffs(1) + calCoeffs(2); %De-amplified volts
 ST = (R*(T+273.15)*log(10)) ./ F;
 E0T = calCoeffs(3)-0.001*((T+273.15)-calCoeffs(4));
 
 dataOut = (pHdaV-E0T)./ST;
