ArgoCanada / bgcArgoDMQC

python package for performing DMQC on BGC-Argo data
MIT License
6 stars 1 forks source link

Switch % saturation calculation to SCOR WG 142 version #27

Closed cgrdn closed 3 years ago

cgrdn commented 4 years ago

Currently, %-sat is calculated by getting the solubility of oxygen in concentration units using the function oxy_sol(), which is based on SAGE-O2 code. After some testing, both the RBR rsktools code (nested function in https://bitbucket.org/rbr/rsktools/src/master/private/deriveO2saturation.m) and the SCOR working group 142 code (https://archimer.ifremer.fr/doc/00348/45915/) appear to agree with each other. Since the SCOR code calculates %-saturation internally, plan to switch to that version - just need to translate it from matlab to python. Functions pO2_to_doxy() and doxy_to_pO2() already exist and are based on that WG as well.

cgrdn commented 4 years ago

Also - this won't matter if I move away from this function - but the unit='millimole/m3' [edit - had written mmol/kg by accident] option in unit.oxy_sol() appears to not work properly. Should either commit to deleting it or double check the coefficients.

cgrdn commented 4 years ago

Should note that current setup seems to be working fine (agrees with SAGE). Should test methods directly against each other as well as in gain results before committing to SCOR function. Priority is consistency with previous methods right now.

dnicholson commented 4 years ago

Hi Chris, I believe the MBARI code currently uses the umol/kg solubility coefficiencts for Aanderaa optodes and then the volumetric (mmol m-3) for Seabird 63 oxygen sensors with the goal of staying consistent with what each vendor was doing. The relevant bit of code from https://github.com/SOCCOM-BGCArgo/ARGO_PROCESSING/blob/master/MFILES/FLOATS/calc_O2_4ARGO.m is below.

% 04/24/19 - Reverted back to the Garcia & Gordon (1992) combined fit coefficients for
%       calculation of oxygen solubility for 4330 optodes with polynomial
%       coefficients.  Although this doesn't conform to the SCOR WG 142
%       recommendation, it is more accurate for these cases because more
%       closely matches what Aanderaa used in derivation of cal coeffs. (And this is
%       also reflected in the Argo O2 processing doc, and verified from Henry Bittig).

% ************************************************************************
% SET VARIABLES & PATHS & FORMATS
% ************************************************************************

% OXYGEN SOLUBILITY COFFICIENTS
%
% NOTE: Aanderaa uses the combined fit coefficients for the salinity terms
%       of the Co* calculation from Garcia & Gordon (1992) Equation 8 for 4330 optodes.
%       Garcia & Gordon suggest using the more precise Benson & Krause
%       coefficients but need to stay be consistent with how the cal coeffs
%       were originally derived from the manufacturer.

% Benson & Krause (cm^3/dm^3) *** USE THESE COEFFICIENTS (for all floats except Aanderaa 4330 exceptions)!!!! ***
pA = [3.88767 -0.256847 4.94457 4.05010 3.22014 2.00907]; % Temperature Coeff
pB = [-8.17083e-3 -1.03410e-2 -7.37614e-3 -6.24523e-3]; % Salinity coff
Co = -4.88682e-7;
O2_volume =  22.3916;

% ************************************************************************
% %Aanderaa default coeff (cm^3/dm^3) (Combined fit Garcia & Gordon 1992)
pA_Aa = [1.71069 0.978188 4.80299 3.99063 3.22400 2.00856]; % Temperature Coeff
pB_Aa = [-4.29155e-3 -6.90358e-3 -6.93498e-3 -6.24097e-3]; % Salinity coff
Co_Aa = -3.11680e-7;
cgrdn commented 3 years ago

Thanks @dnicholson, this is what I have implemented/copied over from SAGE right now, but I didn't realize it was manufacturer specific. My own fault for just looking for the code snippet I needed and not reading the comment about SCOR/manufacturer derivations.

Moving ahead: I will adjust my own code to check the sensor, and as I mentioned in a previous comment, the mmol m-3 code block seems to be malfunctioning. Once those two changes have been committed/validated I will close this issue, without switching gain calculation to use the SCOR WG 142 conversion. Will keep those SCOR functions in unit for the sake of utility though.

cgrdn commented 3 years ago

Fixed in 14f8e85, closing.