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

Contents of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_external/profiles_read_seals.m

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


Revision 1.5 - (show annotations) (download)
Wed Apr 13 21:05:13 2011 UTC (15 years, 6 months ago) by roquet
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +0 -0 lines
FILE REMOVED
profiles_read_argo: bug fix for NaN handling and none adjusted profiles
profiles_read_odv: time and memory optimization.
profiles_read_seals has been removed, as data will be loaded in argo or odv format

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

  ViewVC Help
Powered by ViewVC 1.1.22