Don't know if I really understand.
You test for rank of "ge.1" .... Well, all variables
have a rank of, at least, one. So to me it is
a puzzling test. I wrote the attached [untested]
and it returns all variables with rank ".gt.1"
Good luck
D
Donna Cote wrote:
> Mary helped me with some of this code; getting me started with reading 
> an nc file, collecting a list array of all of the file's variables, and 
> making a loop where I tested each variable for its type and dimensions 
> (at least).
> 
>     f=addfile... "r")
>     varNames=getfilevarnames(f)
>     varNamesSize=dimsizes(varNames)
>     StringOfVarNamesToInsert=""
>     do l=0, varNamesSize-1
>       tmp = f->$varNames(l)$
>       rank=dimsizes(dimsizes(tmp))
>       if (rank.ge.1 .and. isdimnamed(tmp,0) .and. (tmp!0 .eq. "recNum")
>     ) then      ; (B)     ; skip this variable and go to the next in the
>     varNames array
>         if (l.eq.0)
>           StringOfVarNamesToInsert=varNames(l)
>         else
>           StringOfVarNamesToInsert=StringOfVarNamesToInsert+ ", "
>     +varNames(l)
>         end if
>       end if
>       delete(rank)
>       delete(tmp)
>     end do
> 
> What I have, so far, creates a string of variable names delimited with a 
> comma. Example below. I would rather have ncl create an array that is a 
> subset of the varNames array where the names in the new array have 1) a 
> rank of 1+, 2) a named dimension !0, and 3) the !0 dimension name 
> matching "recNum"
> 
> How is that for compliecated? I sort of imagine that I would come up 
> with a function which does these tests and returns True or False to 
> ind(); Maybe:
> 
>     newVarNames = ind( myfunction(tmp).eq. True )
> 
> Am I on the right track? or what has someone found to work for them, 
> along these lines?
> 
> Example string of variable names:
>    rawMETAR, correction, maxTemp24HourQCD, maxTemp24HourQCR, 
> maxTemp24HourQCA, maxTemp24HourDD, maxTemp24Hour, minTemp24HourQCD, 
> minTemp24HourQCR, minTemp24HourQCA, minTemp24HourDD, minTemp24Hour, 
> altimeterQCD, altimeterQCR, altimeterQCA, altimeterDD, altimeter, 
> timeObs, elevation, longitude, latitude, locationName, stationName, wmoId
> 
> Thanks,
> Donna
> 
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
function donna(f:file)
local varNames, varNamesSize, nout, outNames, l, rank, tmp
begin
    varNames     = getfilevarnames(f)
    varNamesSize = dimsizes(varNames)
    nout         = 0
    outNames     = new (varNamesSize,"string")
    do l=0, varNamesSize-1
      rank = dimsizes(filevardimsizes(f, varNames(l)))
           ; (B)     ; skip this variable and go to the next in the
      if (rank.gt.1) then
          tmp = f->$varNames(l)$
          if (isdimnamed(tmp,0) .and. (tmp!0 .eq. "recNum")) then  
              nout = nout+1
              outNames(nout-1) = varNames(l)
          end if
          delete(tmp)
      end if
    end do
    
    return(outNames(0:nout-1))   ; return only selected variable names 
end
    f=addfile("...","r")
    vNam = donna(f)
    print(vNam)
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Apr 09 2009 - 21:16:06 MDT
This archive was generated by hypermail 2.2.0 : Sun Apr 12 2009 - 14:28:35 MDT