source: trunk/src/readERA.m @ 327

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

change svn properties

  • Property svn:keywords set to URL
File size: 2.3 KB
Line 
1%% routine de lecture d un fichier de donnees ERA40 au format netcdf sur
2%  la zone definie par les points z_deb zfin de forme [lat lon time level]
3
4%+
5%
6% .. _readERA.m:
7%
8% =========
9% readERA.m
10% =========
11%
12% EVOLUTIONS
13% ==========
14%
15% $Id: readERA.m 325 2011-08-04 15:30:01Z pinsard $
16%
17% $URL$
18%
19% - fplod 20110124T154122Z aedon.locean-ipsl.upmc.fr (Darwin)
20%
21%   * add rst header
22%
23%-
24
25
26
27
28function[mat_3D,lat ,lon,jours,niveau]=readERA(file, z_deb, z_fin,nom_var,chemin)
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
70ni=find(niveau>=z_deb(4) & niveau<=z_fin(4));
71niveau=niveau(ni);
72 
73variable_p=[];
74variable_m=[];
75 
76if(isempty(niveau)) %variable 3D
77%extraction de la variable pour les longitudes positives et negatives
78if(~isempty(lop))
79  variable_p=nc{nom_var}(jo,la,lop);
80end
81if(~isempty(lom))
82  variable_m=nc{nom_var}(jo,la,lom);
83end
84variable=cat(3,variable_m,variable_p);
85%Remise des latitudes dans le sens ascendant
86variable=variable(:,end:-1:1,:);
87%% mat_3D est la matrice (lat,lon, jours) de sortie
88mat_3D=permute(variable,[2 3 1]); 
89 
90else %Variable 4D dont on moyenne la dimension "niveau"
91%extraction de la variable pour les longitudes positives et negatives
92if(~isempty(lop))
93  variable_p=nc{nom_var}(jo,ni,la,lop);
94end
95if(~isempty(lom))
96 variable_m=nc{nom_var}(jo,ni,la,lom);
97end
98variable=cat(4,variable_m,variable_p);
99%Remise des latitudes dans le sens ascendant
100variable=variable(:,:,end:-1:1,:);
101
102%% mat_3D est la matrice (lat,lon,jours) de sortie
103mat_3D=permute(variable,[3 4 1 2]);
104mat_3D=squeeze(mean(mat_3D,4));
105end
106
Note: See TracBrowser for help on using the repository browser.