Changeset 226 for trunk/SRC/ToBeReviewed/CALCULS/norme.pro
- Timestamp:
- 03/16/07 10:22:26 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/CALCULS/norme.pro
r163 r226 4 4 ;+ 5 5 ; 6 ; @file_comments 6 ; @file_comments 7 7 ; calculate the norm of a field of vectors, then make a possible average. 8 8 ; Comment 1: The field of vector can be, 2d:xy, 3d: xyz or xyt, 9 9 ; 4d: xyzt 10 10 ; Comment 2: 11 ; The calculation of the norm is made before the possible spatial or 12 ; temporal average because the average of the norm is not equal to the 11 ; The calculation of the norm is made before the possible spatial or 12 ; temporal average because the average of the norm is not equal to the 13 13 ; norm of averages 14 14 … … 24 24 ; 25 25 ; @keyword BOXZOOM 26 ; boxzoom on which do the average (by default the domain selected 26 ; boxzoom on which do the average (by default the domain selected 27 27 ; by the last domdef done) 28 28 ; 29 29 ; @keyword DIREC 30 30 ; 't' 'x' 'y' 'z' 'xys' 'xz' 'yz' 'xyz' 'xt' 'yt' 'zt' 'xyt' 31 ; 'xzt' 'yzt' 'xyzt' Direction on which do averages 31 ; 'xzt' 'yzt' 'xyzt' Direction on which do averages 32 32 ; 33 33 ; @returns … … 37 37 ; common.pro 38 38 ; 39 ; @restrictions 40 ; The norm 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. 44 ; 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 39 ; @restrictions 40 ; The norm 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. 44 ; 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 48 ; a geographic domain on which fields U and V are extracted on same points 49 49 ; 50 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! 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 55 ; 56 56 ; @examples 57 ; To calculate the average of the norme of streams on all the domain 57 ; To calculate the average of the norme of streams on all the domain 58 58 ; between 0 et 50: 59 59 ; IDL> res=norme(un,vn,boxzoom=[0,50],dir='xyz') … … 90 90 ; 91 91 ;------------------------------------------------------------ 92 if keyword_set(boxzoom) then BEGIN 92 if keyword_set(boxzoom) then BEGIN 93 93 Case 1 Of 94 94 N_Elements(Boxzoom) Eq 1:bte = [lon1, lon2, lat1, lat2, 0., boxzoom[0]] … … 100 100 ENDCASE 101 101 domdef, boxzoom 102 ENDIF 102 ENDIF 103 103 ;------------------------------------------------------------ 104 104 if NOT keyword_set(direc) then direc = 0 … … 120 120 if grillev EQ '' then grillev = 'V' 121 121 IF grilleu EQ 'V' AND grillev EQ 'U' THEN inverse = 1 122 IF grilleu EQ 'T' AND grillev EQ 'T' THEN BEGIN 123 interpolle = 0 122 IF grilleu EQ 'T' AND grillev EQ 'T' THEN BEGIN 123 interpolle = 0 124 124 return, report('cas non code mais facile a faire!') 125 125 ENDIF ELSE interpolle = 1 … … 140 140 indiceyv = (lindgen(jpj))[firstyv:firstyv+nyv-1] 141 141 indicey = inter(indiceyu, indiceyv) 142 nx = n_elements(indicex) 142 nx = n_elements(indicex) 143 143 ny = n_elements(indicey) 144 144 ;---------------------------------------------------------------------------- … … 149 149 ;---------------------------------------------------------------------------- 150 150 ;---------------------------------------------------------------------------- 151 (size(u))[0] EQ 3 AND date1 EQ date2 :BEGIN 151 (size(u))[0] EQ 3 AND date1 EQ date2 :BEGIN 152 152 ;---------------------------------------------------------------------------- 153 153 indice2d = lindgen(jpi, jpj) … … 160 160 case 1 of 161 161 (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ 162 (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN 162 (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN 163 163 case (size(u))[3] OF 164 nzt:BEGIN 164 nzt:BEGIN 165 165 if nxu NE nx then $ 166 if indicex[0] EQ firstxu then u = u[0:nx-1,*,*] ELSE u = u[1: nx, *,*] 166 if indicex[0] EQ firstxu then u = u[0:nx-1,*,*] ELSE u = u[1: nx, *,*] 167 167 IF nxv NE nx THEN $ 168 168 if indicex[0] EQ firstxv then v = v[0:nx-1,*,*] ELSE v = v[1: nx, *,*] 169 169 IF nyu NE ny THEN $ 170 if indicey[0] EQ firstyu then u = u[*,0:ny-1,*] ELSE u = u[*, 1: ny,*] 170 if indicey[0] EQ firstyu then u = u[*,0:ny-1,*] ELSE u = u[*, 1: ny,*] 171 171 IF nyv NE ny THEN $ 172 172 if indicey[0] EQ firstyv then v = v[*,0:ny-1,*] ELSE v = v[*, 1: ny,*] 173 173 end 174 jpk:BEGIN 174 jpk:BEGIN 175 175 if nxu NE nx then $ 176 if indicex[0] EQ firstxu then u = u[0:nx-1, *,firstzt:lastzt] ELSE u = u[1: nx, *,firstzt:lastzt] 176 if indicex[0] EQ firstxu then u = u[0:nx-1, *,firstzt:lastzt] ELSE u = u[1: nx, *,firstzt:lastzt] 177 177 IF nxv NE nx THEN $ 178 178 if indicex[0] EQ firstxv then v = v[0:nx-1, *,firstzt:lastzt] ELSE v = v[1: nx, *,firstzt:lastzt] 179 179 IF nyu NE ny THEN $ 180 if indicey[0] EQ firstyu then u = u[*, 0:ny-1,firstzt:lastzt] ELSE u = u[*, 1: ny,firstzt:lastzt] 180 if indicey[0] EQ firstyu then u = u[*, 0:ny-1,firstzt:lastzt] ELSE u = u[*, 1: ny,firstzt:lastzt] 181 181 IF nyv NE ny THEN $ 182 182 if indicey[0] EQ firstyv then v = v[*, 0:ny-1,firstzt:lastzt] ELSE v = v[*, 1: ny,firstzt:lastzt] … … 186 186 END 187 187 (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND (size(u))[3] EQ jpk AND $ 188 (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj AND (size(u))[3] EQ jpk :BEGIN 188 (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj AND (size(u))[3] EQ jpk :BEGIN 189 189 u = u[indice3d] 190 190 v = v[indice3d] … … 209 209 if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0,*]=a 210 210 ;---------------------------------------------------------------------------- 211 ; attribution of the mask and of lo gitude and latitude arrays211 ; attribution of the mask and of longitude and latitude arrays 212 212 ;---------------------------------------------------------------------------- 213 213 mask = tmask[indice3d] … … 234 234 ;---------------------------------------------------------------------------- 235 235 ;---------------------------------------------------------------------------- 236 date1 NE date2 AND (size(u))[0] EQ 3 :BEGIN 236 date1 NE date2 AND (size(u))[0] EQ 3 :BEGIN 237 237 indice2d = lindgen(jpi, jpj) 238 238 indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] … … 242 242 case 1 of 243 243 (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ 244 (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN 244 (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN 245 245 if nxu NE nx then $ 246 if indicex[0] EQ firstxu then u = u[0:nx-1, *, *] ELSE u = u[1: nx, *, *] 246 if indicex[0] EQ firstxu then u = u[0:nx-1, *, *] ELSE u = u[1: nx, *, *] 247 247 IF nxv NE nx THEN $ 248 248 if indicex[0] EQ firstxv then v = v[0:nx-1, *, *] ELSE v = v[1: nx, *, *] 249 249 IF nyu NE ny THEN $ 250 if indicey[0] EQ firstyu then u = u[*, 0:ny-1, *] ELSE u = u[*, 1: ny, *] 250 if indicey[0] EQ firstyu then u = u[*, 0:ny-1, *] ELSE u = u[*, 1: ny, *] 251 251 IF nyv NE ny THEN $ 252 252 if indicey[0] EQ firstyv then v = v[*, 0:ny-1, *] ELSE v = v[*, 1: ny, *] 253 253 END 254 254 (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND $ 255 (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN 255 (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN 256 256 u = u[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1, *] 257 257 v = v[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1, *] … … 270 270 ;---------------------------------------------------------------------------- 271 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 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 274 ; considerated (make a small drawing) 275 275 ;---------------------------------------------------------------------------- … … 288 288 res[*,0, *]=!values.f_nan 289 289 mask = where(mask eq 0) 290 IF mask[0] NE -1 THEN BEGIN 290 IF mask[0] NE -1 THEN BEGIN 291 291 coeftps = lindgen(jpt)*nx*ny 292 292 coeftps = replicate(1, n_elements(mask))#coeftps … … 304 304 ;---------------------------------------------------------------------------- 305 305 ;---------------------------------------------------------------------------- 306 date1 NE date2 AND (size(u))[0] EQ 4:BEGIN 306 date1 NE date2 AND (size(u))[0] EQ 4:BEGIN 307 307 indice2d = lindgen(jpi, jpj) 308 308 indice2d = indice2d[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1] … … 314 314 case 1 of 315 315 (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ 316 (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN 316 (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN 317 317 case (size(u))[3] OF 318 nzt:BEGIN 318 nzt:BEGIN 319 319 if nxu NE nx then $ 320 if indicex[0] EQ firstxu then u = u[0:nx-1,*,*,*] ELSE u = u[1: nx, *,*,*] 320 if indicex[0] EQ firstxu then u = u[0:nx-1,*,*,*] ELSE u = u[1: nx, *,*,*] 321 321 IF nxv NE nx THEN $ 322 322 if indicex[0] EQ firstxv then v = v[0:nx-1,*,*,*] ELSE v = v[1: nx, *,*,*] 323 323 IF nyu NE ny THEN $ 324 if indicey[0] EQ firstyu then u = u[*,0:ny-1,*,*] ELSE u = u[*, 1: ny,*,*] 324 if indicey[0] EQ firstyu then u = u[*,0:ny-1,*,*] ELSE u = u[*, 1: ny,*,*] 325 325 IF nyv NE ny THEN $ 326 326 if indicey[0] EQ firstyv then v = v[*,0:ny-1,*,*] ELSE v = v[*, 1: ny,*,*] 327 327 end 328 jpk:BEGIN 328 jpk:BEGIN 329 329 if nxu NE nx then $ 330 if indicex[0] EQ firstxu then u = u[0:nx-1, *,firstzt:lastzt,*] ELSE u = u[1: nx, *,firstzt:lastzt,*] 330 if indicex[0] EQ firstxu then u = u[0:nx-1, *,firstzt:lastzt,*] ELSE u = u[1: nx, *,firstzt:lastzt,*] 331 331 IF nxv NE nx THEN $ 332 332 if indicex[0] EQ firstxv then v = v[0:nx-1, *,firstzt:lastzt,*] ELSE v = v[1: nx, *,firstzt:lastzt,*] 333 333 IF nyu NE ny THEN $ 334 if indicey[0] EQ firstyu then u = u[*, 0:ny-1,firstzt:lastzt,*] ELSE u = u[*, 1: ny,firstzt:lastzt,*] 334 if indicey[0] EQ firstyu then u = u[*, 0:ny-1,firstzt:lastzt,*] ELSE u = u[*, 1: ny,firstzt:lastzt,*] 335 335 IF nyv NE ny THEN $ 336 336 if indicey[0] EQ firstyv then v = v[*, 0:ny-1,firstzt:lastzt,*] ELSE v = v[*, 1: ny,firstzt:lastzt,*] … … 340 340 END 341 341 (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND (size(u))[3] EQ jpk AND $ 342 (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj AND (size(u))[3] EQ jpk :BEGIN 342 (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj AND (size(u))[3] EQ jpk :BEGIN 343 343 u = u[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1,firstzt:lastzt, *] 344 344 v = v[indicex[0]:indicex[0]+nx-1,indicey[0]:indicey[0]+ny-1,firstzt:lastzt, *] … … 356 356 if NOT keyword_set(key_periodic) OR nx NE jpi then v[*,0,*,*]=a 357 357 ;---------------------------------------------------------------------------- 358 ; attribution of the mask and of lo gitude and latitude arrays358 ; attribution of the mask and of longitude and latitude arrays 359 359 ;---------------------------------------------------------------------------- 360 360 mask = tmask[indice3d] … … 370 370 res[*,0, *, *]=!values.f_nan 371 371 mask = where(mask eq 0) 372 IF mask[0] NE -1 THEN BEGIN 372 IF mask[0] NE -1 THEN BEGIN 373 373 coeftps = lindgen(jpt)*nx*ny*nzt 374 374 coeftps = replicate(1, n_elements(mask))#coeftps … … 394 394 case 1 of 395 395 (size(u))[1] EQ nxu AND (size(u))[2] EQ nyu AND $ 396 (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN 396 (size(v))[1] EQ nxv AND (size(v))[2] EQ nyv:BEGIN 397 397 if nxu NE nx then $ 398 if indicex[0] EQ firstxu then u = u[0:nx-1, *] ELSE u = u[1: nx, *] 398 if indicex[0] EQ firstxu then u = u[0:nx-1, *] ELSE u = u[1: nx, *] 399 399 IF nxv NE nx THEN $ 400 400 if indicex[0] EQ firstxv then v = v[0:nx-1, *] ELSE v = v[1: nx, *] 401 401 IF nyu NE ny THEN $ 402 if indicey[0] EQ firstyu then u = u[*, 0:ny-1] ELSE u = u[*, 1: ny] 402 if indicey[0] EQ firstyu then u = u[*, 0:ny-1] ELSE u = u[*, 1: ny] 403 403 IF nyv NE ny THEN $ 404 404 if indicey[0] EQ firstyv then v = v[*, 0:ny-1] ELSE v = v[*, 1: ny] 405 405 END 406 406 (size(u))[1] EQ jpi AND (size(u))[2] EQ jpj AND $ 407 (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN 407 (size(v))[1] EQ jpi AND (size(v))[2] EQ jpj:BEGIN 408 408 u = u[indice2d] 409 409 v = v[indice2d] … … 429 429 ;---------------------------------------------------------------------------- 430 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 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 433 ; considerated (make a small drawing) 434 434 ;---------------------------------------------------------------------------- … … 455 455 endcase 456 456 ;------------------------------------------------------------ 457 if keyword_set(key_performance) THEN print, 'temps norme', systime(1)-tempsun 457 if keyword_set(key_performance) THEN print, 'temps norme', systime(1)-tempsun 458 458 return, res 459 459 end
Note: See TracChangeset
for help on using the changeset viewer.