source: trunk/src/mode_sahelien/composite_olr_phase_num.m @ 91

Last change on this file since 91 was 91, checked in by pinsard, 10 years ago

fix thanks to coding rules

File size: 8.0 KB
Line 
1function composite_olr_phase_num(phase_num)
2% composite_olr_phase_num ++explication between 1 and 8
3
4%+
5%
6% .. _composite_olr_phase_num.m:
7%
8% =========================
9% composite_olr_phase_num.m
10% =========================
11%
12% ++
13%
14% DESCRIPTION
15% ===========
16%
17% From :file:`olr.day.mean.nc` and :file:`phase{phase_num}.txt`, composite_olr_phase_num
18% compute ++, plot ++
19%
20% CAUTIONS
21% ========
22%
23% Need Statistics_Toolbox because of nanmean
24%
25% can't work with octave because of ncload and nanmean
26%
27% EXAMPLES
28% ========
29%
30% Following line read :file:`olr.day.mean.nc` and :file:`phase{phase_num}txt`, compute ++,
31% plot ++
32% ::
33%
34% >> composite_olr_phase_num(1);
35%
36% SEE ALSO
37% ========
38%
39% :ref:`lagged_correlations_eof2_eof3_1030.m`
40%
41% :ref:`composite_olr_phase.m`
42%
43% :ref:`time_serie_histog_phase.m`
44%
45% :ref:`time_serie_histog_phase_num.m`
46%
47% TODO
48% ====
49%
50% improve description
51%
52% improve file pb especialy ncload
53%
54% use return function
55%
56% externalize time selection on olr.day.mean.nc
57%
58% test at the beginning if Statistics_Toolbox  available
59%
60% test at the beginning if octave is running
61%
62% EVOLUTIONS
63% ==========
64%
65% $Id$
66%
67% - fplod 2009-02-11T16:27:34Z aedon.locean-ipsl.upmc.fr (Darwin)
68%
69%   * add try/catch on opening file for reading
70%
71% - fplod 2009-01-28T10:38:44Z aedon.locean-ipsl.upmc.fr (Darwin)
72%
73%   * created from composite_olr_phase8.m to replace it as well as
74%     composite_olr_phase[1-7].m
75%
76%-
77
78global IRCAAM_ID;
79global IRCAAM_OD;
80
81phase_num_min=1;
82phase_num_max=8;
83
84if nargin==1
85 % phase_num must be greater or equal to 1 and lower or equal to 8
86 if ((phase_num < phase_num_min) || (phase_num > phase_num_max))
87  disp(['phase_num_min = ', int2str(phase_num_min)]);
88  disp(['phase_num_max = ', int2str(phase_num_max)]);
89  error('eee : phase_num must be between phase_num_min and phase_num_max');
90 end
91else
92  usage='usage : composite_olr_phase_num(phase_num)';
93  disp(usage);
94  error('eee : wrong arguments numbers')
95end
96
97fullfilename=[IRCAAM_ID,'olr.day.mean.nc'];
98ncload(fullfilename);
99
100clear fullfilename;
101
102% taille 12327x73x144 1er juin 1974-31 decembre2007
103% on enleve les années 1974 a 1978 nombre de jours a enlever au debut 214+365+366+365+365
104% on enleve les années 2001 a 2008 nombre de jours a enlever au debut 12327-(365*3+366+365*3+60)
105
106debut=214+365+366+365+365;
107fin=12327-(365+60);
108olr=olr(debut:fin,21:41,:);
109siz=fin-debut+1;
110for a=1:21;
111   for b=1:144;
112       for c=1:siz;
113          if olr(c,a,b)==32766;
114              olr(c,a,b)=NaN;
115          end;
116       end ;
117   end;
118end;
119olr=olr*0.01+327.65;
120olr1=zeros(siz,21,144);
121olr1(:,:,1:72)=olr(:,:,73:144);
122olr1(:,:,73:144)=olr(:,:,1:72);
123clear olr;
124
125% on permture le temps et l'espce
126% nouvelles dimensions
127% 21 144 siz
128olr1=permute(olr1, [2 3 1]);
129
130for a=1:21;
131   for b=1:144;
132      clear vecteur
133      vecteur=zeros(siz,1);
134      for c=1:siz;
135           vecteur(c)=olr1(a,b,c);
136      end;
137      std_c=nanmean(vecteur);
138      for c=1:siz;
139          olr1(a,b,c)=olr1(a,b,c)-std_c;
140      end;
141   end;
142end;
143
144% on met sous la forme longitude latitude jour
145
146% on selectionne les mois d ete (attention aux années bixestiles!)
147
148siz1=31+28+31+30+31+1;
149siz1bis=31+28+31+30+31+30+31+31+30;
150a=siz1bis-siz1;
151
152olr=zeros(21,144,122,28);
153
154siz2=siz1+366; siz2bis=siz2+a; % 1980
155siz3=siz2+365; siz3bis=siz3+a; % 1981
156siz4=siz3+365; siz4bis=siz4+a; % 1982
157siz5=siz4+365; siz5bis=siz5+a; % 1983
158siz6=siz5+366; siz6bis=siz6+a; % 1984
159siz7=siz6+365; siz7bis=siz7+a; % 1985
160siz8=siz7+365; siz8bis=siz8+a; % 1986
161siz9=siz8+365; siz9bis=siz9+a; % 1987
162siz10=siz9+366; siz10bis=siz10+a; % 1988
163siz11=siz10+365; siz11bis=siz11+a; % 1989
164siz12=siz11+365; siz12bis=siz12+a; % 1990
165siz13=siz12+365; siz13bis=siz13+a; % 1991
166siz14=siz13+366; siz14bis=siz14+a; % 1992
167siz15=siz14+365; siz15bis=siz15+a; % 1993
168siz16=siz15+365; siz16bis=siz16+a; % 1994
169siz17=siz16+365; siz17bis=siz17+a; % 1995
170siz18=siz17+366; siz18bis=siz18+a; % 1996
171siz19=siz18+365; siz19bis=siz19+a; % 1997
172siz20=siz19+365; siz20bis=siz20+a; % 1998
173siz21=siz20+365; siz21bis=siz21+a; % 1999
174siz22=siz21+366; siz22bis=siz22+a; % 2000
175siz23=siz22+365; siz23bis=siz23+a; % 2001
176siz24=siz23+365; siz24bis=siz24+a; % 2002
177siz25=siz24+365; siz25bis=siz25+a; % 2003
178siz26=siz25+366; siz26bis=siz26+a; % 2004
179siz27=siz26+365; siz27bis=siz27+a; % 2005
180siz28=siz27+365; siz28bis=siz28+a; % 2006
181
182olr(:,:,:,1)=olr1(:,:,siz1:siz1bis); % 1979
183olr(:,:,:,2)=olr1(:,:,siz2:siz2bis); % 1980
184olr(:,:,:,3)=olr1(:,:,siz3:siz3bis); % 1981
185olr(:,:,:,4)=olr1(:,:,siz4:siz4bis); % 1982
186olr(:,:,:,5)=olr1(:,:,siz5:siz5bis); % 1983
187olr(:,:,:,6)=olr1(:,:,siz6:siz6bis); % 1984
188olr(:,:,:,7)=olr1(:,:,siz7:siz7bis); % 1985
189olr(:,:,:,8)=olr1(:,:,siz8:siz8bis); % 1986
190olr(:,:,:,9)=olr1(:,:,siz9:siz9bis); % 1987
191olr(:,:,:,10)=olr1(:,:,siz10:siz10bis); % 1988
192olr(:,:,:,11)=olr1(:,:,siz11:siz11bis); % 1989
193olr(:,:,:,12)=olr1(:,:,siz12:siz12bis); % 1990
194olr(:,:,:,13)=olr1(:,:,siz13:siz13bis); % 1991
195olr(:,:,:,14)=olr1(:,:,siz14:siz14bis); % 1992
196olr(:,:,:,15)=olr1(:,:,siz15:siz15bis); % 1993
197olr(:,:,:,16)=olr1(:,:,siz16:siz16bis); % 1994
198olr(:,:,:,17)=olr1(:,:,siz17:siz17bis); % 1995
199olr(:,:,:,18)=olr1(:,:,siz18:siz18bis); % 1996
200olr(:,:,:,19)=olr1(:,:,siz19:siz19bis); % 1997
201olr(:,:,:,20)=olr1(:,:,siz20:siz20bis); % 1998
202olr(:,:,:,21)=olr1(:,:,siz21:siz21bis); % 1999
203olr(:,:,:,22)=olr1(:,:,siz22:siz22bis); % 2000
204olr(:,:,:,23)=olr1(:,:,siz23:siz23bis); % 2001
205olr(:,:,:,24)=olr1(:,:,siz24:siz24bis); % 2002
206olr(:,:,:,25)=olr1(:,:,siz25:siz25bis); % 2003
207olr(:,:,:,26)=olr1(:,:,siz26:siz26bis); % 2004
208olr(:,:,:,27)=olr1(:,:,siz27:siz27bis); % 2005
209olr(:,:,:,28)=olr1(:,:,siz28:siz28bis); % 2006
210
211clear siz1 siz1bis;
212clear siz2 siz2bis;
213clear siz3 siz3bis;
214clear siz4 siz4bis;
215clear siz5 siz5bis;
216clear siz6 siz6bis;
217clear siz7 siz7bis;
218clear siz8 siz8bis;
219clear siz9 siz9bis;
220clear siz10 siz10bis;
221clear siz11 siz11bis;
222clear siz12 siz12bis;
223clear siz13 siz13bis;
224clear siz14 siz14bis;
225clear siz15 siz15bis;
226clear siz16 siz16bis;
227clear siz17 siz17bis;
228clear siz18 siz18bis;
229clear siz19 siz19bis;
230clear siz20 siz20bis;
231clear siz21 siz21bis;
232clear siz22 siz22bis;
233clear siz23 siz23bis;
234clear siz24 siz24bis;
235clear siz25 siz25bis;
236clear siz26 siz26bis;
237clear siz27 siz27bis;
238clear siz28 siz28bis;
239
240%olr=zeros(21,144,122,28);
241olr1=permute(olr,[3 4 1 2]);
242clear olr;
243olr2=reshape(olr1,3416,21,144);
244olr3(:,:)=mean(olr2);
245clear olr2;
246
247fullfilename=[IRCAAM_OD,'phase',int2str(phase_num),'.txt'];
248try
249 status=load(fullfilename);
250catch
251 error('eee : File %s not found\n', fullfilename);
252end
253
254clear fullfilename;
255
256phase=status;
257clear status;
258phase=reshape(phase,122,28,3);
259olr_filtre_compomax=zeros(90,21,144);
260compteurmax=0;
261
262% boucle sur les années
263for a=1:28;
264   % boucle sur les jours
265   for b=1:122;
266      % 1ere condition (laisser une marge de 10)
267      if (b>11 && b<112);
268         if phase(b,a,1)==1;
269            compteurmax=compteurmax+1;
270            olr_filtre_compomax(compteurmax,:,:)=olr1(b,a,:,:);
271         end;
272      end;
273   end;
274end;
275disp(['iii : compteurmax =', int2str(compteurmax)]);
276% on ne selectionne que la partie du tableau ou il y a des valeurs
277olr_filtre_compomax=olr_filtre_compomax(1:compteurmax,:,:);
278
279% on fait la somme des valeurs de olr_filtreentiel sur le nbre d occurences
280% on obtent un tableau de la forme (jours-avant-apres,lon,lat)
281olr_filtre_compomax1(:,:)=mean(olr_filtre_compomax);
282clear olr_filtre_compomax;
283
284x=[-10:1:10]';
285
286lat=lat(21:41)';
287lon=lon-180;
288delta=olr_filtre_compomax1-olr3;
289clear olr3;
290for b=1:21;
291    for c=1:144;
292       if delta(b,c)<-50;
293          delta(b,c)=-50;
294       elseif delta(b,c)>50;
295           delta(b,c)=50;
296       end;
297    end;
298end;
299palette;
300delta(1,1)=-50.0001;
301delta(1,2)=50.0001;
302aa=contourf(lon,lat,delta,[-50:5:50],'LineStyle','none');
303set (gca,'XTick',[-180:60:180],'XTickLabel',[' 180';'120W';' 60W';'   0';' 60E';'120E';' 180'],'fontsize',6);
304set (gca,'YTick',[-10:10:40],'YTickLabel',['   ';'  0';'10N';'20N';'30N';'   '],'fontname','Arial','fontsize',6);
305co=colorbar;
306set(co,'xtick',[-20:10:20],'xticklabel',[-20:10:20],'fontname','Arial','fontsize',6);
307hold on;
308cartemonde1;
309set (gca,'tickDir','out');
310axis equal;
311axis([-180 180 -10 40]);
Note: See TracBrowser for help on using the repository browser.