Changeset 70 for trunk/ReadWrite/idl-NetCDF/ncdf_quickread
- Timestamp:
- 05/16/06 14:41:08 (18 years ago)
- Location:
- trunk/ReadWrite/idl-NetCDF/ncdf_quickread
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ReadWrite/idl-NetCDF/ncdf_quickread/README_ncdf_quickread.txt
r67 r70 28 28 29 29 ncverbose : set equal to 1 if you want to include attributes 30 31 ncfields : Set to a string which is a space-separated list of 32 variables to read. Only the variables specified will be 33 read in (and where ncverbose is set, only the attributes 34 associated with these variables and the global attributes). 35 If unset or the null string, then reads all fields. 30 36 31 37 4) Type: @ncdf_quickread -
trunk/ReadWrite/idl-NetCDF/ncdf_quickread/ncdf_quickread.pro
r67 r70 5 5 6 6 __commands= $ 7 ncdf_quickread_helper(ncfile,verbose=ncverbose,prefix=ncprefix,/reform) 7 ncdf_quickread_helper(ncfile,verbose=ncverbose,prefix=ncprefix, $ 8 fields=ncfields,/reform) 8 9 9 10 for __loop=0,n_elements(__commands)-1 do $ -
trunk/ReadWrite/idl-NetCDF/ncdf_quickread/ncdf_quickread_helper.pro
r67 r70 34 34 ; is used to remove dimensions of size 1. 35 35 ; 02 Oct 03 A.M.Iwi Change into helper routine for ncdf_quickread 36 ; 11 Aug 04 A.M.Iwi Add "fields" option to read only certain fields. 37 ; Also, only stringify attributes of type CHAR. 36 38 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 37 39 … … 139 141 140 142 function ncdf_quickread_helper, infile, verbose=verbose, $ 141 prefix=prefix, reform=reform 143 prefix=prefix, fields=fields, $ 144 reform=reform 142 145 on_error,2 143 146 compile_opt hidden … … 169 172 commands="__ncid = NCDF_OPEN('"+infile+"')" 170 173 174 subset=0 175 if n_elements(fields) ne 0 then begin 176 if (fields ne '') then begin 177 subset=1 178 subfields=strsplit(fields,/extract) 179 endif 180 endif 181 171 182 ; Place the desired variables in local arrays. 172 183 for i=0, ncidinfo.Nvars-1 do begin 173 184 vardata = NCDF_VARINQ(ncid, i) 174 varname = ncdf_quickread_validatename(vardata.Name) 175 if keyword_set(prefix) then varname=prefix+varname 176 commands=$ 177 [commands,"NCDF_VARGET, __ncid, "+strcompress(string(i))+", "+varname] 178 if keyword_set(reform) and vardata.ndims ge 2 $ 179 then commands=[commands,varname+'=reform('+varname+')'] 180 if (keyword_set(verbose)) then begin 181 for j=0, vardata.Natts-1 do begin 182 att = NCDF_ATTNAME(ncid, i, j) 183 attname = strcompress(varname+"_"+strcompress(att,/REMOVE_ALL)) 184 commands=$ 185 [commands,"NCDF_ATTGET, __ncid, "+strcompress(string(i))+$ 186 ", '"+att+"', "+attname] 187 commands=$ 188 [commands,attname+" = STRING("+attname+")"] 189 endfor 185 if not subset then begin 186 wanted=1 187 endif else begin 188 match = where(subfields eq vardata.Name, nmatch) 189 wanted=(nmatch ne 0) 190 endelse 191 if wanted then begin 192 varname = ncdf_quickread_validatename(vardata.Name) 193 if keyword_set(prefix) then varname=prefix+varname 194 commands=$ 195 [commands,"NCDF_VARGET, __ncid, "+strcompress(string(i))+", "+varname] 196 if keyword_set(reform) and vardata.ndims ge 2 $ 197 then commands=[commands,varname+'=reform('+varname+')'] 198 if (keyword_set(verbose)) then begin 199 for j=0, vardata.Natts-1 do begin 200 att = NCDF_ATTNAME(ncid, i, j) 201 attname = strcompress(varname+"_"+strcompress(att,/REMOVE_ALL)) 202 commands=$ 203 [commands,"NCDF_ATTGET, __ncid, "+strcompress(string(i))+$ 204 ", '"+att+"', "+attname] 205 attinfo = ncdf_attinq(ncid, i, att) 206 if attinfo.datatype eq 'CHAR' then $ 207 commands=[commands,attname+" = STRING("+attname+")"] 208 endfor 209 endif 190 210 endif 191 211 endfor … … 198 218 commands=$ 199 219 [commands,"NCDF_ATTGET, __ncid, /GLOBAL, '"+name+"', "+attname] 200 commands=$ 201 [commands,attname+" = STRING("+attname+")"] 220 attinfo = ncdf_attinq(ncid, /global, name) 221 if attinfo.datatype eq 'CHAR' then $ 222 commands=[commands,attname+" = STRING("+attname+")"] 202 223 endfor 203 224 endif 204 225 226 ncdf_close,ncid 205 227 commands=[commands,"NCDF_CLOSE, __ncid"] 206 228
Note: See TracChangeset
for help on using the changeset viewer.