Changeset 142 for trunk/SRC/ToBeReviewed/CALCULS/norme.pro
- Timestamp:
- 07/21/06 14:47:49 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/CALCULS/norme.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:norme 6 ; 7 ; PURPOSE: calcule la norme d''un champ de vecteurs, puis fait une 8 ; moyenne eventuelle. 9 ; Rq1: le champ de vecteur peut etre, 2d:xy, 3d: xyz ou xyt, 10 ; 4d: xyzt 11 ; Rq2: le calcul de la norme est fait avant l''eventuelle 12 ; moyenne spatiale ou temporelle car la moyenne de la norme 13 ; n''est pas egale a la norme des moyennes. 14 ; 15 ; CATEGORY: calcul de post traitement 16 ; 17 ; CALLING SEQUENCE:res=norme(champ_de_vecteurs) 18 ; 19 ; INPUTS:un tableau 2d, 3d ou 4d 20 ; 21 ; KEYWORD PARAMETERS: 22 ; 23 ; BOXZOOM: boxzoom sur laquelle moyenner (par defaut le domaine 24 ; selectionner par le dernier domdef effectue) 25 ; 26 ; DIREC:'t' 'x' 'y' 'z' 'xy' 'xz' 'yz' 'xyz' 'xt' 'yt' 'zt' 'xyt' 27 ; 'xzt' 'yzt' 'xyzt' directions selon lesquelles effectuer les 28 ; moyennes 29 ; 30 ; OUTPUTS:tableau a tracer avec plt, pltz ou pltt. 31 ; 32 ; COMMON BLOCKS: 33 ; common.pro 34 ; 35 ; SIDE EFFECTS: 36 ; 37 ; La norme est calculee aux points T. Pour faire ce calcul, on 38 ; moyenne les champs U et V aux points T avant de calculer la norme. 39 ; Au bord des cotes et du domaine, on ne peut pas calculer les 40 ; champs U et V aux points T, ces points sont donc a la valeur 41 ; !values.f_nan. 5 ; 6 ; @file_comments 7 ; calculate the norme of a field of vectors, then make a possible average. 8 ; Comment 1: The field of vector can be, 2d:xy, 3d: xyz or xyt, 9 ; 4d: xyzt 10 ; Comment 2: 11 ; The calculation of the norme is made before the possible spatial or 12 ; temporal average because the average of the norme is not equal to the 13 ; norme of averages 14 15 ; 16 ; @categories 17 ; Post traitment calculation 18 ; 19 ; @param COMPOSANTEU {in}{required} 20 ; an 2d, 3d or 4d array 21 ; 22 ; @param COMPOSANTEV {in}{required} 23 ; an 2d, 3d or 4d array 24 ; 25 ; @keyword BOXZOOM 26 ; boxzoom on which do the average (by default the domain selected 27 ; by the last domdef done) 28 ; 29 ; @keyword DIREC 30 ; 't' 'x' 'y' 'z' 'xys' 'xz' 'yz' 'xyz' 'xt' 'yt' 'zt' 'xyt' 31 ; 'xzt' 'yzt' 'xyzt' Direction on which do averages 32 ; 33 ; @returns 34 ; Array to trace with plt, pltz or pltt. 35 ; 36 ; @uses 37 ; common.pro 38 ; 39 ; @restrictions 40 ; The norme is calculated on points TTo do this calculation, we average 41 ; field U and Von points T before calculate the norme. At the edge of 42 ; coast and of domain, we can not calculate fields U and V at points T, 43 ; that is why these points are at value !values.f_nan. 42 44 ; 43 ; lorsqu''on fait le calcul sur un domaine geographique reduit, 44 ; les champs U et V ne comprennent pas forcement le meme nombre 45 ; de points. Dans ce cas on redecoupe U et V pour ne garder que 46 ; les points en commun. Au passage on refait un domdef qui 47 ; redefinit un domaine geographique sur lequel les champs U et V 48 ; sont extraits sur les meme points. 49 ; 50 ; RESTRICTIONS: 51 ; 52 ; pour savoir a quel type de tableau on a a faire, on teste la 53 ; taille de celui-ci et les dates donnees par time[0] et 54 ; time[jpt-1] pour savoir si il y a une dimension 55 ; temporelle. Avant de lancer norme s''assurer que time et jpt 56 ; sont bien definis comme il faut! 57 ; 58 ; EXAMPLE: 59 ; 60 ; pour calculer la moyenne de la norme des courants sur tout le 61 ; dommaine entre 0 et 50: 45 ; When we calculate on a reduce geographic domain, field U and V have not 46 ; necessarily the same number of point. In this case, we recut U and V to 47 ; keep only common points. We profit of this to redo a domdef which redefine 48 ; a geographic domain on which fields U and V are extracted on same points 49 ; 50 ; @restrictions 51 ; To know what type of array we work with, we test its size and dates 52 ; gave by time[0] and time[jpt-1] to know if thee is a temporal dimension. 53 ; Before to start norme, make sure that time and jpt are defined how 54 ; they have to! 55 ; 56 ; @examples 57 ; To calculate the average of the norme of streams on all the domain 58 ; between 0 et 50: 62 59 ; IDL> res=norme(un,vn,boxzoom=[0,50],dir='xyz') 63 60 ; 64 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 61 ; @history 62 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 65 63 ; 9/6/1999 64 ; 65 ; @version 66 ; $Id$ 67 ; 66 68 ;- 67 69 ;------------------------------------------------------------ … … 81 83 ENDIF 82 84 ;--------------------------------------------------------- 83 tempsun = systime(1) ; pourkey_performance85 tempsun = systime(1) ; To key_performance 84 86 ; 85 87 IF finite(glamu[0])*finite(gphiu[0])*finite(glamv[0])*finite(gphiv[0]) EQ 0 THEN $ … … 101 103 ;------------------------------------------------------------ 102 104 if NOT keyword_set(direc) then direc = 0 103 ; construction de u et v aux pts T105 ; construction of u and v at points T 104 106 u = litchamp(composanteu) 105 107 v = litchamp(composantev) … … 130 132 131 133 ;------------------------------------------------------------ 132 ; on trouve les points que u et v ont en communs134 ; We find common points between u and v 133 135 ;------------------------------------------------------------ 134 136 indicexu = (lindgen(jpi))[firstxu:firstxu+nxu-1] … … 154 156 indice3d = indice3d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1,firstzt:lastzt] 155 157 ;------------------------------------------------------------ 156 ; extraction de u et v sur le domaine qui convient158 ; extraction of u and v on the appropriated domain 157 159 ;------------------------------------------------------------ 158 160 case 1 of … … 191 193 endcase 192 194 ;------------------------------------------------------------------ 193 ; on reform u et v pour s'assurer qu'aucune dimension n'a ete ecrasee195 ; We reshape u and v to make sure that no dimension has been erased 194 196 ;------------------------------------------------------------------ 195 197 if nzt EQ 1 then begin … … 198 200 endif 199 201 ;------------------------------------------------------------------ 200 ; construction de u et v aux pts T202 ; construction of u and v at points T 201 203 ;----------------------------------------------------------- 202 204 a=u[0,*,*] … … 207 209 if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0,*]=a 208 210 ;---------------------------------------------------------------------------- 209 ; attribution du mask et des tableau de longitude et latitude211 ; attribution of the mask and of logitude and latitude arrays 210 212 ;---------------------------------------------------------------------------- 211 213 mask = tmask[indice3d] … … 222 224 mask = where(mask eq 0) 223 225 IF mask[0] NE -1 THEN res[mask] = valmask 224 ; moyennes en tous genres226 ; All kind of average 225 227 domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, /meme 226 228 if keyword_set(direc) then res = moyenne(res,direc,/nan, boxzoom = boxzoom, /nodomdef) … … 236 238 indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] 237 239 ;------------------------------------------------------------ 238 ; extraction de u et v sur le domaine qui convient240 ; extraction of u and v on the appropriated domain 239 241 ;------------------------------------------------------------ 240 242 case 1 of … … 258 260 endcase 259 261 ;------------------------------------------------------------------ 260 ; construction de u et v aux pts T262 ; construction of u and v at points T 261 263 ;----------------------------------------------------------- 262 264 a=u[0,*,*] … … 267 269 if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0,*]=a 268 270 ;---------------------------------------------------------------------------- 269 ; attribution du mask et des tableau de longitude et latitude270 ; on recupere la grille complette pour etablir un grand mask etendu ds les 4271 ; direction s pour couvrir les points pour lesquels un pt terre a ete pris en272 ; co mpte (faire un petit dessin...)271 ; attribution of the mask and of longitude and latitude arrays. 272 ; We recover the complete grid to establish a big mask extent in the four 273 ; direction to cover pointsfor which a land point has been 274 ; considerated (make a small drawing) 273 275 ;---------------------------------------------------------------------------- 274 276 mask = tmask[indice2d+jpi*jpj*firstzt] 275 277 if ny EQ 1 then mask = reform(mask, nx, ny, /over) 276 278 ;----------------------------------------------------------- 277 ; construction de terre qui contient tous les point a masquer279 ; construction of land containing all points to mask 278 280 ;----------------------------------------------------------- 279 281 if n_elements(valmask) EQ 0 THEN valmask = 1e20 … … 308 310 indice3d = indice3d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1,firstzt:lastzt] 309 311 ;------------------------------------------------------------ 310 ; extraction de u et v sur le domaine qui convient312 ; extraction of u and v on the appropriated domain 311 313 ;------------------------------------------------------------ 312 314 case 1 of … … 345 347 endcase 346 348 ;------------------------------------------------------------------ 347 ; construction de u et v aux pts T349 ; construction of u and v at points T 348 350 ;----------------------------------------------------------- 349 351 a=u[0,*,*,*] … … 354 356 if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0,*,*]=a 355 357 ;---------------------------------------------------------------------------- 356 ; attribution du mask et des tableau de longitude et latitude358 ; attribution of the mask and of logitude and latitude arrays 357 359 ;---------------------------------------------------------------------------- 358 360 mask = tmask[indice3d] … … 375 377 res[temporary(mask)] = valmask 376 378 ENDIF 377 ; moyennes en tous genres379 ; All kind of average 378 380 domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, /meme 379 381 if keyword_set(direc) then res = grossemoyenne(res,direc,/nan, boxzoom = boxzoom, /nodomdef) … … 388 390 indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] 389 391 ;------------------------------------------------------------ 390 ; extraction de u et v sur le domaine qui convient392 ; extraction of u and v on the appropriated domain 391 393 ;------------------------------------------------------------ 392 394 case 1 of … … 410 412 endcase 411 413 ;------------------------------------------------------------------ 412 ; on reform u et v pour s'assurer qu'aucune dimension n'a ete ecrasee414 ; We reshape u and v to make sure that no dimension has been erased 413 415 ;------------------------------------------------------------------ 414 416 if ny EQ 1 then begin … … 417 419 endif 418 420 ;------------------------------------------------------------------ 419 ; construction de u et v aux pts T421 ; construction of u and v at points T 420 422 ;----------------------------------------------------------- 421 423 a=u[0,*] … … 426 428 if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0]=a 427 429 ;---------------------------------------------------------------------------- 428 ; attribution du mask et des tableau de longitude et latitude429 ; on recupere la grille complette pour etablir un grand mask etendu ds les 4430 ; direction s pour couvrir les points pour lesquels un pt terre a ete pris en431 ; co mpte (faire un petit dessin...)430 ; attribution of the mask and of longitude and latitude arrays. 431 ; We recover the complete grid to establish a big mask extent in the four 432 ; direction to cover pointsfor which a land point has been 433 ; considerated (make a small drawing) 432 434 ;---------------------------------------------------------------------------- 433 435 mask = tmask[indice2d+jpi*jpj*firstzt] 434 436 if nyt EQ 1 THEN mask = reform(mask, nx, ny, /over) 435 437 ;----------------------------------------------------------- 436 ; construction de terre qui contient tous les point a masquer438 ; construction of land containing all points to mask 437 439 ;----------------------------------------------------------- 438 440 if n_elements(valmask) EQ 0 THEN valmask = 1e20 … … 446 448 mask = where(mask eq 0) 447 449 IF mask[0] NE -1 THEN res[mask] = valmask 448 ; moyennes en tous genres450 ; All kind of average 449 451 domdef, (glamt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, /meme 450 452 if keyword_set(direc) then res = moyenne(res,direc,/nan, boxzoom = boxzoom, /nodomdef)
Note: See TracChangeset
for help on using the changeset viewer.