Changeset 219 for trunk/SRC/ToBeReviewed/INIT/initncdf.pro
- Timestamp:
- 03/14/07 16:44:26 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/INIT/initncdf.pro
r218 r219 28 28 ; @keyword START1 {default=0}{type=scalar: 0 or 1} 29 29 ; Index the axis from 1 instead of 0 when using 30 ; /xyindex and/or /zindex30 ; /xyindex and/or zindex 31 31 ; 32 32 ; @keyword USEASMASK {type=scalar string} … … 39 39 ; 3 NaN values if existing 40 40 ; 41 ; @keyword XAXISNAME {default='x', 'longitude', 'nav_lon', 'lon', 'lon_rho' or 'NbLongitudes'}{type=scalar string} 42 ; A string giving the name of the variable in the file 43 ; that contains the [xyz]axis. 44 ; 45 ; @keyword YAXISNAME {default='y', 'latitude', 'nav_lat','lat', 'lat_rho' or 'NbLatitudes'}{type=scalar string} 46 ; A string giving the name of the variable in the file 47 ; that contains the [xyz]axis. 48 ; 41 49 ; @keyword ZAXISNAME {default='z', 'level', 'lev', 'depth...'}{type=scalar string} 42 50 ; A string giving the name of the variable in the file … … 55 63 ; 56 64 ; @keyword _EXTRA 57 ; Used to pass keywords to computegrid and ncdf_getaxis65 ; Used to pass keywords to computegrid 58 66 ; 59 67 ; @uses … … 80 88 ;------------------------------------------------------------ 81 89 ;------------------------------------------------------------ 82 PRO initncdf, ncfilein $90 PRO initncdf, ncfilein, XAXISNAME = xaxisname, YAXISNAME = yaxisname $ 83 91 , ZAXISNAME = zaxisname, MASKNAME = maskname $ 84 92 , INVMASK = invmask, USEASMASK = useasmask $ … … 105 113 ; what is inside the file 106 114 inside = ncdf_inquire(cdfid) 107 ;------------------------------------------------------------108 ; name of all dimensions109 namedim = strarr(inside.ndims)110 for dimiq = 0, inside.ndims-1 do begin111 ncdf_diminq, cdfid, dimiq, tmpname, value112 namedim[dimiq] = strlowcase(tmpname)113 ENDFOR114 115 ;---------------------------------------------------------- 115 116 ; name of the variables … … 120 121 ENDFOR 121 122 ;---------------------------------------------------------- 122 ; find the x/yaxis 123 ncdf_getaxis, cdfid, dimidx, dimidy, xaxis, yaxis $ 124 , START1 = start1, XYINDEX = xyindex, ROMSGRID = romsgrid, _extra = ex 123 ; find the xaxis 124 if keyword_set(xaxisname) then xaxisname = strlowcase(xaxisname) ELSE xaxisname = 'x' 125 xvarid = (where(namevar EQ xaxisname OR namevar EQ 'longitude' $ 126 OR namevar EQ 'nav_lon' OR namevar EQ 'lon' $ 127 OR namevar EQ 'lon_rho' OR namevar EQ 'nblongitudes'))[0] 128 if xvarid EQ -1 then begin 129 print, 'the xaxis was not found, check the use of XAXISNAME keyword' 130 stop 131 endif 132 romsgrid = strmid(namevar[xvarid], 0, 4) EQ 'lon_' 133 ; get the size of xaxis 134 xinq = ncdf_varinq(cdfid, xvarid) 135 ncdf_diminq, cdfid, xinq.dim[0], blabla, jpifromx 136 ; should we read or compute the xaxis? 137 IF NOT keyword_set(xyindex) THEN BEGIN 138 ; read the xaxis 139 ncdf_varget, cdfid, xvarid, xaxis 140 ; make sure of the shape of xaxis 141 IF xinq.ndims GE 2 THEN BEGIN 142 ncdf_diminq, cdfid, xinq.dim[1], blabla, jpjfromx 143 xaxis = reform(xaxis, jpifromx, jpjfromx, /over) 144 ENDIF 145 ENDIF ELSE xaxis = keyword_set(start1) + findgen(jpifromx) 146 ;---------------------------------------------------------- 147 ; find the yaxis 148 if keyword_set(yaxisname) then yaxisname = strlowcase(yaxisname) ELSE yaxisname = 'y' 149 yvarid = (where(namevar EQ yaxisname OR namevar EQ 'latitude' $ 150 OR namevar EQ 'nav_lat' OR namevar EQ 'lat' $ 151 OR namevar EQ 'lat_rho' OR namevar EQ 'nblatitudes'))[0] 152 yvarid = yvarid[0] 153 if yvarid EQ -1 then begin 154 print, 'the yaxis was not found, check the use of YAXISNAME keyword' 155 stop 156 endif 157 ; get the size of yaxis and check it is ok with the values found for x 158 yinq = ncdf_varinq(cdfid, yvarid) 159 IF xinq.ndims GE 2 THEN BEGIN 160 ncdf_diminq, cdfid, yinq.dim[0], blabla, jpifromy 161 ncdf_diminq, cdfid, yinq.dim[1], blabla, jpjfromy 162 IF jpifromy NE jpifromx THEN BEGIN 163 print, 'xaxis and y axis do not have the same x dimension...' 164 ENDIF 165 ENDIF ELSE ncdf_diminq, cdfid, yinq.dim[0], blabla, jpjfromy 166 IF n_elements(jpjfromx) NE 0 THEN BEGIN 167 IF jpjfromy NE jpjfromx THEN BEGIN 168 print, 'xaxis and y axis do not have the same y dimension...' 169 ENDIF 170 ENDIF 171 ; should we read or compute the xaxis? 172 IF NOT keyword_set(xyindex) THEN BEGIN 173 ; read the yaxis 174 ncdf_varget, cdfid, yvarid, yaxis 175 ; make sure of the shape of xaxis 176 IF xinq.ndims GE 2 THEN yaxis = reform(yaxis, jpifromy, jpjfromy, /over) 177 ENDIF ELSE yaxis = keyword_set(start1) + findgen(jpjfromy) 125 178 ;---------------------------------------------------------- 126 179 ; find the zaxis
Note: See TracChangeset
for help on using the changeset viewer.