[ncl-talk] Coordinate subscripting with mixed types

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Wed Nov 19 11:22:19 MST 2014


NCL support,

Is there any progress on this request?  This issue keeps coming up in my
work group.  We perform a lot of generalized file handling.  Thank you.

--Dave

On Thu, Aug 22, 2013 at 12:30 PM, David Brown <dbrown at ucar.edu> wrote:

> Hi Dave,
> This is a very good suggestion. We will create a ticket for it.
>  -dave
>
> On Aug 22, 2013, at 12:06 PM, Dave Allured - NOAA Affiliate <
> dave.allured at noaa.gov> wrote:
>
> > NCL support,
> >
> > This is a request for improved support for mixed types in coordinate
> > subscripting.  For example, it is legal to subscript a double
> > coordinate with floats, but going the other way is an error.  This
> > shows that type handling in simple NCL relational operators is more
> > liberal than in coordinate subscripting:
> >
> > lats = (/ 0., 10., 20., 30., 40., 50., 60. /)
> > x    = (/ 0,  111, 222, 333, 444, 555, 666 /)
> > x!0  = "lat"
> > y    = x
> >
> > x&lat = tofloat  (lats)
> > y&lat = todouble (lats)
> >
> > f1 = 20.     ; floats
> > f2 = 40.
> > d1 = 20d     ; doubles
> > d2 = 40d
> >
> > ind1 = ind (y&lat .ge. f1 .and. y&lat .le. f2)
> > print (ind1+"")
> > print ("")
> >
> > ind2 = ind (x&lat .ge. d1 .and. x&lat .le. d2)
> > print (ind2+"")
> > print ("")
> >
> > sub1 = y({f1:f2})    ; float subscripts double
> > print (sub1&lat+" "+typeof(sub1&lat))
> > print ("")
> >
> > sub2 = x({d1:d2})    ; double subscripts float
> > print (sub2&lat+" "+typeof(sub2&lat))
> >
> > Result:
> >
> > NCAR Command Language Version 6.1.2
> > (0)   2
> > (1)   3
> > (2)   4
> > (0)
> > (0)   2
> > (1)   3
> > (2)   4
> > (0)
> > (0)   20 double
> > (1)   30 double
> > (2)   40 double
> > (0)
> > fatal:Coordinate subscript type mismatch. Subscript (0) can not be
> > coerced to type of coordinate variable
> > fatal:["Execute.c":8128]:Execute: Error occurred at or near line 26 in
> > file mixed-mode-coord-subscripts.ncl
> >
> > I think it would be generally helpful if coordinate subscripting could
> > be broadened to support all reasonable cases of mixed types.  At a
> > minimum, please support the same combinations as for the relational
> > operators.  I know that there are simple workarounds, but this
> > improvement would benefit simpler user code and generalized file
> > support.  Thanks for your consideration.
> >
> > --Dave A.
> > NOAA/PSD/CIRES Climate Analysis Branch
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141119/4ddc3652/attachment.html 


More information about the ncl-talk mailing list