/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_external/profiles_read_argo.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_external/profiles_read_argo.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (hide annotations) (download)
Mon Apr 11 21:03:35 2011 UTC (14 years, 3 months ago) by roquet
Branch: MAIN
Changes since 1.2: +79 -111 lines
new interface of import functions, with the possibility to load the dataset when m=0
then retrieve profiles individually
[nprofiles,data]=profile_read_'type'(dataset,nf,0);
then
profileCur=profile_read_'type'(dataset,nf,m,data); (m>0)

1 roquet 1.3 function [varargout]=profile_read_argo(dataset,nf,m,varargin);
2     % read hydrographic data in the ARGO netcdf format
3     % return the m-th profile from the nf-th file referenced in
4     % dataset.fileInList.
5     %
6     % if m=0 :
7     % [nprofiles,data_argo]=profile_read_argo(dataset,nf,0);
8     % nprofiles: number of profiles in the nf-th file
9     % data_argo: argo data in a struct variable
10     %
11     % if m~=0 :
12     % profileCur=profile_read_argo(dataset,nf,m,data_argo);
13     %
14     % profileCur = (m-th profile of nf-th file)
15     % pnum_txt: '5900841'
16     % ymd: 20060101
17     % hms: 3207
18     % lat: -46.709
19     % lon: 137.501
20     % direc: 1
21     % t: [1x115 single]
22     % s: [1x115 single]
23     % p: [1x115 single]
24     % t_ERR: [1x115 single]
25     % s_ERR: [1x115 single]
26     % PorZisBAD: 0
27     %
28 gforget 1.1
29     fileIn=[dataset.dirIn dataset.fileInList(nf).name];
30    
31 roquet 1.3 if m==0; % return the number of profile.
32 gforget 1.2
33 roquet 1.3 %get the number of profiles:
34     list_var={'JULD','LATITUDE','LONGITUDE','DIRECTION','PLATFORM_NUMBER',...
35     'PRES_ADJUSTED','PRES_ADJUSTED_QC',...
36     'TEMP_ADJUSTED','TEMP_ADJUSTED_QC','TEMP_ADJUSTED_ERROR',...
37     'PSAL_ADJUSTED','PSAL_ADJUSTED_QC','PSAL_ADJUSTED_ERROR'};
38     argo_data=[];
39     for ii=1:length(list_var),
40     ncload(fileIn,list_var{ii});
41     argo_data=setfield(argo_data,list_var{ii},eval(list_var{ii}));
42 gforget 1.2 end
43 roquet 1.3 nprofiles = length(JULD);
44 gforget 1.2
45 roquet 1.3 varargout{1}=nprofiles;
46     varargout{2}=argo_data;
47 gforget 1.2
48 roquet 1.3 else;%if m==0;
49 gforget 1.2
50 roquet 1.3 % load data
51     argo_data=varargin{1};
52 gforget 1.2
53     %date, position, etc
54 roquet 1.3 juld=argo_data.JULD(m)+datenum(1950,1,1);
55     [Y, M, D, H, MN, S] = datevec(juld);
56     ymd=Y*1e4+M*1e2+D;
57     hms=H*1e4+MN*1e2+S;
58 gforget 1.2
59 roquet 1.3 lat=argo_data.LATITUDE(m);
60     lon=argo_data.LONGITUDE(m); if lon < 0; lon=lon+360;end;
61 gforget 1.2
62 roquet 1.3 direction=argo_data.DIRECTION(m);
63     direc=0;
64     if(direction=='A');direc=1;end;
65     if(direction=='D');direc=2;end
66 gforget 1.2
67 roquet 1.3 pnum_txt=deblank(argo_data.PLATFORM_NUMBER(m,:));
68     pnum_txt=pnum_txt(ismember(pnum_txt,'0123456789')); pnum=str2num(pnum_txt);
69     if isempty(pnum_txt); pnum_txt='9999'; pnum=9999; disp(['no name for profile ' num2str(m)]); end;
70 gforget 1.2
71    
72 roquet 1.3 % pressure data
73 gforget 1.2
74 roquet 1.3 p=argo_data.PRES_ADJUSTED(m,:);
75     p_QC=argo_data.PRES_ADJUSTED_QC(m,:);
76     p_QC(isnan(p))='5';
77 gforget 1.2
78 roquet 1.3 for n=1:length(p)-1; % doubles
79     tmp1=find(p(n+1:end)==p(n)); p(n+tmp1)=NaN; p_QC(n+tmp1)='5';
80 gforget 1.2 end
81    
82     bad_P=0;
83     tmp1=find(p_QC=='4');
84     if(length(tmp1)<=5);
85     %get rid of these few bad points and keep the profile
86 roquet 1.3 p(tmp1)=NaN;p_QC(tmp1)='5';
87 gforget 1.2 else;
88     %flag the profile (will be masked in the main file)
89     %but keep the bad points (to interp and be able to CHECK)
90     bad_P=1;
91     end;
92    
93 roquet 1.3 % temperature data
94     t=argo_data.TEMP_ADJUSTED(m,:);
95     t_QC=argo_data.TEMP_ADJUSTED_QC(m,:);
96     t_ERR=argo_data.TEMP_ADJUSTED_ERROR(m,:);
97     t_ERR(isnan(t_ERR))=0;
98    
99     % salinity data
100     s=argo_data.PSAL_ADJUSTED(m,:);
101     s_QC=argo_data.PSAL_ADJUSTED_QC(m,:);
102     s_ERR=argo_data.PSAL_ADJUSTED_ERROR(m,:);
103     s_ERR(isnan(s_ERR))=0;
104 gforget 1.2
105    
106 roquet 1.3 if isnan(t(1)); %this file does not contain temperature data...
107 gforget 1.2 t=NaN*p; t_ERR=0*p;
108     else;
109 roquet 1.3 t(~ismember(t_QC,'12'))=NaN;
110 gforget 1.2 end;
111 roquet 1.3 if isnan(s(1)); %this file does not contain salinity data...
112     s=NaN*p; s_ERR=0*p;
113 gforget 1.2 else;
114 roquet 1.3 s(~ismember(s_QC,'12'))=NaN;
115 gforget 1.2 end;
116    
117     profileCur.pnum_txt=pnum_txt;
118     profileCur.ymd=ymd; profileCur.hms=hms;
119     profileCur.lat=lat; profileCur.lon=lon;
120     profileCur.direc=direc;
121     profileCur.t=t;
122     profileCur.s=s;
123     profileCur.p=p;
124     profileCur.t_ERR=t_ERR;
125     profileCur.s_ERR=s_ERR;
126     profileCur.PorZisBAD=bad_P;
127    
128     varargout = {profileCur};
129    
130 gforget 1.1 end;
131    
132    
133    

  ViewVC Help
Powered by ViewVC 1.1.22