function [varargout]=profile_read_seals(dataset,nf,m,varargin); % read seal data in the ARGO netcdf format % % if m=0 : % return the information on the nf-th file referenced in % dataset.fileInList. % [nprofiles,data_seals]=profile_read_seals(dataset,nf,0); % nprofiles: number of profiles in the nf-th file % data_argo: argo data in a struct variable % % if m~=0 : % return the m-th profile from the nf-th file referenced in % dataset.fileInList. % profileCur=profile_read_seals(dataset,nf,m,data_argo); % % profileCur = (m-th profile of nf-th file) % pnum_txt: '5900841' % ymd: 20060101 % hms: 3207 % lat: -46.709 % lon: 137.501 % direc: 1 % t: [1x115 single] % s: [1x115 single] % p: [1x115 single] % t_ERR: [1x115 single] % s_ERR: [1x115 single] % PorZisBAD: 0 % fileIn=[dataset.dirIn dataset.fileInList(nf).name]; if m==0; % return the number of profile. %get the number of profiles: list_var={'JULD','LATITUDE','LONGITUDE', ... 'DIRECTION','PLATFORM_NUMBER',... 'PRES','PRES_QC',... 'TEMP','TEMP_QC',... 'PSAL','PSAL_QC'}; data_seals=[]; for ii=1:length(list_var), ncload(fileIn,list_var{ii}); data_seals=setfield(data_seals,list_var{ii},eval(list_var{ii})); end nprofiles = length(JULD); varargout{1}=nprofiles; varargout{2}=data_seals; else;%if m==0; % load data data_seals=varargin{1}; %date, position, etc juld=data_seals.JULD(m)+datenum(1950,1,1); [Y, M, D, H, MN, S] = datevec(juld); ymd=Y*1e4+M*1e2+D; hms=H*1e4+MN*1e2+S; lat=data_seals.LATITUDE(m); lon=data_seals.LONGITUDE(m); if lon < 0; lon=lon+360;end; direction=data_seals.DIRECTION(m); direc=0; if(direction=='A');direc=1;end; if(direction=='D');direc=2;end pnum_txt=deblank(data_seals.PLATFORM_NUMBER(m,:)); pnum_txt=pnum_txt(ismember(pnum_txt,'0123456789')); pnum=str2num(pnum_txt); if isempty(pnum_txt); pnum_txt='9999'; pnum=9999; disp(['no name for profile ' num2str(m)]); end; % pressure data p=data_seals.PRES(m,:); p_QC=data_seals.PRES_QC(m,:); p_QC(isnan(p))='5'; for n=1:length(p)-1; % doubles tmp1=find(p(n+1:end)==p(n)); p(n+tmp1)=NaN; p_QC(n+tmp1)='5'; end bad_P=0; tmp1=find(p_QC=='4'); if(length(tmp1)<=5); %get rid of these few bad points and keep the profile p(tmp1)=NaN;p_QC(tmp1)='5'; else; %flag the profile (will be masked in the main file) %but keep the bad points (to interp and be able to CHECK) bad_P=1; end; % temperature data t=data_seals.TEMP(m,:); t_QC=data_seals.TEMP_QC(m,:); t_ERR=t*0; % salinity data s=data_seals.PSAL(m,:); s_QC=data_seals.PSAL_QC(m,:); s_ERR=s*0; if isnan(t(1)); %this file does not contain temperature data... t=NaN*p; t_ERR=0*p; else; t(~ismember(t_QC,'12'))=NaN; end; if isnan(s(1)); %this file does not contain salinity data... s=NaN*p; s_ERR=0*p; else; s(~ismember(s_QC,'12'))=NaN; end; profileCur.pnum_txt=pnum_txt; profileCur.ymd=ymd; profileCur.hms=hms; profileCur.lat=lat; profileCur.lon=lon; profileCur.direc=direc; profileCur.t=t; profileCur.s=s; profileCur.p=p; profileCur.t_ERR=t_ERR; profileCur.s_ERR=s_ERR; profileCur.PorZisBAD=bad_P; varargout = {profileCur}; end;