[39] | 1 | ;+ |
---|
| 2 | ; |
---|
[67] | 3 | ; ================= |
---|
| 4 | ; plot_tropflux.pro |
---|
| 5 | ; ================= |
---|
| 6 | ; |
---|
[39] | 7 | ; .. function:: plot_tropflux(tropflux_varname) |
---|
| 8 | ; |
---|
[50] | 9 | ; :param tropflux_varname: variable name to be plot |
---|
| 10 | ; q2m t2m sst ws swr lwr lhf shf |
---|
[39] | 11 | ; |
---|
[50] | 12 | ; Produce +todo+ figures with PROJECT data |
---|
[49] | 13 | ; |
---|
[50] | 14 | ; |
---|
[39] | 15 | ; .. graphviz:: |
---|
| 16 | ; |
---|
| 17 | ; digraph plot_tropflux { |
---|
| 18 | ; graph [ |
---|
| 19 | ; rankdir="LR", |
---|
| 20 | ; ] |
---|
[50] | 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"]; |
---|
[39] | 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", |
---|
[50] | 32 | ; label="${PROJECT}/src/plot_tropflux.pro"]; |
---|
[39] | 33 | ; |
---|
[50] | 34 | ; {file_tropflux_q2m file_tropflux_t2m file_tropflux_sst file_tropflux_ws file_tropflux} -> {plot_tropflux} -> {figure_tropflux_year} |
---|
[39] | 35 | ; |
---|
| 36 | ; } |
---|
| 37 | ; |
---|
| 38 | ; EXAMPLES |
---|
| 39 | ; ======== |
---|
| 40 | ; |
---|
[50] | 41 | ; To plot ++ of q2m from :file:`${PROJECT}/TropFlux_q2m_19890101_20091231.nc`:: |
---|
[39] | 42 | ; |
---|
[50] | 43 | ; IDL> @project_init |
---|
[49] | 44 | ; IDL> tropflux_varname='q2m' |
---|
| 45 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
[39] | 46 | ; |
---|
| 47 | ; **status** is 0 if everything is ok, -1 otherwise |
---|
| 48 | ; |
---|
[50] | 49 | ; :file:`${PROJECT_OD}/plot_tropflux_q2m_year.png` and |
---|
| 50 | ; :file:`${PROJECT_OD}/plot_tropflux_q2m_month.png` have been created. |
---|
[39] | 51 | ; |
---|
[50] | 52 | ; Same idea for t2m from :file:`${PROJECT}/TropFlux_t2m_19890101_20091231.nc`:: |
---|
[49] | 53 | ; |
---|
[50] | 54 | ; IDL> @project_init |
---|
[49] | 55 | ; IDL> tropflux_varname='t2m' |
---|
| 56 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
| 57 | ; |
---|
[50] | 58 | ; Same idea for sst from :file:`${PROJECT}/TropFlux_sst_19890101_20091231.nc`:: |
---|
[49] | 59 | ; |
---|
[50] | 60 | ; IDL> @project_init |
---|
[49] | 61 | ; IDL> tropflux_varname='sst' |
---|
| 62 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
| 63 | ; |
---|
[50] | 64 | ; Same idea for ws from :file:`${PROJECT}/TropFlux_ws_19890101_20091231.nc`:: |
---|
[49] | 65 | ; |
---|
[50] | 66 | ; IDL> @project_init |
---|
[49] | 67 | ; IDL> tropflux_varname='ws' |
---|
| 68 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
| 69 | ; |
---|
[50] | 70 | ; Same idea for swr from :file:`${PROJECT}/TropFlux_19890101_20091231.nc`:: |
---|
[49] | 71 | ; |
---|
[50] | 72 | ; IDL> @project_init |
---|
[49] | 73 | ; IDL> tropflux_varname='swr' |
---|
| 74 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
| 75 | ; |
---|
[50] | 76 | ; Same idea for lwr from :file:`${PROJECT}/TropFlux_19890101_20091231.nc`:: |
---|
[49] | 77 | ; |
---|
[50] | 78 | ; IDL> @project_init |
---|
[49] | 79 | ; IDL> tropflux_varname='lwr' |
---|
| 80 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
| 81 | ; |
---|
[50] | 82 | ; Same idea for lhf from :file:`${PROJECT}/TropFlux_19890101_20091231.nc`:: |
---|
[49] | 83 | ; |
---|
[50] | 84 | ; IDL> @project_init |
---|
[49] | 85 | ; IDL> tropflux_varname='lhf' |
---|
| 86 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
| 87 | ; |
---|
[50] | 88 | ; Same idea for shf from :file:`${PROJECT}/TropFlux_19890101_20091231.nc`:: |
---|
[49] | 89 | ; |
---|
[50] | 90 | ; IDL> @project_init |
---|
[49] | 91 | ; IDL> tropflux_varname='shf' |
---|
| 92 | ; IDL> status = plot_tropflux(tropflux_varname) |
---|
| 93 | ; |
---|
[39] | 94 | ; SEE ALSO |
---|
| 95 | ; ======== |
---|
| 96 | ; |
---|
| 97 | ; :ref:`data_out` |
---|
| 98 | ; |
---|
[50] | 99 | ; :ref:`project_profile.sh` |
---|
| 100 | ; :ref:`project_init.pro` |
---|
[39] | 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 | ; |
---|
[49] | 112 | ; define plots to be put on the website |
---|
[39] | 113 | ; |
---|
[49] | 114 | ; add a keyword debug |
---|
| 115 | ; add a keyworf overwrite |
---|
| 116 | ; |
---|
[39] | 117 | ; lecture du mask oaflux pour initcdf |
---|
| 118 | ; |
---|
| 119 | ; coding rules |
---|
| 120 | ; |
---|
[49] | 121 | ; parametre date debut date fin ? |
---|
[39] | 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 | ; |
---|
[49] | 132 | ; ajuster le format à la dynamique de la variable |
---|
[39] | 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 | ; |
---|
[49] | 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 | ; |
---|
[39] | 157 | ; - fplod 20110408T101102Z cratos.locean-ipsl.upmc.fr (Linux) |
---|
| 158 | ; |
---|
| 159 | ; * creation |
---|
| 160 | ; |
---|
| 161 | ;- |
---|
| 162 | ; |
---|
| 163 | function plot_tropflux, $ |
---|
| 164 | tropflux_varname |
---|
| 165 | ; |
---|
| 166 | compile_opt idl2, strictarrsubs |
---|
| 167 | ; |
---|
| 168 | @cm_4cal |
---|
| 169 | @cm_4data |
---|
| 170 | @cm_4mesh |
---|
| 171 | @cm_4data |
---|
[50] | 172 | @cm_project |
---|
[39] | 173 | ; |
---|
| 174 | status=-1 |
---|
| 175 | ; |
---|
[49] | 176 | debug=0 |
---|
[39] | 177 | overwrite=1 |
---|
| 178 | ; |
---|
| 179 | ; check for tropflux_varname |
---|
| 180 | ; and build input filename |
---|
| 181 | CASE 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 |
---|
| 206 | ELSE: BEGIN |
---|
| 207 | msg = 'eee : ' + tropflux_varname + ' unknown or not handled here' |
---|
| 208 | ras = report(msg) |
---|
| 209 | END |
---|
| 210 | ENDCASE |
---|
| 211 | ; |
---|
| 212 | ; check for input file |
---|
| 213 | ; |
---|
[50] | 214 | ; test if ${PROJECT_ID} defined |
---|
| 215 | CASE project_id_env OF |
---|
[39] | 216 | '' : BEGIN |
---|
[50] | 217 | msg = 'eee : ${PROJECT_ID} is not defined' |
---|
[39] | 218 | ras = report(msg) |
---|
| 219 | STOP |
---|
| 220 | END |
---|
| 221 | ELSE: BEGIN |
---|
[50] | 222 | msg = 'iii : ${PROJECT_ID} is ' + project_id_env |
---|
[39] | 223 | ras = report(msg) |
---|
| 224 | END |
---|
| 225 | ENDCASE |
---|
| 226 | ; |
---|
[50] | 227 | iodirin = isadirectory(project_id_env) |
---|
[39] | 228 | ; |
---|
[50] | 229 | ; existence and protection of ${PROJECT_ID} |
---|
[39] | 230 | IF (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 |
---|
| 234 | ENDIF |
---|
| 235 | ; |
---|
| 236 | ; check if this file exists |
---|
| 237 | fullfilename_in = isafile(iodirin + filename_in, NEW=0, /MUST_EXIST) |
---|
| 238 | print, fullfilename_in |
---|
| 239 | IF fullfilename_in[0] EQ '' THEN BEGIN |
---|
| 240 | msg = 'eee : the file ' + fullfilename_in + ' was not found.' |
---|
| 241 | ras = report(msg) |
---|
| 242 | STOP |
---|
| 243 | ENDIF |
---|
| 244 | print, fullfilename_in[0] |
---|
| 245 | ; |
---|
[50] | 246 | ; test if ${PROJECT_OD} defined |
---|
| 247 | CASE project_od_env OF |
---|
[39] | 248 | '' : BEGIN |
---|
[50] | 249 | msg = 'eee : ${PROJECT_OD} is not defined' |
---|
[39] | 250 | ras = report(msg) |
---|
| 251 | STOP |
---|
| 252 | END |
---|
| 253 | ELSE: BEGIN |
---|
[50] | 254 | msg = 'iii : ${PROJECT_OD} is ' + project_od_env |
---|
[39] | 255 | ras = report(msg) |
---|
| 256 | END |
---|
| 257 | ENDCASE |
---|
| 258 | ; |
---|
| 259 | ; check if output data will be possible |
---|
[50] | 260 | iodirout = isadirectory(project_od_env) |
---|
[39] | 261 | ; |
---|
| 262 | ; existence and protection |
---|
| 263 | IF (FILE_TEST(iodirout, /DIRECTORY, /WRITE) EQ 0) THEN BEGIN |
---|
| 264 | msg = 'eee : the directory' + iodirout + ' was not found.' |
---|
| 265 | ras = report(msg) |
---|
| 266 | STOP |
---|
| 267 | ENDIF |
---|
| 268 | ; |
---|
[49] | 269 | fullfilename_out_year=iodirout+'plot_tropflux_' + tropflux_varname + '_year.png' |
---|
[39] | 270 | print, fullfilename_out_year |
---|
| 271 | ; in order to avoid unexpected overwritten |
---|
| 272 | IF (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 |
---|
| 278 | ENDIF |
---|
| 279 | ; |
---|
[49] | 280 | fullfilename_out_month=iodirout+'plot_tropflux_' + tropflux_varname + '_month.png' |
---|
[39] | 281 | print, fullfilename_out_month |
---|
| 282 | ; in order to avoid unexpected overwritten |
---|
| 283 | IF (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 |
---|
| 289 | ENDIF |
---|
| 290 | ; |
---|
| 291 | ; Read grid and mask |
---|
| 292 | print, fullfilename_in[0] |
---|
| 293 | initncdf, fullfilename_in[0] |
---|
| 294 | ;++ missing value |
---|
| 295 | |
---|
| 296 | IF 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] |
---|
| 300 | ENDIF |
---|
| 301 | ; |
---|
| 302 | ; Read data |
---|
[49] | 303 | tropflux_var=read_ncdf(tropflux_varname,19890101L,19891231L,filename=fullfilename_in[0],/nostruct) |
---|
[39] | 304 | ; |
---|
| 305 | IF 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] |
---|
| 308 | ENDIF |
---|
| 309 | ; |
---|
| 310 | ; plot year mean |
---|
| 311 | plt, tropflux_var, format='(f6.1)', window=0, /landscape, /map |
---|
| 312 | saveimage, fullfilename_out_year, /png |
---|
| 313 | ; |
---|
| 314 | ; ++ defintion des types d'images |
---|
| 315 | plot_month=0 |
---|
| 316 | IF plot_month EQ 1 THEN BEGIN |
---|
| 317 | ; plot monthes on one page (6x2) |
---|
| 318 | nl=4 |
---|
| 319 | nc=2 |
---|
[49] | 320 | ; ++ wating for final plot do be done |
---|
[39] | 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 |
---|
| 327 | ENDIF |
---|
| 328 | ; |
---|
| 329 | status=0 |
---|
| 330 | ; |
---|
| 331 | return, status |
---|
| 332 | ; |
---|
| 333 | END |
---|