function d = get_SBE_k2stem_cal(SBEfile)

% ************************************************************************
% TESTING
% SBEfile = 'C:\temp\10590 Stem Cal Sheet.docx';
% SBEfile = 'C:\temp\10742 Stem Calsheet.docx';
% SBEfile = 'C:\temp\10952 Stem pH Calibration Sheet.pdf';
% SBEfile = '1114-12157-10374 Float Calsheet.pdf';
% SBEfile = 'C:\temp\11045 Stem Calsheet.pdf';
% SBEfile = 'C:\temp\11085 Stem Calsheet.docx';
% ************************************************************************


d= []; % return as default

if ~isfile(SBEfile)
    return
end

[fpath, fname, fext] = fileparts(SBEfile);
if strcmp(fext,'.pdf')
    stem_cal = parse_cal_pdf(SBEfile);
elseif strcmp(fext,'.docx')
    stem_cal = parse_SBEpHcal_doc(SBEfile);
else
    disp('Not a recognized ph stem calibration file type!')
end

% SBE K2 REPORTS ONLY RETURN AN AVERAGE K2 SO PRESSURE DEPENDANCE YET SO
% RETURN 0 order polynomil for k2_Pcoefs = [0,avg_k2];

% BUILD CELL ARRAY OF STRINGS FOR GUI OUTPUT
date_fmt = 'mm/dd/yyyy HH:MM';
results       = cell(30,3);
results(1,:)  = {'Process Date:',datestr(now, date_fmt), ''};
results(2,:)  = {'Durafet SN:',stem_cal.pH.SN, ''};
results(3,:)  = {'pH stem mfg:','SBE', ''};

results(4,:)  = {'PT Source directory :',fpath, ''};
results(5,:)  = {'PT Source file :',[fname,fext] ''};
results(6,:)  = {'HCl concentration:', '', ''};
results(7,:)  = {'k2 Calibration window:', '', ''};
results(8,:)  = {'Data subset:','', ''};
results(9,:)  = {'Vrs drift rate:','', ''};
results(10,:)  = {'Vk drift rate:','', ''};
results(11,:)  = {'Avg std Vk','', ''};
results(12,:)  = {'Average k2:', ...
    sprintf('%0.4e', stem_cal.pH.k2), 'V/degC'};
results(13,:)  = {'Std dev k2:', '', ''};

if isempty(stem_cal.pH.k0)
    results(14,:)  = {'k0 HCL:', 'NaN', 'Volts'};
else
    results(14,:)  = {'k0 HCL:', sprintf('%0.4f', stem_cal.pH.k0), ...
        'Volts'};
end

results(15,:)  = {'Avg Ik:','', ''};
results(16,:)  = {'Std dev Ik:', '', ''};
results(17,:)  = {'Avg Ib:', '', ''};
results(18,:)  = {'Std dev Ib:', '', ''};

results(19,:)  = {'f(P) NSSR:', '', ''};
results(20,:)  = {'f(P) R*R:', '', ''};

Pcoefs = stem_cal.pH.fP;
r = size(Pcoefs,2);
tmp = flip(Pcoefs);

results(size(results,1)+1,:) ={'f(P) c0', '',''};
for i = 1:r
    coef_str = sprintf('%0.0f',i);
    results(size(results,1)+i,:) ={['f(P) c',coef_str], ...
        sprintf('%0.4e',tmp(i)),''};
end



t1 = ~cellfun(@isempty, results(:,1));
results = results(t1,:);

% ************************************************************************
% ************************************************************************
%  OUTPUT TO STRUCTURE
d.DF_SN       = stem_cal.pH.SN;
d.DF_TYPE     = 'SBE';
d.SourceDir   = fpath;
d.SourceFile  = [fname,fext];
d.HCl         = [];
d.tDrift      = []; % array to sub set data to determine ddrift
d.Vrs_Drift   = []; % drift regression stats
d.Vrs_Dcor    = [];
d.Vrs_Vc      = [];
d.Vk_Drift    = []; % drift regression stats
d.avg_std_Vk  = [];
d.avg_Ik      = [];
d.std_Ik      = [];
d.avg_Ib      = [];
d.std_Ib      = [];

d.BinK2_hdr   = {};
d.BinK2_data  = [];
d.k2_Pcoefs   = [0 stem_cal.pH.k2];
d.Results     = results;
d.avg_k2      = stem_cal.pH.k2;
d.std_avg_k2  = [];
d.Vrs_Vc_k2T  = [];
d.fP_SSR      = [];
d.fP_NSSR     = [];
d.fP_RR       = [];
d.Pcoefs      = Pcoefs;
d.stem_mfg    = 'SBE';
d.k0_HCL      = stem_cal.pH.k0;

%clearvars -except d

