source: trunk/src/plot_tropflux.pro @ 67

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

fix for doc

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