source: trunk/src/plot_tropflux.pro @ 50

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

replace TROPFLUX by PROJECT

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