source: trunk/src/plot_tropflux.pro

Last change on this file was 204, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo

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