Re: Re: [ncl-talk] Printing multi-dimensional variables

From: Jan Ploski <Jan.Ploski_at_nyahnyahspammersnyahnyah>
Date: Thu, 26 Jun 2008 17:47:38 +0200

Dennis Shea <shea_at_ucar.edu> schrieb am 06/26/2008 05:40:57 PM:

> What about "write_matrix"?
>
>
> http://www.ncl.ucar.edu/Document/Functions/Built-in/write_matrix.shtml

Dennis,

I looked at it already, but it's not good enough. In particular, it has no
support for printing of subscript labels using coordinate variables
associated with the dimensions AND it is limited to 2d output. That is, it
seems I could not get it produce output like this for my particular
example:

      first second
0 1 -999
6 2 -999
12 3 7
18 4 8

Foremost, it's an issue of the required effort and generality of the
solution. If the user has to do more than print(var), he's probably going
to be unhappy, given that NCL *could* be doing all the formatting for him.

Regards,
Jan Ploski

>
>
> Jan Ploski wrote:
> > Hello,
> >
> > I have a feature request or question concerning pretty-printing of
> > multi-dimensional variables. Consider the following NCL script:
> >
> > names = (/ "first", "second" /)
> > hours = (/ 0, 6, 12, 18 /)
> >
> > var = new((/ 2, 4 /), float, -999.0)
> > var!0 = "name"
> > var!1 = "hour"
> > var&name = names
> > var&hour = hours
> >
> > var({"first"},{0}) = 1
> > var({"first"},{6}) = 2
> > var({"first"},{12}) = 3
> > var({"first"},{18}) = 4
> > var({"second"},{12}) = 7
> > var({"second"},{18}) = 8
> >
> > print(var)
> >
> > The NCL output is:
> >
> > Variable: var
> > Type: float
> > Total Size: 32 bytes
> > 8 values
> > Number of Dimensions: 2
> > Dimensions and sizes: [name | 2] x [hour | 4]
> > Coordinates:
> > name: [first..second]
> > hour: [0..18]
> > Number Of Attributes: 1
> > _FillValue : -999
> > (0,0) 1
> > (0,1) 2
> > (0,2) 3
> > (0,3) 4
> > (1,0) -999
> > (1,1) -999
> > (1,2) 7
> > (1,3) 8
> >
> > In this trivial example it may be easy to translate in your head (1,2)
to
> > a particular combination of dimension names and coordinate values, but

> > when the variables get higher dimensionality and the size of
dimensions
> > increases, you quickly get lost. In fact, I have a user who considers
> > turning away from NCL in favor of Fortran because of this lack of
> > comfortable output formatting (his other major trouble is
understanding
> > slicing/hyperslab operations, but that can be only cured by practice
IMO).
> > Anyway, what he'd like to see in the output is:
> >
> > Variable: var
> > Type: float
> > Total Size: 32 bytes
> > 8 values
> > Number of Dimensions: 2
> > Dimensions and sizes: [name | 2] x [hour | 4]
> > Coordinates:
> > name: [first..second]
> > hour: [0..18]
> > Number Of Attributes: 1
> > _FillValue : -999
> > (name=first,hour=0) 1
> > (name=first,hour=6) 2
> > (name=first,hour=12) 3
> > (name=first,hour=18) 4
> > (name=second,hour=12) 7
> > (name=second,hour=18) 8
> >
> > That is, (optional) dimension names, (optional) coordinates translated

> > using the subscript variable, and missing values optionally left out
of
> > the output.
> >
> > I guess this kind of output would be rather easy to support in a
future
> > version of NCL?... In the meanwhile, I'd like to ask which solution
you
> > think would be easiest:
> > 1) a custom NCL routine to be used instead of print
> > 2) a custom Fortran routine to be used instead of print
> > 3) hacking the NCL source of the print routine directly
> > 4) writing an NCL wrapper/post-processor in Perl (that would require
the
> > values of coordinate variables to be available somewhere in the
output)
> >
> > Regards,
> > Jan Ploski
> > _______________________________________________
> > ncl-talk mailing list
> > ncl-talk_at_ucar.edu
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
>
>
> --
> ======================================================
> Dennis J. Shea tel: 303-497-1361 |
> P.O. Box 3000 fax: 303-497-1333 |
> Climate Analysis Section |
> Climate & Global Dynamics Div. |
> National Center for Atmospheric Research |
> Boulder, CO 80307 |
> USA email: shea 'at' ucar.edu |
> ======================================================
>

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jun 26 2008 - 09:47:38 MDT

This archive was generated by hypermail 2.2.0 : Sat Dec 20 2008 - 12:36:21 MST