Changeset 399
- Timestamp:
- 07/02/09 10:38:54 (15 years ago)
- Location:
- trunk/SRC
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Grid/computegrid.pro
r371 r399 353 353 ;==================================================== 354 354 ; 355 jpiglo = long(nx) 356 jpjglo = long(ny) 357 jpkglo = long(nz) 358 IF keyword_set(romsh) THEN BEGIN 359 jpiglo = jpiglo - 1 360 jpjglo = jpjglo - 1 361 fullcgrid = 1 362 ENDIF 355 IF keyword_set(romsh) THEN fullcgrid = 1 356 CASE 1 OF 357 keyword_set(fbase2tbase):key_gridtype = 'c_f' 358 keyword_set(ubase2tbase):key_gridtype = 'c_u' 359 keyword_set(vbase2tbase):key_gridtype = 'c_v' 360 else:key_gridtype = 'c' 361 ENDCASE 362 IF strlen(key_gridtype) EQ 3 THEN fullcgrid = 1 363 ; 364 IF n_elements(xminmesh) NE 0 AND n_elements(xmaxmesh) NE 0 THEN BEGIN 365 IF nx EQ jpi AND xminmesh EQ ixminmesh AND xmaxmesh EQ ixmaxmesh THEN xalreadycut = 1 366 ENDIF 367 IF keyword_set(xalreadycut) THEN BEGIN 368 xmin = 0 369 xmax = jpi - 1 370 nxx = jpi 371 ENDIF ELSE BEGIN 372 jpiglo = long(nx) 373 IF keyword_set(romsh) THEN jpiglo = jpiglo - 1 374 IF n_elements(xminmesh) NE 0 THEN ixminmesh = long(xminmesh[0]) ELSE ixminmesh = 0l 375 IF n_elements(xmaxmesh) NE 0 THEN ixmaxmesh = long(xmaxmesh[0]) ELSE ixmaxmesh = jpiglo-1 376 IF ixmaxmesh LT 0 THEN ixmaxmesh = jpiglo -1 + ixmaxmesh 377 ixmaxmesh = 0 > ixmaxmesh < (jpiglo-1) 378 ixminmesh = 0 > ixminmesh < ixmaxmesh 379 jpi = ixmaxmesh-ixminmesh+1 380 xmin = ixminmesh 381 xmax = ixmaxmesh 382 nxx = jpiglo 383 ENDELSE 384 385 IF n_elements(yminmesh) NE 0 AND n_elements(ymaxmesh) NE 0 THEN BEGIN 386 IF ny EQ jpj AND yminmesh EQ iyminmesh AND ymaxmesh EQ iymaxmesh THEN yalreadycut = 1 387 ENDIF 388 IF keyword_set(yalreadycut) THEN BEGIN 389 ymin = 0 390 ymax = jpj - 1 391 nyy = jpj 392 ENDIF ELSE BEGIN 393 jpjglo = long(ny) 394 IF keyword_set(romsh) THEN jpjglo = jpjglo - 1 395 IF n_elements(yminmesh) NE 0 THEN iyminmesh = long(yminmesh[0]) ELSE iyminmesh = 0l 396 IF n_elements(ymaxmesh) NE 0 THEN iymaxmesh = long(ymaxmesh[0]) ELSE iymaxmesh = jpjglo-1 397 IF key_gridtype EQ 'c_v' OR key_gridtype EQ 'c_f' THEN iymaxmesh = iymaxmesh-1 398 IF iymaxmesh LT 0 THEN iymaxmesh = jpjglo -1 + iymaxmesh 399 iymaxmesh = 0 > iymaxmesh < (jpjglo-1) 400 iyminmesh = 0 > iyminmesh < iymaxmesh 401 jpj = iymaxmesh-iyminmesh+1 402 ymin = iyminmesh 403 ymax = iymaxmesh 404 nyy = jpjglo 405 ENDELSE 406 407 IF n_elements(zminmesh) NE 0 AND n_elements(zmaxmesh) NE 0 THEN BEGIN 408 IF nz EQ jpk AND zminmesh EQ izminmesh AND zmaxmesh EQ izmaxmesh THEN zalreadycut = 1 409 ENDIF 410 IF keyword_set(zalreadycut) THEN BEGIN 411 zmin = 0 412 zmax = jpk - 1 413 nzz = jpk 414 ENDIF ELSE BEGIN 415 jpkglo = long(nz) 416 IF n_elements(zminmesh) NE 0 THEN izminmesh = long(zminmesh[0]) ELSE izminmesh = 0l 417 IF n_elements(zmaxmesh) NE 0 THEN izmaxmesh = long(zmaxmesh[0]) ELSE izmaxmesh = jpkglo-1 418 IF izmaxmesh LT 0 THEN izmaxmesh = jpkglo -1 + izmaxmesh 419 izmaxmesh = 0 > izmaxmesh < (jpkglo-1) 420 izminmesh = 0 > izminmesh < izmaxmesh 421 jpk = izmaxmesh-izminmesh+1 422 zmin = izminmesh 423 zmax = izmaxmesh 424 nzz = jpkglo 425 ENDELSE 363 426 ; 364 427 ; impact of plain keyword: … … 372 435 ENDIF 373 436 ; 374 IF n_elements(xminmesh) NE 0 THEN ixminmesh = long(xminmesh[0]) ELSE ixminmesh = 0l375 IF n_elements(xmaxmesh) NE 0 THEN ixmaxmesh = long(xmaxmesh[0]) ELSE ixmaxmesh = jpiglo-1376 IF n_elements(yminmesh) NE 0 THEN iyminmesh = long(yminmesh[0]) ELSE iyminmesh = 0l377 IF n_elements(ymaxmesh) NE 0 THEN iymaxmesh = long(ymaxmesh[0]) ELSE iymaxmesh = jpjglo-1378 IF n_elements(zminmesh) NE 0 THEN izminmesh = long(zminmesh[0]) ELSE izminmesh = 0l379 IF n_elements(zmaxmesh) NE 0 THEN izmaxmesh = long(zmaxmesh[0]) ELSE izmaxmesh = jpkglo-1380 ;381 CASE 1 OF382 keyword_set(fbase2tbase):key_gridtype = 'c_f'383 keyword_set(ubase2tbase):key_gridtype = 'c_u'384 keyword_set(vbase2tbase):key_gridtype = 'c_v'385 else:key_gridtype = 'c'386 ENDCASE387 IF key_gridtype EQ 'c_v' OR key_gridtype EQ 'c_f' THEN BEGIN388 iymaxmesh = iymaxmesh-1389 ENDIF390 IF strlen(key_gridtype) EQ 3 THEN fullcgrid = 1391 ;392 IF ixmaxmesh LT 0 THEN ixmaxmesh = jpiglo -1 + ixmaxmesh393 IF iymaxmesh LT 0 THEN iymaxmesh = jpjglo -1 + iymaxmesh394 IF izmaxmesh LT 0 THEN izmaxmesh = jpkglo -1 + izmaxmesh395 437 ; avoid basics errors... 396 ixmaxmesh = 0 > ixmaxmesh < (jpiglo-1)397 ixminmesh = 0 > ixminmesh < ixmaxmesh398 iymaxmesh = 0 > iymaxmesh < (jpjglo-1)399 iyminmesh = 0 > iyminmesh < iymaxmesh400 izmaxmesh = 0 > izmaxmesh < (jpkglo-1)401 izminmesh = 0 > izminmesh < izmaxmesh402 ;403 jpi = ixmaxmesh-ixminmesh+1404 jpj = iymaxmesh-iyminmesh+1405 jpk = izmaxmesh-izminmesh+1406 438 ; 407 439 jpidta = jpiglo … … 468 500 ; force glamt to have 2 dimensions 469 501 ; 470 CASE size(reform(glamt), /n_dimensions) OF 471 0:glamt = replicate(glamt, jpi, jpj) 472 1:glamt = glamt[ixminmesh:ixmaxmesh]#replicate(1, jpj) 473 2:glamt = glamt[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh] 502 IF n_elements(glamt) EQ nxx*nyy THEN glamt = reform(glamt, nxx, nyy, /over) $ 503 ELSE glamt = reform(glamt, nxx, /over) 504 CASE size(glamt, /n_dimensions) OF 505 1:BEGIN 506 IF n_elements(glamt) EQ 1 THEN glamt = replicate(glamt[0], jpi, jpj) $ 507 ELSE glamt = glamt[xmin:xmax]#replicate(1, jpj) 508 END 509 2:glamt = glamt[xmin:xmax, ymin:ymax] 474 510 ENDCASE 475 511 ; keep 2d array even with degenerated dimension … … 498 534 ; force gphit to have 2 dimensions 499 535 ; 500 CASE size(reform(gphit), /n_dimensions) OF 501 0:gphit = replicate(gphit, jpi, jpj) 502 1:gphit = replicate(1, jpi)#gphit[iyminmesh:iymaxmesh] 503 2:gphit = gphit[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh] 536 IF n_elements(gphit) EQ nxx*nyy THEN gphit = reform(gphit, nxx, nyy, /over) $ 537 ELSE gphit = reform(gphit, nyy, /over) 538 CASE size(gphit, /n_dimensions) OF 539 1:BEGIN 540 IF n_elements(gphit) EQ 1 THEN gphit = replicate(gphit[0], jpi, jpj) $ 541 ELSE gphit = replicate(1, jpi)#gphit[ymin:ymax] 542 END 543 2:gphit = gphit[xmin:xmax, ymin:ymax] 504 544 ENDCASE 505 545 ; keep 2d array even with degenerated dimension … … 990 1030 END 991 1031 ELSE:BEGIN 992 gdept = zaxis[ izminmesh:izmaxmesh]1032 gdept = zaxis[zmin:zmax] 993 1033 IF n_elements(zreverse) EQ 0 THEN BEGIN 994 1034 IF jpk GT 1 THEN BEGIN … … 1028 1068 ; 1029 1069 if tmask[0] NE -1 then BEGIN 1070 tmask = byte(temporary(tmask)) 1030 1071 IF keyword_set(romsh) THEN tmask = tmask[0:jpiglo-1, 0:jpjglo-1] 1031 IF n_elements(mask) EQ jpiglo*jpjglo AND jpkgloGT 1 THEN BEGIN1032 tmask = tmask[*]#replicate(1 , jpkglo)1033 tmask = reform(tmask, jpiglo, jpjglo, jpkglo, /overwrite)1072 IF n_elements(mask) EQ nxx*nyy AND nzz GT 1 THEN BEGIN 1073 tmask = tmask[*]#replicate(1b, nzz) 1074 tmask = reform(tmask, nxx, nyy, nzz, /overwrite) 1034 1075 ENDIF 1035 IF jpiglo EQ 1 OR jpjglo EQ 1 THEN tmask = reform(tmask, jpiglo, jpjglo, jpkglo, /overwrite)1036 tmask = byte(tmask[ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh, izminmesh:izmaxmesh])1037 tmask = reform(tmask, jpi, jpj, jpk, /over)1076 IF nxx EQ 1 OR nyy EQ 1 OR nzz EQ 1 THEN tmask = reform(tmask, nxx, nyy, nzz, /overwrite) 1077 tmask = tmask[xmin:xmax, ymin:ymax, zmin:zmax] 1078 IF jpi EQ 1 OR jpj EQ 1 OR jpk EQ 1 THEN tmask = reform(tmask, jpi, jpj, jpk, /over) 1038 1079 if key_shift NE 0 then tmask = shift(tmask, key_shift, 0, 0) 1039 1080 ; because tmask = reverse(tmask, 2) is not working if the 3rd … … 1242 1283 ENDELSE 1243 1284 IF keyword_set(romsh) THEN $ 1244 romszinfos = {h:romsh[ ixminmesh:ixmaxmesh, iyminmesh:iymaxmesh], zeta:replicate(0., jpi, jpj), theta_s:-1, theta_b:-1, hc:-1} $1285 romszinfos = {h:romsh[xmin:xmax, ymin:ymax], zeta:replicate(0., jpi, jpj), theta_s:-1, theta_b:-1, hc:-1} $ 1245 1286 ELSE romszinfos = {h:-1, zeta:-1, theta_s:-1, theta_b:-1, hc:-1} 1246 1287 -
trunk/SRC/ReadWrite/ncdf_getaxis.pro
r391 r399 51 51 ; x/yaxis = keyword_set(start1) + findgen(jpi/jpj) 52 52 ; 53 ; @keyword XMINMESH {default=0L}{type=scalar} 54 ; Define common (cm_4mesh) variables ixminmesh used to define the localization 55 ; of the first point of the grid along the x direction in a zoom of the original grid 56 ; 57 ; @keyword YMINMESH {default=0L}{type=scalar} 58 ; Define common (cm_4mesh) variables iyminmesh used to define the localization 59 ; of the first point of the grid along the y direction in a zoom of the original grid 60 ; 61 ; @keyword XMAXMESH {default=jpiglo-1}{type=scalar} 62 ; Define common (cm_4mesh) variables ixmaxmesh used to define the localization 63 ; of the last point of the grid along the x direction in a zoom of the original grid 64 ; Note that if XMAXMESH < 0 then ixmaxmesh is defined as ixmaxmesh = jpiglo -1 + xmaxmesh 65 ; 66 ; @keyword YMAXMESH {default=jpjglo-1}{type=scalar} 67 ; Define common (cm_4mesh) variables iymaxmesh used to define the localization 68 ; of the last point of the grid along the y direction in a zoom of the original grid 69 ; Note that if YMAXMESH < 0 then iymaxmesh is defined as iymaxmesh = jpjglo -1 + ymaxmesh 70 ; 53 71 ; @keyword _EXTRA 54 72 ; Used to be able to call ncdf_getaxis with _extra … … 62 80 ;- 63 81 PRO ncdf_getaxis, fileid, dimidx, dimidy, xaxis, yaxis $ 64 , XAXISNAME=xaxisname, YAXISNAME=yaxisname $ 65 , XDIMNAME=xdimname, YDIMNAME=ydimname $ 66 , XYINDEX=xyindex, START1=start1 $ 67 , ROMSGRID=romsgrid, _EXTRA=ex 82 , XAXISNAME = xaxisname, YAXISNAME = yaxisname $ 83 , XDIMNAME = xdimname, YDIMNAME = ydimname $ 84 , XYINDEX = xyindex, START1 = start1 $ 85 , XMINMESH = xminmesh, XMAXMESH = xmaxmesh $ 86 , YMINMESH = yminmesh, YMAXMESH = ymaxmesh $ 87 , ROMSGRID = romsgrid, _EXTRA = ex 68 88 ; 69 89 compile_opt idl2, strictarrsubs 70 90 ; 71 @cm_general ; needed for iodir 72 ; 91 @cm_general ; needed for iodir 92 @cm_4mesh 93 ; 94 IF n_elements(xminmesh) NE 0 THEN ixminmesh = 0L > long(xminmesh[0]) ELSE ixminmesh = 0l 95 IF n_elements(yminmesh) NE 0 THEN iyminmesh = 0L > long(yminmesh[0]) ELSE iyminmesh = 0l 96 IF n_elements(zminmesh) NE 0 THEN izminmesh = 0L > long(zminmesh[0]) ELSE izminmesh = 0l 73 97 ; should we open the file? 74 98 IF size(fileid, /type) EQ 7 THEN $ … … 140 164 xaxisname = xinq.name 141 165 dimidx = xinq.dim[0] 142 IF xinq.ndims GE 2 THEN ncdf_diminq, cdfid, xinq.dim[1], blabla, jpjfromx 166 xoffset = lonarr(xinq.ndims) 167 xcount = lonarr(xinq.ndims) 168 FOR i = 0, xinq.ndims -1 DO BEGIN 169 ncdf_diminq, cdfid, xinq.dim[i], blabla, tmpsz 170 xcount[i] = tmpsz 171 ENDFOR 172 jpiglo = xcount[0] 173 IF n_elements(xmaxmesh) NE 0 THEN BEGIN 174 IF xmaxmesh GE 0 THEN ixmaxmesh = long(xmaxmesh[0]) ELSE ixmaxmesh = xcount[0] -1 + long(xmaxmesh[0]) 175 ENDIF ELSE ixmaxmesh = xcount[0] - 1L 176 ixmaxmesh = 0 > ixmaxmesh < (xcount[0] - 1L) ; make sure ixmaxmesh is not too big 177 xoffset[0] = ixminmesh 178 xcount[0] = ixmaxmesh - ixminmesh + 1L 179 jpifromx = xcount[0] 180 jpi = jpifromx 181 IF xinq.ndims GE 2 THEN BEGIN 182 jpjglo = xcount[1] 183 IF n_elements(ymaxmesh) NE 0 THEN BEGIN 184 IF ymaxmesh GE 0 THEN iymaxmesh = long(ymaxmesh[0]) ELSE iymaxmesh = xcount[1] - 1L + long(ymaxmesh[0]) 185 ENDIF ELSE iymaxmesh = xcount[1] - 1L 186 iymaxmesh = 0 > iymaxmesh < (xcount[1] - 1L) ; make sure ixmaxmesh is not too big 187 xoffset[1] = iyminmesh 188 xcount[1] = iymaxmesh - iyminmesh + 1L 189 jpjfromx = xcount[1] 190 jpj = jpjfromx 191 ENDIF 143 192 ENDELSE 144 IF arg_present(xdimname) THEN ncdf_diminq, cdfid, dimidx, xdimname, jpifromx193 IF arg_present(xdimname) THEN ncdf_diminq, cdfid, dimidx, xdimname, tmp 145 194 ; 146 195 IF arg_present(xaxis) THEN BEGIN 147 ncdf_diminq, cdfid, dimidx, blabla, jpifromx148 196 ; should we read or compute the xaxis? 149 197 IF keyword_set(xyindex) OR xvarid EQ -1 THEN BEGIN … … 152 200 ENDIF ELSE BEGIN 153 201 ; read the xaxis 154 ncdf_varget, cdfid, xvarid, xaxis 202 ncdf_varget, cdfid, xvarid, xaxis, offset = xoffset, count = xcount 155 203 ncdf_getatt, cdfid, xvarid, ADD_OFFSET = add_offset, SCALE_FACTOR = scale_factor 156 204 IF scale_factor NE 1. THEN xaxis = temporary(xaxis) * scale_factor … … 208 256 yinq = ncdf_varinq(cdfid, yvarid) 209 257 yaxisname = yinq.name 210 IF yinq.ndims GE 2 THEN BEGIN 211 ncdf_diminq, cdfid, yinq.dim[0], blabla, jpifromy 212 dimidy = yinq.dim[1] 213 ENDIF ELSE dimidy = yinq.dim[0] 258 IF yinq.ndims GE 2 THEN dimidy = yinq.dim[1] ELSE dimidy = yinq.dim[0] 259 yoffset = lonarr(yinq.ndims) 260 ycount = lonarr(yinq.ndims) 261 FOR i = 0, yinq.ndims -1 DO BEGIN 262 ncdf_diminq, cdfid, yinq.dim[i], blabla, tmpsz 263 ycount[i] = tmpsz 264 ENDFOR 265 idy = yinq.ndims GE 2 266 jpjglo = ycount[idy] 267 IF n_elements(ymaxmesh) NE 0 THEN BEGIN 268 IF ymaxmesh GE 0 THEN iymaxmesh = long(ymaxmesh[0]) ELSE iymaxmesh = ycount[idy] - 1L + long(ymaxmesh[0]) 269 ENDIF ELSE iymaxmesh = ycount[idy] - 1L 270 iymaxmesh = iymaxmesh < (ycount[idy] - 1L) ; make sure ixmaxmesh is not too big 271 yoffset[idy] = iyminmesh 272 ycount[idy] = iymaxmesh - iyminmesh + 1L 273 jpjfromy = ycount[idy] 274 jpj = jpjfromy 275 IF yinq.ndims GE 2 THEN BEGIN 276 jpiglo = ycount[0] 277 IF n_elements(xmaxmesh) NE 0 THEN BEGIN 278 IF xmaxmesh GE 0 THEN ixmaxmesh = long(xmaxmesh[0]) ELSE ixmaxmesh = ycount[0] - 1L + long(xmaxmesh[0]) 279 ENDIF ELSE ixmaxmesh = ycount[0] - 1L 280 ixmaxmesh = ixmaxmesh < (ycount[0] - 1L) ; make sure ixmaxmesh is not too big 281 yoffset[0] = ixminmesh 282 ycount[0] = ixmaxmesh - ixminmesh + 1L 283 jpifromy = xcount[0] 284 jpi = jpifromy 285 ENDIF 214 286 ENDELSE 215 IF arg_present(ydimname) THEN ncdf_diminq, cdfid, dimidy, ydimname, jpjfromy287 IF arg_present(ydimname) THEN ncdf_diminq, cdfid, dimidy, ydimname, tmp 216 288 ; 217 289 IF arg_present(yaxis) THEN BEGIN 218 290 IF n_elements(jpifromy) NE 0 THEN BEGIN 291 IF n_elements(jpifromx) EQ 0 THEN ncdf_diminq, cdfid, dimidx, blabla, jpifromx 219 292 IF jpifromy NE jpifromx THEN BEGIN 220 293 dummy = report('x/y axes do not have the same x dimension...') … … 222 295 ENDIF 223 296 ENDIF 224 ncdf_diminq, cdfid, dimidy, blabla, jpjfromy225 297 IF n_elements(jpjfromx) NE 0 THEN BEGIN 298 IF n_elements(jpjfromy) EQ 0 THEN ncdf_diminq, cdfid, dimidy, blabla, jpjfromy 226 299 IF jpjfromy NE jpjfromx THEN BEGIN 227 300 dummy = report(' x/y axes do not have the same y dimension...') … … 234 307 ENDIF ELSE BEGIN 235 308 ; read the yaxis 236 ncdf_varget, cdfid, yvarid, yaxis 309 ncdf_varget, cdfid, yvarid, yaxis, offset = yoffset, count = ycount 237 310 ncdf_getatt, cdfid, yvarid, ADD_OFFSET = add_offset, SCALE_FACTOR = scale_factor 238 311 IF scale_factor NE 1. THEN yaxis = temporary(yaxis) * scale_factor -
trunk/SRC/ReadWrite/ncdf_getmask.pro
r391 r399 56 56 ; 3) !Values.f_nan (can be used only with NE and EQ operators) 57 57 ; 58 ; @keyword XMINMESH {default=0L}{type=scalar} 59 ; Define common (cm_4mesh) variables ixminmesh used to define the localization 60 ; of the first point of the grid along the x direction in a zoom of the original grid 61 ; 62 ; @keyword YMINMESH {default=0L}{type=scalar} 63 ; Define common (cm_4mesh) variables iyminmesh used to define the localization 64 ; of the first point of the grid along the y direction in a zoom of the original grid 65 ; 66 ; @keyword ZMINMESH {default=0L}{type=scalar} 67 ; Define common (cm_4mesh) variables izminmesh used to define the localization 68 ; of the first point of the grid along the z direction in a zoom of the original grid 69 ; 70 ; @keyword XMAXMESH {default=jpiglo-1}{type=scalar} 71 ; Define common (cm_4mesh) variables ixmaxmesh used to define the localization 72 ; of the last point of the grid along the x direction in a zoom of the original grid 73 ; Note that if XMAXMESH < 0 then ixmaxmesh is defined as ixmaxmesh = jpiglo -1 + xmaxmesh 74 ; 75 ; @keyword YMAXMESH {default=jpjglo-1}{type=scalar} 76 ; Define common (cm_4mesh) variables iymaxmesh used to define the localization 77 ; of the last point of the grid along the y direction in a zoom of the original grid 78 ; Note that if YMAXMESH < 0 then iymaxmesh is defined as iymaxmesh = jpjglo -1 + ymaxmesh 79 ; 80 ; @keyword ZMAXMESH {default=jpkglo-1}{type=scalar} 81 ; Define common (cm_4mesh) variables izmaxmesh used to define the localization 82 ; of the last point of the grid along the z direction in a zoom of the original grid 83 ; Note that if ZMAXMESH < 0 then izmaxmesh is defined as izmaxmesh = jpkglo -1 + maxmesh 84 ; 58 85 ; @keyword 59 86 ; _EXTRA to be able to call ncdf_getmask with _extra keyword … … 80 107 , MASKNAME = maskname, USEASMASK = useasmask $ 81 108 , MISSING_VALUE = missing_value, INVMASK = invmask $ 109 , XMINMESH = xminmesh, XMAXMESH = xmaxmesh $ 110 , YMINMESH = yminmesh, YMAXMESH = ymaxmesh $ 111 , ZMINMESH = zminmesh, ZMAXMESH = zmaxmesh $ 82 112 , TESTOP = testop, _EXTRA = ex 83 113 ; 84 114 compile_opt idl2, strictarrsubs 85 115 ; 86 @cm_general ; needed for iodir 116 @cm_general ; needed for iodir 117 ; 118 IF n_elements(xminmesh) NE 0 THEN ixminmesh = 0L > long(xminmesh[0]) ELSE ixminmesh = 0l 119 IF n_elements(yminmesh) NE 0 THEN iyminmesh = 0L > long(yminmesh[0]) ELSE iyminmesh = 0l 120 IF n_elements(zminmesh) NE 0 THEN izminmesh = 0L > long(zminmesh[0]) ELSE izminmesh = 0l 87 121 ; 88 122 IF NOT (keyword_set(maskname) OR keyword_set(useasmask)) AND keyword_set(romsgrid) THEN maskname = 'mask_rho' … … 111 145 ; is the mask variable containing the record dimension? 112 146 withrcd = (where(mskinq.dim EQ inq.recdim))[0] 113 IF withrcd NE -1 THEN BEGIN114 147 ; in order to read only the first record 115 148 ; we need to get the size of each dimension 116 count = replicate(1L, mskinq.ndims) 117 FOR d = 0, mskinq.ndims -1 DO BEGIN 118 IF d NE withrcd THEN BEGIN 119 ncdf_diminq, cdfid, mskinq.dim[d], name, size 120 count[d] = size 121 ENDIF 122 ENDFOR 149 offset = lonarr(mskinq.ndims) 150 count = replicate(1L, mskinq.ndims) 151 FOR d = 0, mskinq.ndims -1 DO BEGIN 152 IF d NE withrcd THEN BEGIN 153 ncdf_diminq, cdfid, mskinq.dim[d], name, size 154 count[d] = size 155 ENDIF 156 ENDFOR 157 158 IF n_elements(xmaxmesh) NE 0 THEN BEGIN 159 IF xmaxmesh GE 0 THEN ixmaxmesh = long(xmaxmesh[0]) ELSE ixmaxmesh = count[0] - 1L + long(xmaxmesh[0]) 160 ENDIF ELSE ixmaxmesh = count[0] - 1L 161 ixmaxmesh = 0 > ixmaxmesh < (count[0] - 1L) ; make sure ixmaxmesh is not too big 162 jpiglo = count[0] 163 offset[0] = ixminmesh 164 count[0] = ixmaxmesh - ixminmesh + 1L 165 jpi = count[0] 166 167 IF n_elements(ymaxmesh) NE 0 THEN BEGIN 168 IF ymaxmesh GE 0 THEN iymaxmesh = long(ymaxmesh[0]) ELSE iymaxmesh = count[1] - 1L + long(ymaxmesh[0]) 169 ENDIF ELSE iymaxmesh = count[1] - 1L 170 iymaxmesh = 0 > iymaxmesh < (count[1] - 1L) ; make sure ixmaxmesh is not too big 171 jpjglo = count[1] 172 offset[1] = iyminmesh 173 count[1] = iymaxmesh - iyminmesh + 1L 174 jpj = count[1] 175 176 IF (mskinq.ndims EQ 3 AND withrcd EQ -1) OR (mskinq.ndims EQ 4) THEN BEGIN 177 IF n_elements(zmaxmesh) NE 0 THEN BEGIN 178 IF zmaxmesh GE 0 THEN izmaxmesh = long(zmaxmesh[0]) ELSE izmaxmesh = count[2] - 1L + long(zmaxmesh[0]) 179 ENDIF ELSE izmaxmesh = count[2] - 1L 180 izmaxmesh = 0 > izmaxmesh < (count[2] - 1L) ; make sure ixmaxmesh is not too big 181 jpkglo = count[2] 182 offset[2] = izminmesh 183 count[2] = izmaxmesh - izminmesh + 1L 184 jpk = count[2] 185 ENDIF 186 123 187 ; read the variable for the first record 124 ncdf_varget, cdfid, mskid, mask, count = count 125 ENDIF ELSE ncdf_varget, cdfid, mskid, mask 126 188 ncdf_varget, cdfid, mskid, mask, count = count, offset = offset 189 127 190 ; get add_offset, scale factor and missing value attributes 128 191 ncdf_getatt, cdfid, mskid, add_offset = add, scale_factor = scl, missing_value = miss -
trunk/SRC/ToBeReviewed/LECTURE/read_ncdf.pro
r398 r399 340 340 ; vardate 341 341 ; We make a legible date 342 caldat, time[0], year, month, day342 caldat, time[0], month, day, year 343 343 vardate = string(format = '(C(CMoA))', 31*(month-1))+' '+strtrim(day, 1)+', '+strtrim(year, 1) 344 344 varexp = file_basename(filename)
Note: See TracChangeset
for help on using the changeset viewer.