source: trunk/src/mode_sahelien/time_serie_histog_phase_num.m @ 59

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

add some try/catch on opening file for reading

File size: 6.2 KB
Line 
1function time_serie_histog_phase_num(phase_num)
2% time_serie_histog_phase_num ++explication between 1 and 8
3
4%+
5% module
6% ======
7%
8% ++
9%
10% DESCRIPTION
11% ===========
12%
13% From ``occu.txt`` and phase\ *phase_num*\ .txt, time_serie_histog_phase_num plots
14% for each WT ++.
15%
16% EXAMPLES
17% ========
18%
19% Following line read phase1.txt and occu.txt and plots for each WT ++
20% ::
21%
22% >> time_serie_histog_phase_num(1);
23%
24% SEE ALSO
25% ========
26%
27% lagged_correlations_eof2_eof3_1030.m_
28%
29% .. _lagged_correlations_eof2_eof3_1030.m : lagged_correlations_eof2_eof3_1030.m.html
30%
31% composite_olr_phase_num.m_
32%
33% .. _composite_olr_phase_num.m : composite_olr_phase_num.m.html
34%
35% composite_olr_phase.m_
36%
37% .. _composite_olr_phase.m : composite_olr_phase.m.html
38%
39% time_serie_histog_phase.m_
40%
41% .. _time_serie_histog_phase.m : time_serie_histog_phase.m.html
42%
43% TODO
44% ====
45%
46% improve description
47%
48% improve file pb
49%
50% use return function
51%
52% EVOLUTIONS
53% ==========
54%
55% $Id$
56%
57%
58% - fplod 2009-02-11T16:27:34Z aedon.locean-ipsl.upmc.fr (Darwin)
59%
60%   * add try/catch on opening file for reading
61%
62% - fplod 2009-01-28T09:01:45Z aedon.locean-ipsl.upmc.fr (Darwin)
63%
64%   * created from time_serie_histog_phase1.m to replace it as well as
65%     time_serie_histog_phase[2-8].m
66%
67%-
68
69global IRCAAM_ID;
70
71phase_num_min=1;
72phase_num_max=8;
73
74if nargin==1
75 % phase_num must be greater or equal to 1 and lower or equal to 8
76 if ((phase_num < phase_num_min) || (phase_num > phase_num_max))
77  disp(['phase_num_min = ', int2str(phase_num_min)]);
78  disp(['phase_num_max = ', int2str(phase_num_max)]);
79  error('eee : phase_num must be between phase_num_min and phase_num_max');
80 end
81else
82  usage='usage : time_serie_histog_phase_num(phase_num)';
83  disp(usage);
84  error('eee : wrong arguments numbers')
85end
86
87fullfilename=[IRCAAM_ID,'phase',int2str(phase_num),'.txt'];
88try
89 status=load(fullfilename);
90catch
91 error('eee : File %s not found\n', fullfilename);
92end
93
94clear fullfilename;
95
96phase=status;
97clear status;
98phase=reshape(phase,122,28,3);
99
100%%%%%%%%%%%% FICHIER TYPE DE TEMPS
101% on ouvre le fichier
102fullfilename=[IRCAAM_ID,'occu.txt'];
103status=load(fullfilename);
104clear fullfilename;
105occu=status;
106clear status;
107
108% on reorganise le fichier de type de temps (jours,annees,cluster)
109y=reshape(occu,122,58,4);
110clear occu;
111
112% on selectionne les annees de 1979 a 2006
113occu_type_tps(:,:,:)=y(:,30:57,:);
114clear y;
115
116% intialisation des tableaux
117type_temps_compomax=zeros(80,21,4);
118compteurmax=0;
119
120% boucle sur les annees
121for a=1:28;
122   for b=1:122;
123      % 1ere condition (laisser une marge de 10)
124      if (b>11 && b<112);
125%        condition 1 on est a un maximum deltas apres sont negetifs et
126%             delta avant postifs
127         if phase(b,a,1)==1;
128            compteurmax=compteurmax+1;
129            type_temps_compomax(compteurmax,1,:)=occu_type_tps(b-10,a,:);
130            type_temps_compomax(compteurmax,2,:)=occu_type_tps(b-9,a,:);
131            type_temps_compomax(compteurmax,3,:)=occu_type_tps(b-8,a,:);
132            type_temps_compomax(compteurmax,4,:)=occu_type_tps(b-7,a,:);
133            type_temps_compomax(compteurmax,5,:)=occu_type_tps(b-6,a,:);
134            type_temps_compomax(compteurmax,6,:)=occu_type_tps(b-5,a,:);
135            type_temps_compomax(compteurmax,7,:)=occu_type_tps(b-4,a,:);
136            type_temps_compomax(compteurmax,8,:)=occu_type_tps(b-3,a,:);
137            type_temps_compomax(compteurmax,9,:)=occu_type_tps(b-2,a,:);
138            type_temps_compomax(compteurmax,10,:)=occu_type_tps(b-1,a,:);
139            type_temps_compomax(compteurmax,11,:)=occu_type_tps(b,a,:);
140            type_temps_compomax(compteurmax,12,:)=occu_type_tps(b+1,a,:);
141            type_temps_compomax(compteurmax,13,:)=occu_type_tps(b+2,a,:);
142            type_temps_compomax(compteurmax,14,:)=occu_type_tps(b+3,a,:);
143            type_temps_compomax(compteurmax,15,:)=occu_type_tps(b+4,a,:);
144            type_temps_compomax(compteurmax,16,:)=occu_type_tps(b+5,a,:);
145            type_temps_compomax(compteurmax,17,:)=occu_type_tps(b+6,a,:);
146            type_temps_compomax(compteurmax,18,:)=occu_type_tps(b+7,a,:);
147            type_temps_compomax(compteurmax,19,:)=occu_type_tps(b+8,a,:);
148            type_temps_compomax(compteurmax,20,:)=occu_type_tps(b+9,a,:);
149            type_temps_compomax(compteurmax,21,:)=occu_type_tps(b+10,a,:);
150         end;
151      end;
152   end;
153end;
154
155% on ne selectionne que la partie du tableau ou il y a des valeurs
156type_temps_compomax=type_temps_compomax(1:compteurmax,:,:);
157
158type_temps_moy=reshape(occu_type_tps,3416,4);
159disp(['iii : compteurmax =', int2str(compteurmax)]);
160% on fait la somme des types de temps sur toute la periode de temps
161% on obtent un tableau de la forme (jours-avant-apres,cluster)
162
163type_temps_compomax1(:,:)=sum(type_temps_compomax);
164type_temps_moy=sum(type_temps_moy);
165
166clear type_temps_compomax;
167
168% on fait la somme => le nbre de jour avec 1 type de temps persistant
169% pour chaque jour
170sum_kara_max=sum((type_temps_compomax1)');
171
172% on traduit le nbre d occurence en frequences relatives
173kara_max=zeros(21,4);
174kara_moy=zeros(21,4);
175for a=1:21;
176   for b=1:4;
177      kara_max(a,b)=type_temps_compomax1(a,b)/sum_kara_max(a);
178      kara_moy(b)=type_temps_moy(b)/3416;
179   end;
180end;
181
182x=[-10:1:10]';
183kara_diff=zeros(21,4);
184for a=1:21;
185    for b=1:4
186       kara_diff(a,b)=kara_max(a,b)-kara_moy(b);
187    end;
188end;
189
190offset=mod(phase_num-1,4)*4;
191for a=1:4;
192    subplot(4,4,a+offset);
193    diff=kara_diff(:,a)*100;
194    jour=[-10:10]';
195    if a==1;
196       bar(jour,diff,'r');
197       c=[1 0.55 0];
198       bar(jour,diff),colormap(c);
199    elseif a==2;
200       bar(jour,diff,'g');
201    elseif a==3;
202       bar(jour,diff,'b');
203    else
204       bar(jour,diff,'r');
205    end;
206    set (gca,'XTick',[-10:2:10],'XTickLabel',[-10:2:10],'fontname','Arial','fontsize',6);
207    set (gca,'YTick',[-20:10:20],'YTickLabel',[-20:5:20],'fontname','Arial','fontsize',6);
208    axis([-10 10 -20 20]);
209    set (gca,'tickDir','out');
210    if a==1;
211       title('Atl low','Fontsize',8,'Fontname','Arial');
212       ylabel=['Phase ' int2str(phase_num)];
213       text(-20,0,ylabel);
214       clear ylabel;
215    elseif a==2;
216       title('Atl Ridge','Fontsize',8,'Fontname','Arial');
217    elseif a==3;
218       title('NAO-','Fontsize',8,'Fontname','Arial');
219    else
220       title('Blocking','Fontsize',8,'Fontname','Arial');
221    end;
222end;
223clear offset;
Note: See TracBrowser for help on using the repository browser.