Changeset 37 for trunk/ToBeReviewed/PLOTS/DIVERS/checkfield.pro
- Timestamp:
- 05/02/06 16:55:58 (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/ToBeReviewed/PLOTS/DIVERS/checkfield.pro
r35 r37 20 20 ; 21 21 ; KEYWORD PARAMETERS: 22 ; 23 ; /WDEPTH: to specify that the field is at W depth instad of T 24 ; depth (automatically activated if vargrid eq 'W') 22 25 ; 23 26 ; OUTPUTS: … … 36 39 ;------------------------------------------------------------ 37 40 ;------------------------------------------------------------ 38 ;------------------------------------------------------------ 39 FUNCTION checkfield, field, procedure, TYPE = type, BOITE = boite, DIREC = direc, NOQUESTION = noquestion, VECTEUR = vecteur, _EXTRA = ex 40 ;-------------------------------------------------------------- 41 @common 41 FUNCTION err_1d, type, n1, name, n2 42 return, report(['Error in "' + type + '" type plot with a 1D input array:' $ 43 , 'the number of elements of the input vector ('+strtrim(n1, 1)+') ' $ 44 , 'is not equal to ' + name + ' ('+strtrim(n2, 1)+')'], /simple) 45 END 46 ; 47 FUNCTION err_2d, type, sz, nx, ny, nz 48 @cm_4mesh 49 @cm_4cal 50 return, report(['Error in "' + type + '" type plot with a 2D input array:' $ 51 , 'the array dimensions ' + tostr(sz[1:2]) + ' are incompatible' $ 52 , 'with the the domain dimensions ' $ 53 , '[jpi/nx, jpj/ny, jpk/nz, jpt] = [' $ 54 + strtrim(jpi, 1) + '/' + strtrim(nx, 1) $ 55 + ', ' + strtrim(jpj, 1) + '/' + strtrim(ny, 1) $ 56 + ', ' + strtrim(jpk, 1) + '/' + strtrim(nz, 1) $ 57 + ', ' + strtrim(jpt, 1) + ']'], /simple) 58 END 59 ; 60 FUNCTION err_3d, type, sz, nx, ny, nz 61 @cm_4mesh 62 @cm_4cal 63 return, report(['Error in "' + type + '" type plot with a 3D input array:' $ 64 , 'the array dimensions ' + tostr(sz[1:3]) + ' are incompatible' $ 65 , 'with the the domain dimensions ' $ 66 , '[jpi/nx, jpj/ny, jpk/nz, jpt] = [' $ 67 + strtrim(jpi, 1) + '/' + strtrim(nx, 1) $ 68 + ', ' + strtrim(jpj, 1) + '/' + strtrim(ny, 1) $ 69 + ', ' + strtrim(jpk, 1) + '/' + strtrim(nz, 1) $ 70 + ', ' + strtrim(jpt, 1) + ']'], /simple) 71 END 72 ;-------------------------------------------------------------- 73 ; 74 FUNCTION checkfield, field, procedure, TYPE = type, BOXZOOM = boxzoom, DIREC = direc, NOQUESTION = noquestion, VECTEUR = vecteur, WDEPTH = wdepth, _EXTRA = ex 75 ;-------------------------------------------------------------- 76 ; include commons 77 @cm_4mesh 78 @cm_4cal 79 @cm_4data 80 IF NOT keyword_set(key_forgetold) THEN BEGIN 81 @updatenew 82 @updatekwd 83 ENDIF 42 84 ;-------------------------------------------------------------- 43 85 ; I1) lecture du champ 44 86 ;-------------------------------------------------------------- 45 if n_elements(field) EQ 0 then return, report('field undefined') 46 z2d = litchamp(field) 47 nan = total(finite(z2d,/nan)) < 1 87 if n_elements(field) EQ 0 then return, report('field undefined') 88 arr = litchamp(field) 89 ; first check 90 IF n_elements(arr) EQ 1 THEN BEGIN 91 if arr EQ -1 then $ 92 return, report('Error: input array = -1. Maybe the reading did ont perform well...', /simple) $ 93 ELSE return, report('Error: input array is a scalar', /simple) 94 ENDIF 95 nan = total(finite(arr, /nan)) < 1 48 96 ;--------------------------------------------------------------- 49 97 ; redefinition du domaine 50 98 ;--------------------------------------------------------------- 51 minprof = 0 52 profdefault = 200 53 if keyword_set(boite) then BEGIN 54 ; 55 ; if n_elements(integration3d) EQ 0 THEN integration3d = n_elements(boite) ne 4 56 ; 57 neleboitein = N_Elements(Boite) 58 Case neleboitein Of 59 1:boite=[lon1, lon2, lat1, lat2, minprof,boite[0]] 60 2:boite=[lon1, lon2, lat1, lat2, boite[0],boite[1]] 61 4:$ 62 if strpos(type, 'z') NE -1 THEN boite=[Boite, minprof, profdefault] $ 63 ELSE boite=[Boite, prof1, prof2] 64 5:boite=[Boite[0:3], minprof, Boite[4]] 65 6:boite=Boite 66 Else: return, report('Mauvaise Definition de Boite') 67 ENDCASE 68 ENDIF ELSE neleboitein = 0 99 minprof = 0. 100 profdefault = 200. 101 ; 102 Case n_elements(boxzoom) OF 103 0: 104 1:localbox = [minprof, boxzoom[0]] 105 2:localbox = boxzoom 106 4:if strpos(type, 'z') NE -1 THEN $ 107 localbox = [boxzoom, minprof, profdefault] ELSE localbox = boxzoom 108 5:localbox = [Boxzoom[0:3], minprof, Boxzoom[4]] 109 6:localbox = boxzoom 110 Else: return, report('Bad definition of boxzoom') 111 ENDCASE 112 ; 113 if keyword_set(localbox) then BEGIN 114 if keyword_set(vecteur) then grillechoice = [vargrid, 'T', 'U', 'V'] $ 115 ELSE grillechoice = [vargrid, 'T'] 116 if keyword_set(wdepth) then grillechoice = [grillechoice, 'W'] 117 domdef, localbox, GRIDTYPE = grillechoice, _extra = ex 118 ENDIF 119 ; 69 120 ; la procedure domdef determine les elements qui sont a l''interieur 70 ; de la bo ite.121 ; de la boxzoom. 71 122 ; si on fait un plot contenant l''axe z: 72 123 ; Suivant l''axe z si on veut par ex faire un dessin … … 76 127 ; elevees). Pour ne pas que le dessin s''arrete a 900 mais bien a 77 128 ; 1000, on va aller chercher le niveau au dessous de 1000, d''ou la 78 ; manip suivante sur la bo ite: l''approfondir de 1 niveau sur la129 ; manip suivante sur la boxzoom: l''approfondir de 1 niveau sur la 79 130 ; verticale (si possible) sans changer les y range. 80 if strpos(type, 'z') NE -1 THEN BEGIN 81 if NOT keyword_set(boite) then boite = 1.*[lon1,lon2,lat1,lat2,minprof, profdefault] 82 !y.range = [boite[5], boite[4]] ;on garde les yranges (axe z) avant de changer la boite. 83 profmax = boite[5] 84 if vargrid EQ 'W' then gdep = gdepw ELSE gdep = gdept 85 ; check with vertical grid limits (nearest level) 86 gwork = gdep 87 ; check the increse or decrese of the z axis 88 IF gwork[1] LE gwork[0] THEN gwork = reverse(gdep, 1) 89 niveauprof = where(gwork ge boite[5]) & niveauprof = niveauprof[0] 90 if niveauprof NE -1 then boite[5] = gwork[niveauprof]+1 91 ENDIF 92 if keyword_set(boite) then BEGIN 93 if keyword_set(vecteur) then grillechoice = [vargrid, 'T', 'U', 'V'] ELSE grillechoice = [vargrid, 'T'] 94 if neleboitein LE 2 then domdef, boite, GRILLE=grillechoice ELSE domdef, boite, GRILLE=grillechoice, _extra = ex 95 ENDIF 131 if strpos(type, 'z') NE -1 THEN BEGIN 132 if NOT keyword_set(localbox) then BEGIN 133 localbox = [minprof, profdefault] 134 if keyword_set(wdepth) then grillechoice = 'W' $ 135 ELSE grillechoice = vargrid 136 domdef, localbox, GRIDTYPE = grillechoice 137 END 138 nelbox = n_elements(localbox) 139 ;on garde les yranges (axe z) avant de changer la boxzoom. 140 !y.range = [localbox[nelbox-1], localbox[nelbox-2]] 141 if vargrid EQ 'W' OR keyword_set(wdepth) then BEGIN 142 firstzw = 0 > (firstzw-1) 143 lastzw = (lastzw+1) < (jpk-1) 144 nzw = lastzw - firstzw + 1 145 ENDIF ELSE BEGIN 146 firstzt = 0 > (firstzt-1) 147 lastzt = (lastzt+1) < (jpk-1) 148 nzt = lastzt - firstzt + 1 149 ENDELSE 150 @updateold 151 ENDIF 152 ; make the automatic definition of type for pltz if type is not specified. 153 IF type EQ 'z' AND procedure EQ 'pltz' THEN $ 154 if (lon2-lon1) gt (lat2-lat1) then type = 'xz' else type = 'yz' 155 ; make the automatic definition of type for pltt if type is not specified. 156 IF type EQ 'unkownpltt' AND procedure EQ 'pltt' THEN $ 157 if (lon2-lon1) gt (lat2-lat1) then type = 'xt' else type = 'yt' 96 158 ;-------------------------------------------------------------- 97 159 ; verification de la taille du tableau d''entree et de la valeur de type 98 160 ;-------------------------------------------------------------- 99 grille, mask, glam, gphi, gdep, nx, ny,nz,premierx,premiery,premierz,dernierx,derniery,dernierz 100 taille=size(z2d) 101 case taille[0] of 102 ;-------------------------------------------------------------- 103 0:BEGIN 104 if z2d EQ -1 then $ 105 return, report('Attention le tableau est egale a -1. Probleme lors de la lecture...') $ 106 ELSE return, report('Attention le tableau est un scalaire') 107 END 108 ;-------------------------------------------------------------- 109 1:BEGIN 110 nele = n_elements(z2d) 111 case type of 112 't':if jpt NE nele then $ 113 return, report('jpt: '+strtrim(jpt, 1)+' n''est pas egale au nombres d''elements du vecteur: '+strtrim(nele, 1)) 114 'x':BEGIN 115 case nele of 116 jpi:z2d = z2d[premierx:dernierx] 117 nx: 118 ELSE:return, report('nx: '+strtrim(nx, 1)+' n''est pas egale au nombres d''elements du vecteur: '+strtrim(nele, 1)) 119 endcase 120 end 121 'y':BEGIN 122 case nele of 123 jpj:z2d = z2d[premiery:derniery] 124 ny: 125 ELSE:return, report('ny: '+strtrim(ny, 1)+' n''est pas egale au nombres d''elements du vecteur: '+strtrim(nele, 1)) 126 endcase 127 END 128 'z':BEGIN 129 case nele of 130 jpk:z2d = z2d[premierz:dernierz] 131 nz: 132 ELSE:return, report('nz: '+strtrim(nz, 1)+' n''est pas egale au nombres d''elements du vecteur: '+strtrim(nele, 1)) 133 endcase 134 END 135 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 1d en entree: '+strtrim(nele, 1)) 136 ENDCASE 137 END 138 ;-------------------------------------------------------------- 139 2:BEGIN 140 case type of 141 'x':BEGIN 142 case taille[2] of 143 ny:direc = 'y' 144 jpj:direc = 'y' 145 jpt:direc = 't' 146 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 2d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 147 endcase 148 end 149 'y':BEGIN 150 case 1 of 151 taille[1] EQ jpi OR taille[1] EQ nx:direc = 'x' 152 taille[2] EQ jpt:direc = 't' 153 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 2d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 154 endcase 155 END 156 'z':BEGIN 157 if taille[2] EQ jpt then direc = 't' $ 158 ELSE return, report('imcompatibilite entre type: '+type+' et la taille du tableau 2d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 159 END 160 't':BEGIN 161 case 1 of 162 taille[1] EQ jpi OR taille[1] EQ nx:BEGIN 163 direc = 'x' 164 timearray = 1 165 END 166 jpt EQ 1:BEGIN 167 ras = report('Field average: '+strtrim(moyenne(z2d, 'xy', boite = boite, NAN = nan, _extra = ex), 1)+' in box: '+tostr(boite)) 168 return, -1 169 END 170 ELSE: return, report('imcompatibilite entre type: '+type+' et la taille du tableau 2d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 171 ENDCASE 172 END 173 'xy':BEGIN 174 case 1 of 175 taille[1] eq nx and taille[2] eq ny: 176 taille[1] eq jpi and taille[2] eq jpj:z2d=z2d[premierx:dernierx, premiery:derniery] 177 else:return, report('Probleme d''adequation entre les tailles du domaine nx*ny '+strtrim(nx, 1)+'*'+strtrim(ny, 1)+' et du tableau '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 178 endcase 179 if vargrid EQ 'W' then niveau = premierzw+1 ELSE niveau = premierzt+1 180 END 181 'xz':BEGIN 182 case 1 of 183 taille[1] eq jpi and taille[2] eq jpk:z2d = z2d[premierx:dernierx,premierz:dernierz] 184 taille[1] eq nx and taille[2] eq jpk:z2d = z2d[*,premierz:dernierz] 185 taille[1] eq nx and taille[2] eq nz: 186 else:return, report('Probleme d''adequation entre les tailles du domaine nx*nz '+strtrim(nx, 1)+'*'+strtrim(nz, 1)+'et du tableau'+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 187 endcase 188 END 189 'yz':BEGIN 190 case 1 of 191 taille[1] eq jpj and taille[2] eq jpk:z2d = z2d[premiery:derniery,premierz:dernierz] 192 taille[1] eq ny and taille[2] eq jpk:z2d = z2d[*,premierz:dernierz] 193 taille[1] eq ny and taille[2] eq nz: 194 else:return, report('Probleme d''adequation entre les tailles du domaine ny*nz '+strtrim(ny, 1)+'*'+strtrim(nz, 1)+'et du tableau'+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 195 endcase 196 END 197 'xt':BEGIN 198 case 1 of 199 taille[1] eq jpi and taille[2] eq jpt:z2d = z2d[premierx:dernierx,*] 200 taille[1] eq nx and taille[2] eq jpt: 201 else:return, report('Probleme d''adequation entre les tailles du domaine nx*jpt '+strtrim(nx, 1)+'*'+strtrim(jpt, 1)+'et du tableau'+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 202 endcase 203 END 204 'yt':BEGIN 205 case 1 of 206 taille[1] eq jpj and taille[2] eq jpt:z2d = z2d[premiery:derniery,*] 207 taille[1] eq ny and taille[2] eq jpt: 208 else:return, report('Probleme d''adequation entre les tailles du domaine ny*jpt '+strtrim(ny, 1)+'*'+strtrim(jpt, 1)+'et du tableau'+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 209 endcase 210 END 211 'zt':BEGIN 212 case 1 of 213 taille[1] eq jpk and taille[2] eq jpt:z2d = z2d[premierz:dernierz,*] 214 taille[1] eq nz and taille[2] eq jpt: 215 else:return, report('Probleme d''adequation entre les tailles du domaine nz*jpt '+strtrim(nz, 1)+'*'+strtrim(jpt, 1)+'et du tableau'+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)) 216 endcase 217 END 218 endcase 219 END 220 ;-------------------------------------------------------------- 221 3:BEGIN 222 case type of 223 'x':BEGIN 224 case taille[3] of 225 nz:direc = 'yz' 226 jpk:direc = 'yz' 227 jpt:direc = 'yt' 228 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 3d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 229 endcase 230 END 231 'y':BEGIN 232 case taille [3] of 233 nz:direc = 'xz' 234 jpk:direc = 'xz' 235 jpt:direc = 'xt' 236 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 3d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 237 endcase 238 END 239 'z':BEGIN 240 case taille [3] of 241 nz:direc = 'xy' 242 jpk:direc = 'xy' 243 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 3d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 244 endcase 245 END 246 't':BEGIN 247 IF jpt EQ 1 THEN BEGIN 248 ras = report('Field average: '+strtrim(moyenne(z2d, 'xyz', boite = boite, NAN = nan, _extra = ex), 1)+' in box: '+tostr(boite)) 249 return, -1 250 ENDIF ELSE BEGIN 251 direc = 'xy' 252 timearray = 1 253 ENDELSE 254 END 255 'xy':BEGIN 256 case 1 of 257 taille[3] EQ jpt:BEGIN 258 direc = 't' 259 if vargrid EQ 'W' then niveau = premierzw+1 ELSE niveau = premierzt+1 260 END 261 taille[3] EQ nz OR taille[3] EQ jpk:BEGIN 262 if keyword_set(boite) OR keyword_set(noquestion) then begin 263 direc = 'z' 264 if vargrid EQ 'W' then niveau = premierzw+1 ELSE niveau = premierzt+1 265 ENDIF ELSE BEGIN 266 if vargrid EQ 'W' then premierz = premierzw ELSE premierz = premierzt 267 if NZ NE 1 then begin 268 niveau = xquestion('Le tableau d''entree est un tableau 3d,' $ 269 +'!C a quel niveau faut-il faire le graphique?', '1', /chkwidget) 270 niveau = 1 > fix(niveau) < (jpk-premierz) 271 case 1 of 272 taille[1] EQ nx AND taille[2] EQ ny: $ 273 z2d=z2d[*, *,niveau-1] 274 taille[1] EQ jpi AND taille[2] EQ jpj: $ 275 z2d=z2d[premierx:dernierx, premiery:derniery,niveau-1] 276 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 3d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 277 endcase 278 ENDIF ELSE niveau = 1 279 niveau = premierz+niveau 280 endelse 281 END 282 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 3d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 283 endcase 284 END 285 'xz':BEGIN 286 case 1 of 287 (taille[2] EQ ny OR taille[2] EQ jpj) AND taille[3] EQ jpk:BEGIN 288 z2d = z2d[*, *, premierz:dernierz] 289 direc = 'y' 290 END 291 (taille[2] EQ ny OR taille[2] EQ jpj) AND taille[3] EQ nz:direc = 'y' 292 taille[3] EQ jpt:direc = 't' 293 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 3d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 294 endcase 295 END 296 'yz':BEGIN 297 case 1 of 298 (taille[1] EQ nx OR taille[1] EQ jpi) AND taille[3] EQ jpk:BEGIN 299 z2d = z2d[*, *, premierz:dernierz] 300 direc = 'x' 301 END 302 (taille[1] EQ nx OR taille[1] EQ jpi) AND taille[3] EQ nz:direc = 'x' 303 ELSE:return, report('imcompatibilite entre type: '+type+' et la taille du tableau 3d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 304 endcase 305 END 306 'xt':BEGIN & direc = 'y' & timearray = 1 & end 307 'yt':BEGIN & direc = 'x' & timearray = 1 & end 308 'zt':return, report('imcompatibilite entre type: '+type+' et la taille du tableau 3d en entree: '+strtrim(taille[1], 1)+'*'+strtrim(taille[2], 1)+'*'+strtrim(taille[3], 1)) 309 ENDCASE 310 end 311 ;-------------------------------------------------------------- 312 4:BEGIN 313 case type of 314 'x':direc = 'yzt' 315 'y':direc = 'xzt' 316 'z':direc = 'xyt' 317 't':direc = 'xyz' 318 'xy':BEGIN 319 if keyword_set(boite) OR keyword_set(noquestion) then begin 320 if vargrid EQ 'W' then niveau = premierzw+1 ELSE niveau = premierzt+1 321 direc = 'zt' 322 ENDIF ELSE BEGIN 323 if vargrid EQ 'W' then premierz = premierzw ELSE premierz = premierzt 324 if NZ NE 1 then begin 325 niveau = xquestion('Le tableau d''entree est un tableau 4d,' $ 326 +'!C a quel niveau faut-il faire le graphique?', '1', /chkwidget) 327 niveau = 1 > fix(niveau) < (jpk-premierz) 328 z2d=reform(z2d[*,*,niveau-1, *], /over) 329 ENDIF ELSE niveau = 1 330 niveau = premierz+niveau 331 direc = 't' 332 ENDELSE 333 END 334 'xz':direc = 'yt' 335 'yz':direc = 'xt' 336 'xt':direc = 'yz' 337 'yt':direc = 'xz' 338 'zt':direc = 'xy' 339 endcase 340 END 341 ENDCASE 342 ;-------------------------------------------------------------- 343 if keyword_set(direc) then begin 344 if strpos(direc, 't') NE -1 OR keyword_set(timearray) OR taille[0] EQ 4 then $ 345 z2d = grossemoyenne(z2d, direc, boite = boite, NAN = nan, /nodomdef, _extra = ex) $ 346 ELSE z2d = moyenne(z2d, direc, boite = boite, NAN = nan, /nodomdef, _extra = ex) 347 ENDIF 348 ;-------------------------------------------------------------- 349 ;-------------------------------------------------------------- 350 ;-------------------------------------------------------------- 351 ;-------------------------------------------------------------- 352 return, z2d 353 end 161 grille, -1, -1, -1, -1, nx, ny, nz, firstx, firsty $ 162 , firstz, lastx, lasty, lastz, WDEPTH = wdepth 163 ;-------------------------------------------------------------- 164 ; basic checks 165 ;-------------------------------------------------------------- 166 CASE 1 OF 167 nx EQ 1: IF strpos(type, 'x') NE -1 THEN return, report('Error: impossible to make a "' + type + '" type plot with nx = 1 ', /simple) 168 ny EQ 1: IF strpos(type, 'y') NE -1 THEN return, report('Error: impossible to make a "' + type + '" type plot with ny = 1 ', /simple) 169 nz EQ 1: IF strpos(type, 'z') NE -1 THEN return, report('Error: impossible to make a "' + type + '" type plot with nz = 1 ', /simple) 170 jpt EQ 1: IF strpos(type, 't') NE -1 THEN return, report('Error: impossible to make a "' + type + '" type plot with jpt = 1 ', /simple) 171 ELSE: 172 ENDCASE 173 ;-------------------------------------------------------------- 174 ; is the size of the array compatible with teh domain? 175 ;-------------------------------------------------------------- 176 arr = fitintobox(temporary(arr), nx, ny, nz, firstx, firsty $ 177 , firstz, lastx, lasty, lastz) 178 ;-------------------------------------------------------------- 179 sz = size(arr) 180 case sz[0] of 181 ;-------------------------------------------------------------- 182 0:return, arr 183 ;-------------------------------------------------------------- 184 1:BEGIN 185 nele = n_elements(arr) 186 case type of 187 't':if jpt NE nele THEN return, err_1d(type, nele, 'jpt', jpt) 188 'x':IF nx NE nele THEN return, err_1d(type, nele, 'nx', nx) 189 'y':IF ny NE nele THEN return, err_1d(type, nele, 'ny', ny) 190 'z':IF nz NE nele THEN return, err_1d(type, nele, 'nz', nx) 191 ELSE:return, report('Error: ' $ 192 , 'Impossible to make a "'+type+'" plot with a 1D array', /simple) 193 ENDCASE 194 END 195 ;-------------------------------------------------------------- 196 2:BEGIN 197 case type of 198 'x':BEGIN 199 case 1 of 200 sz[1] EQ nx AND sz[2] EQ ny:direc = 'y' ; xy array 201 sz[1] EQ nx AND ny EQ 1 AND sz[2] EQ nz:direc = 'z' ; x(y)z array 202 sz[1] EQ nx AND sz[2] EQ jpt:direc = 't' ; xt array 203 ELSE:return, err_2d(type, sz, nx, ny, nz) 204 endcase 205 end 206 'y':BEGIN 207 case 1 of 208 sz[1] EQ nx AND sz[2] EQ ny:direc = 'x' ; xy array 209 nx EQ 1 AND sz[1] EQ ny AND sz[2] EQ nz:direc = 'z' ; (x)yz array 210 sz[1] EQ ny AND sz[2] EQ jpt:direc = 't' ; yt array 211 ELSE:return, err_2d(type, sz, nx, ny, nz) 212 endcase 213 END 214 'z':BEGIN 215 case 1 of 216 sz[1] EQ nx AND ny EQ 1 AND sz[2] EQ nz:direc = 'x' ; x(y)z array 217 nx EQ 1 AND sz[1] EQ ny AND sz[2] EQ nz:direc = 'y' ; (x)yz array 218 sz[1] EQ nz AND sz[2] EQ jpt:direc = 't' ; zt array 219 ELSE:return, err_2d(type, sz, nx, ny, nz) 220 endcase 221 END 222 't':BEGIN 223 case 1 OF 224 sz[1] EQ nx AND sz[2] EQ jpt:direc = 'x' ; xt array 225 nx EQ 1 AND sz[1] EQ ny AND sz[2] EQ jpt:direc = 'y' ; (x)yt array 226 nx EQ 1 AND ny EQ 1 AND sz[1] EQ nz AND sz[2] EQ jpt:direc = 'z' ; (x)(y)zt array 227 ELSE:return, err_2d(type, sz, nx, ny, nz) 228 ENDCASE 229 END 230 'xy':IF sz[1] NE nx OR sz[2] ne ny THEN return, err_2d(type, sz, nx, ny, nz) ; xy array 231 'xz':IF sz[1] NE nx OR sz[2] ne nz THEN return, err_2d(type, sz, nx, ny, nz) ; xz array 232 'yz':IF sz[1] NE ny OR sz[2] NE nz THEN return, err_2d(type, sz, nx, ny, nz) ; yz array 233 'xt':IF sz[1] NE nx OR sz[2] NE jpt THEN return, err_2d(type, sz, nx, ny, nz) ; xt array 234 'yt':IF sz[1] NE ny OR sz[2] NE jpt THEN return, err_2d(type, sz, nx, ny, nz) ; yt array 235 'zt':IF sz[1] NE nz OR sz[2] NE jpt THEN return, err_2d(type, sz, nx, ny, nz) ; zt array 236 ENDCASE 237 END 238 ;-------------------------------------------------------------- 239 3:BEGIN 240 case type of 241 'x':BEGIN 242 case 1 of 243 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ nz:direc = 'yz' ; xyz array 244 sz[1] EQ nx AND ny EQ 1 AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'zt' ; x(y)zt array 245 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ jpt:direc = 'yt' ; xyt array 246 ELSE:return, err_3d(type, sz, nx, ny, nz) 247 endcase 248 END 249 'y':BEGIN 250 case 1 of 251 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ nz:direc = 'xz' ; xyz array 252 nx EQ 1 AND sz[1] EQ ny AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'zt' ; (x)yzt array 253 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ jpt:direc = 'xt' ; xyt array 254 ELSE:return, err_3d(type, sz, nx, ny, nz) 255 endcase 256 END 257 'z':BEGIN 258 case 1 of 259 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ nz:direc = 'xy' ; xyz array 260 nx EQ 1 AND sz[1] EQ ny AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'yt' ; (x)yzt array 261 sz[1] EQ nx AND ny EQ 1 AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'xt' ; x(y)zt array 262 ELSE:return, err_3d(type, sz, nx, ny, nz) 263 endcase 264 END 265 't':BEGIN 266 case 1 of 267 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ jpt:direc = 'xy' ; xyt array 268 nx EQ 1 AND sz[1] EQ ny AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'yz' ; (x)yzt array 269 sz[1] EQ nx AND ny EQ 1 AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'xz' ; x(y)zt array 270 ELSE:return, err_3d(type, sz, nx, ny, nz) 271 endcase 272 END 273 'xy':BEGIN 274 case 1 OF 275 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ nz:direc = 'z' ; xyz array 276 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ jpt:direc = 't' ; xyt array 277 ELSE:return, err_3d(type, sz, nx, ny, nz) 278 endcase 279 END 280 'xz':BEGIN 281 case 1 of 282 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ nz:direc = 'y' ; xyz array 283 sz[1] EQ nx AND ny EQ 1 AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 't' ; x(y)zt 284 ELSE:return, err_3d(type, sz, nx, ny, nz) 285 endcase 286 END 287 'yz':BEGIN 288 case 1 of 289 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ nz:direc = 'x' ; xyz array 290 nx EQ 1 AND sz[1] EQ ny AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 't' ; (x)yzt 291 ELSE:return, err_3d(type, sz, nx, ny, nz) 292 endcase 293 END 294 'xt':BEGIN 295 case 1 of 296 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ jpt:direc = 'y' ; xyt array 297 sz[1] EQ nx AND ny EQ 1 AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'z' ; x(y)zt array 298 ELSE:return, err_3d(type, sz, nx, ny, nz) 299 endcase 300 END 301 'yt':BEGIN 302 case 1 of 303 sz[1] EQ nx AND sz[2] EQ ny AND sz[3] EQ jpt:direc = 'x' ; xyt array 304 nx EQ 1 AND sz[1] EQ ny AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'z' ; (x)yzt array 305 ELSE:return, err_3d(type, sz, nx, ny, nz) 306 endcase 307 END 308 'zt':BEGIN 309 case 1 of 310 sz[1] EQ nx AND ny EQ 1 AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'x' ; x(y)zt array 311 nx EQ 1 AND sz[1] EQ ny AND sz[2] EQ nz AND sz[3] EQ jpt:direc = 'y' ; (x)yzt array 312 ELSE:return, err_3d(type, sz, nx, ny, nz) 313 ENDCASE 314 END 315 ENDCASE 316 END 317 ;-------------------------------------------------------------- 318 4:BEGIN 319 CASE type OF 320 'x':direc = 'yzt' 321 'y':direc = 'xzt' 322 'z':direc = 'xyt' 323 't':direc = 'xyz' 324 'xy':direc = 'zt' 325 'xz':direc = 'yt' 326 'yz':direc = 'xt' 327 'xt':direc = 'yz' 328 'yt':direc = 'xz' 329 'zt':direc = 'xy' 330 ENDCASE 331 END 332 ENDCASE 333 ;-------------------------------------------------------------- 334 IF keyword_set(direc) THEN BEGIN 335 IF strpos(direc, 't') NE -1 OR strpos(type, 't') NE -1 THEN $ 336 arr = grossemoyenne(temporary(arr), direc, boxzoom = localbox $ 337 , NAN = nan, /NODOMDEF, WDEPTH = wdepth, _extra = ex) $ 338 ELSE arr = moyenne(temporary(arr), direc, boxzoom = localbox $ 339 , NAN = nan, /NODOMDEF, WDEPTH = wdepth, _extra = ex) 340 ENDIF 341 ;-------------------------------------------------------------- 342 ;-------------------------------------------------------------- 343 ;-------------------------------------------------------------- 344 ;-------------------------------------------------------------- 345 RETURN, arr 346 END
Note: See TracChangeset
for help on using the changeset viewer.