Re: get dimension sizes

From: Jeff <jeffelf_at_nyahnyahspammersnyahnyah>
Date: Sun Jan 16 2011 - 11:31:04 MST

Hi Dennis,

Thank you for prompt reply and the example.

Have a nice weekend.
Yaosheng

On Sun, Jan 16, 2011 at 1:27 PM, Dennis Shea <shea@ucar.edu> wrote:
> If the variable is a "coordinate variable" [ie, a variable
> name is the same as its' dimension name, eg time(time) ] then
>
> dimt = filevardimsizes(f,"time")
> print(dimt)
>
> Otherwise, you can write your own function. See the examples at:
> http://www.ncl.ucar.edu/Document/Functions/Built-in/getvardims.shtml
>
> undef("my_filevardimsizes")
> function my_filevardimsizes(f[1]:file, dname[1]:string)
> local fdimnames, dsizes, i
> begin
>  fdimnames = getvardims(f)      ; all dimension names on file
>  if (any(fdimnames.eq.dname)) then
>      dsizes = getfiledimsizes(f)
>      i = ind(fdimnames.eq.dname)
>      return(dsizes(i))
>  else
>      print("my_filevardimsizes: warning: no dimension named "+dname)
>      return(-999)
>  end if
> end
>
>
>
>
> On 1/16/11 11:03 AM, Jeff wrote:
>>
>> Hi Sir/Madam,
>>
>> I'm looking for a function returning the dimension size for a given
>> dimension specified via dimension name.
>>
>> Say, I know there is a dimension called "time" in file f, so a
>> function(f, "time") will return the size of dimension "time".
>>
>> I browsed the functions on NCL website, and it seems that all relevant
>> functions are returning the dimension sizes of all dimensions for
>> either a file or a var.
>>
>> Is there any function doing what I'm looking for?
>>
>> Thanks.
>> Yaosheng
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Jan 16 11:31:13 2011

This archive was generated by hypermail 2.1.8 : Tue Jan 25 2011 - 14:22:15 MST