source: trunk/src/readERA_LE.m @ 325

Last change on this file since 325 was 325, checked in by pinsard, 13 years ago

rehab MSG, EPSAT tools (to be cont.)

  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1function[mat_3D,lat ,lon,jours,niveau]=readERA(file, z_deb, z_fin,nom_var,chemin)
2%
3%+
4%
5% ============
6% readERA_LE.m
7% ============
8%
9%
10% .. function:: readERA(file, z_deb, z_fin,nom_var,chemin)
11%
12% DESCRIPTION
13% ===========
14%
15% routine de lecture d un fichier de donnees ERA40 au format netcdf sur
16% la zone definie par les points z_deb zfin de forme [lat lon time level]
17%
18% EVOLUTIONS
19% ==========
20%
21% $Id$
22%
23% $URL$
24%
25% - fplod 20110705T125628Z cratos.locean-ipsl.upmc.fr (Linux)
26%
27%   * minimal header
28%
29%-
30if(nargin<2)
31z_deb=[ -30 -60 datenum(1957,1,1) 500] 
32end
33if(nargin<3)
34z_fin=[ 45 50 datenum(2020,1,1) 500]   
35end
36if(nargin<4)
37  [groupe,reste]=strtok(file,'.');
38  [nom_var,reste]=strtok(reste,'.');
39end
40if(nargin<5)
41     chemin='/homedata/eymard/OPERA_Trop/';
42end
43if(chemin(end)~='/')
44chemin=[chemin,'/'];
45end
46
47file=[chemin,file];
48
49nc=netcdf(file,'nowrite');
50longitude=nc{'lon'}(:);
51latitude=nc{'lat'}(:);
52jours=nc{'time'}(:);
53niveau=nc{'level'}(:);
54
55jo=find(jours~=0);
56jours=jours(jo)/24+datenum(1957,01,01); % En jours juliens
57jo=find(jours>z_deb(3) & jours<z_fin(3));
58jours=jours(jo);
59
60
61lom=find(longitude-360>z_deb(2) & longitude-360<z_fin(2));
62lop=find(longitude>z_deb(2) & longitude<z_fin(2));
63lon=cat(1,longitude(lom)-360,longitude(lop));
64
65
66%[lat,la]=sort(latitude,'ascend');
67la=find(latitude>z_deb(1) & latitude<z_fin(1));
68lat=sort(latitude(la),'ascend');
69
70if(nom_var=='r')
71ni=find(niveau>=z_deb(4) & niveau<=z_fin(4));
72
73coef=[1 0.8 0.4 0.4];  % RH  la meilleure corr 2006 pour B5
74coef=[0.6 0.8 1 0.8];  % RH  la meilleure corr 2006 pour B3 (mais moins sensible que B5)
75%coef=[0 1 1 0];  % pour verif
76coef
77else
78ni=[min(ni) max(ni)];  % pour geopt
79end
80niveau=niveau(ni);
81
82 
83variable_p=[];
84variable_m=[];
85 
86if(isempty(niveau)) %variable 3D
87%extraction de la variable pour les longitudes positives et negatives
88if(~isempty(lop))
89  variable_p=nc{nom_var}(jo,la,lop);
90end
91if(~isempty(lom))
92  variable_m=nc{nom_var}(jo,la,lom);
93end
94variable=cat(3,variable_m,variable_p);
95%Remise des latitudes dans le sens ascendant
96variable=variable(:,end:-1:1,:);
97%% mat_3D est la matrice (lat,lon, jours) de sortie
98mat_3D=permute(variable,[2 3 1]); 
99
100
101 else %Variable 4D dont on moyenne la dimension "niveau" (nom_var=r) ou la difference (geopt)
102%extraction de la variable pour les longitudes positives et negatives
103if(~isempty(lop))
104  variable_p=nc{nom_var}(jo,ni,la,lop);
105end
106if(~isempty(lom))
107 variable_m=nc{nom_var}(jo,ni,la,lom);
108end
109variable=cat(4,variable_m,variable_p);
110%Remise des latitudes dans le sens ascendant
111variable=variable(:,:,end:-1:1,:);
112
113%% mat_3D est la matrice (lat,lon,jours) de sortie
114if(nom_var=='r')
115nom_var
116  mat_3D_lev=permute(variable,[3 4 1 2]);
117%mat_3D=squeeze(mean(mat_3D_lev,4));
118mat_3D=squeeze(mat_3D_lev(:,:,:,1)*coef(1));
119for i=2:size(niveau)
120  mat_3D=mat_3D+mat_3D_lev(:,:,:,i)*coef(i);
121end
122 else
123nom_var
124   mat_3D=permute(variable,[2,3,4,1]);
125mat_3D=squeeze(diff(mat_3D));
126
127end
128end
129
Note: See TracBrowser for help on using the repository browser.