1 | function[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 | %- |
---|
30 | if(nargin<2) |
---|
31 | z_deb=[ -30 -60 datenum(1957,1,1) 500] |
---|
32 | end |
---|
33 | if(nargin<3) |
---|
34 | z_fin=[ 45 50 datenum(2020,1,1) 500] |
---|
35 | end |
---|
36 | if(nargin<4) |
---|
37 | [groupe,reste]=strtok(file,'.'); |
---|
38 | [nom_var,reste]=strtok(reste,'.'); |
---|
39 | end |
---|
40 | if(nargin<5) |
---|
41 | chemin='/homedata/eymard/OPERA_Trop/'; |
---|
42 | end |
---|
43 | if(chemin(end)~='/') |
---|
44 | chemin=[chemin,'/']; |
---|
45 | end |
---|
46 | |
---|
47 | file=[chemin,file]; |
---|
48 | |
---|
49 | nc=netcdf(file,'nowrite'); |
---|
50 | longitude=nc{'lon'}(:); |
---|
51 | latitude=nc{'lat'}(:); |
---|
52 | jours=nc{'time'}(:); |
---|
53 | niveau=nc{'level'}(:); |
---|
54 | |
---|
55 | jo=find(jours~=0); |
---|
56 | jours=jours(jo)/24+datenum(1957,01,01); % En jours juliens |
---|
57 | jo=find(jours>z_deb(3) & jours<z_fin(3)); |
---|
58 | jours=jours(jo); |
---|
59 | |
---|
60 | |
---|
61 | lom=find(longitude-360>z_deb(2) & longitude-360<z_fin(2)); |
---|
62 | lop=find(longitude>z_deb(2) & longitude<z_fin(2)); |
---|
63 | lon=cat(1,longitude(lom)-360,longitude(lop)); |
---|
64 | |
---|
65 | |
---|
66 | %[lat,la]=sort(latitude,'ascend'); |
---|
67 | la=find(latitude>z_deb(1) & latitude<z_fin(1)); |
---|
68 | lat=sort(latitude(la),'ascend'); |
---|
69 | |
---|
70 | if(nom_var=='r') |
---|
71 | ni=find(niveau>=z_deb(4) & niveau<=z_fin(4)); |
---|
72 | |
---|
73 | coef=[1 0.8 0.4 0.4]; % RH la meilleure corr 2006 pour B5 |
---|
74 | coef=[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 |
---|
76 | coef |
---|
77 | else |
---|
78 | ni=[min(ni) max(ni)]; % pour geopt |
---|
79 | end |
---|
80 | niveau=niveau(ni); |
---|
81 | |
---|
82 | |
---|
83 | variable_p=[]; |
---|
84 | variable_m=[]; |
---|
85 | |
---|
86 | if(isempty(niveau)) %variable 3D |
---|
87 | %extraction de la variable pour les longitudes positives et negatives |
---|
88 | if(~isempty(lop)) |
---|
89 | variable_p=nc{nom_var}(jo,la,lop); |
---|
90 | end |
---|
91 | if(~isempty(lom)) |
---|
92 | variable_m=nc{nom_var}(jo,la,lom); |
---|
93 | end |
---|
94 | variable=cat(3,variable_m,variable_p); |
---|
95 | %Remise des latitudes dans le sens ascendant |
---|
96 | variable=variable(:,end:-1:1,:); |
---|
97 | %% mat_3D est la matrice (lat,lon, jours) de sortie |
---|
98 | mat_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 |
---|
103 | if(~isempty(lop)) |
---|
104 | variable_p=nc{nom_var}(jo,ni,la,lop); |
---|
105 | end |
---|
106 | if(~isempty(lom)) |
---|
107 | variable_m=nc{nom_var}(jo,ni,la,lom); |
---|
108 | end |
---|
109 | variable=cat(4,variable_m,variable_p); |
---|
110 | %Remise des latitudes dans le sens ascendant |
---|
111 | variable=variable(:,:,end:-1:1,:); |
---|
112 | |
---|
113 | %% mat_3D est la matrice (lat,lon,jours) de sortie |
---|
114 | if(nom_var=='r') |
---|
115 | nom_var |
---|
116 | mat_3D_lev=permute(variable,[3 4 1 2]); |
---|
117 | %mat_3D=squeeze(mean(mat_3D_lev,4)); |
---|
118 | mat_3D=squeeze(mat_3D_lev(:,:,:,1)*coef(1)); |
---|
119 | for i=2:size(niveau) |
---|
120 | mat_3D=mat_3D+mat_3D_lev(:,:,:,i)*coef(i); |
---|
121 | end |
---|
122 | else |
---|
123 | nom_var |
---|
124 | mat_3D=permute(variable,[2,3,4,1]); |
---|
125 | mat_3D=squeeze(diff(mat_3D)); |
---|
126 | |
---|
127 | end |
---|
128 | end |
---|
129 | |
---|