<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:΢ÈíÑźÚ
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><br>Dennis,<br>Thanks. So great. I will use it as soon as possible and let you know if any problem I still have.<br>Best,<br>Ting<br><div><hr id="stopSpelling">Date: Fri, 24 Apr 2015 15:40:31 -0600<br>Subject: Re: [ncl-talk] how to get the dimension size in netcdf file<br>From: shea@ucar.edu<br>To: dbrown@ucar.edu<br>CC: leiting2002@hotmail.com; ncl-talk@ucar.edu<br><br><div dir="ltr"><div><div><div><div><div>Likely, I am misunderstanding<br></div><div><br>undef("LeiTing")<br></div>function LeiTing(f:file, dimName:string)<br></div><div>local dNames, dSizes, i<br></div>begin<br><br> dNames= getvardims(f) <br> dSizes = getfiledimsizes(f) <br><br></div><div> i = ind(dNames.eq.dimName)<br></div><div> if (.not.ismissing(i)) then<br></div><div> return(dSizes(i))<br></div><div> else<br></div><div> print("LeiTing: FATAL: dimName="+dimName+" not present")<br></div><div> print("dNames+" "+dSizes)<br></div><div> exit<br></div><div> end if<br><br></div>end<br><br></div>The above can be expanded to multiple 'dimNames'<br><br></div>D<br></div><div class="ecxgmail_extra"><br><div class="ecxgmail_quote">On Fri, Apr 24, 2015 at 3:19 PM, David Brown <span dir="ltr"><<a href="mailto:dbrown@ucar.edu" target="_blank">dbrown@ucar.edu</a>></span> wrote:<br><blockquote class="ecxgmail_quote" style="border-left:1px #ccc solid;padding-left:1ex;">Hi Dennis,<br>
That was my original suggestion -- at least indirectly -- since that<br>
is what the example in getfiledimsizes does.<br>
<br>
My understanding is that Ting would like a function something like<br>
getdimsize(f, dimname). Or more likely a plural version that would<br>
work with an array of dimnames.<br>
-dave<br>
<div class="ecxHOEnZb"><div class="h5"><br>
<br>
On Fri, Apr 24, 2015 at 3:01 PM, Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> wrote:<br>
> Is this what you want?<br>
><br>
> Remember 'f' (below) has a dual nature ... It is both a variable and a file<br>
> reference<br>
><br>
> f = addfile("...","r")<br>
><br>
> dNames= getvardims(f)<br>
> dSizes = getfiledimsizes(f)<br>
> print (dNames+" "+dSizes)<br>
><br>
><br>
> On Fri, Apr 24, 2015 at 2:45 PM, LeiTing <<a href="mailto:leiting2002@hotmail.com">leiting2002@hotmail.com</a>> wrote:<br>
>><br>
>> Dave and Alan,<br>
>> My apology for causing that misunderstanding.<br>
>> Dave, you are right! I missed that function is aksing for a dim size of a<br>
>> variable.<br>
>> In my case, those dimensions are only defined however not used for any<br>
>> variables, which are still significant.<br>
>> Thanks again.<br>
>> Best,<br>
>> Ting<br>
>><br>
>> > Date: Fri, 24 Apr 2015 14:25:53 -0600<br>
>> > Subject: Re: [ncl-talk] how to get the dimension size in netcdf file<br>
>> > From: <a href="mailto:dbrown@ucar.edu">dbrown@ucar.edu</a><br>
>> > To: <a href="mailto:abrammer@albany.edu">abrammer@albany.edu</a><br>
>> > CC: <a href="mailto:leiting2002@hotmail.com">leiting2002@hotmail.com</a>; <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
>><br>
>> ><br>
>> > getfilevardimsizes gets the sizes of the dimensions the apply to a<br>
>> > specific variable. I thought the question was how to get the size of a<br>
>> > dimension by name from the file without specifying a particular<br>
>> > variable.<br>
>> > -dave<br>
>> ><br>
>> ><br>
>> > On Fri, Apr 24, 2015 at 12:53 PM, Alan Brammer <<a href="mailto:abrammer@albany.edu">abrammer@albany.edu</a>><br>
>> > wrote:<br>
>> > > Isn't that functionality in this function?<br>
>> > ><br>
>> > > <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/getfilevardimsizes.shtml" target="_blank">https://www.ncl.ucar.edu/Document/Functions/Built-in/getfilevardimsizes.shtml</a><br>
>> > ><br>
>> > ><br>
>> > > Alan.<br>
>> > ><br>
>> > > On 24 April 2015 at 14:36, David Brown <<a href="mailto:dbrown@ucar.edu">dbrown@ucar.edu</a>> wrote:<br>
>> > >><br>
>> > >> Well we would need to create another function to do that. We will<br>
>> > >> consider it. Thanks for the suggestion.<br>
>> > >> -dave<br>
>> > >><br>
>> > >> On Fri, Apr 24, 2015 at 12:32 PM, LeiTing <<a href="mailto:leiting2002@hotmail.com">leiting2002@hotmail.com</a>><br>
>> > >> wrote:<br>
>> > >> > Dave,<br>
>> > >> > Thank you so much. That is already the solution I need.<br>
>> > >> > However, can NCL be "smarter" that ,say, I can directly ask for the<br>
>> > >> > size<br>
>> > >> > of<br>
>> > >> > a named dimension?<br>
>> > >> > I know I can do it after using the function you pointed out,<br>
>> > >> > however,<br>
>> > >> > I'm<br>
>> > >> > just wondering if there are some tip that directly do it.<br>
>> > >> > Thanks a lot.<br>
>> > >> > Ting<br>
>> > >> ><br>
>> > >> >> Date: Fri, 24 Apr 2015 12:01:50 -0600<br>
>> > >> >> Subject: Re: [ncl-talk] how to get the dimension size in netcdf<br>
>> > >> >> file<br>
>> > >> >> From: <a href="mailto:dbrown@ucar.edu">dbrown@ucar.edu</a><br>
>> > >> >> To: <a href="mailto:leiting2002@hotmail.com">leiting2002@hotmail.com</a><br>
>> > >> >> CC: <a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
>> > >> ><br>
>> > >> >><br>
>> > >> >> Hi Ting,<br>
>> > >> >> getfiledimsizes is the function to use.<br>
>> > >> >> See<br>
>> > >> >><br>
>> > >> >><br>
>> > >> >> <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/getfiledimsizes.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Built-in/getfiledimsizes.shtml</a><br>
>> > >> >><br>
>> > >> >> The example shows how to get the dimensions names along with the<br>
>> > >> >> sizes.<br>
>> > >> >> -dave<br>
>> > >> >><br>
>> > >> >><br>
>> > >> >> On Fri, Apr 24, 2015 at 10:12 AM, LeiTing<br>
>> > >> >> <<a href="mailto:leiting2002@hotmail.com">leiting2002@hotmail.com</a>><br>
>> > >> >> wrote:<br>
>> > >> >> > Dear Ncl folks,<br>
>> > >> >> > I apologize first if this is a duplicated question though I<br>
>> > >> >> > haven't<br>
>> > >> >> > found<br>
>> > >> >> > it.<br>
>> > >> >> > I have a netcdf file (the "sparse grid" by NSSL), with ncdump<br>
>> > >> >> > output<br>
>> > >> >> > as<br>
>> > >> >> > ^^^^^^^^^^^^<br>
>> > >> >> > dimensions:<br>
>> > >> >> > Lat = 236 ;<br>
>> > >> >> > Lon = 355 ;<br>
>> > >> >> > pixel = 12596 ;<br>
>> > >> >> > variables:<br>
>> > >> >> > float RefQC(pixel) ;<br>
>> > >> >> > ..............................<br>
>> > >> >> > VV<br>
>> > >> >> ><br>
>> > >> >> > I want to get the dimension lat and lon, which can 't be<br>
>> > >> >> > obtained by<br>
>> > >> >> > ,say,<br>
>> > >> >> > dimsize (RefQC).<br>
>> > >> >> > They are also not global attributes.<br>
>> > >> >> > Hence, I 'm lost on how to access those definitions of "lat" and<br>
>> > >> >> > "lon"<br>
>> > >> >> > in<br>
>> > >> >> > the netcdf file.<br>
>> > >> >> > Your help is appreciated.<br>
>> > >> >> > Best wishes,<br>
>> > >> >> > Ting<br>
>> > >> >> ><br>
>> > >> >> ><br>
>> > >> >> > _______________________________________________<br>
>> > >> >> > ncl-talk mailing list<br>
>> > >> >> > List instructions, subscriber options, unsubscribe:<br>
>> > >> >> > <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
>> > >> >> ><br>
>> > >> _______________________________________________<br>
>> > >> ncl-talk mailing list<br>
>> > >> List instructions, subscriber options, unsubscribe:<br>
>> > >> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
>> > ><br>
>> > ><br>
>><br>
>> _______________________________________________<br>
>> ncl-talk mailing list<br>
>> List instructions, subscriber options, unsubscribe:<br>
>> <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
>><br>
><br>
</div></div></blockquote></div><br></div></div>                                            </div></body>
</html>