[ncl-talk] Coordinate subscripting with mixed types

David Brown dbrown at ucar.edu
Thu Nov 20 10:36:38 MST 2014


Hi Dave,
I am back now and I will look into this issue soon.
 -dave

On Thu, Nov 20, 2014 at 12:52 AM, Dave Allured - NOAA Affiliate
<dave.allured at noaa.gov> wrote:
> Mary,
>
> The "totype" workaround is working fine, it's just that the issue keeps
> coming back whenever we encounter type variations in new data and program
> combinations.  For this and my original reasons, it would be helpful to have
> this feature in the language.
>
> --Dave
>
> On Wed, Nov 19, 2014 at 3:37 PM, Mary Haley <haley at ucar.edu> wrote:
>>
>> Hi Dave,
>>
>> Our JIRA ticket database is down for maintenance at the moment, so I can't
>> check the status.  I'm pretty sure nothing has been done on it yet.  Dave
>> Brown will be the one to answer this, but he's not in this week.
>>
>> You had mentioned that "totype" would work as a temporary fix.  Is this
>> still working for you for now?
>>
>> --Mary
>>
>>
>> On Wed, Nov 19, 2014 at 11:22 AM, Dave Allured - NOAA Affiliate
>> <dave.allured at noaa.gov> wrote:
>>>
>>> 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
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>


More information about the ncl-talk mailing list