Changeset 399 for trunk/SRC/ReadWrite/ncdf_getaxis.pro
- Timestamp:
- 07/02/09 10:38:54 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.