[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[226] | 3 | ; @file_comments |
---|
[163] | 4 | ; calculate the norm of a field of vectors, then make a possible average. |
---|
[142] | 5 | ; Comment 1: The field of vector can be, 2d:xy, 3d: xyz or xyt, |
---|
| 6 | ; 4d: xyzt |
---|
| 7 | ; Comment 2: |
---|
[226] | 8 | ; The calculation of the norm is made before the possible spatial or |
---|
| 9 | ; temporal average because the average of the norm is not equal to the |
---|
[163] | 10 | ; norm of averages |
---|
[2] | 11 | ; |
---|
[142] | 12 | ; @categories |
---|
[157] | 13 | ; Calculation |
---|
[2] | 14 | ; |
---|
[142] | 15 | ; @param COMPOSANTEU {in}{required} |
---|
| 16 | ; an 2d, 3d or 4d array |
---|
[2] | 17 | ; |
---|
[142] | 18 | ; @param COMPOSANTEV {in}{required} |
---|
| 19 | ; an 2d, 3d or 4d array |
---|
[2] | 20 | ; |
---|
[142] | 21 | ; @keyword BOXZOOM |
---|
[226] | 22 | ; boxzoom on which do the average (by default the domain selected |
---|
[254] | 23 | ; by the last <pro>domdef</pro> done) |
---|
[2] | 24 | ; |
---|
[142] | 25 | ; @keyword DIREC |
---|
| 26 | ; 't' 'x' 'y' 'z' 'xys' 'xz' 'yz' 'xyz' 'xt' 'yt' 'zt' 'xyt' |
---|
[226] | 27 | ; 'xzt' 'yzt' 'xyzt' Direction on which do averages |
---|
[2] | 28 | ; |
---|
[142] | 29 | ; @returns |
---|
| 30 | ; Array to trace with plt, pltz or pltt. |
---|
[2] | 31 | ; |
---|
[142] | 32 | ; @uses |
---|
| 33 | ; common.pro |
---|
[2] | 34 | ; |
---|
[226] | 35 | ; @restrictions |
---|
[264] | 36 | ; The norm is calculated on points T. To do this calculation, we average |
---|
| 37 | ; field U and V on points T before calculate the norme. At the edge of |
---|
[226] | 38 | ; coast and of domain, we can not calculate fields U and V at points T, |
---|
| 39 | ; that is why these points are at value !values.f_nan. |
---|
| 40 | ; |
---|
| 41 | ; When we calculate on a reduce geographic domain, field U and V have not |
---|
| 42 | ; necessarily the same number of point. In this case, we recut U and V to |
---|
[254] | 43 | ; keep only common points. We profit of this to redo a <pro>domdef</pro> which redefine |
---|
[142] | 44 | ; a geographic domain on which fields U and V are extracted on same points |
---|
[2] | 45 | ; |
---|
[226] | 46 | ; To know what type of array we work with, we test its size and dates |
---|
| 47 | ; gave by time[0] and time[jpt-1] to know if thee is a temporal dimension. |
---|
| 48 | ; Before to start norme, make sure that time and jpt are defined how |
---|
| 49 | ; they have to! |
---|
[2] | 50 | ; |
---|
[142] | 51 | ; @examples |
---|
[226] | 52 | ; To calculate the average of the norme of streams on all the domain |
---|
[264] | 53 | ; between 0 and 50: |
---|
[142] | 54 | ; IDL> res=norme(un,vn,boxzoom=[0,50],dir='xyz') |
---|
[2] | 55 | ; |
---|
[142] | 56 | ; @history |
---|
[157] | 57 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[142] | 58 | ; 9/6/1999 |
---|
[2] | 59 | ; |
---|
[142] | 60 | ; @version |
---|
| 61 | ; $Id$ |
---|
[2] | 62 | ; |
---|
| 63 | ;- |
---|
[231] | 64 | ; |
---|
[232] | 65 | FUNCTION norme, composanteu, composantev, BOXZOOM = boxzoom, DIREC = direc, _EXTRA = ex |
---|
[114] | 66 | ; |
---|
| 67 | compile_opt idl2, strictarrsubs |
---|
| 68 | ; |
---|
[25] | 69 | @cm_4mesh |
---|
| 70 | @cm_4data |
---|
| 71 | @cm_4cal |
---|
| 72 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 73 | @updatenew |
---|
| 74 | @updatekwd |
---|
| 75 | ENDIF |
---|
| 76 | ;--------------------------------------------------------- |
---|
[142] | 77 | tempsun = systime(1) ; To key_performance |
---|
[25] | 78 | ; |
---|
| 79 | IF finite(glamu[0])*finite(gphiu[0])*finite(glamv[0])*finite(gphiv[0]) EQ 0 THEN $ |
---|
| 80 | return, report(['This version of norme is based on Arakawa C-grid.' $ |
---|
| 81 | , 'U and V grids must therefore be defined']) |
---|
| 82 | ; |
---|
[2] | 83 | ;------------------------------------------------------------ |
---|
[226] | 84 | if keyword_set(boxzoom) then BEGIN |
---|
[25] | 85 | Case 1 Of |
---|
| 86 | N_Elements(Boxzoom) Eq 1:bte = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] |
---|
| 87 | N_Elements(Boxzoom) Eq 2:bte = [lon1, lon2, lat1, lat2, boxzoom[0], boxzoom[1]] |
---|
| 88 | N_Elements(Boxzoom) Eq 4:bte = [Boxzoom, vert1, vert2] |
---|
| 89 | N_Elements(Boxzoom) Eq 5:bte = [Boxzoom[0:3], 0, Boxzoom[4]] |
---|
| 90 | N_Elements(Boxzoom) Eq 6:bte = Boxzoom |
---|
| 91 | Else: return, report('Mauvaise Definition de Boxzoom') |
---|
| 92 | ENDCASE |
---|
| 93 | domdef, boxzoom |
---|
[226] | 94 | ENDIF |
---|
[25] | 95 | ;------------------------------------------------------------ |
---|
[2] | 96 | if NOT keyword_set(direc) then direc = 0 |
---|
[142] | 97 | ; construction of u and v at points T |
---|
[2] | 98 | u = litchamp(composanteu) |
---|
| 99 | v = litchamp(composantev) |
---|
| 100 | date1 = time[0] |
---|
| 101 | if n_elements(jpt) EQ 0 then date2 = date1 ELSE date2 = time[jpt-1] |
---|
| 102 | |
---|
| 103 | if (size(u))[0] NE (size(v))[0] then return, -1 |
---|
| 104 | |
---|
| 105 | vargrid='T' |
---|
| 106 | varname = 'norme ' |
---|
| 107 | valmask = 1e20 |
---|
| 108 | ; |
---|
| 109 | grilleu = litchamp(composanteu, /grid) |
---|
| 110 | if grilleu EQ '' then grilleu = 'U' |
---|
| 111 | grillev = litchamp(composantev, /grid) |
---|
| 112 | if grillev EQ '' then grillev = 'V' |
---|
| 113 | IF grilleu EQ 'V' AND grillev EQ 'U' THEN inverse = 1 |
---|
[226] | 114 | IF grilleu EQ 'T' AND grillev EQ 'T' THEN BEGIN |
---|
| 115 | interpolle = 0 |
---|
[2] | 116 | return, report('cas non code mais facile a faire!') |
---|
| 117 | ENDIF ELSE interpolle = 1 |
---|
| 118 | if keyword_set(inverse) then begin |
---|
| 119 | rien = u |
---|
| 120 | u = v |
---|
| 121 | v = rien |
---|
| 122 | endif |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | ;------------------------------------------------------------ |
---|
[142] | 126 | ; We find common points between u and v |
---|
[2] | 127 | ;------------------------------------------------------------ |
---|
[25] | 128 | indicexu = (lindgen(jpi))[firstxu:firstxu+nxu-1] |
---|
| 129 | indicexv = (lindgen(jpi))[firstxv:firstxv+nxv-1] |
---|
[2] | 130 | indicex = inter(indicexu, indicexv) |
---|
[25] | 131 | indiceyu = (lindgen(jpj))[firstyu:firstyu+nyu-1] |
---|
| 132 | indiceyv = (lindgen(jpj))[firstyv:firstyv+nyv-1] |
---|
[2] | 133 | indicey = inter(indiceyu, indiceyv) |
---|
[226] | 134 | nx = n_elements(indicex) |
---|
[2] | 135 | ny = n_elements(indicey) |
---|
| 136 | ;---------------------------------------------------------------------------- |
---|
| 137 | case 1 of |
---|
| 138 | ;---------------------------------------------------------------------------- |
---|
| 139 | ;---------------------------------------------------------------------------- |
---|
| 140 | ;xyz |
---|
| 141 | ;---------------------------------------------------------------------------- |
---|
| 142 | ;---------------------------------------------------------------------------- |
---|
[226] | 143 | (size(u))[0] EQ 3 AND date1 EQ date2 :BEGIN |
---|
[2] | 144 | ;---------------------------------------------------------------------------- |
---|
| 145 | indice2d = lindgen(jpi, jpj) |
---|
| 146 | indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] |
---|
| 147 | indice3d = lindgen(jpi, jpj, jpk) |
---|
[25] | 148 | indice3d = indice3d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1,firstzt:lastzt] |
---|
[2] | 149 | ;------------------------------------------------------------ |
---|
[142] | 150 | ; extraction of u and v on the appropriated domain |
---|
[2] | 151 | ;------------------------------------------------------------ |
---|
| 152 | case 1 of |
---|
| 153 | (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ |
---|
[226] | 154 | (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN |
---|
[2] | 155 | case (size(u))[3] OF |
---|
[226] | 156 | nzt:BEGIN |
---|
[2] | 157 | if nxu NE nx then $ |
---|
[226] | 158 | if indicex[0] EQ firstxu then u = u[0:nx-1,*,*] ELSE u = u[1: nx, *,*] |
---|
[2] | 159 | IF nxv NE nx THEN $ |
---|
[25] | 160 | if indicex[0] EQ firstxv then v = v[0:nx-1,*,*] ELSE v = v[1: nx, *,*] |
---|
[2] | 161 | IF nyu NE ny THEN $ |
---|
[226] | 162 | if indicey[0] EQ firstyu then u = u[*,0:ny-1,*] ELSE u = u[*, 1: ny,*] |
---|
[2] | 163 | IF nyv NE ny THEN $ |
---|
[25] | 164 | if indicey[0] EQ firstyv then v = v[*,0:ny-1,*] ELSE v = v[*, 1: ny,*] |
---|
[2] | 165 | end |
---|
[226] | 166 | jpk:BEGIN |
---|
[2] | 167 | if nxu NE nx then $ |
---|
[226] | 168 | if indicex[0] EQ firstxu then u = u[0:nx-1, *,firstzt:lastzt] ELSE u = u[1: nx, *,firstzt:lastzt] |
---|
[2] | 169 | IF nxv NE nx THEN $ |
---|
[25] | 170 | if indicex[0] EQ firstxv then v = v[0:nx-1, *,firstzt:lastzt] ELSE v = v[1: nx, *,firstzt:lastzt] |
---|
[2] | 171 | IF nyu NE ny THEN $ |
---|
[226] | 172 | if indicey[0] EQ firstyu then u = u[*, 0:ny-1,firstzt:lastzt] ELSE u = u[*, 1: ny,firstzt:lastzt] |
---|
[2] | 173 | IF nyv NE ny THEN $ |
---|
[25] | 174 | if indicey[0] EQ firstyv then v = v[*, 0:ny-1,firstzt:lastzt] ELSE v = v[*, 1: ny,firstzt:lastzt] |
---|
[2] | 175 | end |
---|
| 176 | ELSE: return, report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs') |
---|
| 177 | endcase |
---|
| 178 | END |
---|
| 179 | (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND (size(u))[3] EQ jpk AND $ |
---|
[226] | 180 | (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj AND (size(u))[3] EQ jpk :BEGIN |
---|
[2] | 181 | u = u[indice3d] |
---|
| 182 | v = v[indice3d] |
---|
| 183 | END |
---|
| 184 | ELSE: return, report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs') |
---|
| 185 | endcase |
---|
| 186 | ;------------------------------------------------------------------ |
---|
[142] | 187 | ; We reshape u and v to make sure that no dimension has been erased |
---|
[2] | 188 | ;------------------------------------------------------------------ |
---|
| 189 | if nzt EQ 1 then begin |
---|
| 190 | u = reform(u, nx, ny, nzt, /over) |
---|
| 191 | v = reform(v, nx, ny, nzt, /over) |
---|
| 192 | endif |
---|
| 193 | ;------------------------------------------------------------------ |
---|
[142] | 194 | ; construction of u and v at points T |
---|
[2] | 195 | ;----------------------------------------------------------- |
---|
[114] | 196 | a=u[0,*,*] |
---|
[2] | 197 | u=(u+shift(u,1,0,0))/2. |
---|
[114] | 198 | if NOT keyword_set(key_periodic) OR nx NE jpi then u[0,*,*]=a |
---|
| 199 | a=v[*,0,*] |
---|
[2] | 200 | v=(v+shift(v,0,1,0))/2. |
---|
[114] | 201 | if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0,*]=a |
---|
[2] | 202 | ;---------------------------------------------------------------------------- |
---|
[226] | 203 | ; attribution of the mask and of longitude and latitude arrays |
---|
[2] | 204 | ;---------------------------------------------------------------------------- |
---|
| 205 | mask = tmask[indice3d] |
---|
| 206 | if nzt EQ 1 then mask = reform(mask, nx, ny, nzt, /over) |
---|
| 207 | ;----------------------------------------------------------- |
---|
| 208 | if n_elements(valmask) EQ 0 THEN valmask = 1e20 |
---|
| 209 | landu = where(u GE valmask/10) |
---|
| 210 | if landu[0] NE -1 then u[landu] = 0 |
---|
| 211 | landv = where(v GE valmask/10) |
---|
| 212 | if landv[0] NE -1 then v[landv] = 0 |
---|
| 213 | res=sqrt(u^2+v^2) |
---|
[114] | 214 | if NOT keyword_set(key_periodic) OR nx NE jpi then res[0,*, *]=!values.f_nan |
---|
| 215 | res[*,0, *]=!values.f_nan |
---|
[2] | 216 | mask = where(mask eq 0) |
---|
[114] | 217 | IF mask[0] NE -1 THEN res[mask] = valmask |
---|
[142] | 218 | ; All kind of average |
---|
[25] | 219 | domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, /meme |
---|
| 220 | if keyword_set(direc) then res = moyenne(res,direc,/nan, boxzoom = boxzoom, /nodomdef) |
---|
[2] | 221 | ;----------------------------------------------------------- |
---|
| 222 | END |
---|
| 223 | ;---------------------------------------------------------------------------- |
---|
| 224 | ;---------------------------------------------------------------------------- |
---|
| 225 | ;xyt |
---|
| 226 | ;---------------------------------------------------------------------------- |
---|
| 227 | ;---------------------------------------------------------------------------- |
---|
[226] | 228 | date1 NE date2 AND (size(u))[0] EQ 3 :BEGIN |
---|
[2] | 229 | indice2d = lindgen(jpi, jpj) |
---|
| 230 | indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] |
---|
| 231 | ;------------------------------------------------------------ |
---|
[142] | 232 | ; extraction of u and v on the appropriated domain |
---|
[2] | 233 | ;------------------------------------------------------------ |
---|
| 234 | case 1 of |
---|
| 235 | (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ |
---|
[226] | 236 | (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN |
---|
[2] | 237 | if nxu NE nx then $ |
---|
[226] | 238 | if indicex[0] EQ firstxu then u = u[0:nx-1, *, *] ELSE u = u[1: nx, *, *] |
---|
[2] | 239 | IF nxv NE nx THEN $ |
---|
[25] | 240 | if indicex[0] EQ firstxv then v = v[0:nx-1, *, *] ELSE v = v[1: nx, *, *] |
---|
[2] | 241 | IF nyu NE ny THEN $ |
---|
[226] | 242 | if indicey[0] EQ firstyu then u = u[*, 0:ny-1, *] ELSE u = u[*, 1: ny, *] |
---|
[2] | 243 | IF nyv NE ny THEN $ |
---|
[25] | 244 | if indicey[0] EQ firstyv then v = v[*, 0:ny-1, *] ELSE v = v[*, 1: ny, *] |
---|
[2] | 245 | END |
---|
| 246 | (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND $ |
---|
[226] | 247 | (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN |
---|
[2] | 248 | u = u[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1, *] |
---|
| 249 | v = v[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1, *] |
---|
| 250 | END |
---|
| 251 | ELSE:return, report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs') |
---|
| 252 | endcase |
---|
| 253 | ;------------------------------------------------------------------ |
---|
[142] | 254 | ; construction of u and v at points T |
---|
[2] | 255 | ;----------------------------------------------------------- |
---|
[114] | 256 | a=u[0,*,*] |
---|
[2] | 257 | u=(u+shift(u,1,0,0))/2. |
---|
[114] | 258 | if NOT keyword_set(key_periodic) OR nx NE jpi then u[0,*,*]=a |
---|
| 259 | a=v[*,0,*] |
---|
[2] | 260 | v=(v+shift(v,0,1,0))/2. |
---|
[114] | 261 | if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0,*]=a |
---|
[2] | 262 | ;---------------------------------------------------------------------------- |
---|
[142] | 263 | ; attribution of the mask and of longitude and latitude arrays. |
---|
[226] | 264 | ; We recover the complete grid to establish a big mask extent in the four |
---|
| 265 | ; direction to cover pointsfor which a land point has been |
---|
[142] | 266 | ; considerated (make a small drawing) |
---|
[2] | 267 | ;---------------------------------------------------------------------------- |
---|
[25] | 268 | mask = tmask[indice2d+jpi*jpj*firstzt] |
---|
[2] | 269 | if ny EQ 1 then mask = reform(mask, nx, ny, /over) |
---|
| 270 | ;----------------------------------------------------------- |
---|
[142] | 271 | ; construction of land containing all points to mask |
---|
[2] | 272 | ;----------------------------------------------------------- |
---|
| 273 | if n_elements(valmask) EQ 0 THEN valmask = 1e20 |
---|
| 274 | landu = where(u GE valmask/10) |
---|
| 275 | if landu[0] NE -1 then u[landu] = 0 |
---|
| 276 | landv = where(v GE valmask/10) |
---|
| 277 | if landv[0] NE -1 then v[landv] = 0 |
---|
| 278 | res=sqrt(u^2+v^2) |
---|
[114] | 279 | if NOT keyword_set(key_periodic) OR nx NE jpi then res[0,*, *]=!values.f_nan |
---|
| 280 | res[*,0, *]=!values.f_nan |
---|
[2] | 281 | mask = where(mask eq 0) |
---|
[226] | 282 | IF mask[0] NE -1 THEN BEGIN |
---|
[2] | 283 | coeftps = lindgen(jpt)*nx*ny |
---|
| 284 | coeftps = replicate(1, n_elements(mask))#coeftps |
---|
| 285 | mask = (temporary(mask))[*]#replicate(1, jpt) |
---|
| 286 | mask =temporary(mask[*]) + temporary(coeftps[*]) |
---|
[114] | 287 | res[temporary(mask)] = valmask |
---|
[2] | 288 | ENDIF |
---|
| 289 | ; moyennes en tous genres |
---|
[25] | 290 | domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, /meme |
---|
| 291 | if keyword_set(direc) then res = grossemoyenne(res,direc,/nan, boxzoom = boxzoom, /nodomdef) |
---|
[2] | 292 | END |
---|
| 293 | ;---------------------------------------------------------------------------- |
---|
| 294 | ;---------------------------------------------------------------------------- |
---|
| 295 | ;xyzt |
---|
| 296 | ;---------------------------------------------------------------------------- |
---|
| 297 | ;---------------------------------------------------------------------------- |
---|
[226] | 298 | date1 NE date2 AND (size(u))[0] EQ 4:BEGIN |
---|
[2] | 299 | indice2d = lindgen(jpi, jpj) |
---|
| 300 | indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] |
---|
| 301 | indice3d = lindgen(jpi, jpj, jpk) |
---|
[25] | 302 | indice3d = indice3d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1,firstzt:lastzt] |
---|
[2] | 303 | ;------------------------------------------------------------ |
---|
[142] | 304 | ; extraction of u and v on the appropriated domain |
---|
[2] | 305 | ;------------------------------------------------------------ |
---|
| 306 | case 1 of |
---|
| 307 | (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ |
---|
[226] | 308 | (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN |
---|
[2] | 309 | case (size(u))[3] OF |
---|
[226] | 310 | nzt:BEGIN |
---|
[2] | 311 | if nxu NE nx then $ |
---|
[226] | 312 | if indicex[0] EQ firstxu then u = u[0:nx-1,*,*,*] ELSE u = u[1: nx, *,*,*] |
---|
[2] | 313 | IF nxv NE nx THEN $ |
---|
[25] | 314 | if indicex[0] EQ firstxv then v = v[0:nx-1,*,*,*] ELSE v = v[1: nx, *,*,*] |
---|
[2] | 315 | IF nyu NE ny THEN $ |
---|
[226] | 316 | if indicey[0] EQ firstyu then u = u[*,0:ny-1,*,*] ELSE u = u[*, 1: ny,*,*] |
---|
[2] | 317 | IF nyv NE ny THEN $ |
---|
[25] | 318 | if indicey[0] EQ firstyv then v = v[*,0:ny-1,*,*] ELSE v = v[*, 1: ny,*,*] |
---|
[2] | 319 | end |
---|
[226] | 320 | jpk:BEGIN |
---|
[2] | 321 | if nxu NE nx then $ |
---|
[226] | 322 | if indicex[0] EQ firstxu then u = u[0:nx-1, *,firstzt:lastzt,*] ELSE u = u[1: nx, *,firstzt:lastzt,*] |
---|
[2] | 323 | IF nxv NE nx THEN $ |
---|
[25] | 324 | if indicex[0] EQ firstxv then v = v[0:nx-1, *,firstzt:lastzt,*] ELSE v = v[1: nx, *,firstzt:lastzt,*] |
---|
[2] | 325 | IF nyu NE ny THEN $ |
---|
[226] | 326 | if indicey[0] EQ firstyu then u = u[*, 0:ny-1,firstzt:lastzt,*] ELSE u = u[*, 1: ny,firstzt:lastzt,*] |
---|
[2] | 327 | IF nyv NE ny THEN $ |
---|
[25] | 328 | if indicey[0] EQ firstyv then v = v[*, 0:ny-1,firstzt:lastzt,*] ELSE v = v[*, 1: ny,firstzt:lastzt,*] |
---|
[2] | 329 | end |
---|
| 330 | ELSE: return, report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs') |
---|
| 331 | endcase |
---|
| 332 | END |
---|
| 333 | (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND (size(u))[3] EQ jpk AND $ |
---|
[226] | 334 | (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj AND (size(u))[3] EQ jpk :BEGIN |
---|
[25] | 335 | u = u[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1,firstzt:lastzt, *] |
---|
| 336 | v = v[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1,firstzt:lastzt, *] |
---|
[2] | 337 | END |
---|
| 338 | ELSE: return, report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs') |
---|
| 339 | endcase |
---|
| 340 | ;------------------------------------------------------------------ |
---|
[142] | 341 | ; construction of u and v at points T |
---|
[2] | 342 | ;----------------------------------------------------------- |
---|
[114] | 343 | a=u[0,*,*,*] |
---|
[2] | 344 | u=(u+shift(u,1,0,0,0))/2. |
---|
[114] | 345 | if NOT keyword_set(key_periodic) OR nx NE jpi then u[0,*,*,*]=a |
---|
| 346 | a=v[*,0,*,*] |
---|
[2] | 347 | v=(v+shift(v,0,1,0,0))/2. |
---|
[114] | 348 | if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0,*,*]=a |
---|
[2] | 349 | ;---------------------------------------------------------------------------- |
---|
[226] | 350 | ; attribution of the mask and of longitude and latitude arrays |
---|
[2] | 351 | ;---------------------------------------------------------------------------- |
---|
| 352 | mask = tmask[indice3d] |
---|
| 353 | if nzt EQ 1 then mask = reform(mask, nx, ny, nzt, /over) |
---|
| 354 | ;----------------------------------------------------------- |
---|
| 355 | if n_elements(valmask) EQ 0 THEN valmask = 1e20 |
---|
| 356 | landu = where(u GE valmask/10) |
---|
| 357 | if landu[0] NE -1 then u[landu] = 0 |
---|
| 358 | landv = where(v GE valmask/10) |
---|
| 359 | if landv[0] NE -1 then v[landv] = 0 |
---|
| 360 | res=sqrt(u^2+v^2) |
---|
[114] | 361 | if NOT keyword_set(key_periodic) OR nx NE jpi then res[0,*, *, *]=!values.f_nan |
---|
| 362 | res[*,0, *, *]=!values.f_nan |
---|
[2] | 363 | mask = where(mask eq 0) |
---|
[226] | 364 | IF mask[0] NE -1 THEN BEGIN |
---|
[2] | 365 | coeftps = lindgen(jpt)*nx*ny*nzt |
---|
| 366 | coeftps = replicate(1, n_elements(mask))#coeftps |
---|
| 367 | mask = (temporary(mask))[*]#replicate(1, jpt) |
---|
| 368 | mask =temporary(mask[*]) + temporary(coeftps[*]) |
---|
[114] | 369 | res[temporary(mask)] = valmask |
---|
[2] | 370 | ENDIF |
---|
[142] | 371 | ; All kind of average |
---|
[25] | 372 | domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, /meme |
---|
| 373 | if keyword_set(direc) then res = grossemoyenne(res,direc,/nan, boxzoom = boxzoom, /nodomdef) |
---|
[2] | 374 | END |
---|
| 375 | ;---------------------------------------------------------------------------- |
---|
| 376 | ;---------------------------------------------------------------------------- |
---|
| 377 | ;xy |
---|
| 378 | ;---------------------------------------------------------------------------- |
---|
| 379 | ;---------------------------------------------------------------------------- |
---|
| 380 | ELSE:BEGIN ;xy |
---|
| 381 | indice2d = lindgen(jpi, jpj) |
---|
| 382 | indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] |
---|
| 383 | ;------------------------------------------------------------ |
---|
[142] | 384 | ; extraction of u and v on the appropriated domain |
---|
[2] | 385 | ;------------------------------------------------------------ |
---|
| 386 | case 1 of |
---|
| 387 | (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ |
---|
[226] | 388 | (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN |
---|
[2] | 389 | if nxu NE nx then $ |
---|
[226] | 390 | if indicex[0] EQ firstxu then u = u[0:nx-1, *] ELSE u = u[1: nx, *] |
---|
[2] | 391 | IF nxv NE nx THEN $ |
---|
[25] | 392 | if indicex[0] EQ firstxv then v = v[0:nx-1, *] ELSE v = v[1: nx, *] |
---|
[2] | 393 | IF nyu NE ny THEN $ |
---|
[226] | 394 | if indicey[0] EQ firstyu then u = u[*, 0:ny-1] ELSE u = u[*, 1: ny] |
---|
[2] | 395 | IF nyv NE ny THEN $ |
---|
[25] | 396 | if indicey[0] EQ firstyv then v = v[*, 0:ny-1] ELSE v = v[*, 1: ny] |
---|
[2] | 397 | END |
---|
| 398 | (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND $ |
---|
[226] | 399 | (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN |
---|
[2] | 400 | u = u[indice2d] |
---|
| 401 | v = v[indice2d] |
---|
| 402 | END |
---|
| 403 | ELSE:return, report('problemes d''adequation entre la taille du domaine et la taille des matrices necessaires a tracer des vecteurs') |
---|
| 404 | endcase |
---|
| 405 | ;------------------------------------------------------------------ |
---|
[142] | 406 | ; We reshape u and v to make sure that no dimension has been erased |
---|
[2] | 407 | ;------------------------------------------------------------------ |
---|
| 408 | if ny EQ 1 then begin |
---|
| 409 | u = reform(u, nx, ny, /over) |
---|
| 410 | v = reform(v, nx, ny, /over) |
---|
| 411 | endif |
---|
| 412 | ;------------------------------------------------------------------ |
---|
[142] | 413 | ; construction of u and v at points T |
---|
[2] | 414 | ;----------------------------------------------------------- |
---|
[114] | 415 | a=u[0,*] |
---|
[2] | 416 | u=(u+shift(u,1,0))/2. |
---|
[114] | 417 | if NOT keyword_set(key_periodic) OR nx NE jpi then u[0,*]=a |
---|
| 418 | a=v[*,0] |
---|
[2] | 419 | v=(v+shift(v,0,1))/2. |
---|
[114] | 420 | if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0]=a |
---|
[2] | 421 | ;---------------------------------------------------------------------------- |
---|
[142] | 422 | ; attribution of the mask and of longitude and latitude arrays. |
---|
[226] | 423 | ; We recover the complete grid to establish a big mask extent in the four |
---|
| 424 | ; direction to cover pointsfor which a land point has been |
---|
[142] | 425 | ; considerated (make a small drawing) |
---|
[2] | 426 | ;---------------------------------------------------------------------------- |
---|
[25] | 427 | mask = tmask[indice2d+jpi*jpj*firstzt] |
---|
[2] | 428 | if nyt EQ 1 THEN mask = reform(mask, nx, ny, /over) |
---|
| 429 | ;----------------------------------------------------------- |
---|
[142] | 430 | ; construction of land containing all points to mask |
---|
[2] | 431 | ;----------------------------------------------------------- |
---|
| 432 | if n_elements(valmask) EQ 0 THEN valmask = 1e20 |
---|
| 433 | landu = where(u GE valmask/10) |
---|
| 434 | if landu[0] NE -1 then u[landu] = 0 |
---|
| 435 | landv = where(v GE valmask/10) |
---|
| 436 | if landv[0] NE -1 then v[landv] = 0 |
---|
| 437 | res=sqrt(u^2+v^2) |
---|
[114] | 438 | if NOT keyword_set(key_periodic) OR nx NE jpi then res[0,*]=!values.f_nan |
---|
| 439 | res[*,0]=!values.f_nan |
---|
[2] | 440 | mask = where(mask eq 0) |
---|
[114] | 441 | IF mask[0] NE -1 THEN res[mask] = valmask |
---|
[142] | 442 | ; All kind of average |
---|
[25] | 443 | domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, /meme |
---|
| 444 | if keyword_set(direc) then res = moyenne(res,direc,/nan, boxzoom = boxzoom, /nodomdef) |
---|
[2] | 445 | END |
---|
| 446 | ;---------------------------------------------------------------------------- |
---|
| 447 | endcase |
---|
| 448 | ;------------------------------------------------------------ |
---|
[226] | 449 | if keyword_set(key_performance) THEN print, 'temps norme', systime(1)-tempsun |
---|
[2] | 450 | return, res |
---|
| 451 | end |
---|