[ncl-talk] variable dimension specifier

Kyle Griffin ksgriffin2 at wisc.edu
Sun Feb 15 20:22:18 MST 2015


Mark,

You can also read in the entirety of the file variable without specifying
any colons at all; e.g.

data=fh->pr

is an acceptable and functional statement, assuming you would read in the
entirety of each dimension. This is the closest thing I'm aware of in NCL
to what you're talking about.

If you wanted to use this to create colons for less than all of the
dimensions associated with a variable, then I think you'd have to use
getfilevardimsizes and if/else statements. It would be a relatively simple
function to write if you intend to use it frequently and likely worth it
compared to the wasted time of reading in unnecessary data from the file.


Kyle

----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
Room 1421
1225 W Dayton St, Madison, WI 53706
Email: ksgriffin2 at wisc.edu

On Sun, Feb 15, 2015 at 9:08 PM, <Mark.Collier at csiro.au> wrote:

> Hi Jatin,
> the problem is being at to specify a range of colons, e.g.
>
> :,:,:
>
> :,:
>
> :
>
> without having to use if else if statements…some languages have a function
> for this, it may not be easy to implement in NCL.
>
> It would be a way of making certain code more compact and general.
>
> Regards, Mark.
>
> > On 16 Feb 2015, at 1:22 pm, Jatin Kala <jatin.kala.jk at gmail.com> wrote:
> >
> > Hi Mark,
> > Maybe use something like getfilevardimsizes:
> >
> https://www.ncl.ucar.edu/Document/Functions/Built-in/getfilevardimsizes.shtml
> > That should tell you the number of dims
> >
> >
> >
> >
> > On 16/02/15 12:41 PM, Mark.Collier at csiro.au wrote:
> >> Hi,
> >> is it possible to reference an input variable dimension list with a
> variable, for example
> >>
> >> data=fh->pr(colons)
> >>
> >> where the variable pr is defined in the data file pointed to be the
> file handle fh.
> >>
> >> where colons is a list that could vary in length, e.g. “:,:,:” or “:,:”
> depending on whether it was a 3,2 or n dimensioned quantity?
> >>
> >> The reason for this, is sometimes it is necessary to specify the colon
> list without knowing the variables dimension, and without having to result
> to if, else if control flow for each dimension case…
> >>
> >> Ideally colons could be a function taking an integer argument to
> specify the list
> >>
> >> e.g. colons(3) would reflect “:,:,:”
> >>
> >> I’ve tried to do this but I guess the : are a unique quantity not able
> to be defined by a simple string argument…
> >>
> >> Thanks,
> >> Mark.
> >> _______________________________________________
> >> 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/20150215/db52f334/attachment.html 


More information about the ncl-talk mailing list