Changeset 226 for trunk/SRC/Computation/grad.pro
- Timestamp:
- 03/16/07 10:22:26 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Computation/grad.pro
r168 r226 13 13 ; 3D (xyz or yt) or 4D (xyzt) array or a structure readable by litchamp 14 14 ; and containing a 2D (xy), 3D (xyz or yt) or 4D (xyzt) array. 15 ; note that the dimension of the arr y must suit the domain dimension.15 ; note that the dimension of the array must suit the domain dimension. 16 16 ; 17 17 ; @param DIREC {type=scalar string} … … 22 22 ; 23 23 ; @uses 24 ; cm_4cal, cm_4data, cm_4mmesh 24 ; cm_4cal, cm_4data, cm_4mmesh 25 25 ; 26 26 ; @restrictions 27 ; - Works only for Arakawa C-grid. 27 ; - Works only for Arakawa C-grid. 28 28 ; - When computing the gradient, the result is not on the same grid point 29 29 ; than the input data. In consequence, we update, vargrid and the grid position 30 30 ; parameters (firstx[tuvf], lastx[tuvf], nx[tuvf], firsty[tuvf], lasty[tuvf], 31 31 ; ny[tuvf], firstz[tw], lastz[tw], nz[tw]). 32 ; - points that cannot be computed (domain bo ndaries, coastline) are set to NaN32 ; - points that cannot be computed (domain boundaries, coastline) are set to NaN 33 33 ; - the common variable jpt is used to differ xyz (jpt=1) and xyt (jpt\=1) cases. 34 34 ; … … 54 54 @cm_4cal ; for jpt 55 55 @cm_4data ; for varname, vargrid, vardate, varunit, valmask 56 @cm_4mesh 56 @cm_4mesh 57 57 ;------------------------------------------------------------ 58 58 ; … … 64 64 szres = size(res) 65 65 grille, mask, glam, gphi, gdep, nx, ny, nz $ 66 , firstx, firsty, firstz, lastx, lasty, lastz 66 , firstx, firsty, firstz, lastx, lasty, lastz 67 67 ; 68 68 if n_elements(valmask) EQ 0 then valmask = 1.e20 … … 72 72 'T':BEGIN 73 73 case direc of 74 'x':BEGIN 74 'x':BEGIN 75 75 divi = e1u[firstx:lastx, firsty:lasty] 76 76 newmask = (umask())[firstx:lastx, firsty:lasty, firstz:lastz] 77 77 vargrid = 'U' 78 firstxu = firstxt & lastxu = lastxt & nxu = nxt 78 firstxu = firstxt & lastxu = lastxt & nxu = nxt 79 79 firstyu = firstyt & lastyu = lastyt & nyu = nyt 80 80 END … … 83 83 newmask = (vmask())[firstx:lastx, firsty:lasty, firstz:lastz] 84 84 vargrid = 'V' 85 firstxv = firstxt & lastxv = lastxt & nxv = nxt 85 firstxv = firstxt & lastxv = lastxt & nxv = nxt 86 86 firstyv = firstyt & lastyv = lastyt & nyv = nyt 87 87 END … … 90 90 newmask = mask 91 91 vargrid = 'W' 92 firstzw = firstzt & lastzw = lastzt & nzw = nzt 92 firstzw = firstzt & lastzw = lastzt & nzw = nzt 93 93 END 94 94 ELSE:return, report('Bad definition of direction argument') … … 97 97 'W':BEGIN 98 98 case direc of 99 'x':BEGIN 99 'x':BEGIN 100 100 divi = e1u[firstx:lastx, firsty:lasty] 101 101 newmask = (umask())[firstx:lastx, firsty:lasty, firstz:lastz] 102 102 vargrid = 'U' 103 firstxu = firstxt & lastxu = lastxt & nxu = nxt 103 firstxu = firstxt & lastxu = lastxt & nxu = nxt 104 104 firstyu = firstyt & lastyu = lastyt & nyu = nyt 105 105 END … … 108 108 newmask = (vmask())[firstx:lastx, firsty:lasty, firstz:lastz] 109 109 vargrid = 'V' 110 firstxv = firstxt & lastxv = lastxt & nxv = nxt 110 firstxv = firstxt & lastxv = lastxt & nxv = nxt 111 111 firstyv = firstyt & lastyv = lastyt & nyv = nyt 112 112 END … … 115 115 newmask = mask 116 116 vargrid = 'T' 117 firstzt = firstzw & lastzt = lastzw & nzt = nzw 117 firstzt = firstzw & lastzt = lastzw & nzt = nzw 118 118 END 119 119 ELSE:return, report('Bad definition of direction argument') … … 126 126 newmask = tmask[firstx:lastx, firsty:lasty, firstz:lastz] 127 127 vargrid = 'T' 128 firstxt = firstxu & lastxt = lastxu & nxt = nxu 128 firstxt = firstxu & lastxt = lastxu & nxt = nxu 129 129 firstyt = firstyu & lastyt = lastyu & nyt = nyu 130 130 END … … 133 133 newmask = (fmask())[firstx:lastx, firsty:lasty, firstz:lastz] 134 134 vargrid = 'F' 135 firstxf = firstxu & lastxf = lastxu & nxf = nxu 135 firstxf = firstxu & lastxf = lastxu & nxf = nxu 136 136 firstyf = firstyu & lastyf = lastyu & nyf = nyu 137 137 END … … 140 140 newmask = mask 141 141 vargrid = 'W' 142 firstzw = firstzt & lastzw = lastzt & nzw = nzt 142 firstzw = firstzt & lastzw = lastzt & nzw = nzt 143 143 END 144 144 ELSE:return, report('Bad definition of direction argument') … … 165 165 newmask = mask 166 166 vargrid = 'W' 167 firstzw = firstzt & lastzw = lastzt & nzw = nzt 167 firstzw = firstzt & lastzw = lastzt & nzw = nzt 168 168 END 169 169 ELSE:return, report('Bad definition of direction argument') … … 191 191 if land[0] NE -1 then res[temporary(land)] = !values.f_nan 192 192 case direc of 193 'x':BEGIN 193 'x':BEGIN 194 194 res = (shift(res, -1, 0)-res)/temporary(divi) 195 195 if key_periodic EQ 0 OR nx NE jpi THEN res[nx-1, *] = !values.f_nan 196 196 if vargrid EQ 'T' OR vargrid EQ 'V' then res = shift(temporary(res), 1, 0) 197 197 END 198 'y':BEGIN 198 'y':BEGIN 199 199 res = (shift(res, 0, -1)-res)/temporary(divi) 200 200 res[*, ny-1] = !values.f_nan 201 if vargrid EQ 'T' OR vargrid EQ 'U' then res = shift(temporary(res), 0, 1) 201 if vargrid EQ 'T' OR vargrid EQ 'U' then res = shift(temporary(res), 0, 1) 202 202 END 203 203 ELSE:return, report('Bad definition of direction argument for the type of array') … … 217 217 divi = (temporary(divi))[*]#replicate(1., jpt) 218 218 case direc of 219 'x':BEGIN 219 'x':BEGIN 220 220 res = (shift(res, -1, 0, 0)-res)/temporary(divi) 221 221 if key_periodic EQ 0 OR nx NE jpi THEN res[nx-1, *, *] = !values.f_nan 222 222 if vargrid EQ 'T' OR vargrid EQ 'V' then res = shift(temporary(res), 1, 0, 0) 223 223 END 224 'y':BEGIN 224 'y':BEGIN 225 225 res = (shift(res, 0, -1, 0)-res)/temporary(divi) 226 226 res[*, ny-1, *] = !values.f_nan 227 if vargrid EQ 'T' OR vargrid EQ 'U' then res = shift(temporary(res), 0, 1, 0) 227 if vargrid EQ 'T' OR vargrid EQ 'U' then res = shift(temporary(res), 0, 1, 0) 228 228 END 229 229 ELSE:return, report('Bad definition of direction argument for the type of array') … … 242 242 if land[0] NE -1 then res[temporary(land)] = !values.f_nan 243 243 case direc OF 244 'x':BEGIN 244 'x':BEGIN 245 245 divi = (temporary(divi))[*]#replicate(1., nz) 246 246 res = (shift(res, -1, 0, 0)-res)/temporary(divi) … … 248 248 if vargrid EQ 'T' OR vargrid EQ 'V' then res = shift(temporary(res), 1, 0, 0) 249 249 END 250 'y':BEGIN 250 'y':BEGIN 251 251 divi = (temporary(divi))[*]#replicate(1., nz) 252 252 res = (shift(res, 0, -1, 0)-res)/temporary(divi) 253 253 res[*, ny-1, *] = !values.f_nan 254 if vargrid EQ 'T' OR vargrid EQ 'U' then res = shift(temporary(res), 0, 1, 0) 254 if vargrid EQ 'T' OR vargrid EQ 'U' then res = shift(temporary(res), 0, 1, 0) 255 255 END 256 256 'z':BEGIN 257 257 divi = replicate(1., nx*ny)#(temporary(divi))[*] 258 258 if nx EQ 1 OR ny EQ 1 then res = reform(res, nx, ny, nz, /overwrite) 259 if vargrid EQ 'W' THEN BEGIN 259 if vargrid EQ 'W' THEN BEGIN 260 260 res = (shift(res, 0, 0, 1)-res)/temporary(divi) 261 261 res[*, *, 0] = !values.f_nan … … 279 279 ENDIF 280 280 case direc OF 281 'x':BEGIN 281 'x':BEGIN 282 282 divi = (temporary(divi))[*]#replicate(1., nz*jpt) 283 283 res = (shift(res, -1, 0, 0, 0)-res)/temporary(divi) … … 285 285 if vargrid EQ 'T' OR vargrid EQ 'V' then res = shift(temporary(res), 1, 0, 0, 0) 286 286 END 287 'y':BEGIN 287 'y':BEGIN 288 288 divi = (temporary(divi))[*]#replicate(1., nz*jpt) 289 289 res = (shift(res, 0, -1, 0, 0)-res)/temporary(divi) 290 290 res[*, ny-1, *, *] = !values.f_nan 291 if vargrid EQ 'T' OR vargrid EQ 'U' then res = shift(temporary(res), 0, 1, 0, 0) 291 if vargrid EQ 'T' OR vargrid EQ 'U' then res = shift(temporary(res), 0, 1, 0, 0) 292 292 END 293 293 'z':BEGIN … … 295 295 divi = (temporary(divi))[*]#replicate(1L, jpt) 296 296 if nx EQ 1 OR ny EQ 1 then res = reform(res, nx, ny, nz, jpt, /overwrite) 297 if vargrid EQ 'W' THEN BEGIN 297 if vargrid EQ 'W' THEN BEGIN 298 298 res = (shift(res, 0, 0, 1, 0)-res)/temporary(divi) 299 299 res[*, *, 0, *] = !values.f_nan
Note: See TracChangeset
for help on using the changeset viewer.