Changeset 303 for trunk/SRC/Interpolation
- Timestamp:
- 10/16/07 14:59:26 (17 years ago)
- Location:
- trunk/SRC/Interpolation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Interpolation/compute_fromirr_bilinear_weigaddr.pro
r297 r303 130 130 ; 131 131 alladdr = lindgen(jpio, jpjo-1) 132 alladdrm1 = shift(alladdr, -1) 133 IF ((jpio EQ 92 ) AND (jpjo EQ 76 OR jpjo EQ 75 OR jpjo EQ 74 )) OR $ 134 ((jpio EQ 182 ) AND (jpjo EQ 149 OR jpjo EQ 148 OR jpjo EQ 147 )) OR $ 135 ((jpio EQ 722 ) AND (jpjo EQ 522 OR jpjo EQ 521 OR jpjo EQ 520 )) OR $ 136 ((jpio EQ 1442) AND (jpjo EQ 1021 OR jpjo EQ 1020 OR jpjo EQ 1019)) THEN alladdrm1[jpio-1, *] = alladdr[2, *] 137 132 138 celladdr = lonarr(4, jpio*(jpjo-1)) 133 139 celladdr[0, *] = alladdr 134 celladdr[1, *] = shift(alladdr, -1)135 celladdr[2, *] = shift(alladdr + jpio, -1)136 celladdr[3, *] = alladdr+ jpio140 celladdr[1, *] = alladdrm1 141 celladdr[2, *] = temporary(alladdrm1) + jpio 142 celladdr[3, *] = temporary(alladdr) + jpio 137 143 ; 138 144 ; list the cells that have at least 1 ocean point as corner … … 153 159 ; We look for which ocean water cell contains the atmosphere water point 154 160 ; 155 delta = max([(360./jpio), (180./jpjo)])* 4.161 delta = max([(360./jpio), (180./jpjo)])* 3. 156 162 FOR n = 0L, nawater-1 DO BEGIN 157 163 ; control print … … 185 191 ; ORCA cases : orca grid is irregular only northward of 40N 186 192 CASE 1 OF 187 (jpio EQ 90 OR jpio EQ 92) AND (jpjo EQ 76 OR jpjo EQ 75 OR jpjo EQ 74 ):onsphere = yy GT 40188 (jpio EQ 180 OR jpio EQ 182) AND (jpjo EQ 149 OR jpjo EQ 148 OR jpjo EQ 147 ):onsphere = yy GT 40189 (jpio EQ 720 OR jpio EQ 722)AND (jpjo EQ 522 OR jpjo EQ 521 OR jpjo EQ 520 ):onsphere = yy GT 40193 (jpio EQ 90 OR jpio EQ 92 ) AND (jpjo EQ 76 OR jpjo EQ 75 OR jpjo EQ 74 ):onsphere = yy GT 40 194 (jpio EQ 180 OR jpio EQ 182 ) AND (jpjo EQ 149 OR jpjo EQ 148 OR jpjo EQ 147 ):onsphere = yy GT 40 195 (jpio EQ 720 OR jpio EQ 722 ) AND (jpjo EQ 522 OR jpjo EQ 521 OR jpjo EQ 520 ):onsphere = yy GT 40 190 196 (jpio EQ 1440 OR jpio EQ 1442) AND (jpjo EQ 1021 OR jpjo EQ 1020 OR jpjo EQ 1019):onsphere = yy GT 40 191 197 ELSE:onsphere = 1 … … 202 208 , xcell[2, good], ycell[2, good] $ 203 209 , xcell[1, good], ycell[1, good] $ 204 , onsphere = onsphere, newcoord = newcoord, /noprint )210 , onsphere = onsphere, newcoord = newcoord, /noprint, delta = delta, /double) 205 211 ; keep only the first cell (if the atmospheric point was located in several ocean cells) 206 212 ind = ind[0] … … 266 272 ; for all the bad points, look for a neighbor 267 273 neig = lonarr(n_elements(bad)) 268 FOR i = 0, n_elements(bad)-1 DO BEGIN 269 neig[i] = (neighbor(alon[badaddr[i]], alat[badaddr[i]], goodlon, goodlat, /sphere))[0] 274 onsphere = 1 275 FOR i = 0L, n_elements(bad)-1L DO BEGIN 276 IF (i MOD 500) EQ 0 THEN print, i 277 xtmp = alon[badaddr[i]] 278 ytmp = alat[badaddr[i]] 279 CASE 1 OF 280 ; if we are near the north pole 281 ytmp GE (90-delta):keep = where(goodlat GE 90-3*delta, cnt) 282 ; if we are near the longitude periodicity area 283 xtmp LE delta OR xtmp GE (360-delta):keep = where((goodlon LE 3*delta OR goodlon GE (360-3*delta)) $ 284 AND goodlat GE (ytmp-3*delta) AND goodlat LE (ytmp+3*delta), cnt) 285 ; other cases 286 ELSE:BEGIN 287 keep = where(goodlon GE (xtmp-3*delta) AND goodlon LE (xtmp+3*delta) $ 288 AND goodlat GE (ytmp-3*delta) AND goodlat le (ytmp+3*delta), cnt) 289 ; ORCA cases : orca grid is irregular only northward of 40N 290 CASE 1 OF 291 (jpio EQ 90 OR jpio EQ 92 ) AND (jpjo EQ 76 OR jpjo EQ 75 OR jpjo EQ 74 ):onsphere = yy GT 40 292 (jpio EQ 180 OR jpio EQ 182 ) AND (jpjo EQ 149 OR jpjo EQ 148 OR jpjo EQ 147 ):onsphere = yy GT 40 293 (jpio EQ 720 OR jpio EQ 722 ) AND (jpjo EQ 522 OR jpjo EQ 521 OR jpjo EQ 520 ):onsphere = yy GT 40 294 (jpio EQ 1440 OR jpio EQ 1442) AND (jpjo EQ 1021 OR jpjo EQ 1020 OR jpjo EQ 1019):onsphere = yy GT 40 295 ELSE: 296 ENDCASE 297 END 298 ENDCASE 299 IF cnt NE 0 THEN BEGIN 300 neig[i] = keep[(neighbor(xtmp, ytmp, goodlon[keep], goodlat[keep], sphere = onsphere))[0]] 301 ENDIF ELSE neig[i] = (neighbor(alon[badaddr[i]], alat[badaddr[i]], goodlon, goodlat, sphere = onsphere))[0] 270 302 ENDFOR 271 303 ; get the address regarding foraddr … … 274 306 foraddr[bad] = foraddr[neig] 275 307 forweight[bad, *] = forweight[neig, *] 276 endif308 ENDIF 277 309 ; transform the address of the ocean cell into the address of its 4 corners 278 310 newaaddr = celladdr[*, temporary(foraddr)] -
trunk/SRC/Interpolation/file_interp.pro
r292 r303 402 402 off = [0, 0, k] 403 403 ncdf_varget, inid, i, data, offset = off, count = incnt 404 IF n_elements(inmasksz) GE 3 THEN BEGIN 405 IF inmasksz[2] EQ indimsz[varinq.dim[2]] AND varinq.dim[2] NE ininq.recdim THEN tmpmsk = inmask[*, *, k] $ 406 ELSE tmpmsk = inmask[*, *, 0] 407 ENDIF ELSE tmpmsk = inmask[*, *, 0] 404 408 IF inmasksz[2] EQ indimsz[varinq.dim[2]] AND varinq.dim[2] NE ininq.recdim THEN tmpmsk = inmask[*, *, k] $ 405 409 ELSE tmpmsk = inmask[*, *, 0] … … 414 418 FOR k = 0, indimsz[varinq.dim[2]]-1 DO BEGIN 415 419 incnt = [indimsz[varinq.dim[0: 1]], 1, 1] 416 outcnt = [outdimsz[varinq.dim[0: 1]], 1 ]420 outcnt = [outdimsz[varinq.dim[0: 1]], 1, 1] 417 421 off = [0, 0, k, t] 418 422 ncdf_varget, inid, i, data, offset = off, count = incnt 419 IF inmasksz[2] EQ indimsz[varinq.dim[2]] THEN tmpmsk = inmask[*, *, k] ELSE tmpmsk = inmask 423 IF n_elements(inmasksz) GE 3 THEN BEGIN 424 IF inmasksz[2] EQ indimsz[varinq.dim[2]] THEN tmpmsk = inmask[*, *, k] ELSE tmpmsk = inmask 425 ENDIF ELSE tmpmsk = inmask[*, *, 0] 420 426 IF interp THEN data = call_interp2d(temporary(data), inlon, inlat, temporary(tmpmsk), outlon, outlat $ 421 427 , INIRR = inirr, METHOD = method, SMOOTH = smooth $ -
trunk/SRC/Interpolation/inquad.pro
r297 r303 33 33 ; automatically. 34 34 ; 35 ; @keyword ZOOMRADIUS {default=4} 36 ; the zoom (circle centered on the (x,y) with a radius of 37 ; zoomradius degree where we look for the quadrilateral which 38 ; contains the (x,y) point) used for the satellite projection 39 ; when /ONSPHERE is activated. 40 ; 4 seems to be the minimum which can be used. 41 ; Can be increase if the cell size is larger than 5 degrees. 35 ; @keyword DELTA {default=4} 36 ; to speed up the program, we reduce the aera where we look for potential 37 ; quadrilaterals containing (x,y). Delta defines the limit of the box 38 ; centred on (x,y) with a zonal and meridional extent of delta degrees. 42 39 ; 43 40 ; @keyword NOPRINT … … 85 82 ;- 86 83 ; 87 FUNCTION inquad, x, y, x1, y1, x2, y2, x3, y3, x4, y4, ONSPHERE = onsphere, DOUBLE = double, ZOOMRADIUS = zoomradius, NOPRINT = noprint, NEWCOORD = newcoord84 FUNCTION inquad, x, y, x1, y1, x2, y2, x3, y3, x4, y4, ONSPHERE = onsphere, DOUBLE = double, DELTA = delta, NOPRINT = noprint, NEWCOORD = newcoord 88 85 ; 89 86 compile_opt idl2, strictarrsubs … … 113 110 save = {map:!map, x:!x, y:!y, z:!z, p:!p} 114 111 ; do a satellite projection 115 IF NOT keyword_set( zoomradius) THEN zoomradius= 4116 map_set, y[0], x[0], 0, /s atellite, sat_p = [1+zoomradius*20/6371.229, 0, 0], /noerase, /iso, /noborder112 IF NOT keyword_set(delta) THEN delta = 4 113 map_set, y[0], x[0], 0, /stereo, limit = [y[0]-delta/2, x[0]-delta/2, y[0]+delta/2, x[0]+delta/2], /noerase, /iso, /noborder 117 114 ; use normal coordinates to reject cells which are out of the projection. 118 115 tmp = convert_coord(x, y, /DATA, /TO_NORMAL, DOUBLE = double) … … 218 215 ; quadrilateral. 219 216 ; row j of test corresponds to all the points localized in cell j 217 218 IF keyword_set(double) THEN one = 1.d ELSE one = 1. 219 nquad_1 = replicate(one, nquad) 220 ntofind_1 = replicate(one, ntofind) 221 x_nquad = x[*]#replicate(one, nquad) 222 y_nquad = y[*]#replicate(one, nquad) 223 220 224 test = $ 221 ; (x-x1) 222 ((x[*]#replicate(1, nquad)-replicate(1, ntofind)#x1[*]) $ 223 ; *(y2-y1) 224 *(replicate(1, ntofind)#(y2-y1)[*]) $ 225 ; GE (x2-x1) 226 GE ((replicate(1, ntofind)#(x2-x1)[*]) $ 227 ; *(y-y1) 228 *(y[*]#replicate(1, nquad)-replicate(1, ntofind)#y1[*]))) 229 ;------- 230 test = temporary(test) $ 231 ; *(x-x2) 232 *((x[*]#replicate(1, nquad)-replicate(1, ntofind)#x2[*]) $ 233 ; *(y3-y2) 234 *(replicate(1, ntofind)#(y3-y2)[*]) $ 235 ; GE (x3-x2) 236 GE ((replicate(1, ntofind)#(x3-x2)[*]) $ 237 ; *(y-y2) 238 *(y[*]#replicate(1, nquad)-replicate(1, ntofind)#y2[*]))) 239 ;------- 240 test = temporary(test) $ 241 ; *(x-x3) 242 *((x[*]#replicate(1, nquad)-replicate(1, ntofind)#x3[*]) $ 243 ; *(y4-y3) 244 *(replicate(1, ntofind)#(y4-y3)[*]) $ 245 ; GE (x4-x3) 246 GE ((replicate(1, ntofind)#(x4-x3)[*]) $ 247 ; *(y-y3) 248 *(y[*]#replicate(1, nquad)-replicate(1, ntofind)#y3[*]))) 249 ;------- 250 test = temporary(test) $ 251 ; *(x-x4) 252 *((x[*]#replicate(1, nquad)-replicate(1, ntofind)#x4[*]) $ 253 ; *(y1-y4) 254 *(replicate(1, ntofind)#(y1-y4)[*]) $ 255 ; GE (x1-x4) 256 GE ((replicate(1, ntofind)#(x1-x4)[*]) $ 257 ; *(y-y4) 258 *(y[*]#replicate(1, nquad)-replicate(1, ntofind)#y4[*]))) 225 ; (x-x1)*(y2-y1) GE (x2-x1)*(y-y1) 226 ( (x_nquad - ntofind_1#x1[*]) * (ntofind_1#(y2-y1)[*]) ) GE ( (ntofind_1#(x2-x1)[*]) * (y_nquad - ntofind_1#y1[*]) ) AND $ 227 ; *(x-x2)*(y3-y2) GE (x3-x2)*(y-y2) 228 ( (x_nquad - ntofind_1#x2[*]) * (ntofind_1#(y3-y2)[*]) ) GE ( (ntofind_1#(x3-x2)[*]) * (y_nquad - ntofind_1#y2[*]) ) AND $ 229 ; *(x-x3)*(y4-y3) GE (x4-x3)*(y-y3) 230 ( (x_nquad - ntofind_1#x3[*]) * (ntofind_1#(y4-y3)[*]) ) GE ( (ntofind_1#(x4-x3)[*]) * (y_nquad - ntofind_1#y3[*]) ) AND $ 231 ; *(x-x4)*(y1-y4) GE (x1-x4)*(y-y4) 232 ( (x_nquad - ntofind_1#x4[*]) * (ntofind_1#(y1-y4)[*]) ) GE ( (ntofind_1#(x1-x4)[*]) * (y_nquad - ntofind_1#y4[*]) ) 233 ; 234 nquad_1 = 1 & ntofind_1 = 1 & x_nquad = 1 & y_nquad = 1 ; free memory 259 235 ; 260 236 ; check test if ntofind gt 1
Note: See TracChangeset
for help on using the changeset viewer.