[ncl-talk] how to get the dimension size in netcdf file

LeiTing leiting2002 at hotmail.com
Tue May 12 05:08:10 MDT 2015


Dennis,
Thanks. So great. I will use it as soon as possible and let you know if any problem I still have.
Best,
Ting
Date: Fri, 24 Apr 2015 15:40:31 -0600
Subject: Re: [ncl-talk] how to get the dimension size in netcdf file
From: shea at ucar.edu
To: dbrown at ucar.edu
CC: leiting2002 at hotmail.com; ncl-talk at ucar.edu

Likely, I am misunderstanding

undef("LeiTing")
function LeiTing(f:file, dimName:string)
local dNames, dSizes, i
begin

   dNames= getvardims(f)  
   dSizes   = getfiledimsizes(f)  

   i = ind(dNames.eq.dimName)
   if (.not.ismissing(i)) then
       return(dSizes(i))
   else
       print("LeiTing: FATAL: dimName="+dimName+" not present")
       print("dNames+"   "+dSizes)
       exit
   end if

end

The above can be expanded to multiple 'dimNames'

D

On Fri, Apr 24, 2015 at 3:19 PM, David Brown <dbrown at ucar.edu> wrote:
Hi Dennis,

That was my original suggestion -- at least indirectly -- since that

is what the example in getfiledimsizes does.



My understanding is that Ting would like a function something like

getdimsize(f, dimname). Or more likely a plural version that would

work with an array of dimnames.

 -dave





On Fri, Apr 24, 2015 at 3:01 PM, Dennis Shea <shea at ucar.edu> wrote:

> Is this what you want?

>

> Remember 'f' (below) has a dual nature ... It is both a variable and a file

> reference

>

>    f = addfile("...","r")

>

>    dNames= getvardims(f)

>    dSizes   = getfiledimsizes(f)

>    print (dNames+"   "+dSizes)

>

>

> On Fri, Apr 24, 2015 at 2:45 PM, LeiTing <leiting2002 at hotmail.com> wrote:

>>

>> Dave and Alan,

>> My apology for causing that misunderstanding.

>> Dave, you are right! I missed that function is aksing for a dim size of a

>> variable.

>> In my case, those dimensions are only defined however not used for any

>> variables, which are still significant.

>> Thanks again.

>> Best,

>> Ting

>>

>> > Date: Fri, 24 Apr 2015 14:25:53 -0600

>> > Subject: Re: [ncl-talk] how to get the dimension size in netcdf file

>> > From: dbrown at ucar.edu

>> > To: abrammer at albany.edu

>> > CC: leiting2002 at hotmail.com; ncl-talk at ucar.edu

>>

>> >

>> > getfilevardimsizes gets the sizes of the dimensions the apply to a

>> > specific variable. I thought the question was how to get the size of a

>> > dimension by name from the file without specifying a particular

>> > variable.

>> > -dave

>> >

>> >

>> > On Fri, Apr 24, 2015 at 12:53 PM, Alan Brammer <abrammer at albany.edu>

>> > wrote:

>> > > Isn't that functionality in this function?

>> > >

>> > > https://www.ncl.ucar.edu/Document/Functions/Built-in/getfilevardimsizes.shtml

>> > >

>> > >

>> > > Alan.

>> > >

>> > > On 24 April 2015 at 14:36, David Brown <dbrown at ucar.edu> wrote:

>> > >>

>> > >> Well we would need to create another function to do that. We will

>> > >> consider it. Thanks for the suggestion.

>> > >> -dave

>> > >>

>> > >> On Fri, Apr 24, 2015 at 12:32 PM, LeiTing <leiting2002 at hotmail.com>

>> > >> wrote:

>> > >> > Dave,

>> > >> > Thank you so much. That is already the solution I need.

>> > >> > However, can NCL be "smarter" that ,say, I can directly ask for the

>> > >> > size

>> > >> > of

>> > >> > a named dimension?

>> > >> > I know I can do it after using the function you pointed out,

>> > >> > however,

>> > >> > I'm

>> > >> > just wondering if there are some tip that directly do it.

>> > >> > Thanks a lot.

>> > >> > Ting

>> > >> >

>> > >> >> Date: Fri, 24 Apr 2015 12:01:50 -0600

>> > >> >> Subject: Re: [ncl-talk] how to get the dimension size in netcdf

>> > >> >> file

>> > >> >> From: dbrown at ucar.edu

>> > >> >> To: leiting2002 at hotmail.com

>> > >> >> CC: ncl-talk at ucar.edu

>> > >> >

>> > >> >>

>> > >> >> Hi Ting,

>> > >> >> getfiledimsizes is the function to use.

>> > >> >> See

>> > >> >>

>> > >> >>

>> > >> >> http://www.ncl.ucar.edu/Document/Functions/Built-in/getfiledimsizes.shtml

>> > >> >>

>> > >> >> The example shows how to get the dimensions names along with the

>> > >> >> sizes.

>> > >> >> -dave

>> > >> >>

>> > >> >>

>> > >> >> On Fri, Apr 24, 2015 at 10:12 AM, LeiTing

>> > >> >> <leiting2002 at hotmail.com>

>> > >> >> wrote:

>> > >> >> > Dear Ncl folks,

>> > >> >> > I apologize first if this is a duplicated question though I

>> > >> >> > haven't

>> > >> >> > found

>> > >> >> > it.

>> > >> >> > I have a netcdf file (the "sparse grid" by NSSL), with ncdump

>> > >> >> > output

>> > >> >> > as

>> > >> >> > ^^^^^^^^^^^^

>> > >> >> > dimensions:

>> > >> >> > Lat = 236 ;

>> > >> >> > Lon = 355 ;

>> > >> >> > pixel = 12596 ;

>> > >> >> > variables:

>> > >> >> > float RefQC(pixel) ;

>> > >> >> > ..............................

>> > >> >> > VV

>> > >> >> >

>> > >> >> > I want to get the dimension lat and lon, which can 't be

>> > >> >> > obtained by

>> > >> >> > ,say,

>> > >> >> > dimsize (RefQC).

>> > >> >> > They are also not global attributes.

>> > >> >> > Hence, I 'm lost on how to access those definitions of "lat" and

>> > >> >> > "lon"

>> > >> >> > in

>> > >> >> > the netcdf file.

>> > >> >> > Your help is appreciated.

>> > >> >> > Best wishes,

>> > >> >> > Ting

>> > >> >> >

>> > >> >> >

>> > >> >> > _______________________________________________

>> > >> >> > 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

>> > >

>> > >

>>

>> _______________________________________________

>> ncl-talk mailing list

>> List instructions, subscriber options, unsubscribe:

>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

>>

>


 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150512/12539af9/attachment.html 


More information about the ncl-talk mailing list