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

Annotation 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.1 - (hide annotations) (download)
Wed Nov 3 20:01:04 2010 UTC (16 years ago) by gforget
Branch: MAIN
*** empty log message ***

1 gforget 1.1 function [varargout]=profile_read_seals(dataset,nf,m);
2    
3     fileIn=[dataset.dirIn dataset.fileInList(nf).name];
4    
5     %output:
6     % ymd hms imonth lat lon direc p t s p_ERR t_ERR s_ERR
7    
8     %common block:
9     global PLATFORM_NUMBER_fillval PLATFORM_NUMBER;
10     global VECdateOBS LATITUDE LONGITUDE DIRECTION;
11     global PRES PRES_ADJUSTED PRES_ADJUSTED_QC PRES_fillval PRES_QC;
12     global TEMP TEMP_ADJUSTED TEMP_ADJUSTED_QC TEMP_fillval TEMP_QC TEMP_ADJUSTED_ERROR;
13     global PSAL PSAL_ADJUSTED PSAL_ADJUSTED_QC PSAL_fillval PSAL_QC PSAL_ADJUSTED_ERROR;
14    
15    
16     if m==0;
17     %read the file and put the data in common blocks:
18    
19     clear PRES* PSAL* TEMP*;
20     global PRES PRES_ADJUSTED PRES_ADJUSTED_QC PRES_fillval PRES_QC;
21     global TEMP TEMP_ADJUSTED TEMP_ADJUSTED_QC TEMP_fillval TEMP_QC TEMP_ADJUSTED_ERROR;
22     global PSAL PSAL_ADJUSTED PSAL_ADJUSTED_QC PSAL_fillval PSAL_QC PSAL_ADJUSTED_ERROR;
23     TEMP=8888*ones(500,1);PSAL=8888*ones(500,1);
24    
25     %WHAT IS WRONG HERE???
26     %if ( rep_nb~=1|isempty(findstr(fileIn,'20050911_prof')) )
27    
28    
29     eval(['ncload ' fileIn ';']);
30    
31     %some dimensions inversions exist for _QC variables (!?)
32     if size(PRES_QC,1)~=size(PRES,1)
33     PRES_QC=PRES_QC';
34     if ~isempty(who('PRES_ADJUSTED_QC'));PRES_ADJUSTED_QC=PRES_ADJUSTED_QC';end;
35     if ~isempty(who('PSAL_QC'));PSAL_QC=PSAL_QC';end;
36     if ~isempty(who('PSAL_ADJUSTED_QC'));PSAL_ADJUSTED_QC=PSAL_ADJUSTED_QC';end;
37     if ~isempty(who('TEMP_QC'));TEMP_QC=TEMP_QC';end;
38     if ~isempty(who('TEMP_ADJUSTED_QC'));TEMP_ADJUSTED_QC=TEMP_ADJUSTED_QC';end;
39     end
40    
41     if size(PLATFORM_NUMBER,1)~=size(PRES,1); PLATFORM_NUMBER=PLATFORM_NUMBER'; end; %'
42    
43     %get the fillvalues:
44     nc = netcdf(fileIn, 'nowrite');
45     PRES_fillval=fillval(nc{'PRES'});
46     PSAL_fillval=fillval(nc{'PSAL'});
47     TEMP_fillval=fillval(nc{'TEMP'});
48     PLATFORM_NUMBER_fillval=fillval(nc{'PLATFORM_NUMBER'});
49     nc = close(nc);
50    
51     REFdateOBS=str2num(strvcat(REFERENCE_DATE_TIME(1:4),REFERENCE_DATE_TIME(5:6),REFERENCE_DATE_TIME(7:8),REFERENCE_DATE_TIME(9:10),REFERENCE_DATE_TIME(11:12),REFERENCE_DATE_TIME(13:14)))';%'
52     REFdateOBS=jul_0h(REFdateOBS);
53     VECdateOBS=REFdateOBS+JULD;
54    
55     xx=size(PRES);mloc=xx(1);mpts=xx(2);
56    
57     varargout(1) = {length(LONGITUDE)};
58    
59     else;%if m~=0;
60     %select one profile for output:
61    
62     %date, position, etc
63    
64     tmp1=greg_0h(VECdateOBS(m));
65     ymd=tmp1(1)*1e4+tmp1(2)*1e2+tmp1(3);
66     hms=tmp1(4)*1e4+tmp1(5)*1e2+tmp1(6);
67    
68     lat=LATITUDE(m);
69     lon=LONGITUDE(m);
70     if lon < 0; lon=lon+360; end;
71    
72     %%%%%%%ilon=find(((vec_lon-lon).^2)==min((vec_lon-lon).^2)); ilon=ilon(1);
73     %%%%%%%ilat=find(((vec_lat-lat).^2)==min((vec_lat-lat).^2)); ilat=ilat(1);
74    
75     direc=0;if(DIRECTION(m)=='A');direc=1;end;if(DIRECTION(m)=='D');direc=2;end
76    
77     pnum_txt=deblank(PLATFORM_NUMBER(m,:));
78     pnum_txt=pnum_txt(pnum_txt~=PLATFORM_NUMBER_fillval);
79     pnum=double(pnum_txt); pnum=pnum(find(pnum>=48&pnum<=57)); pnum=str2num(char(pnum));
80     if isempty(pnum); pnum_txt='9999'; pnum=9999; end;
81    
82     %observations
83    
84     % if ~isempty(PRES_ADJUSTED), %taking adjusted fields
85     % p=PRES_ADJUSTED(m,:);
86     % p_QC=PRES_ADJUSTED_QC(m,:);
87     % t=TEMP_ADJUSTED(m,:);
88     % t_QC=TEMP_ADJUSTED_QC(m,:);
89     % s=PSAL_ADJUSTED(m,:);
90     % s_QC=PSAL_ADJUSTED_QC(m,:);
91     % t_ERR=TEMP_ADJUSTED_ERROR(m,:);
92     % t_ERR(t_ERR==TEMP_fillval|isnan(t_ERR))=0;
93     % s_ERR=PSAL_ADJUSTED_ERROR(m,:);
94     % s_ERR(s_ERR==PSAL_fillval|isnan(s_ERR))=0;
95     %
96     % else
97     p=PRES(m,:);
98     p_QC=PRES_QC(m,:);
99     t=TEMP(m,:);
100     t_QC=TEMP_QC(m,:);
101     s=PSAL(m,:);
102     s_QC=PSAL_QC(m,:);
103     t_ERR=p*0; s_ERR=p*0;
104    
105     % end
106    
107    
108     p(isnan(p))=PRES_fillval;
109     p_QC(isnan(p))='5';
110     for n=1:length(p)-1;
111     tmp1=find(p(n+1:end)==p(n)&p(n+1:end)~=PRES_fillval);
112     p(n+tmp1)=PRES_fillval;p_QC(n+tmp1)='5';
113     end
114    
115     bad_P=0;
116     tmp1=find(p_QC=='4');
117     if(length(tmp1)<=5);
118     %get rid of these few bad points and keep the profile
119     p(tmp1)=PRES_fillval;p_QC(tmp1)='5';
120     else;
121     %flag the profile (will be masked in the main file)
122     %but keep the bad points (to interp and be able to CHECK)
123     bad_P=1;
124     end;
125    
126     p(p==PRES_fillval)=NaN;
127     p(p==PRES_fillval)=NaN;
128     if isempty(whos('t')); %this file does not contain salinity data...
129     t=NaN*p; t_ERR=0*p;
130     else;
131     t(t_QC~='1'&t_QC~='2')=NaN;
132     end;
133    
134     if isempty(whos('s')); %this file does not contain salinity data...
135     s=NaN*t; s_ERR=0*t_ERR;
136     else;
137     s(s_QC~='1'&s_QC~='2')=NaN;
138     end;
139    
140    
141     profileCur.pnum_txt=pnum_txt;
142     profileCur.ymd=ymd; profileCur.hms=hms;
143     profileCur.lat=lat; profileCur.lon=lon;
144     profileCur.direc=direc;
145     profileCur.t=t;
146     profileCur.s=s;
147     profileCur.p=p;
148     profileCur.t_ERR=t_ERR;
149     profileCur.s_ERR=s_ERR;
150     profileCur.PorZisBAD=bad_P;
151    
152     %bad_latlon=0;
153     %if profileCur.lat<-90|profileCur.lat>90; bad_latlon=1; end;
154     %if profileCur.lon<-180|profileCur.lon>360; bad_latlon=1; end;
155     %profileCur.LONorLATisBAD=bad_latlon;
156    
157     varargout = {profileCur};
158    
159     end;
160    
161    
162    

  ViewVC Help
Powered by ViewVC 1.1.22