1 | ;+ |
---|
2 | ; |
---|
3 | ; ================= |
---|
4 | ; plot_tropflux.pro |
---|
5 | ; ================= |
---|
6 | ; |
---|
7 | ; .. function:: plot_tropflux(tropflux_varname) |
---|
8 | ; |
---|
9 | ; :param tropflux_varname: variable name to be plot |
---|
10 | ; q2m t2m sst ws swr lwr lhf shf |
---|
11 | ; |
---|
12 | ; Produce +todo+ figures with PROJECT data |
---|
13 | ; |
---|
14 | ; .. graphviz:: |
---|
15 | ; |
---|
16 | ; digraph plot_tropflux { |
---|
17 | ; |
---|
18 | ; file_tropflux_q2m [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/TropFlux_q2m_19890101_20091231.nc"]; |
---|
19 | ; file_tropflux_t2m [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/tropFlux_t2m_19890101_20091231.nc"]; |
---|
20 | ; file_tropflux_ws [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/TropFlux_ws_19890101_20091231.nc"]; |
---|
21 | ; file_tropflux_sst [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/TropFlux_sst_19890101_20091231.nc"]; |
---|
22 | ; file_tropflux [shape=ellipse,fontname=Courier,label="${PROJECT_ID}/TropFlux_19890101_20091231.nc"]; |
---|
23 | ; figure_tropflux_year [shape=ellipse,fontname=Courier,label="${PROJECT_OD}/plot_tropflux_++_year.png"]; |
---|
24 | ; |
---|
25 | ; plot_tropflux [shape=box, |
---|
26 | ; fontname=Courier, |
---|
27 | ; color=blue, |
---|
28 | ; URL="http://forge.ipsl.jussieu.fr/tropflux/browser/trunk/src/plot_tropflux.pro", |
---|
29 | ; label="${PROJECT}/src/plot_tropflux.pro"]; |
---|
30 | ; |
---|
31 | ; {file_tropflux_q2m file_tropflux_t2m file_tropflux_sst file_tropflux_ws file_tropflux} -> {plot_tropflux} -> {figure_tropflux_year} |
---|
32 | ; |
---|
33 | ; } |
---|
34 | ; |
---|
35 | ; EXAMPLES |
---|
36 | ; ======== |
---|
37 | ; |
---|
38 | ; To plot ++ of q2m from :file:`${PROJECT}/TropFlux_q2m_19890101_20091231.nc`:: |
---|
39 | ; |
---|
40 | ; IDL> @project_init |
---|
41 | ; IDL> tropflux_varname='q2m' |
---|
42 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
43 | ; |
---|
44 | ; **status** is 0 if everything is ok, -1 otherwise |
---|
45 | ; |
---|
46 | ; :file:`${PROJECT_OD}/plot_tropflux_q2m_year.png` and |
---|
47 | ; :file:`${PROJECT_OD}/plot_tropflux_q2m_month.png` have been created. |
---|
48 | ; |
---|
49 | ; Same idea for t2m from :file:`${PROJECT}/TropFlux_t2m_19890101_20091231.nc`:: |
---|
50 | ; |
---|
51 | ; IDL> @project_init |
---|
52 | ; IDL> tropflux_varname='t2m' |
---|
53 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
54 | ; |
---|
55 | ; Same idea for sst from :file:`${PROJECT}/TropFlux_sst_19890101_20091231.nc`:: |
---|
56 | ; |
---|
57 | ; IDL> @project_init |
---|
58 | ; IDL> tropflux_varname='sst' |
---|
59 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
60 | ; |
---|
61 | ; Same idea for ws from :file:`${PROJECT}/TropFlux_ws_19890101_20091231.nc`:: |
---|
62 | ; |
---|
63 | ; IDL> @project_init |
---|
64 | ; IDL> tropflux_varname='ws' |
---|
65 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
66 | ; |
---|
67 | ; Same idea for swr from :file:`${PROJECT}/TropFlux_19890101_20091231.nc`:: |
---|
68 | ; |
---|
69 | ; IDL> @project_init |
---|
70 | ; IDL> tropflux_varname='swr' |
---|
71 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
72 | ; |
---|
73 | ; Same idea for lwr from :file:`${PROJECT}/TropFlux_19890101_20091231.nc`:: |
---|
74 | ; |
---|
75 | ; IDL> @project_init |
---|
76 | ; IDL> tropflux_varname='lwr' |
---|
77 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
78 | ; |
---|
79 | ; Same idea for lhf from :file:`${PROJECT}/TropFlux_19890101_20091231.nc`:: |
---|
80 | ; |
---|
81 | ; IDL> @project_init |
---|
82 | ; IDL> tropflux_varname='lhf' |
---|
83 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
84 | ; |
---|
85 | ; Same idea for shf from :file:`${PROJECT}/TropFlux_19890101_20091231.nc`:: |
---|
86 | ; |
---|
87 | ; IDL> @project_init |
---|
88 | ; IDL> tropflux_varname='shf' |
---|
89 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
90 | ; |
---|
91 | ; SEE ALSO |
---|
92 | ; ======== |
---|
93 | ; |
---|
94 | ; :ref:`data_out` |
---|
95 | ; |
---|
96 | ; :ref:`project_profile.sh` |
---|
97 | ; :ref:`project_init.pro` |
---|
98 | ; |
---|
99 | ; :func:`report <saxo:report>` |
---|
100 | ; :func:`initncdf <saxo:initncdf>` |
---|
101 | ; :func:`read_ncdf <saxo:read_ncdf>` |
---|
102 | ; :func:`monthname <saxo:monthname>` |
---|
103 | ; :func:`isadirectory <saxo:isadirectory>` |
---|
104 | ; :func:`isafile <saxo:isafile>` |
---|
105 | ; |
---|
106 | ; TODO |
---|
107 | ; ==== |
---|
108 | ; |
---|
109 | ; define plots to be put on the website |
---|
110 | ; |
---|
111 | ; add a keyword debug |
---|
112 | ; add a keyworf overwrite |
---|
113 | ; |
---|
114 | ; lecture du mask oaflux pour initcdf |
---|
115 | ; |
---|
116 | ; coding rules |
---|
117 | ; |
---|
118 | ; parametre date debut date fin ? |
---|
119 | ; |
---|
120 | ; parametre version ? |
---|
121 | ; |
---|
122 | ; parametre pour website |
---|
123 | ; ref to tip on mouse on mac (cf mail seb) |
---|
124 | ; |
---|
125 | ; add parameter interactif or debug pour tvplus |
---|
126 | ; |
---|
127 | ; add parameter saveimage |
---|
128 | ; |
---|
129 | ; ajuster le format à la dynamique de la variable |
---|
130 | ; |
---|
131 | ; check arg |
---|
132 | ; |
---|
133 | ; loop on month : min and max values for same color scale |
---|
134 | ; 6x2 pose un pb car la legende est trop grande ce qui laisse peu de |
---|
135 | ; place pour le dessin |
---|
136 | ; |
---|
137 | ; KNOWN ISSUES |
---|
138 | ; ============ |
---|
139 | ; |
---|
140 | ; test of existence of fullfilename_in not very efficient because |
---|
141 | ; MUST_EXIST keyword of :func:`isafile <saxo:isafile>` not yet implemented |
---|
142 | ; |
---|
143 | ; EVOLUTIONS |
---|
144 | ; ========== |
---|
145 | ; |
---|
146 | ; $Id$ |
---|
147 | ; |
---|
148 | ; - fplod 20110422T095159Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
149 | ; |
---|
150 | ; * fix read_ncdf call |
---|
151 | ; * improve example |
---|
152 | ; * fix typo |
---|
153 | ; |
---|
154 | ; - fplod 20110408T101102Z cratos.locean-ipsl.upmc.fr (Linux) |
---|
155 | ; |
---|
156 | ; * creation |
---|
157 | ; |
---|
158 | ;- |
---|
159 | ; |
---|
160 | function plot_tropflux, $ |
---|
161 | tropflux_varname |
---|
162 | ; |
---|
163 | compile_opt idl2, strictarrsubs |
---|
164 | ; |
---|
165 | @cm_4cal |
---|
166 | @cm_4data |
---|
167 | @cm_4mesh |
---|
168 | @cm_4data |
---|
169 | @cm_project |
---|
170 | ; |
---|
171 | status=-1 |
---|
172 | ; |
---|
173 | debug=0 |
---|
174 | overwrite=1 |
---|
175 | ; |
---|
176 | ; check for tropflux_varname |
---|
177 | ; and build input filename |
---|
178 | CASE tropflux_varname OF |
---|
179 | 'q2m': BEGIN |
---|
180 | filename_in='TropFlux_q2m_19890101_20091231.nc' |
---|
181 | END |
---|
182 | 't2m': BEGIN |
---|
183 | filename_in='TropFlux_t2m_19890101_20091231.nc' |
---|
184 | END |
---|
185 | 'sst': BEGIN |
---|
186 | filename_in='TropFlux_sst_19890101_20091231.nc' |
---|
187 | END |
---|
188 | 'ws' : BEGIN |
---|
189 | filename_in='TropFlux_ws_19890101_20091231.nc' |
---|
190 | END |
---|
191 | 'swr' : BEGIN |
---|
192 | filename_in='TropFlux_19890101_20091231.nc' |
---|
193 | END |
---|
194 | 'lwr' : BEGIN |
---|
195 | filename_in='TropFlux_19890101_20091231.nc' |
---|
196 | END |
---|
197 | 'lhf' : BEGIN |
---|
198 | filename_in='TropFlux_19890101_20091231.nc' |
---|
199 | END |
---|
200 | 'shf' : BEGIN |
---|
201 | filename_in='TropFlux_19890101_20091231.nc' |
---|
202 | END |
---|
203 | ELSE: BEGIN |
---|
204 | msg = 'eee : ' + tropflux_varname + ' unknown or not handled here' |
---|
205 | ras = report(msg) |
---|
206 | END |
---|
207 | ENDCASE |
---|
208 | ; |
---|
209 | ; check for input file |
---|
210 | ; |
---|
211 | ; test if ${PROJECT_ID} defined |
---|
212 | CASE project_id_env OF |
---|
213 | '' : BEGIN |
---|
214 | msg = 'eee : ${PROJECT_ID} is not defined' |
---|
215 | ras = report(msg) |
---|
216 | STOP |
---|
217 | END |
---|
218 | ELSE: BEGIN |
---|
219 | msg = 'iii : ${PROJECT_ID} is ' + project_id_env |
---|
220 | ras = report(msg) |
---|
221 | END |
---|
222 | ENDCASE |
---|
223 | ; |
---|
224 | iodirin = isadirectory(project_id_env) |
---|
225 | ; |
---|
226 | ; existence and protection of ${PROJECT_ID} |
---|
227 | IF (FILE_TEST(iodirin, /DIRECTORY, /EXECUTABLE, /READ) EQ 0) THEN BEGIN |
---|
228 | msg = 'eee : the directory' + iodirin + ' is not accessible.' |
---|
229 | ras = report(msg) |
---|
230 | STOP |
---|
231 | ENDIF |
---|
232 | ; |
---|
233 | ; check if this file exists |
---|
234 | fullfilename_in = isafile(iodirin + filename_in, NEW=0, /MUST_EXIST) |
---|
235 | print, fullfilename_in |
---|
236 | IF fullfilename_in[0] EQ '' THEN BEGIN |
---|
237 | msg = 'eee : the file ' + fullfilename_in + ' was not found.' |
---|
238 | ras = report(msg) |
---|
239 | STOP |
---|
240 | ENDIF |
---|
241 | print, fullfilename_in[0] |
---|
242 | ; |
---|
243 | ; test if ${PROJECT_OD} defined |
---|
244 | CASE project_od_env OF |
---|
245 | '' : BEGIN |
---|
246 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
247 | ras = report(msg) |
---|
248 | STOP |
---|
249 | END |
---|
250 | ELSE: BEGIN |
---|
251 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
252 | ras = report(msg) |
---|
253 | END |
---|
254 | ENDCASE |
---|
255 | ; |
---|
256 | ; check if output data will be possible |
---|
257 | iodirout = isadirectory(project_od_env) |
---|
258 | ; |
---|
259 | ; existence and protection |
---|
260 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
261 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
262 | ras = report(msg) |
---|
263 | STOP |
---|
264 | ENDIF |
---|
265 | ; |
---|
266 | fullfilename_out_year=iodirout+'plot_tropflux_' + tropflux_varname + '_year.png' |
---|
267 | print, fullfilename_out_year |
---|
268 | ; in order to avoid unexpected overwritten |
---|
269 | IF (FILE_TEST(fullfilename_out_year) EQ 1) THEN BEGIN |
---|
270 | msg = 'eee : the file ' + fullfilename_out_year + ' already exists.' |
---|
271 | IF overwrite EQ 0 THEN BEGIN |
---|
272 | ras = report(msg) |
---|
273 | STOP |
---|
274 | ENDIF |
---|
275 | ENDIF |
---|
276 | ; |
---|
277 | fullfilename_out_month=iodirout+'plot_tropflux_' + tropflux_varname + '_month.png' |
---|
278 | print, fullfilename_out_month |
---|
279 | ; in order to avoid unexpected overwritten |
---|
280 | IF (FILE_TEST(fullfilename_out_month) EQ 1) THEN BEGIN |
---|
281 | IF overwrite EQ 0 THEN BEGIN |
---|
282 | msg = 'eee : the file ' + fullfilename_out_month + ' already exists.' |
---|
283 | ras = report(msg) |
---|
284 | STOP |
---|
285 | ENDIF |
---|
286 | ENDIF |
---|
287 | ; |
---|
288 | ; Read grid and mask |
---|
289 | print, fullfilename_in[0] |
---|
290 | initncdf, fullfilename_in[0] |
---|
291 | ;++ missing value |
---|
292 | |
---|
293 | IF debug EQ 1 THEN BEGIN |
---|
294 | ; afficher ce que l'on veut verifier : tmask values should be 1.e20 on earth |
---|
295 | ; and ++ an ocean |
---|
296 | ; ++ pb souris mac tvplus, tmask[*,*,0] |
---|
297 | ENDIF |
---|
298 | ; |
---|
299 | ; Read data |
---|
300 | tropflux_var=read_ncdf(tropflux_varname,19890101L,19891231L,filename=fullfilename_in[0],/nostruct) |
---|
301 | ; |
---|
302 | IF debug EQ 1 THEN BEGIN |
---|
303 | ; afficher ce que l'on veut vérifier : tropflux_var missing are NaN, values on earth are 1.e20 |
---|
304 | ; ++ pb souris mac tvplus, tropflux_var[*,*,0] |
---|
305 | ENDIF |
---|
306 | ; |
---|
307 | ; plot year mean |
---|
308 | plt, tropflux_var, format='(f6.1)', window=0, /landscape, /map |
---|
309 | saveimage, fullfilename_out_year, /png |
---|
310 | ; |
---|
311 | ; ++ defintion des types d'images |
---|
312 | plot_month=0 |
---|
313 | IF plot_month EQ 1 THEN BEGIN |
---|
314 | ; plot monthes on one page (6x2) |
---|
315 | nl=4 |
---|
316 | nc=2 |
---|
317 | ; ++ wating for final plot do be done |
---|
318 | jpt=nc*nl |
---|
319 | FOR itime = 0L, jpt - 1 DO BEGIN |
---|
320 | vardate=monthname(itime + 1) |
---|
321 | plt, tropflux_var[*,*,itime], noerase = (itime GT 0), small= [nc, nl, itime + 1] , format='(f6.1)', /landscape, window=1 |
---|
322 | ENDFOR |
---|
323 | saveimage, fullfilename_out_month, /png |
---|
324 | ENDIF |
---|
325 | ; |
---|
326 | status=0 |
---|
327 | ; |
---|
328 | return, status |
---|
329 | ; |
---|
330 | END |
---|