function ctd=getfromprevious(ctd,dirunspiked,cname);
% temporary function to pass on data between two version: get
% unspiked oxygen from that directory

strfe=sprintf('load %sCaliprofiles/ox_cal_%s_STN%03d_CAST%02d.mat ',...
    dirunspiked,cname,ctd.stat,ctd.cast);
disp(strfe);
eval(strfe)
%verify we have the right config
if (ctd.dayd~=cdayd)|(abs(ctd.latx-clatx)>1e-4)|(abs(ctd.lonx-clonx)>1e-4)|...
        (ctd.iswitch~=iswitch)|(ctd.wswitch~=wswitch)|~strcmp(ctd.csuf,csuf)
    error('different parameters in previous profiles')
end
if ~isequaln(ctd.dpres,pres)
    error('not the same pressures')
end
%Everything is good so we can use the interpolated oxygen from previous
%data
ctd.oxcali=oxi;
ctd.oxcali_qc=oxi_qc;

%correct flags for NaNs ("bad measurements")
ginan=find(isnan(ctd.oxcali));
ctd.oxcali_qc(ginan)=4;

end