source: trunk/SRC/Computation/norm.pro @ 325

Last change on this file since 325 was 325, checked in by pinsard, 17 years ago

modification of some headers (+some corrections) to prepare usage of the new idldoc

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