source: trunk/src/SIMULS_IRCAAM/prepare_olr_filtre_simulation.m @ 91

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

better representation of variable parts in filenames

File size: 3.7 KB
Line 
1function prepare_olr_filtre_simulation(ircaam_dataset,simulation)
2% prepare_olr_filtre_simulation ++explication ircaam_dataset,simulation
3
4%+
5%
6%  .. _prepare_olr_filtre_simulation.m:
7%
8% ===============================
9% prepare_olr_filtre_simulation.m
10% ===============================
11%
12% ce programme prepare les fichiers d'OLR de simulations IRCAAM CNRM
13% pour le programme de filtrage
14%
15% DESCRIPTION
16% ===========
17%
18% From :file:`rlut_d.{simulation}.197106-09.nc`,
19% ``prepare_olr_filtre_simulation`` compute ++.
20%
21% ``prepare_olr_filtre_simulation`` write
22% :file:`olr_nofiltre_arpege_{simulation}.dat`.
23%
24% CAUTIONS
25% ========
26%
27% can't work with octave because of ncload.
28%
29% EXAMPLES
30% ========
31%
32% Following line read from :file:`rlut_d.AfNQIVIV.197106-09.nc` to
33% :file:`rlut_d.AfNQIVIV.200006-09.nc`,
34% compute ++,
35% write :file:`olr_nofiltre_arpege_AfNQIVIV.dat`::
36%
37% >> prepare_olr_filtre_simulation('arpege','AfNQIVIV')
38%
39% SEE ALSO
40% ========
41%
42% :ref:`carte_eof_df.m`
43%
44% TODO
45% ====
46%
47% improve description
48%
49% improve file pb
50%
51% use return function
52%
53% EVOLUTIONS
54% ==========
55%
56% $Id$
57%
58% - fplod 2009-02-10T15:54:57Z aedon.locean-ipsl.upmc.fr (Darwin)
59%
60%   * force output to be written using IEEE floating point 32 bits
61%
62% - fplod 2009-02-04T09:40:31Z aedon.locean-ipsl.upmc.fr (Darwin)
63%
64%   * force output to be written using IEEE floating point with little-endian
65%     byte order
66%
67% - fplod 2009-02-02T13:45:57Z aedon.locean-ipsl.upmc.fr (Darwin)
68%
69%   * created from prepare_olr_filtre_AFR.m to replace it as well as
70%     prepare_olr_filtre_AS.m, prepare_olr_filtre_CTL.m,
71%     prepare_olr_filtre_CTL_clim.m and prepare_olr_filtre_TR.m
72%
73%     Dataset ``arpege`` will be forced in output file names.
74%
75%     Simulation name will be add to output file names (see parameters).
76%
77%     1990 is added to years set.
78%-
79
80global IRCAAM_ID;
81global IRCAAM_OD;
82
83% force output to be written using IEEE floating point with little-endian byte
84% order
85machineformat='l';
86
87if nargin==2
88 % ircaam_dataset must be equal to arpege
89 if ~strcmp(ircaam_dataset,'arpege')
90  disp(['ircaam_dataset = ', ircaam_dataset]);
91  error('eee : ircaam_dataset must be equal to arpege');
92 end
93 if strcmp(ircaam_dataset,'arpege')
94  list_simulation={'AfNQIVIV','TrNQIVIV','AsNQIVIV','CtIV','CtCl'};
95 end
96 switch simulation
97  case list_simulation
98   % ok
99  otherwise
100   disp(['simulation = ', simulation]);
101   disp(['list_simulation = ', mat2str(list_simulation)]);
102   error('eee : simulation must be equal to one of list_simulation');
103 end
104 clear list_simulation;
105else
106  usage='usage : prepare_olr_filtre_simulation(ircaam_dataset,simulation)';
107  disp(usage);
108  error('eee : wrong arguments numbers')
109end
110
111close all;
112
113iyearmin=1971;
114iyearmax=2000;
115nbyear=iyearmax-iyearmin+1;
116
117olr=zeros(122,nbyear,64,128);
118
119iiyear=0;
120for iyear=iyearmin:iyearmax
121 cyear=num2str(iyear);
122 fullfilename=[IRCAAM_ID,'rlut_d.',simulation,'.',cyear,'06-09.nc'];
123 ncload(fullfilename,'rlut');
124 clear fullfilename;
125 iiyear=iiyear+1;
126 olr(:,iiyear,:,:)=rlut;
127 clear rlut;
128end;
129
130% selection du domaine geographique
131olr1=zeros(122,nbyear,64,128);
132olr1(:,:,:,1:64)=olr(:,:,:,65:128);
133olr1(:,:,:,65:128)=olr(:,:,:,1:64);
134clear olr;
135olr=olr1;
136clear olr1;
137olr=olr(:,:,29:43,54:77);
138tps=size(olr,1)*size(olr,2);
139olr=reshape(olr,tps,15,24);
140olr=permute(olr,[3 2 1]);
141olr=reshape(olr,360,tps);
142
143switch simulation
144 case {'CtIV','CtCl'}
145  % nothing
146 otherwise
147  for a=1:360;
148   clear vaude;
149   vaude=olr(a,:);
150   vaude=vaude';
151   vaude=mean(vaude);
152   olr(a,:)=olr(a,:)-vaude;
153  end;
154end
155
156fullfilename=[IRCAAM_OD,'olr_nofiltre_',ircaam_dataset,'_', simulation, '.dat'];
157fid=fopen(fullfilename,'w',machineformat);
158clear fullfilename;
159fwrite(fid,olr,'float32');
160fclose(fid);
Note: See TracBrowser for help on using the repository browser.