source: trunk/src/mode_sahelien/composite_pluie_eof234_1030.m @ 16

Last change on this file since 16 was 16, checked in by pinsard, 15 years ago

remove trailing blanks, split lines with multiple statements

File size: 7.5 KB
Line 
1%
2
3%%%%%%%%%%%%%%% FICHIER pluie IRD
4% ouverture / lecture du fichier
5clear;
6cd('Pluie_ird_25');
7
8% on selectionne les mois d ete (attention aux annees bixestiles!)
9
10siz1=31+28+31+30+31+1;
11siz1bis=31+28+31+30+31+30+31+31+30;
12pluie=zeros(41,17,122,12);
13
14clear v fid;
15fid=fopen('pluvio.79.haut','r','b');
16siz=41*17*365;
17v=fread(fid,siz,'float');
18fclose(fid);
19v=reshape(v,41,17,365);
20clear a b c;
21for a=1:41;
22   for b=1:17;
23       for c=1:365;
24          if v(a,b,c)>990;
25              v(a,b,c)=NaN;
26          elseif v(a,b,c)<0;
27              v(a,b,c)=NaN;
28          end;
29       end;
30   end;
31end;
32pluie(:,:,:,1)=v(:,:,siz1:siz1bis); % 1979
33
34clear v fid;
35fid=fopen('pluvio.80.haut','r','b');
36siz=41*17*366;
37v=fread(fid,siz,'float');
38fclose(fid);
39v=reshape(v,41,17,366);
40clear a b c;
41for a=1:41;
42   for b=1:17;
43       for c=1:366;
44          if v(a,b,c)>990;
45              v(a,b,c)=NaN;
46          elseif v(a,b,c)<0;
47              v(a,b,c)=NaN;
48          end;
49       end;
50   end;
51end;
52pluie(:,:,:,2)=v(:,:,siz1+1:siz1bis+1); % 1980
53
54clear v fid;
55fid=fopen('pluvio.81.haut','r','b');
56siz=41*17*365;
57v=fread(fid,siz,'float');
58fclose(fid);
59v=reshape(v,41,17,365);
60clear a b c;
61for a=1:41;
62   for b=1:17;
63       for c=1:365;
64          if v(a,b,c)>990;
65              v(a,b,c)=NaN;
66          elseif v(a,b,c)<0;
67              v(a,b,c)=NaN;
68          end;
69       end;
70   end;
71end;
72pluie(:,:,:,3)=v(:,:,siz1:siz1bis); % 1981
73
74clear v fid; fid=fopen('pluvio.82.haut','r','b'); siz=41*17*365;
75v=fread(fid,siz,'float'); fclose(fid);
76v=reshape(v,41,17,365);
77clear a b c;
78for a=1:41;
79   for b=1:17;
80       for c=1:365;
81          if v(a,b,c)>990;
82              v(a,b,c)=NaN;
83          elseif v(a,b,c)<0;
84              v(a,b,c)=NaN;
85          end;
86       end;
87   end;
88end;
89pluie(:,:,:,4)=v(:,:,siz1:siz1bis); % 1982
90
91clear v fid; fid=fopen('pluvio.83.haut','r','b'); siz=41*17*365;
92v=fread(fid,siz,'float'); fclose(fid);
93v=reshape(v,41,17,365);
94clear a b c;
95for a=1:41;
96   for b=1:17;
97       for c=1:365;
98          if v(a,b,c)>990;
99              v(a,b,c)=NaN;
100          elseif v(a,b,c)<0;
101              v(a,b,c)=NaN;
102          end;
103       end;
104   end;
105end;
106
107
108pluie(:,:,:,5)=v(:,:,siz1:siz1bis); % 1983
109
110clear v fid; fid=fopen('pluvio.84.haut','r','b'); siz=41*17*366;
111v=fread(fid,siz,'float'); fclose(fid);
112v=reshape(v,41,17,366);
113clear a b c;
114for a=1:41;
115   for b=1:17;
116       for c=1:366;
117          if v(a,b,c)>990;
118              v(a,b,c)=NaN;
119          elseif v(a,b,c)<0;
120              v(a,b,c)=NaN;
121          end;
122       end;
123   end;
124end;
125pluie(:,:,:,6)=v(:,:,siz1+1:siz1bis+1); % 1984
126
127clear v fid; fid=fopen('pluvio.85.haut','r','b'); siz=41*17*365;
128v=fread(fid,siz,'float'); fclose(fid);
129v=reshape(v,41,17,365);
130clear a b c;
131for a=1:41;
132   for b=1:17;
133       for c=1:365;
134          if v(a,b,c)>990;
135              v(a,b,c)=NaN;
136          elseif v(a,b,c)<0;
137              v(a,b,c)=NaN;
138          end;
139       end;
140   end;
141end;
142pluie(:,:,:,7)=v(:,:,siz1:siz1bis); % 1985
143
144clear v fid; fid=fopen('pluvio.86.haut','r','b'); siz=41*17*365;
145v=fread(fid,siz,'float'); fclose(fid);
146v=reshape(v,41,17,365);
147clear a b c;
148for a=1:41;
149   for b=1:17;
150       for c=1:365;
151          if v(a,b,c)>990;
152              v(a,b,c)=NaN;
153          elseif v(a,b,c)<0;
154              v(a,b,c)=NaN;
155          end;
156       end;
157   end;
158end;
159pluie(:,:,:,8)=v(:,:,siz1:siz1bis); % 1986
160
161clear v fid; fid=fopen('pluvio.87.haut','r','b'); siz=41*17*365;
162v=fread(fid,siz,'float'); fclose(fid);
163v=reshape(v,41,17,365);
164clear a b c;
165for a=1:41;
166   for b=1:17;
167       for c=1:365;
168          if v(a,b,c)>990;
169              v(a,b,c)=NaN;
170          elseif v(a,b,c)<0;
171              v(a,b,c)=NaN;
172          end;
173       end;
174   end;
175end;
176pluie(:,:,:,9)=v(:,:,siz1:siz1bis); % 1987
177
178clear v fid; fid=fopen('pluvio.88.haut','r','b'); siz=41*17*366;
179v=fread(fid,siz,'float'); fclose(fid);
180v=reshape(v,41,17,366);
181clear a b c;
182for a=1:41;
183   for b=1:17;
184       for c=1:366;
185          if v(a,b,c)>990;
186              v(a,b,c)=NaN;
187          elseif v(a,b,c)<0;
188              v(a,b,c)=NaN;
189          end;
190       end;
191   end;
192end;
193pluie(:,:,:,10)=v(:,:,siz1:siz1bis); % 1988
194
195clear v fid; fid=fopen('pluvio.89.haut','r','b'); siz=41*17*365;
196v=fread(fid,siz,'float'); fclose(fid);
197v=reshape(v,41,17,365);
198clear a b c;
199for a=1:41;
200   for b=1:17;
201       for c=1:365;
202          if v(a,b,c)>990;
203              v(a,b,c)=NaN;
204          elseif v(a,b,c)<0;
205              v(a,b,c)=NaN;
206          end;
207       end;
208   end;
209end;
210pluie(:,:,:,11)=v(:,:,siz1:siz1bis); % 1989
211
212clear v fid; fid=fopen('pluvio.90.haut','r','b'); siz=41*17*365;
213v=fread(fid,siz,'float'); fclose(fid);
214v=reshape(v,41,17,365);
215clear a b c;
216for a=1:41;
217   for b=1:17;
218       for c=1:365;
219          if v(a,b,c)>990;
220              v(a,b,c)=NaN;
221          elseif v(a,b,c)<0;
222              v(a,b,c)=NaN;
223          end;
224       end;
225   end;
226end;
227pluie(:,:,:,12)=v(:,:,siz1:siz1bis); % 1990
228
229clear siz sizbis;
230clear v;
231cd('..');
232save pluie.mat pluie;
233clear
234
235load pluie.mat;
236% pluie dimension : lon lat jours annee (41 17 122 12) => jour annee lat lon  (17 41 122 12)
237
238load eof24_1030.txt
239
240% on met sous la forme annee mois
241eof24_1030=reshape(eof24_1030,122,28);
242% selection des annees avant 1990
243olr_eof=eof24_1030(:,1:12);
244clear eof24_1030
245
246% on calcule l ecart type sur la serie temporelle de l'olr
247k=122*12;
248olrbis=reshape(olr_eof,k,1);
249olrbis=std(olrbis);
250
251% intialisation des tableaux
252pluie_filtre_compomax=NaN*ones(30,17,41);
253pluie_filtre_compomin=NaN*ones(30,17,41);
254pluie=permute(pluie,[3 4 2 1]);
255compteurmax=0;
256compteurmin=0;
257
258% boucle sur les annees
259for a=1:12;
260   clear delta;
261   delta=zeros(122,1);
262   % boucle sur les jours : on prepare avant
263   for b=1:122;
264        if b>1;
265            delta(b)=olr_eof(b,a)-olr_eof(b-1,a);
266        end;
267   end;
268   % boucle sur les jours
269   for b=1:122;
270      % 1ere condition (laisser une marge de 10)
271      if (b>20 && b<112);
272% cas 1 : max deltas apres negetifs et deltas avant postifs
273         if (delta(b+1)<0 && delta(b)<0 && delta(b-1)>0 && delta(b-2)>0 && olr_eof(b,a)>olrbis);
274            compteurmax=compteurmax+1;
275            pluie_filtre_compomax(compteurmax,:,:)=pluie(b,a,:,:);
276% cas 2 : min deltas apres positifs et deltas avant negatifs
277         elseif (delta(b+1)>0 && delta(b)>0 && delta(b-1)<0 && delta(b-2)<0 && olr_eof(b,a)<(-olrbis));
278            compteurmin=compteurmin+1;
279            pluie_filtre_compomin(compteurmin,:,:)=pluie(b,a,:,:);
280         end;
281      end;
282   end;
283end;
284
285
286% on fait la somme des valeurs de pluie_filtreentiel sur le nbre d occurences
287% on obtent un tableau de la forme (jours-avant-apres,lon,lat)
288pluie_filtre_compomin1(:,:)=nanmean(pluie_filtre_compomin);
289clear pluie_filtre_compomin;
290pluie_filtre_compomax1(:,:)=nanmean(pluie_filtre_compomax);
291clear pluie_filtre_compomax;
292
293clear pluie_min pluie_max;
294
295pluie_min=pluie_filtre_compomin1;
296pluie_max=pluie_filtre_compomax1;
297
298diff=pluie_min-pluie_max;
299
300sauvegrads('composite_pluie_eof234',diff,[-70 2.5 -10 2.5]);
301
302for b=1:17;
303    for c=1:41;
304         if diff(b,c)<-5;
305             diff(b,c)=5;
306          elseif diff(b,c)>5;
307             diff(b,c)=5;
308         end;
309    end;
310end
311diff(1,1)=-5.01;
312diff(1,2)=5.01;
313
314palette
315lat=[-10:2.5:30];
316lon=[-70:2.5:30]';
317
318contourf(lon,lat,diff,[-5:0.5:5],'LineStyle','none');
319caxis([-5 5])
320co=colorbar('horiz');
321set(co,'position',[0.15 0.26 0.3 0.02]);
322set(co,'xtick',[-4:2:4],'xticklabel',[-4:2:4],'fontname','Arial','fontsize',4);
323
324hold on;
Note: See TracBrowser for help on using the repository browser.