Changeset 142 for trunk/SRC/ToBeReviewed/CALCULS
- Timestamp:
- 07/21/06 14:47:49 (18 years ago)
- Location:
- trunk/SRC/ToBeReviewed/CALCULS
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/CALCULS/curl.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:curl 6 ; 7 ; PURPOSE:calcule la composante verticale du rotationnel d''un champ 8 ; de vecteur horizontaux 9 ; 10 ; CATEGORY:calcule sur les matrices 11 ; 12 ; CALLING SEQUENCE:res=curl(u,v) 13 ; 14 ; INPUTS: 15 ; u et v deux matrices representant les coordonnes d''un 16 ; champ de vecteur 17 ; 18 ; KEYWORD PARAMETERS: 19 ; 20 ; OUTPUTS:res: une matrice 2d 21 ; 22 ; COMMON BLOCKS: 23 ; common.pro 24 ; 25 ; SIDE EFFECTS: 26 ; 27 ; RESTRICTIONS: 28 ; les matrices u et v peuvent de 2 a 4 dimensions. 29 ; attention pour distinger les differents configurations de u et v 30 ; (xy, xyz, xyt, xyzt), on regarde la variable du common 31 ; -time qui contient le calendrier en jour julien d''IDL auquel 32 ; se rapportent u et v ansi que la variable 33 ; -jpt qui est le nombre de pas de temps a considerer ds time. 34 ; les tableaux u et v sont decoupes sur le meme domaine 35 ; geographique. A cause du decalage des grilles T, U, V et F il est 36 ; possiible que ces 2 tableaux n''aient pas la meme taille et se 37 ; repportent a des indices differents. Si tel est le cas les tableaux 38 ; sont redecoupes sur les indices qu'ils ont en commun et le dommaine 39 ; est redefinit pour qu'il colle a ces indices communs. 40 ; pour eviter ces redecoupes utiliser le mot cles /memeindice ds 41 ; domdef.pro 42 ; 43 ; 44 ; les points sur le bord du dessin sont mis a !values.f_nan 45 ; 46 ; EXAMPLE: 47 ; 48 ; MODIFICATION HISTORY:Guillaume Roullet (grlod@ipsl.jussieu.fr) 5 ; 6 ; @file_comments 7 ; Calculate the vertical component of the curl of a field of horizontal vectors 8 ; 9 ; @categories 10 ; Calculation on matrixes 11 ; 12 ; @param UU 13 ; Matrix representing coordinates of a field of vectors 14 ; 15 ; @param VV 16 ; Matrix representing coordinates of a field of vectors 17 ; 18 ; @returns RES 19 ; A 2d matrix 20 ; 21 ; @uses 22 ; common.pro 23 ; 24 ; @restrictions 25 ; U and V matrixes can be 2 or 4d. 26 ; Beware, to discern differents configuration of U and V (xy, xyz, xyt, xyzt), 27 ; we look at the variable of the common 28 ; -time which contain the calendar in IDL julian days to which U and 29 ; V refered to, in the same way as the variable 30 ; -jpt which is the number of time's step to consider in time. 31 ; U and V arrays ae cut in the same geographic domain. Because of the gap of 32 ; T, U, V and F grids, it is possible that these two arrays hase not the same 33 ; size and refered to different indexes. In this case, arrays are recut on 34 ; common indexesand the domain is redifined to match with these common 35 ; indexes. To avoid these recuts, use the keyword /memeindice in domdef.pro 36 ; 37 ; 38 ; Points on the drawing edge are at !values.f_nan 39 ; 40 ; @history 41 ; Guillaume Roullet (grlod@ipsl.jussieu.fr) 49 42 ; 50 43 ; Sebastien Masson (smasson@lodyc.jussieu.fr) … … 53 46 ; 21/5/1999: valeurs manquantes a !values.f_nan 54 47 ;periodicite 48 ; 49 ; @version 50 ; $Id$ 51 ; 55 52 ;- 56 53 ;------------------------------------------------------------ … … 62 59 ; 63 60 @common 64 tempsun = systime(1) ; pourkey_performance61 tempsun = systime(1) ; To key_performance 65 62 ; 66 63 IF finite(glamu[0])*finite(gphiu[0])*finite(glamv[0])*finite(gphiv[0]) EQ 0 THEN $ … … 76 73 77 74 ;------------------------------------------------------------ 78 ; on trouve les points que u et v ont en communs75 ; We find common points between U and V 79 76 ;------------------------------------------------------------ 80 77 indicexu = (lindgen(jpi))[firstxu:firstxu+nxu-1] … … 95 92 indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] 96 93 ;------------------------------------------------------------ 97 ; extraction de u et v sur le domaine qui convient94 ; extraction of U and V on the appropriated domain 98 95 ;------------------------------------------------------------ 99 96 case 1 of … … 117 114 endcase 118 115 ;------------------------------------------------------------ 119 ; calcul du rotationnel116 ; calculation of the curl 120 117 ;------------------------------------------------------------ 121 118 coefu = (e1u[indice2d])[*]#replicate(1, nzt) … … 142 139 psi = tabf*psi 143 140 ;------------------------------------------------------------ 144 ; mise a !values.f_nan de la bordure141 ; Edging put at !values.f_nan 145 142 ;------------------------------------------------------------ 146 143 if NOT keyword_set(key_periodic) OR nx NE jpi then begin … … 155 152 if terref[0] NE -1 then psi[temporary(terref)] = valmask 156 153 ;------------------------------------------------------------ 157 ; pour le trace graphique154 ; For the graphic drawing 158 155 ;------------------------------------------------------------ 159 156 domdef, (glagmt[indice2d])[0, 0], (glamu[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphiv[indice2d])[0, ny-1], vert1, vert2, gridtype = ['t', 'f'] … … 171 168 indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] 172 169 ;------------------------------------------------------------ 173 ; extraction de u et v sur le domaine qui convient170 ; extraction of U and V on the appropriated domain 174 171 ;------------------------------------------------------------ 175 172 case 1 of … … 196 193 endcase 197 194 ;---------------------------------------------------------------------------- 198 ; calcul du rotationnel195 ; Calculation of the curl 199 196 ;---------------------------------------------------------------------------- 200 197 coefu = e1u[indice2d]*(umask())[indice2d+jpi*jpj*firstzt] … … 214 211 tabf = reform(tabf, nx, ny, jpt, /over) 215 212 ;------------------------------------------------------------ 216 ; calcul du rotationnel213 ; Calculation of the curl 217 214 ;------------------------------------------------------------ 218 215 zu = u*temporary(coefu) … … 222 219 psi = tabf*psi 223 220 ;------------------------------------------------------------ 224 ; mise a !values.f_nan de la bordure221 ; extraction of U and V on the appropriated domain 225 222 ;------------------------------------------------------------ 226 223 if NOT keyword_set(key_periodic) OR nx NE jpi then begin … … 255 252 indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] 256 253 ;------------------------------------------------------------ 257 ; extraction de u et v sur le domaine qui convient258 254 ;------------------------------------------------------------ 259 255 case 1 of … … 278 274 endcase 279 275 ;------------------------------------------------------------ 280 ; calcul du rotationnel276 ; Calculation of the curl 281 277 ;------------------------------------------------------------ 282 278 coefu = e1u[indice2d]*(umask())[indice2d+jpi*jpj*firstzt] … … 295 291 296 292 ;------------------------------------------------------------ 297 ; mise a !values.f_nan de la bordure293 ; Edging put at !values.f_nan 298 294 ;------------------------------------------------------------ 299 295 if NOT keyword_set(key_periodic) OR nx NE jpi then begin … … 308 304 if terref[0] NE -1 then psi[temporary(terref)] = valmask 309 305 ;------------------------------------------------------------ 310 ; pour le trace graphique306 ; for the graphic drawing 311 307 ;------------------------------------------------------------ 312 308 domdef, (glamt[indice2d])[0, 0], (glamf[indice2d])[nx-1, 0],(gphit[indice2d])[0, 0], (gphif[indice2d])[0, ny-1], vert1, vert2, gridtype = ['t', 'f'] -
trunk/SRC/ToBeReviewed/CALCULS/depth2floatlevel.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:depth2floatlevel 5 ; @file_comments 6 ; Rather comparable to depth2level but here, the calculated level is in float. 7 ; For example, the level 5.4 correspond to a depth equal 8 ; to gdep[5]+.4*(gdep[6]-gdep[5]) 6 9 ; 7 ; PURPOSE: assez comparable a depth2level mais ici le niveau calcule 8 ; est en float. Par ex le niveau 5.4 correspond a une profondeur egale 9 ; a gdep[5]+.4*(gdep[6]-gdep[5]) 10 ; @categories 11 ; Without loop. 10 12 ; 11 ; CATEGORY: SANS BOUCLE 13 ; @param TAB {in}{required} 14 ; 2d depth array (or a structure respecting litchamp criterions) 12 15 ; 13 ; CALLING SEQUENCE:res=depth2floatlevel(depth2d) 14 ; 15 ; INPUTS: depth2d tableau 2d de profondeur (ou une structure repondant 16 ; aux criteres de litchamp) 16 ; @keyword NOMASK 17 ; To do not mask land points 17 18 ; 18 ; KEYWORD PARAMETERS:19 ; /NOMASK: pour ne pas masquer les points terres19 ; @returns 20 ; An 2d array of float containing levels's values. 20 21 ; 21 ; OUTPUTS: un tableau 2d de float contenant les valeurs des niveaux. 22 ; @uses 23 ; common.pro 22 24 ; 23 ; COMMON BLOCKS:common.pro 25 ; @restrictions 26 ; Accept values at !values.f_nan and mask land points at valmask. 24 27 ; 25 ; SIDE EFFECTS:accepte les vcaleurs a !values.f_nan et masque les 26 ; points terres a valmask. 27 ; 28 ; RESTRICTIONS: 29 ; 30 ; EXAMPLE: 31 ; 28 ; @examples 32 29 ; IDL> a=(jpk-1)/(1.*jpi*jpj)*findgen(jpi,jpj) 33 30 ; IDL> plt, 1e6*(a-floatlevel2depth(depth2floatlevel(a))),/nocontour … … 35 32 ; ->champ nul a 1e-6 pres 36 33 ; 37 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 34 ; @history 35 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 38 36 ; 15/06/2000 37 ; 38 ; @version 39 ; $Id$ 40 ; 39 41 ;- 40 42 ;------------------------------------------------------------ … … 45 47 compile_opt idl2, strictarrsubs 46 48 ; 47 tempsun = systime(1) ; pour key_performance49 tempsun = systime(1) ; for key_performance 48 50 @common 49 51 ;------------------------------------------------------------ … … 55 57 levellow = depth2level(depthin, /lower, /nomask) 56 58 depthlow = level2depth(levellow, /nomask) 57 ; calcul e de la distance depthlow-depthup et gestion du cas ou cette58 ; distance est nulle ou egale a!values.f_nan59 ; calculate the distance depthlow-depthup and management of the case 60 ; of this distance is null or eqal to !values.f_nan 59 61 divi = depthlow-depthup 60 62 nan = where(finite(divi) EQ 0) … … 62 64 nan = where(divi EQ 0) 63 65 if nan[0] NE -1 then divi[nan] = !values.f_nan 64 ; calcul e du resultat66 ; calculation of the result 65 67 res = levelup+(depthin-depthup)/divi 66 ; on masque les points terre avalmask68 ; We mask land point at valmask 67 69 if NOT keyword_set(nomask) then begin 68 70 grille,mask -
trunk/SRC/ToBeReviewed/CALCULS/depth2level.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME: depth2level6 5 ; 7 ; PURPOSE: permet de passer d''un tableau 2d de profondeur au tableau8 ; 2d correspondant de niveaux.6 ; @file_comments 7 ; Allows to pass from a 2d depth array to a corresponding 2d level array. 9 8 ; 10 ; CATEGORY: SANS BOUCLE 9 ; @categories 10 ; Without loop 11 11 ; 12 ; CALLING SEQUENCE: res=depth2level(depth2d) 12 ; @param TAB 13 ; 2d depth array (or a structure respecting litchamp critrions) 13 14 ; 14 ; INPUTS: depth2d tableau 2d de profondeur (ou une structure repondant15 ; aux criteres de litchamp)15 ; @keyword UPPER 16 ; (activated by default) We select the level just above the depth 16 17 ; 17 ; KEYWORD PARAMETERS: 18 ; @keyword LOWER 19 ; We select the level just below the depth 18 20 ; 19 ; /UPPER: (active par defaut) on selectionne le niveau20 ; directement au dessus de la profondeur21 ; @keyword CLOSER 22 ; We select the depth's closer level 21 23 ; 22 ; /LOWER: on selectionne le niveau directement au dessous de la23 ; profondeur24 ; @keyword NOMASK 25 ; To do not mask land points 24 26 ; 25 ; /CLOSER: on selectionne le niveau le plus proche de la26 ; profondeur27 ; @returns 28 ; It is a 2d array containing level's values. 27 29 ; 28 ; /NOMASK: pour ne pas masquer les points terres 30 ; @uses 31 ; common.pro 29 32 ; 30 ; OUTPUTS: un tableau 2d contenant les valeurs des niveaux. 33 ; @restrictions 34 ; For depthes out of gdep's values, the value !values.f_nan is sent back. 35 ; if the depth is superior to this one of the bottom, we send back jpk-1 in 36 ; the upper case, and !values.f_nan in the lower case. 31 37 ; 32 ; COMMON BLOCKS:common.pro 33 ; 34 ; SIDE EFFECTS:pour les profondeurs hors des valeurs de gdep, la 35 ; valeur !values.f_nan est retournee. 36 ; Si la profondeur est superieur a celle du fond, on retourne 37 ; jpk-1dans le cas upper, et !values.f_nan ds le cas lower. 38 ; 39 ; RESTRICTIONS: 40 ; 41 ; EXAMPLE: 42 ; 43 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 38 ; @history 39 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 44 40 ; 17/6/1999 45 41 ; 15/6/2000 accepte !values.f_nan 42 ; 43 ; @version 44 ; $Id$ 46 45 ;- 47 46 ;------------------------------------------------------------ … … 53 52 compile_opt idl2, strictarrsubs 54 53 ; 55 tempsun = systime(1) ; pour key_performance54 tempsun = systime(1) ; for key_performance 56 55 @common 57 56 ;------------------------------------------------------------ … … 59 58 if keyword_set(lower) THEN upper = 0 60 59 ;------------------------------------------------------------ 61 ; lecture du champ d''entree et recuperation de la taille du sous 62 ; domaine utilise 60 ; Reading of the input field and recuperation of the used subdomain's size 63 61 ;------------------------------------------------------------ 64 62 in = litchamp(tab) 65 63 grille,mask,-1,-1,gdep,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz 66 64 ;--------------------------------------------------------------- 67 ; verification de la coherence entre la taille du tableau et le domaine definit par domdef65 ; Verification of the coherence between array's size and the defined by domdef domain 68 66 ;--------------------------------------------------------------- 69 67 IF ny EQ 1 THEN in = reform(in, nx, ny, /over) … … 78 76 ;------------------------------------------------------------ 79 77 ;------------------------------------------------------------ 80 ; vire les points a!values.f_nan78 ; delete points at !values.f_nan 81 79 notanumber = where(finite(in, /nan) EQ 1) 82 80 if notanumber[0] NE -1 then in[notanumber] = 0 83 81 ;------------------------------------------------------------ 84 ; on transforme le tableau 2d de profondeur en tableau 2d de niveaux 85 ; correspondant aux profondeurs 82 ; We transform the 2d deth value in a 2d array of levels corresponding to depthes 86 83 ;------------------------------------------------------------ 87 ; on passe en tableaux qui ont la taille des tableaux 3d84 ; We go on array who have the size of 3d arrays 88 85 prof=replicate(1,nx*ny)#gdep[firstz:lastz] 89 86 in = in[*]#replicate(1, nz) … … 99 96 IF notvalid[0] NE -1 THEN levels[notvalid] = !values.f_nan 100 97 101 ; si closer est active98 ; If closer is activated 102 99 if keyword_set(closer) then begin 103 100 test = [ [[litchamp(tab)-level2depth(levels)]] $ … … 108 105 endif 109 106 ;------------------------------------------------------------ 110 ; on replace les points a!values.f_nan107 ; We put back points at !values.f_nan 111 108 if notanumber[0] NE -1 then levels[notanumber] = !values.f_nan 112 ; on masque les points terres avalmask109 ; We mask land points at valmask 113 110 if NOT keyword_set(nomask) then begin 114 111 if n_elements(valmask) EQ 0 then valmask = 1e20 -
trunk/SRC/ToBeReviewed/CALCULS/depth2mask.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME: depth2mask6 5 ; 7 ; PURPOSE: permet de passer d''un tableau 2d de profondeur seuil au8 ; tableau 3d de mask avec des 1 ds les niveaux au dessus de la9 ; profondeur seuil et des 0 en dessous.6 ; @file_comments 7 ; Allows to pass from a 2d depth sill array to a 3d array of mask 8 ; with one of levels above the sill depth and 0s below. 10 9 ; 11 ; CATEGORY: SANS BOUCLE 10 ; @categories 11 ; Without loop 12 12 ; 13 ; CALLING SEQUENCE: res=depth2mask(depht2d) 13 ; @param TAB 14 ; 2d sill depth array (or a structure respecting litchamp critrions) 14 15 ; 15 ; INPUTS: depht2d tableau 2d de profondeur seuil (ou une structure repondant 16 ; aux criteres de litchamp) 17 ; 18 ; KEYWORD PARAMETERS: 19 ; 20 ; /UPPER: (active par defaut) on selectionne le niveau 21 ; directement au dessus de la profondeur 22 ; 23 ; /LOWER: on selectionne le niveau directement au dessous de la 24 ; profondeur 25 ; 26 ; /CLOSER: on selectionne le niveau le plus proche de la 27 ; profondeur 28 ; 29 ; OUTPUTS: un tableau 3d contenant le mask associe au tableau 2d de 16 ; @keyword _EXTRA 17 ; used to pass your keywords 18 ; 19 ; @returns 20 ; It is a 3d array containing the mas associated to the 2d sill depth array 30 21 ; profondeurs seuil 31 22 ; 32 ; COMMON BLOCKS:33 ; 23 ; @uses 24 ; common.pro 34 25 ; 35 ; SIDE EFFECTS: 26 ; @history 27 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 28 ; 17/6/1999 36 29 ; 37 ; RESTRICTIONS: 30 ; @version 31 ; $Id$ 38 32 ; 39 ; EXAMPLE:40 ;41 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr)42 ; 17/6/199943 33 ;- 44 34 ;------------------------------------------------------------ … … 50 40 compile_opt idl2, strictarrsubs 51 41 ; 52 tempsun = systime(1) ; pour key_performance42 tempsun = systime(1) ; For key_performance 53 43 @common 54 44 ;------------------------------------------------------------ 55 ; on transforme le tableau 2d de profondeur en tableau 2d de niveaux 56 ; correspondant aux profondeurs 45 ; We transform the 2d deth value in a 2d array of levels corresponding to depthes 57 46 ;------------------------------------------------------------ 58 47 niveaux = depth2level(tab, _extra = ex) 59 48 IF niveaux[0] EQ -1 THEN return, -1 60 49 ;------------------------------------------------------------ 61 ; on transforme le tableau 2d de niveaux en tableau 3d demask50 ; We transform the 2d array in a 3d array of mask 62 51 ;------------------------------------------------------------ 63 52 mask = level2mask(niveaux) -
trunk/SRC/ToBeReviewed/CALCULS/determ2.pro
r134 r142 1 1 ;+ 2 ; NAME:determ23 2 ; 4 ; PURPOSE: computes the determinant of n 2 by 2 arrays 3 ; file_comments 4 ; computes the determinant of n 2 by 2 arrays 5 ; Z2DS is an 2*2*n array 5 6 ; 6 ; CATEGORY: no DO loops and better accuracy 7 ; @categories 8 ; Without loop 9 ; 10 ; @param A {in}{required} 11 ; n element array 12 ; Defined as z2ds[0, 0, *] = z1d00 7 13 ; 8 ; CALLING SEQUENCE: 2 cases:9 ; res = determ2(z2ds)10 ; res = determ2(z1d00,z1d01,z1d10,z1d11)14 ; @param B {in}{required} 15 ; n element array 16 ; Defined as z2ds[0, 1, *] = z1d01 11 17 ; 12 ; INPUTS: 13 ; z2ds: an 2*2*n array 14 ; or 15 ; z1d00,z1d01,z1d10,z1d11: the four n elements arrays 16 ; defined as: 17 ; z2ds[0, 0, *] = z1d00 18 ; z2ds[0, 1, *] = z1d01 19 ; z2ds[1, 0, *] = z1d10 20 ; z2ds[1, 1, *] = z1d11 18 ; @param C {in}{required} 19 ; n element array 20 ; Defined as z2ds[1, 0, *] = z1d10 21 21 ; 22 ; OUTPUTS: n elements array, the determinent of each 2*2 arrrays 22 ; @param D {in}{required} 23 ; n element array 24 ; Defined as z2ds[1, 1, *] = z1d11 23 25 ; 24 ; EXAMPLE: 26 ; @returns 27 ; n elements array, the determinent of each 2*2 arrrays 25 28 ; 29 ; @examples 26 30 ; a=findgen(2,2,5) 27 31 ; print, determ2(a) 28 32 ; FOR i=0,4 DO print, determ(a[*,*,i]) ; IDL solution 29 33 ; 30 ; MODIFICATION HISTORY:34 ; @history 31 35 ; S. Masson (smasson@lodyc.jussieu.fr) 32 36 ; July 11th, 2002 37 ; 38 ; @version 39 ; $Id$ 40 ; 33 41 ;- 34 42 FUNCTION determ2, a, b, c, d -
trunk/SRC/ToBeReviewed/CALCULS/determ3.pro
r134 r142 1 1 ;+ 2 ; NAME:determ33 2 ; 4 ; PURPOSE: computes the determinant of n 3 by 3 arrays 3 ; @file_comments 4 ; computes the determinant of n 3 by 3 arrays. 5 ; Z2DS is an 3*3*n array 5 6 ; 6 ; CATEGORY: no DO loops and better accuracy 7 ; @categories 8 ; Without loop 7 9 ; 8 ; CALLING SEQUENCE:2 cases:9 ; res = determ2(z2ds)10 ; res = determ2(in00, in01, in02, in10, in11, in12, in20, in21, in22)10 ; @param IN00 {in}{required} 11 ; It is an n element array 12 ; defined by in00 = z2ds[0, 0, *] 11 13 ; 12 ; INPUTS: 13 ; z2ds: an 3*3*n array 14 ; or 15 ; in00, in01, in02, in10, in11, in12, in20, in21, in22: the nine n 16 ; elements arrays defined as: 17 ; in00 = z2ds[0, 0, *] 18 ; in01 = z2ds[0, 1, *] 19 ; in02 = z2ds[0, 2, *] 20 ; in10 = z2ds[1, 0, *] 21 ; in11 = z2ds[1, 1, *] 22 ; in12 = z2ds[1, 2, *] 23 ; in20 = z2ds[2, 0, *] 24 ; in21 = z2ds[2, 1, *] 25 ; in22 = z2ds[2, 2, *] 14 ; @param IN01 {in}{required} 15 ; It is an n element array 16 ; defined by in01 = z2ds[0, 1, *] 26 17 ; 27 ; OUTPUTS: n elements array, the determinent of each 3*3 arrrays 18 ; @param IN02 {in}{required} 19 ; It is an n element array 20 ; defined by in02 = z2ds[0, 2, *] 28 21 ; 29 ; EXAMPLE: 22 ; @param IN10 {in}{required} 23 ; It is an n element array 24 ; defined by in10 = z2ds[1, 0, *] 30 25 ; 26 ; 27 ; @param IN11 {in}{required} 28 ; It is an n element array 29 ; defined by in11 = z2ds[1, 1, *] 30 ; 31 ; 32 ; @param IN12 {in}{required} 33 ; It is an n element array 34 ; defined by in12 = z2ds[1, 2, *] 35 ; 36 ; 37 ; @param IN20 {in}{required} 38 ; It is an n element array 39 ; defined by in20 = z2ds[2, 0, *] 40 ; 41 ; 42 ; @param IN21 {in}{required} 43 ; It is an n element array 44 ; defined by in21 = z2ds[2, 1, *] 45 ; 46 ; 47 ; @param IN22 {in}{required} 48 ; It is an n element array 49 ; defined by in22 = z2ds[2, 2, *] 50 ; 51 ; @returns 52 ; n elements array, the determinent of each 3*3 arrrays 53 ; 54 ; @examples 31 55 ; a=findgen(3,3,5) 32 56 ; print, determ3(a^2) 33 57 ; FOR i=0,4 DO print, determ((a[*,*,i])^2) ; IDL solution 34 58 ; 35 ; MODIFICATION HISTORY:59 ; @history 36 60 ; S. Masson (smasson@lodyc.jussieu.fr) 37 61 ; July 11th, 2002 62 ; 63 ; @version 64 ; $Id$ 65 ; 38 66 ;- 39 67 FUNCTION determ3, in00, in01, in02, in10, in11, in12, in20, in21, in22 -
trunk/SRC/ToBeReviewed/CALCULS/div.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:div 6 ; 7 ; PURPOSE:calcule la divergence d'un champ 2D 8 ; 9 ; CATEGORY:calcule sur les matrices 10 ; 11 ; CALLING SEQUENCE:res=div(u,v) 12 ; 13 ; INPUTS: 14 ; u et v deux matrices representant les coordonnes d''un 15 ; champ de vecteur 16 ; 17 ; KEYWORD PARAMETERS: 18 ; 19 ; OUTPUTS:res: une matrice 2d 20 ; 21 ; COMMON BLOCKS: 22 ; common.pro 23 ; 24 ; SIDE EFFECTS: 25 ; 26 ; RESTRICTIONS: 27 ; les matrices u et v peuvent de 2 a 4 dimensions. 28 ; attention pour distinger les differents configurations de u et v 29 ; (xy, xyz, xyt, xyzt), on regarde la variable du common 30 ; -time qui contient le calendrier en jour julien d''IDL auquel 31 ; se rapportent u et v ansi que la variable 32 ; -jpt qui est le nombre de pas de temps a considerer ds time. 33 ; les tableaux u et v sont decoupes sur le meme domaine 34 ; geographique. A cause du decalage des grilles T, U, V et F il est 35 ; possiible que ces 2 tableaux n''aient pas la meme taille et se 36 ; repportent a des indices differents. Si tel est le cas les tableaux 37 ; sont redecoupes sur les indices qu'ils ont en commun et le dommaine 38 ; est redefinit pour qu'il colle a ces indices communs. 39 ; pour eviter ces redecoupes utiliser le mot cles /memeindice ds 40 ; domdef.pro 41 ; 42 ; les points sur le bord du dessin sont mis a !values.f_nan 43 ; 44 ; EXAMPLE: 45 ; 46 ; MODIFICATION HISTORY:Guillaume Roullet (grlod@ipsl.jussieu.fr) 5 ; 6 ; @file_comments 7 ; calculation of the divergence of a 2d field 8 ; 9 ; @categories 10 ; Calculation on matrixes 11 ; 12 ; @param UU 13 ; Matrix representing coordinates of a field of vectors 14 ; 15 ; @param VV 16 ; Matrix representing coordinates of a field of vectors 17 ; 18 ; @returns RES 19 ; A 2d matrix 20 ; 21 ; @uses 22 ; common.pro 23 ; 24 ; @restrictions 25 ; U and V matrixes can be 2 or 4d. 26 ; Beware, to discern differents configuration of U and V (xy, xyz, xyt, xyzt), 27 ; we look at the variable of the common 28 ; -time which contain the calendar in IDL julian days to which U and 29 ; V refered to, in the same way as the variable 30 ; -jpt which is the number of time's step to consider in time. 31 ; U and V arrays ae cut in the same geographic domain. Because of the gap of 32 ; T, U, V and F grids, it is possible that these two arrays hase not the same 33 ; size and refered to different indexes. In this case, arrays are recut on 34 ; common indexesand the domain is redifined to match with these common 35 ; indexes. To avoid these recuts, use the keyword /memeindice in domdef.pro 36 ; 37 ; 38 ; Points on the drawing edge are at !values.f_nan 39 ; 40 ; 41 ; @history 42 ; Guillaume Roullet (grlod@ipsl.jussieu.fr) 47 43 ; Creation : printemps 1998 48 44 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 49 45 ; adaptation pour marcher avec un domaine reduit 50 ; 12/1/2000 46 ; 12/1/2000; 47 ; 48 ; @version 49 ; $Id$ 50 ; 51 51 ;- 52 52 ;------------------------------------------------------------ … … 57 57 compile_opt idl2, strictarrsubs 58 58 ; 59 tempsun = systime(1) ; pour key_performance59 tempsun = systime(1) ; For key_performance 60 60 @common 61 61 ; … … 72 72 73 73 ;------------------------------------------------------------ 74 ; on trouve les points que u et v ont en communs74 ; We find common points between U and V 75 75 ;------------------------------------------------------------ 76 76 indicexu = (lindgen(jpi))[firstxu:firstxu+nxu-1] … … 91 91 (size(u))[0] EQ 3 AND date1 EQ date2 :BEGIN 92 92 ;------------------------------------------------------------ 93 ; extraction de u et v sur le domaine qui convient93 ; extraction of U and V on the appropriated domain 94 94 ;------------------------------------------------------------ 95 95 case 1 of … … 139 139 *tmask[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1, firstzt:lastzt] 140 140 ;------------------------------------------------------------ 141 ; mise a !values.f_nan de la bordure141 ; Edging put at !values.f_nan 142 142 ;------------------------------------------------------------ 143 143 if NOT keyword_set(key_periodic) OR nx NE jpi then begin … … 154 154 if terre[0] NE -1 then zdiv[temporary(terre)] = valmask 155 155 ;------------------------------------------------------------ 156 ; pour le trace graphique156 ; For the graphic drawing 157 157 ;------------------------------------------------------------ 158 158 vargrid = 'T' … … 169 169 date1 NE date2 AND (size(u))[0] EQ 3 :BEGIN 170 170 ;------------------------------------------------------------ 171 ; extraction de u et v sur le domaine qui convient171 ; extraction of U and V on the appropriated domain 172 172 ;------------------------------------------------------------ 173 173 case 1 of … … 191 191 endcase 192 192 ;------------------------------------------------------------ 193 ; calcul de ladivergence193 ; Calculation of the divergence 194 194 ;------------------------------------------------------------ 195 195 zu = e2u[indice2d]*(umask())[indice2d+jpi*jpj*firstzt] … … 213 213 zdiv = temporary(zdiv)*(zu-shift(zu, 1, 0, 0)+zv-shift(zv, 0, 1, 0)) 214 214 ;------------------------------------------------------------ 215 ; mise a !values.f_nan de la bordure215 ; Edging put at !values.f_nan 216 216 ;------------------------------------------------------------ 217 217 if NOT keyword_set(key_periodic) OR nx NE jpi then begin … … 225 225 if terre[0] NE -1 then zdiv[temporary(terre)] = valmask 226 226 ;------------------------------------------------------------ 227 ; pour le trace graphique227 ; for the graphic drawing 228 228 ;------------------------------------------------------------ 229 229 vargrid = 'T' … … 250 250 indice3d = indice3d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1, firstzt] 251 251 ;------------------------------------------------------------ 252 ; extraction de u et v sur le domaine qui convient252 ; extraction of U and V on the appropriated domain 253 253 ;------------------------------------------------------------ 254 254 case 1 of … … 275 275 endcase 276 276 ;------------------------------------------------------------ 277 ; calcul de ladivergence277 ; Calculation of the divergence 278 278 ;------------------------------------------------------------ 279 279 zu = temporary(u)*e2u[indice2d]*(umask())[indice3d] … … 286 286 zdiv = temporary(zdiv)*tmask[indice3d]/(e1t[indice2d]*e2t[indice2d]) 287 287 ;------------------------------------------------------------ 288 ; mise a !values.f_nan de la bordure288 ; Edging put at !values.f_nan 289 289 ;------------------------------------------------------------ 290 290 if NOT keyword_set(key_periodic) OR nx NE jpi then begin … … 301 301 if terre[0] NE -1 then zdiv[temporary(terre)] = valmask 302 302 ;------------------------------------------------------------ 303 ; pour le trace graphique303 ; for the graphic drawing 304 304 ;------------------------------------------------------------ 305 305 vargrid = 'T' -
trunk/SRC/ToBeReviewed/CALCULS/floatlevel2depth.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:floatlevel2depth6 5 ; 7 ; PURPOSE: assez comparable a level2depth. C'est la fonction inverse8 ; dedepth2floatlevel6 ; @file_comments 7 ; Rather comparable to level2depth. It is the invert funcion of depth2floatlevel 9 8 ; 10 ; CATEGORY:SANS BOUCLE 9 ; @categories 10 ; Without loop 11 11 ; 12 ; CALLING SEQUENCE:res=floatlevel2depth(niveau) 13 ; 14 ; INPUTS: tableau 2d de niveaux seuil (ou une structure repondant aux 15 ; criteres de litchamp) 12 ; @param TAB 13 ; 2d array of sill levels (or a structure respecting litchamp criterions) 16 14 ; 17 ; KEYWORD PARAMETERS:18 ; /NOMASK: pour ne pas masquer les points terres15 ; @keyword NOMASK 16 ; To do not mask land points 19 17 ; 20 ; OUTPUTS: un tableau 2d contenant des profondeurs 18 ; @returns 19 ; 2d array containing depthes 21 20 ; 22 ; COMMON BLOCKS:common.pro 21 ; @uses 22 ; common.pro 23 23 ; 24 ; SIDE EFFECTS: 25 ; 26 ; RESTRICTIONS: 27 ; 28 ; EXAMPLE: 29 ; 24 ; @examples 30 25 ; IDL> a=gdept[jpk-1]/(1.*jpi*jpj)*findgen(jpi,jpj) 31 26 ; IDL> plt, 1e6*(a-floatlevel2depth(depth2floatlevel(a))),/nocontour 32 27 ; 33 ; -> champ nul a1e-6 pres28 ; ->null field at 1e-6 pres 34 29 ; 35 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 30 ; @history 31 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 36 32 ; 15/6/2000 33 ; 34 ; @version 35 ; $Id$ 36 ; 37 37 ;- 38 38 ;------------------------------------------------------------ … … 43 43 compile_opt idl2, strictarrsubs 44 44 ; 45 tempsun = systime(1) ; pourkey_performance45 tempsun = systime(1) ; To key_performance 46 46 @common 47 47 ;------------------------------------------------------------ 48 48 flevelin = litchamp(tab) 49 ; on vire les points a!values.f_nan49 ; We delete points at !values.f_nan 50 50 notanumber = where(finite(flevelin, /nan) EQ 1) 51 51 if notanumber[0] NE -1 then flevelin[notanumber] = 0 52 ; on seuil (vire les points terres a valmask par ex)52 ; We sill (delete land points at valmask for example) 53 53 flevelin = 0 > flevelin < (jpk-1) 54 ; on calcule la profondeur54 ; We caculate the depth 55 55 depthup = level2depth(floor(flevelin), /nomask) 56 56 depthlow= level2depth(ceil(flevelin), /nomask) 57 57 weight = flevelin-floor(flevelin) 58 58 res = depthup+weight*(depthlow-depthup) 59 ; on replace les points a!values.f_nan59 ; We put back points at !values.f_nan 60 60 if notanumber[0] NE -1 then res[notanumber] = !values.f_nan 61 ; on masque les points terres avalmask61 ; We mask land points at valmask 62 62 if NOT keyword_set(nomask) then begin 63 63 grille,mask -
trunk/SRC/ToBeReviewed/CALCULS/fsfzpt.pro
r134 r142 12 12 ; annex 6 freezing point of seawater F.J.Millero pp.29-35 13 13 ; checkvalue: fsfzpt=-2.588567 deg.c,for s=40.0,p=500 decibars 14 ; 15 ; @todo seb 16 ; 14 17 ;- 15 18 FUNCTION fsfzpt, pfs, pfp -
trunk/SRC/ToBeReviewed/CALCULS/grad.pro
r134 r142 26 26 ; 27 27 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 28 ; 29 ; @todo seb: remplir les truc! 30 ; 28 31 ; 29 32 ;- -
trunk/SRC/ToBeReviewed/CALCULS/grossemoyenne.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME: grossemoyenne 6 ; 7 ; PURPOSE: averages a 3- or 4-d time serie field over a selected 8 ; geographical area or along the time axis. For one ore more 9 ; selected axes (x, y, z, t) 10 ; 11 ; CATEGORY: 12 ; 13 ; CALLING SEQUENCE: result = grossemoyenne(tab,'direc',BOXZOOM=boxzoom) 14 ; 15 ; INPUTS: tab = 3 or 4d field 16 ; direc ='x' 'y' 'z' 't' 'xy' 'xz' 'yz' 'xyz' 'xt' 'yt' 'zt' 17 ; 'xyt' 'xzt' 'yzt' or 'xyzt' 18 ; 19 ; KEYWORD PARAMETERS: 20 ; 21 ; boxzoom = [xmin,xmax,ymin,ymax (,(zmin,)zmax)] pour plus 22 ; de detail cf domdef 23 ; boxzoom peut prendre 5 formes: 24 ; [vert2], [vert1, vert2],[lon1, lon2, lat1, lat2], 25 ; [lon1, lon2, lat1, lat2, vert2],[lon1, lon2, lat1, lat2, vert1,vert2] 5 ; 6 ; @file_comments 7 ; averages a 3- or 4-d time serie field over a selected 8 ; geographical area or along the time axis. For one ore more 9 ; selected axes (x, y, z, t) 10 ; 11 ; @categories 12 ; 13 ; @param TAB {in}{required} 14 ; 3 or 4d field 15 ; 16 ; @param DIREC {in}{required} 17 ; 'x' 'y' 'z' 't' 'xy' 'xz' 'yz' 'xyz' 'xt' 'yt' 'zt' 18 ; 'xyt' 'xzt' 'yzt' or 'xyzt' 19 ; 20 ; @keyword BOXZOOM 21 ; [xmin,xmax,ymin,ymax (,(zmin,)zmax)] to more details, see domdef 22 ; boxzoom can have 5 forms: 23 ; [vert2], [vert1, vert2],[lon1, lon2, lat1, lat2], 24 ; [lon1, lon2, lat1, lat2, vert2],[lon1, lon2, lat1, lat2, vert1,vert2] 26 25 ; 27 ; NAN: not a number, a activer si l''on peut faire veut 28 ; faire une moyenne sans tenir compte de certaines 29 ; valeurs masques de tab. 30 ; si les valeurs masques de tab sont la valeur consacree 31 ; par IDL (!values.f_nan), il suffit de mettre /NAN. 32 ; si les valeurs masques de tab on pour valeur a (a doit 33 ; etre differente de 1 (correspond a nan = 34 ; !values.f_nan) et de 0 (qui desactive nan). 35 ; Il faut mettre NAN=a. 36 ; Rq: en sorties les points de result qui sont NAN 37 ; auront pour valeur a ou !values.f_nan. 26 ; @keyword NAN 27 ; not a number, we activate it if we want to average without considerate some masked values of TAB. 28 ; If masked values of TAB are values consecrated by IDL(!values.f_nan), wr just have to put NAN. 29 ; If masked values of TAB are valued a (a must be different of 1, corresponding to nan = 30 ; !values.f_nan and of 0, which desactivate nan). We have to put NAN=a. 31 ; Comment: In output, rsult points which are NAN will be valued a or !values.f_nan. 38 32 ; 39 ; NODOMDEF: activer si l''on ne veut pas passer ds 40 ; domdef bien que le mot cle boxzoom soit present (comme 41 ; c''est le cas qd grossemoyenne est appelee via 42 ; checkfield) 43 ; 44 ; INTEGRATION: pour faire une integrale plutot qu''une 45 ; moyenne 46 ; 47 ; /SPATIALFIRST, when performing at the same time 48 ; spatial and temporal mean, grossemoyenne is assuming 49 ; that the mask is not changing with the time. In 50 ; consequence, grossemoyenne performs temporal mean 51 ; first and then call moyenne. Activate /SPATIALFIRST if 52 ; you want to perform the spatial mean before the 53 ; temporal mean. Note that if NAN is activated, then 54 ; SPATIALFIRST is activated automatically. 55 ; 56 ; /TEMPORALFIRST: to force to perform first temporal 57 ; mean even if nan is activated (see SPATIALFIRST 58 ; explanations...) 33 ; @keyword NODOMDEF 34 ; We activate it if we do not want to pass in domdef even if the keyword boxzoom 35 ; is present (like when grossemoyenne is called via checkfield) 36 ; 37 ; @keyword INTEGRATION 38 ; To make an integral rather than an average 39 ; 40 ; @keyword SPATIALFIRST 41 ; when performing at the same time 42 ; spatial and temporal mean, grossemoyenne is assuming 43 ; that the mask is not changing with the time. In 44 ; consequence, grossemoyenne performs temporal mean 45 ; first and then call moyenne. Activate /SPATIALFIRST if 46 ; you want to perform the spatial mean before the 47 ; temporal mean. Note that if NAN is activated, then 48 ; SPATIALFIRST is activated automatically. 49 ; 50 ; @keyword TEMPORALFIRST 51 ; to force to perform first temporal 52 ; mean even if nan is activated (see SPATIALFIRST 53 ; explanations...) 59 54 ; 60 55 ; 61 ; /WDEPTH: to specify that the field is at W depth instad of T 62 ; depth (automatically activated if vargrid eq 'W') 63 ; 64 ; OUTPUTS: 65 ; 66 ; COMMON BLOCKS: result:un tableau 67 ; common domdef 68 ; 69 ; SIDE EFFECTS: met les valeurs correspondants a la terre a 1e20 70 ; 71 ; RESTRICTIONS: 72 ; 73 ; EXAMPLE: 74 ; 75 ; MODIFICATION HISTORY: Jerome Vialard (jv@lodyc.jussieu.fr) 56 ; @keyword WDEPTH 57 ; to specify that the field is at W depth instad of T 58 ; depth (automatically activated if vargrid eq 'W') 59 ; 60 ; @uses 61 ; result:un tableau 62 ; common 63 ; domdef 64 ; 65 ; @restrictions Put values corresponding to land at 1.e20 66 ; 67 ; @history 68 ; Jerome Vialard (jv@lodyc.jussieu.fr) 76 69 ; 2/7/98 77 70 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 78 ; adaptation pour les tableaux comportants une dimension temporelle71 ; adaptation array containing a temporal dimension 79 72 ; 14/8/98 80 73 ; 15/1/98 81 ; 12/3/99 adaptation pour NAN et utilisation de TEMPORARY 74 ; 12/3/99 adaptation for NAN and utilisation of TEMPORARY 75 ; 76 ; @version 77 ; $Id$ 82 78 ;- 83 ;------------------------------------------------------------ 84 ;------------------------------------------------------------ 85 ;------------------------------------------------------------ 86 ; PLAN DU PROGRAMME: 87 ;------------------------------------------------------------ 88 ;------------------------------------------------------------ 89 ;I) preliminaires 90 ; I.1) determination des directions de moyennes d''apres direc 91 ; I.2) verification de la taille du tableau d''entree 92 ; I.3) obtention des facteurs d''echelles et du masque sur le sous 93 ; domaine concerne par la moyenne 94 ;II) moyennes pour les tableaux 3d (x,y,t) 95 ; II.1) verification de la coherence de la taille du tableau a 96 ; moyenner 97 ; II.2) renvoie sur moyenne qd une moyenne sur t est demandee 98 ; II.3) differents types de moyennes possibles 99 ;III) moyennes pour les tableaux 4d (x,y,z,t) 100 ; III.1) verification de la coherence de la taille du tableau a 101 ; moyenner 102 ; III.2) differents types de moyennes possibles 103 ;IV ) finitions 104 ; IV.1) on masque les terres par une valeur a 1e+20 105 ; IV.2) on remplace, quand nan ne 1, !values.f_nan par nan 106 ; IV.3) on revient au sous domaine initial. 107 ;------------------------------------------------------------ 108 ;------------------------------------------------------------ 109 ;------------------------------------------------------------ 79 110 80 function grossemoyenne, tab, direc, BOXZOOM = boxzoom, INTEGRATION = integration $ 111 81 , NAN = nan, NODOMDEF = nodomdef, WDEPTH = wdepth $ … … 124 94 ENDIF 125 95 ;--------------------------------------------------------- 126 tempsun = systime(1) ; pour key_performance127 ;------------------------------------------------------------ 128 ;I) prelimina ires96 tempsun = systime(1) ; For key_performance 97 ;------------------------------------------------------------ 98 ;I) preliminaries 129 99 ;------------------------------------------------------------ 130 100 dirt = 0 … … 134 104 dim = 'aa' 135 105 ;------------------------------------------------------------ 136 ; I.1) direction(s) suivants lesquelles on integre106 ; I.1) Directions(s) we follow to integrate 137 107 ;------------------------------------------------------------ 138 108 if ( strpos(direc, 't') ge 0 ) then dirt = 1 … … 144 114 IF keyword_set(temporalfirst) THEN spatialfirst = 0 145 115 ;------------------------------------------------------------ 146 ; I.2) verification de la taille du tableau d'entree116 ; I.2) verification of the input array's size 147 117 ;------------------------------------------------------------ 148 118 taille = size(tab) … … 161 131 endcase 162 132 ;------------------------------------------------------------ 163 ; I.4) obtention des facteurs d''echelles et du masque sur le sous 164 ; domaine concerne par la moyenne 165 ; redefinition du domaine ajuste a boxzoom (a 6 elements) 166 ; ceci va nous permetre de faire les calcules que sur le sous domaine 167 ; comcerne par la moyenne. domdef, suivit de grille nous donne tous 168 ; les tableaux de la grille sur le sous domaine 133 ; I.3) Obtainment of scale's factors and of the mask on the subdomain concernedby the average. 134 ; Redefinition of the domain ajusted at boxzoom (at 6 elements) 135 ; This will allowed us to calculate only in the domain concerned by the average. 136 ; Domdef, followed by grid give us all arrays of the grid on the subdomain 169 137 ;------------------------------------------------------------ 170 138 if keyword_set(boxzoom) then BEGIN … … 184 152 ENDIF 185 153 ;--------------------------------------------------------------- 186 ; attribution du mask et des tableaux de longitude et latitude...154 ; attribution of the mask and of longitude and latitude arrays... 187 155 ;--------------------------------------------------------------- 188 156 grille, mask, glam, gphi, gdep, nx, ny, nz, firstx, firsty, firstz, lastx, lasty, lastz, e1, e2, e3, WDEPTH = wdepth 189 157 ;------------------------------------------------------------ 190 ; I. 3) si dirt eq 1 on fait la moyenne temporelle et on envoie dsmoyenne158 ; I.4) if dirt equal 1, we make the temporal average and we send it in moyenne 191 159 ;------------------------------------------------------------ 192 160 if dirt EQ 1 AND NOT keyword_set(spatialfirst) then begin … … 252 220 ;------------------------------------------------------------ 253 221 ;------------------------------------------------------------ 254 ; II) Cas serie tableaux 2d(tab3d)222 ; II) Case 2d arrays series (tab3d) 255 223 ;------------------------------------------------------------ 256 224 ;------------------------------------------------------------ 257 225 if (dim eq '3d') then begin 258 226 ;--------------------------------------------------------------- 259 ; II.1) verification de la coherence de la taille du tableau a 260 ; moyenner 261 ; verification de la coherence entre la taille du tableau et le 262 ; domaine definit par domdef 263 ; le tableau en entree doit avoir soit la taille du domaine total 264 ; (jpi,jpj,jpt) soit celle du domaine reduit (nx,ny,jpt) 227 ; II.1) verification of the coherence of the array's size to average 228 ; Verification of the coherence between the array's size and the domain defined by domdef 229 ; The input array must have either the total domain's size (jpi,jpj,jpt) or this 230 ; one of the reduced domain (nx,ny,jpt) 265 231 ;--------------------------------------------------------------- 266 232 case 1 of … … 275 241 endcase 276 242 if keyword_set(nan) NE 0 then BEGIN 277 if nan NE 1 then BEGIN ; si nan n''est pas!values.f_nan278 ; on le met a!values.f_nan243 if nan NE 1 then BEGIN ; If nan is not !values.f_nan 244 ; we put it at !values.f_nan 279 245 if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ 280 246 ELSE notanumber = where(abs(res) GT abs(nan)/10.) … … 283 249 ENDIF 284 250 ;--------------------------------------------------------------- 285 ; rq IL FAUT FAIRE ATTENTION AUX CAS OU LA DIM A MOYENNER = 1, ET286 ; S'ASSURER QU'ELLE EXISTE BIEN. D'OU LES reform(...,nx,ny,...) QUI287 ; PEUVENT SEMBLER INUTILE AU DEPART251 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 252 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 253 ; LOOK USELESS AT THE BEGINNING 288 254 ;--------------------------------------------------------------- 289 255 if nx EQ 1 OR ny EQ 1 then BEGIN … … 295 261 mask = reform(mask, nx, ny, nz, /over) 296 262 ;--------------------------------------------------------------- 297 ; II.3) differents types de moyennes263 ; II.3) Different types of average 298 264 ;--------------------------------------------------------------- 299 265 if keyword_set(nan) NE 0 then msknan = finite(res) ELSE msknan = -1 … … 352 318 ;------------------------------------------------------------ 353 319 ;------------------------------------------------------------ 354 ; III) Cas serie tableaux 3d(tab4d)320 ; III) Case 3d arrays series (tab4d) 355 321 ;------------------------------------------------------------ 356 322 if (dim eq '4d') then begin 357 323 ;--------------------------------------------------------------- 358 ; III.1) verification de la coherence de la taille du tableau a 359 ; moyenner 360 ; verification de la coherence entre la taille du tableau et le 361 ; domaine definit par domdef 362 ; le tableau en entree doit avoir soit la taille du domaine total 363 ; (jpi,jpj,jpk,jpt) soit celle du domaine reduit (nx,ny,ny,jpt) 324 ; III.1) Verification of the coherence of the array to average size 325 ; Verification of the coherence between the array's size and the domain 326 ; defind by domdef 327 ; The input array must have either the total domain size (jpi,jpj,jpk,jpt) 328 ; or this one of the reduced domain (nx,ny,ny,jpt) 364 329 ;--------------------------------------------------------------- 365 330 case 1 of … … 382 347 if nx EQ 1 OR ny EQ 1 OR nz EQ 1 OR jpt EQ 1 then res = reform(res, nx, ny, nz, jpt, /over) 383 348 if keyword_set(nan) NE 0 then BEGIN 384 if nan NE 1 then BEGIN ; si nan n''est pas!values.f_nan385 ; on le met a!values.f_nan349 if nan NE 1 then BEGIN ; if nan is not !values.f_nan 350 ; we put it at !values.f_nan 386 351 if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ 387 352 ELSE notanumber = where(abs(res) GT abs(nan)/10.) … … 390 355 ENDIF 391 356 ;--------------------------------------------------------------- 392 ; rq IL FAUT FAIRE ATTENTION AUX CAS OU LA DIM A MOYENNER = 1, ET393 ; S'ASSURER QU'ELLE EXISTE BIEN. D'OU LES reform(...,nx,ny,...) QUI394 ; PEUVENT SEMBLER INUTILE AU DEPART357 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 358 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 359 ; LOOK USELESS AT THE BEGINNING 395 360 ;--------------------------------------------------------------- 396 361 if nx EQ 1 OR ny EQ 1 OR nz EQ 1 then BEGIN … … 410 375 ENDIF ELSE bottom = -1 411 376 ;--------------------------------------------------------------- 412 ; III.2) different s types de moyennes377 ; III.2) different average types 413 378 ;--------------------------------------------------------------- 414 379 IF keyword_set(nan) NE 0 THEN msknan = finite(res) ELSE msknan = -1 … … 608 573 ;------------------------------------------------------------ 609 574 ;------------------------------------------------------------ 610 ;IV ) fini tions611 ;------------------------------------------------------------ 612 ;------------------------------------------------------------ 613 ; IV.1) on masque les terres par une valeur a 1e+20575 ;IV ) finishing 576 ;------------------------------------------------------------ 577 ;------------------------------------------------------------ 578 ; IV.1) We mask land by a value equal to 1.e+20 614 579 ;------------------------------------------------------------ 615 580 valmask = 1e+20 … … 619 584 ENDIF 620 585 ;------------------------------------------------------------ 621 ; IV.2) on remplace, quand nan ne 1, !values.f_nan parnan586 ; IV.2) We replace, when nan equal 1, !values.f_nan by nan 622 587 ;------------------------------------------------------------ 623 588 if keyword_set(nan) NE 0 then BEGIN … … 630 595 ENDIF 631 596 ;------------------------------------------------------------ 632 ; IV.3) on se remplace ds le sous domaine qui etait definit a l''entree de 633 ; moyenne 597 ; IV.3) We replace in the domain whch was defined at the entry of average 634 598 ;------------------------------------------------------------ 635 599 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4grmoyenne.dat' -
trunk/SRC/ToBeReviewed/CALCULS/hdyn.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:hdyn6 5 ; 7 ; PURPOSE:calcule la hauteur dynamique par rapport a un etat de 8 ; reference pour une profondeur de reference. Cf les mots cles pour 9 ; les differentes possibilites. 10 ; Par defaut l''etat de reference est 11 ; rho=1020 et la profondeur de reference est gdepw[ka] avec ka le 12 ; premier niveau W directement au dessus de 1000 m. 6 ; @file_comments 7 ; Calculate the height by rapport to a reference state for a depth reference. 8 ; See keywords for different possibilities. By default, the state reference 9 ; is rho=1020 and the depth reference is gdepw[ka] with ka the first W level 10 ; directly above 1000 m. 13 11 ; 14 ; CATEGORY: calculs de post-traitement 12 ; @categories 13 ; Post-traiment calculation 15 14 ; 16 ; CALLING SEQUENCE:res=hdyn(sn,tn) 15 ; @param TABSN {in}{required} 16 ; array representing the salinity 17 17 ; 18 ; INPUTS:sn et tn sont des tableaux de meme taille representant la19 ; salinite et la temperature.18 ; @param TABTN {in}{required} 19 ; array representing the temperature.Has the same size than SN 20 20 ; 21 ; KEYWORD PARAMETERS: 21 ; @keyword GILL We activate this key if we want to calculate the dinamic height 22 ; like in the GILL page 215, which means by rapport to a reference state which 23 ; vary in depth and which is determinated by a reference temperature tref at 0°C 24 ; and a reference salinity sref at 35psu 22 25 ; 23 ; GILL: activer cette cle si on veut faire le calcul de la 24 ; hauteur dynamique comme ds le GILL page 215 cad par rapport a 25 ; un etat de reference qui varie en profondeur et qui est 26 ; determine par une temperature de reference tref a 0 degre et 27 ; une salinite de reference sref a 35psu 26 ; @keyword LEVEL 27 ; It is the same reference level to take. This level is defined like 28 ; that gdepw[level] is the reference depth 29 ; 30 ; @keyword SREF 31 ; Give a value to this keyword to change the reference salinity used in the 32 ; calculation when GILL is activated. 33 ; 34 ; @keyword TREF 35 ; Give a value to this keyword to change the reference temperature used in the 36 ; calculation when GILL is activated. 37 ; 38 ; @keyword PROFREF 39 ; Give a depth to this keyword which will be considerated as the refeence depth 40 ; (in this case, LEVEL has not any effect). the calculation will be effectuated 41 ; until this depth effecting an interpolation between the the last W level above 42 ; PROFREF and PROFREF. 28 43 ; 29 ; LEVEL: C''est le niveau de reference a prendre. Ce niveau est 30 ; definit tel que gdepw[level] est la profondeur de reference 44 ; @keyword SURFACE_LEVEL 45 ; It is the level where we wan to calculate the dynamic height. By default, it is 46 ; the level 0. 31 47 ; 32 ; SREF: donner une valeur a ce mot cle pour changer la salinite 33 ; de reference utiliser ds le calcul lorsque GILL est active. 34 ; 35 ; TREF: donner une valeur a ce mot cle pour changer la temperature 36 ; de reference utiliser ds le calcul lorsque GILL est active. 48 ; @returns 49 ; An array of the same size of sn and tn representing the dynamic height calculated 50 ; from a reference depth nd by rapport to a reference state. 37 51 ; 38 ; PROFREF: donner a ce mot cle une profondeur qui sera prise comme 39 ; la profondeur de reference (ds ce cas LEVEL n'' a aucun 40 ; effet). le calcul sera alors effectue jusqu''a cette 41 ; profondeur en effectuant une interpolation entre le dernier 42 ; niveau W au dessus de PROFREF et PROFREF. 52 ; @uses 53 ; common.pro 43 54 ; 44 ; SURFACE_LEVEL: C''est le niveau auquel on veut calculer la 45 ; hauteur dynamique. Par defaut c''est le niveau 0. 55 ; @restrictions 56 ; Points for which we can not calculate the dynamic height (whose the batymetry 57 ; is less deep than the reference depth) are put at the value !values.f_nan 46 58 ; 47 ; OUTPUTS:un tableau de la meme taille que sn et tn representant la 48 ; hauteur dynamique calculee a partir d''une profondeur de reference 49 ; et par rapport a un etat de reference. 59 ; @restrictions 60 ; approximation: The pressure in decibars is equal to the depth in meters (the pressure increase of 1bar all 10m) 50 61 ; 51 ; COMMON BLOCKS:52 ; common.pro62 ; @history 63 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 53 64 ; 54 ; SIDE EFFECTS: 55 ; les points pour lesquels on nje peut calcule la hauteur dynamique 56 ; (dont la batymetrie est moins profonde que la profondeur de 57 ; reference) sont mis a la valeur !values.f_nan 58 ; 59 ; RESTRICTIONS:approximation: la pression en decibars est egale a la 60 ; profondeur en metres (la pression augmente de 1bar tous les 10m) 61 ; 62 ; EXAMPLE: 63 ; 64 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 65 ; @version 66 ; $Id$ 65 67 ; 66 68 ;- … … 72 74 compile_opt idl2, strictarrsubs 73 75 ; 74 tempsun = systime(1) ; pour key_performance76 tempsun = systime(1) ; for key_performance 75 77 @common 76 78 77 79 if NOT keyword_set(surface_level) then surface_level = 0 78 ; u tile si GILL est active80 ; useful if GILL is activated 79 81 if NOT keyword_set(tref) then tref = 0. 80 82 if NOT keyword_set(sref) then sref = 35. 81 ; on determine si besoin est la profondeur de reference et le niveau 82 ; W situe directement au dessus. 83 ; If needed, we determinate the reference depth and the W level situated directly above. 83 84 if keyword_set(profref) then begin 84 85 rien = where(gdepw LE profref, level) -
trunk/SRC/ToBeReviewed/CALCULS/level2depth.pro
r134 r142 4 4 ;------------------------------------------------------------ 5 5 ;+ 6 ; NAME:level2depht7 6 ; 8 ; PURPOSE: permet de passer d''un tableau 2d de niveau au9 ; tableau 2d de profondeur correspondant a ces niveaux7 ; @file_comments 8 ; Allows to pass from a 2d level array to a 2d depth array corresponding o these levels 10 9 ; 11 ; CATEGORY: SANS BOUCLE 10 ; @categories 11 ; Without loop 12 12 ; 13 ; CALLING SEQUENCE: res=level2depth(niveau) 13 ; @param TAB {in}{required} 14 ; 2d level array of sill levels (or a structure respecting litchamp criterions) 14 15 ; 15 ; INPUTS: niveau tableau 2d de niveaux seuil (ou une structure repondant16 ; aux criteres de litchamp)16 ; @keyword NOMASK 17 ; To do not mask land points. 17 18 ; 18 ; KEYWORD PARAMETERS:19 ; /NOMASK: pour ne pas masquer les points terres19 ; @returns 20 ; 2d array containing depthes 20 21 ; 21 ; OUTPUTS: un tableau 2d contenant des profondeurs 22 ; @uses 23 ; common.pro 22 24 ; 23 ; COMMON BLOCKS: 24 ; common.pro 25 ; 26 ; SIDE EFFECTS: 27 ; 28 ; RESTRICTIONS: 29 ; 30 ; EXAMPLE: 31 ; 32 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 25 ; @history 26 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 33 27 ; 17/6/1999 34 28 ; 14/6/2000 accepte !values.f_nan 29 ; 30 ; @version 31 ; $Id$ 32 ; 35 33 ;- 36 34 ;------------------------------------------------------------ … … 41 39 compile_opt idl2, strictarrsubs 42 40 ; 43 tempsun = systime(1) ; pourkey_performance41 tempsun = systime(1) ; To key_performance 44 42 @common 45 43 ;------------------------------------------------------------ 46 ; lecture du champ d''entree et recuperation de la taille du sous 47 ; domaine utilise 44 ; Reading of the input field and recovery of the used subdomain's size 48 45 ;------------------------------------------------------------ 49 46 niveaux = litchamp(tab) 50 47 grille,mask, -1, -1,gdep,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz 51 48 ;--------------------------------------------------------------- 52 ; verification de la coherence entre la taille du tableau et le domaine definit pardomdef49 ; verification of the coherence between array's size and the domain definied by domdef 53 50 ;--------------------------------------------------------------- 54 51 taille = size(niveaux) -
trunk/SRC/ToBeReviewed/CALCULS/level2index.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:level2index6 5 ; 7 ; PURPOSE: on veut ds une matrice 3d extraire un tableau 2d (x,y) dont 8 ; chacun des elements a ete extrait a un niveau specifie par le 9 ; tableau 2d level (typiquement, on veut obtenir la salinite le long 10 ; d''une isopycne que l''on a reperee par son niveau). 11 ; level2index est une fonction qui donne en fonction de level un 12 ; tableau 2d d'indice qui permettra d''extraire le tableau 2d du 13 ; tableau 3d... 6 ; @file_comments 7 ; We want, from a 3d matrix, to extract a 2d (x,y) array whose each element 8 ; has been extract from a level specified by the 2d level array (typically, 9 ; we want to obtain the salinity along an isopycn we have repered by its level). 10 ; level2index is a function who give, in function of level, a 2d indexes array 11 ; which will allow to extract the 2d array from the 3d array... 14 12 ; 15 ; CATEGORY: SANS BOUCLE 13 ; @categories 14 ; without loop 16 15 ; 17 ; CALLING SEQUENCE: index=level2index(level) 18 ; 19 ; INPUTS:level: un tableau 2d de niveaux 16 ; @param LEVEL {in}{required} 17 ; A 2d level array 20 18 ; 21 ; KEYWORD PARAMETERS: 19 ; @returns 20 ; a 2d indexes array 22 21 ; 23 ; OUTPUTS: untableau 2d d''indices 22 ; @history 23 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 24 ; 24/11/1999 24 25 ; 25 ; COMMON BLOCKS: 26 ; @version 27 ; $Id$ 26 28 ; 27 ; SIDE EFFECTS:28 ;29 ; RESTRICTIONS:30 ;31 ; EXAMPLE:32 ;33 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr)34 ; 24/11/199935 29 ;- 36 30 ;------------------------------------------------------------ … … 38 32 ;------------------------------------------------------------ 39 33 FUNCTION level2index, level 40 ; un elements de tableau 3d (dont les 2 premieres dimensions sont nx et 41 ; ny) dont les coordonnes sont i, j et k a pour indice ds le meme 42 ; tableau 3d i + j*nx + k*(nx*ny) 43 ; level etant donne, pour chaque points de level on connait i, j et k, 44 ; on peut donc calculer l''indice. 34 ; An element of 3d array (whose the two first dimensions are nx and ny) whose 35 ; coordinates are i, j and k have for index in the same 3d array i + j*nx + k*(nx*ny) 36 ; level given, for each point of level, we know i, j et k, 37 ; so we can calculate the index 45 38 ; 46 39 compile_opt idl2, strictarrsubs … … 49 42 nx = taille[1] 50 43 ny = taille[2] 51 ; tableauk*(nx*ny)44 ; array k*(nx*ny) 52 45 tabknxny = (nx*ny)*long(level) 53 46 ; -
trunk/SRC/ToBeReviewed/CALCULS/level2mask.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:level2mask6 5 ; 7 ; PURPOSE: permet de passer d''un tableau 2d de niveau seuil au8 ; tableau 3d de mask avec des 1 ds les niveaux au dessus du9 ; niveau seuil et des 0 en dessous (et sur).6 ; @file_comments 7 ; Allow to pass from a 2d sill level array to the 3d mask array with 1s in 8 ; levels above the sill level and 0s below (and on it) 10 9 ; 11 ; CATEGORY: SANS BOUCLE 10 ; @categories 11 ; without loop 12 12 ; 13 ; CALLING SEQUENCE: res=level2mask(niveau) 13 ; @param TAB {in}{required} 14 ; 2d level array of sill level (or a structure respecting litchamp criterions) 14 15 ; 15 ; INPUTS: niveau tableau 2d de niveaux seuil (ou une structure repondant16 ; aux criteres de litchamp)16 ; @returns 17 ; It is a 3d array containing the mask associated to the 2d sill level array 17 18 ; 18 ; KEYWORD PARAMETERS: 19 ; @uses 20 ; common.pro 19 21 ; 20 ; OUTPUTS: un tableau 3d contenant le mask associe au tableau 2d de 21 ; niveaux seuil 22 ; 23 ; COMMON BLOCKS: 24 ; common.pro 25 ; 26 ; SIDE EFFECTS: 27 ; 28 ; RESTRICTIONS: 29 ; 30 ; EXAMPLE: 31 ; 32 ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) 22 ; @history 23 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 33 24 ; 17/6/1999 34 25 ; Setp 2004: boundary level have 0 values and not 1 (as it was 35 26 ; explained before in the header). see: 36 27 ; print, array_equal(niveau, total(level2mask(niveau),3)) 28 ; 29 ; 30 ; @version 31 ; $Id$ 37 32 ; 38 33 ;- … … 45 40 compile_opt idl2, strictarrsubs 46 41 ; 47 tempsun = systime(1) ; pourkey_performance42 tempsun = systime(1) ; To key_performance 48 43 @common 49 44 ;------------------------------------------------------------ 50 ; lecture du champ d''entree et recuperation de la taille du sous 51 ; domaine utilise 45 ; Reading of the input field and recovery of the size of the used subdomain 52 46 ;------------------------------------------------------------ 53 47 niveaux = litchamp(tab) 54 48 grille,maskterre, -1, -1, -1,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz 55 49 ;--------------------------------------------------------------- 56 ; verification de la coherence entre la taille du tableau et le domaine definit par domdef50 ; verification of the coherence between the array's size and the defined by domdef domain 57 51 ;--------------------------------------------------------------- 58 52 IF ny EQ 1 THEN niveaux = reform(niveaux, nx, ny, /over) … … 66 60 ;------------------------------------------------------------ 67 61 ;------------------------------------------------------------ 68 ; on transforme le tableau 2d de niveaux en tableau 3d de mask62 ; We transform the 2d leval array in 3d mask array 69 63 ;------------------------------------------------------------ 70 64 mask = reform( niveaux[*]#(1./(indgen(nz)+1)), nx, ny, nz ) -
trunk/SRC/ToBeReviewed/CALCULS/moyenne.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME: moyenne6 ; 7 ; PURPOSE:averages a 2- or 3-d field over a selected5 ; 6 ; @file_comments 7 ; averages a 2- or 3-d field over a selected 8 8 ; geographical area and along one ore more 9 9 ; selected axes (x, y or z) 10 10 ; 11 ; CATEGORY: 12 ; 13 ; CALLING SEQUENCE: result = moyenne(tab,'direc',BOXZOOM=boxzoom) 14 ; 15 ; INPUTS: tab = 2 or 3d field 16 ; direc = 'x' 'y' 'z' 'xy' 'xz' 'yz' or 'xyz' 17 ; 18 ; KEYWORD PARAMETERS: 19 ; 20 ; BOXZOOM = [xmin,xmax,ymin,ymax (,(zmin,)zmax)] pour plus 21 ; de detail cf domdef. 22 ; boxzoom peut prendre 5 formes: 23 ; [vert2], [vert1, vert2],[lon1, lon2, lat1, lat2], 24 ; [lon1, lon2, lat1, lat2, vert2],[lon1, lon2, lat1, 25 ; lat2, vert1,vert2] 26 ; 27 ; NAN: not a number, a activer si l''on peut faire veut 28 ; faire une moyenne sans tenir compte de certaines 29 ; valeurs masques de tab. 30 ; si les valeurs masques de tab sont la valeur consacree 31 ; par IDL (!values.f_nan), il suffit de mettre /NAN. 32 ; si les valeurs masques de tab on pour valeur a (a doit 33 ; etre differente de 1 (correspond a nan = 34 ; !values.f_nan) et de 0 (qui desactive nan) 35 ; il faut mettre NAN=a. 36 ; Rq: en sorties les points de result qui sont NAN 37 ; auront pour valeur a ou !values.f_nan. 38 ; 39 ; NODOMDEF: activer si l''on ne veut pas passer ds 40 ; domdef bien que le mot cle boxzoom soit present (comme 41 ; c''est le cas qd moyenne est appelee via checkfield) 11 ; @categories 12 ; 13 ; @param TAB {in}{required} 14 ; 2 or 3d field 15 ; 16 ; @param DIREC {in}{required} 17 ; 'x' 'y' 'z' 'xy' 'xz' 'yz' or 'xyz' 18 ; 19 ; @keyword BOXZOOM 20 ; [xmin,xmax,ymin,ymax (,(zmin,)zmax)] to more details, see domdef 21 ; boxzoom can have 5 forms: 22 ; [vert2], [vert1, vert2],[lon1, lon2, lat1, lat2], 23 ; [lon1, lon2, lat1, lat2, vert2],[lon1, lon2, lat1, lat2, vert1,vert2] 24 ; 25 ; @keyword NAN 26 ; not a number, we activate it if we want to average without considerate some masked values of TAB. 27 ; If masked values of TAB are values consecrated by IDL(!values.f_nan), wr just have to put NAN. 28 ; If masked values of TAB are valued a (a must be different of 1, corresponding to nan = 29 ; !values.f_nan and of 0, which desactivate nan). We have to put NAN=a. 30 ; Comment: In output, rsult points which are NAN will be valued a or !values.f_nan. 42 31 ; 43 ; INTEGRATION: pour faire une integrale plutot qu''une moyenne 32 ; @keyword NODOMDEF 33 ; We activate it if we do not want to pass in domdef even if the keyword boxzoom 34 ; is present (like when grossemoyenne is called via checkfield) 35 ; 36 ; @keyword INTEGRATION 37 ; To make an integral rather than an average 44 38 ; 45 ; /WDEPTH: to specify that the field is at W depth instad of T 46 ; depth (automatically activated if vargrid eq 'W') 39 ; @keyword WDEPTH 40 ; to specify that the field is at W depth instad of T 41 ; depth (automatically activated if vargrid eq 'W') 47 42 ; 48 ; OUTPUTS: result:un tableau 49 ; 50 ; COMMON BLOCKS: 51 ; common domdef 52 ; 53 ; SIDE EFFECTS:met les valeurs correspondants a la terre a 1e20 54 ; 55 ; RESTRICTIONS: 56 ; 57 ; EXAMPLE: 58 ; 59 ; MODIFICATION HISTORY: Jerome Vialard (jv@lodyc.jussieu.fr) 43 ; @returns 44 ; An array 45 ; 46 ; @uses 47 ; common 48 ; domdef 49 ; 50 ; @restrictions Put values corresponding to land at 1.e20 51 ; 52 ; @history 53 ; Jerome Vialard (jv@lodyc.jussieu.fr) 60 54 ; 2/7/98 61 55 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 62 ; mise au propre de certains truc (les terres...)63 56 ; 14/8/98 64 57 ; 15/1/98 65 ; 11/3/99 adaptation pour NAN 66 ; 28/7/99 moyennes tableaux 1d 58 ; 11/3/99 adaptation for NAN 59 ; 28/7/99 Averages 1d arrays 60 ; 61 ; @version 62 ; $Id$ 63 ; 67 64 ;- 68 ;------------------------------------------------------------ 69 ;------------------------------------------------------------ 70 ; PLAN DU PROGRAMME: 71 ;------------------------------------------------------------ 72 ;------------------------------------------------------------ 73 ;I) preliminaires 74 ; I.1) determination des directions de moyennes d''apres direc 75 ; I.2) verification de la taille du tableau d''entree 76 ; I.3) obtention des facteurs d''echelles et du masque sur le sous 77 ; domaine concerne par la moyenne 78 ; ) moyennes pour les tableaux 1d (x,y) 79 ;II) moyennes pour les tableaux 2d (x,y) 80 ; II.1) verification de la coherence de la taille du tableau a 81 ; moyenner 82 ; II.2) differents types de moyennes possibles 83 ;III) moyennes pour les tableaux 3d (x,y,z) 84 ; III.1) verification de la coherence de la taille du tableau a 85 ; moyenner 86 ; III.2) differents types de moyennes possibles 87 ;IV ) finitions 88 ; IV.1) on masque les terres par une valeur a 1e+20 89 ; IV.2) on remplace, quand nan ne 1, !values.f_nan par nan 90 ; IV.3) on revient au sous domaine initial. 91 ;------------------------------------------------------------ 92 ;------------------------------------------------------------ 65 93 66 function moyenne, tab, direc, BOXZOOM = boxzoom, INTEGRATION = integration $ 94 67 , NAN = nan, NODOMDEF = nodomdef, WDEPTH = wdepth $ … … 106 79 ENDIF 107 80 ;--------------------------------------------------------- 108 tempsun = systime(1) ; pourkey_performance109 ;------------------------------------------------------------ 110 ;I) prelimina ires81 tempsun = systime(1) ; To key_performance 82 ;------------------------------------------------------------ 83 ;I) preliminaries 111 84 ;------------------------------------------------------------ 112 85 dirt = 0 … … 115 88 dirz = 0 116 89 ;------------------------------------------------------------ 117 ; I.1) direction(s) suivants lesquelles on integre90 ; I.1) Directions(s) we follow to integrate 118 91 ;------------------------------------------------------------ 119 92 if ( strpos(direc, 't') ge 0 ) then dirt = 1 … … 123 96 if (dirx eq 0 and diry eq 0 and dirz eq 0) then return, tab 124 97 ;------------------------------------------------------------ 125 ; I.2) verification de la taille du tableau d'entree98 ; I.2) verification of the input array's size 126 99 ;------------------------------------------------------------ 127 100 taille = size(tab) … … 139 112 endcase 140 113 ;------------------------------------------------------------ 141 ; I.3) obtention des facteurs d''echelles et du masque sur le sous 142 ; domaine concerne par la moyenne 143 ; redefinition du domaine ajuste a boxzoom (a 6 elements) 144 ; ceci va nous permetre de faire les calcules que sur le sous domaine 145 ; comcerne par la moyenne. domdef, suivit de grille nous donne tous 146 ; les tableaux de la grille sur le sous domaine 114 ; I.3) Obtainment of scale's factors and of the mask on the subdomain concernedby the average. 115 ; Redefinition of the domain ajusted at boxzoom (at 6 elements) 116 ; This will allowed us to calculate only in the domain concerned by the average. 117 ; Domdef, followed by grid give us all arrays of the grid on the subdomain 147 118 ;------------------------------------------------------------ 148 119 if keyword_set(boxzoom) then BEGIN … … 162 133 ENDIF 163 134 ;--------------------------------------------------------------- 164 ; attribution du mask et des tableaux de longitude et latitude...135 ; attribution of the mask and of longitude and latitude arrays... 165 136 ;--------------------------------------------------------------- 166 137 IF vargrid EQ 'W' THEN wdepth = 1 … … 168 139 ;------------------------------------------------------------ 169 140 ;------------------------------------------------------------ 170 ; II) Cas du tableau 1d141 ; II) Case of the 1d array 171 142 ;------------------------------------------------------------ 172 143 ;------------------------------------------------------------ … … 177 148 ENDIF 178 149 case 1 of 179 nx EQ 1 AND ny EQ 1:BEGIN ;vect eur suivantz150 nx EQ 1 AND ny EQ 1:BEGIN ;vector following z 180 151 case n_elements(tab) of 181 152 jpk:res = tab[firstz:lastz] … … 194 165 ENDELSE 195 166 END 196 ny EQ 1:BEGIN ;vect eur suivantx167 ny EQ 1:BEGIN ;vector following x 197 168 case n_elements(tab) of 198 169 jpi:res = tab[firstx:lastx] … … 211 182 ENDELSE 212 183 END 213 nx EQ 1:BEGIN ;vect eur suivanty184 nx EQ 1:BEGIN ;vector following y 214 185 case n_elements(tab) of 215 186 jpj:res = tab[firsty:lasty] … … 232 203 ;------------------------------------------------------------ 233 204 ;------------------------------------------------------------ 234 ; II) Cas du tableau 2d205 ; II) Case of the 2d array 235 206 ;------------------------------------------------------------ 236 207 ;------------------------------------------------------------ 237 208 if (dim eq '2d') then begin 238 209 ;--------------------------------------------------------------- 239 ; II.1) verification de la coherence de la taille du tableau a 240 ; moyenner 241 ; verification de la coherence entre la taille du tableau et le 242 ; domaine definit par domdef 243 ; le tableau en entree doit avoir soit la taille du domaine total 244 ; (jpi,jpj) soit celle du domaine reduit (nx,ny) 210 ; II.1) verification of the coherence of the array's size to average 211 ; Verification of the coherence between the array's size and the domain defined by domdef 212 ; The input array must have either the total domain's size (jpi,jpj) or this 213 ; one of the reduced domain (nx,ny) 245 214 ;--------------------------------------------------------------- 246 215 case 1 of … … 254 223 ENDCASE 255 224 if keyword_set(nan) NE 0 then BEGIN 256 if nan NE 1 then BEGIN ; si nan n''est pas!values.f_nan257 ; on le met a!values.f_nan225 if nan NE 1 then BEGIN ; If nan is not !values.f_nan 226 ; we put it at !values.f_nan 258 227 if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ 259 228 ELSE notanumber = where(abs(res) GT abs(nan)/10.) … … 262 231 ENDIF 263 232 ;--------------------------------------------------------------- 264 ; rq IL FAUT FAIRE ATTENTION AUX CAS OU LA DIM A MOYENNER = 1, ET265 ; S'ASSURER QU'ELLE EXISTE BIEN. D'OU LES reform(...,nx,ny,...) QUI266 ; PEUVENT SEMBLER INUTILE AU DEPART233 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 234 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 235 ; LOOK USELESS AT THE BEGINNING 267 236 ;--------------------------------------------------------------- 268 237 if nx EQ 1 OR ny EQ 1 then BEGIN … … 274 243 mask = reform(mask, nx, ny, nz, /over) 275 244 ;--------------------------------------------------------------- 276 ; II.3) differents types de moyennes245 ; II.3) Different types of average 277 246 ;--------------------------------------------------------------- 278 247 mask = mask[*, *, 0] … … 330 299 ;------------------------------------------------------------ 331 300 ;------------------------------------------------------------ 332 ; III) Cas du tableau 3d301 ; III) Case 3d arrays series (tab4d) 333 302 ;------------------------------------------------------------ 334 303 ;------------------------------------------------------------ 335 304 if (dim eq '3d') then begin 336 305 ;--------------------------------------------------------------- 337 ; III.1) verification de la coherence de la taille du tableau a 338 ; moyenner 339 ; verification de la coherence entre la taille du tableau et le 340 ; domaine definit par domdef 341 ; le tableau en entree doit avoir soit la taille du domaine total 342 ; (jpi,jpj,jpk) soit celle du domaine reduit (nx,ny,ny) 306 ; III.1) Verification of the coherence of the array to average size 307 ; Verification of the coherence between the array's size and the domain 308 ; defind by domdef 309 ; The input array must have either the total domain size (jpi,jpj,jpk) 310 ; or this one of the reduced domain (nx,ny,ny) 343 311 ;--------------------------------------------------------------- 344 312 case 1 of … … 356 324 endcase 357 325 if keyword_set(nan) NE 0 then BEGIN 358 if nan NE 1 then BEGIN ; si nan n''est pas!values.f_nan359 ; on le met a!values.f_nan326 if nan NE 1 then BEGIN ; if nan is not !values.f_nan 327 ; we put it at !values.f_nan 360 328 if abs(nan) LT 1e6 then notanumber = where(res EQ nan) $ 361 329 ELSE notanumber = where(abs(res) GT abs(nan)/10.) … … 364 332 ENDIF 365 333 ;--------------------------------------------------------------- 366 ; rq IL FAUT FAIRE ATTENTION AUX CAS OU LA DIM A MOYENNER = 1, ET367 ; S'ASSURER QU'ELLE EXISTE BIEN. D'OU LES reform(...,nx,ny,...) QUI368 ; PEUVENT SEMBLER INUTILE AU DEPART334 ; Comment : WE HAVE TO BE CAREFUL ABOUT CASES WHERE THE DIMENSION TO AVERAGE = 1, 335 ; AND MAKE SURE THAT IT EXIST. THAT IS WHY WE USE reform(...,nx,ny,...) WHICH CAN 336 ; LOOK USELESS AT THE BEGINNING 369 337 ;--------------------------------------------------------------- 370 338 if nx EQ 1 OR ny EQ 1 OR nz EQ 1 then BEGIN … … 387 355 ENDIF ELSE bottom = -1 388 356 ;--------------------------------------------------------------- 389 ; III.2) different s types de moyennes357 ; III.2) different average types 390 358 ;--------------------------------------------------------------- 391 359 if keyword_set(nan) NE 0 then msknan = finite(res) ELSE msknan = -1 … … 570 538 ;------------------------------------------------------------ 571 539 ;------------------------------------------------------------ 572 ;IV ) fini tions573 ;------------------------------------------------------------ 574 ;------------------------------------------------------------ 575 ; IV.1) on masque les terres par une valeur a 1e+20540 ;IV ) finishing 541 ;------------------------------------------------------------ 542 ;------------------------------------------------------------ 543 ; IV.1) We mask land by a value equal to 1.e+20 576 544 ;------------------------------------------------------------ 577 545 valmask = 1e+20 … … 581 549 ENDIF 582 550 ;------------------------------------------------------------ 583 ; IV.2) on remplace, quand nan ne 1, !values.f_nan parnan551 ; IV.2) We replace, when nan equal 1, !values.f_nan by nan 584 552 ;------------------------------------------------------------ 585 553 if keyword_set(nan) NE 0 then BEGIN … … 592 560 ENDIF 593 561 ;------------------------------------------------------------ 594 ; IV.3) on se remplace ds le sous domaine qui etait definit a l''entree de 595 ; moyenne 562 ; IV.3) We replace in the domain whch was defined at the entry of average 596 563 ;------------------------------------------------------------ 597 564 if keyword_set(savedbox) THEN restoreboxparam, 'boxparam4moyenne.dat' -
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) -
trunk/SRC/ToBeReviewed/CALCULS/projectondepth.pro
r134 r142 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:projectondepth6 5 ; 7 ; PURPOSE: routine permettant de projeter un champ 3d suivant un8 ; tableau de profondeurs.6 ; @file_comments 7 ; Allows to project a 3d field following a depth array. 9 8 ; 10 ; CATEGORY: sans boucles 9 ; @categories 10 ; without loop 11 11 ; 12 ; CALLING SEQUENCE:res=projectondepth(arrayin, depthin) 12 ; @param ARRAYIN 13 ; It is a 3d array whose 3rd dimension must be equal to jpk 13 14 ; 14 ; INPUTS: 15 ; arrayin: un tableau 3d dont la 3eme dimension doit etre egale 16 ; a jpk 17 ; depthin: un tableau 2d indiquant n chaque point a quel 18 ; profondeur projeter 15 ; @param DEPTHIN 16 ; It is a 2d array indicating for each point n, at which depth to project 19 17 ; 20 ; KEYWORD PARAMETERS:none 18 ; @returns 19 ; A 2d array which is the projection of the 3d array following depthes indicated by depthin 21 20 ; 22 ; OUTPUTS:res: un tableau 2d projection du tableau 3d suivant les23 ; profondeurs indiquees par depthin21 ; @uses 22 ; common.pro 24 23 ; 25 ; COMMON BLOCKS:common.pro 24 ; @restrictions 25 ; points at !values.f_nan impossible calculation. Land points masked at valmask. 26 26 ; 27 ; SIDE EFFECTS: points a !values.f_nan qd calcul impossible. points 28 ; terres masques a Valmask. 29 ; 30 ; RESTRICTIONS: 31 ; 32 ; EXAMPLE: 33 ; 34 ; on contruit un tableau de profondeurs possibles 27 ; @examples 28 ; we build a possible depthes array 35 29 ; IDL> a=gdept[jpk-1]/(1.*jpi*jpj)*findgen(jpi,jpj) 36 ; on contruit un tableau a projeter sur ces profondeurs. pour le test 37 ; on construit un tableau 3d dont chaque vecteur suivant z est la 38 ; profondeur. 30 ; We build an array to project on these depthes. For the test, 31 ; we build a 3d array whose each vector following z is the depth. 39 32 ; IDL> arraytest=replicate(1,jpi*jpj)#gdept 40 33 ; IDL> arraytest=reform(arraytest,jpi,jpj,jpk, /over) 41 ; on test la projection du tabeau profondeur sur la profondeur...34 ; We test the projection of the depth array on the depth... 42 35 ; IDL> plt, 1e6*(a-projectondepth(arraytest,a)),/nocontour 43 ; -> champ nul a1e-6 pres36 ; ->null field at 1e-6 pres 44 37 ; 45 ; verifcation en projettant la temperature sur la profondeur de la 20 46 ; degres par exemple... 38 ; verifcation projecting the temperature of 20°C for example... 47 39 ; 48 ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) 40 ; @history 41 ; Sebastien Masson (smasson@lodyc.jussieu.fr) 49 42 ; 15/6/2000 43 ; 44 ; @version 45 ; $Id$ 46 ; 50 47 ;- 51 48 ;------------------------------------------------------------ … … 56 53 compile_opt idl2, strictarrsubs 57 54 ; 58 tempsun = systime(1) ; pourkey_performance55 tempsun = systime(1) ; To key_performance 59 56 @common 60 57 ;------------------------------------------------------------ 61 58 depth = litchamp(depthin) 62 59 array = litchamp(arrayin) 63 ; petitesverifications60 ; Small verifications 64 61 tailledepth = size(depth) 65 62 taillearray = size(array) 66 63 if tailledepth[0] NE 2 THEN return, report('Depth array must have 2 dimensions') 67 64 if taillearray[0] NE 3 THEN return, report('Array in must have 3 dimensions') 68 ; verification de la coherence entre la taille du tableau et le 69 ; domaine 65 ; verification of the coherence between array's size and the domain 70 66 grille, mask, -1, -1, -1,nx,ny,nz,firstx,firsty,firstz,lastx,lasty,lastz 71 67 case 1 of … … 84 80 ; 85 81 flevel = depth2floatlevel(depth) 86 ; on vire les points a!values.f_nan82 ; we delete points at !values.f_nan 87 83 notanumber = where(finite(flevel, /nan) EQ 1) 88 84 if notanumber[0] NE -1 then flevel[notanumber] = 0 89 ; on seuil (vire les points terres a valmask par ex)85 ; we sill (delete land points at valmask for example) 90 86 flevel = 0 > flevel < (jpk-1) 91 87 ; … … 99 95 res = res+weight*(array[indexlow]-res) 100 96 ; 101 ; on replace les points a!values.f_nan97 ; We put back points at !values.f_nan 102 98 if notanumber[0] NE -1 then res[notanumber] = !values.f_nan 103 99 if out[0] NE -1 then res[out] = !values.f_nan 104 ; on masque les points terres avalmask100 ; We mask land points at valmask 105 101 if n_elements(valmask) EQ 0 then valmask = 1e20 106 102 terre = where((temporary(mask))[*, *, 0] EQ 0) -
trunk/SRC/ToBeReviewed/CALCULS/remplit.pro
r134 r142 14 14 ; and stays at !values.f_nan. 15 15 ; 16 ; 17 ; @todo seb 16 18 ; 17 19 ;- -
trunk/SRC/ToBeReviewed/CALCULS/rhon.pro
r134 r142 7 7 ;; par seb. 8 8 ;; 9 ; 10 ; @todo seb 11 ; 9 12 ;- 10 13 FUNCTION rhon, sn, tn, INSITU = insitu, SIGMA_N = sigma_n
Note: See TracChangeset
for help on using the changeset viewer.