Re: Conversion of List Object to array changed from 6.0 to 6.1. Why?

From: Wei Huang <huangwei_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 25 2014 - 16:54:04 MDT

Karl,

The default list type when creating a list variable was changed
from "CONCAT" AND "FIFO" to "FIFO" (in 6.1.0?).
The reason is now list has been used in more places rather then
it is originally designed for.

The behavior you have observed is what we wanted/planned.
In you case,

my_list = [/42, 43, 44/] a list.
newlist = my_list[:]

will created a newlist which is a sublist of my list (here a whole copy of
my_list).
You my do newlist = my_list[1:2], will be list of 2 items.

In 6.0.0, where the list default type is "CANCAT" and "FIFO",
where in 6.0.0, newlist = my_list[1:2] will return the concatenate
my_list's 1 and 2 item, which now become an array.

While in 6.2.0, the default type is "FIFO", newlist = my_list[1:2] will b=
e
a new
list with 2 items.

If you want it to return an array of 2 elements, you can use:
ListSetType(my_list, "CAT")
then myarr = my_list[1:2] will return an array with 2 elements.

The following script demonstrate how to use "join", "cat", and sub-setting.

 a = (/1, 2, 3, 4/)
 b = (/5, 6, 7, 8/)
 c = (/9, 10/)
 d = [/"11", "abc", 5.0, 6q, 7L, 8H/]

 lab = [/a, b/]

 ListSetType(lab, "join")
 jab = lab[:]
 print(jab)

 ListSetType(lab, "cat")
 cab = lab[:]
 print(cab)

 lac = [/a, c/]

;Do not "join" a and c, as they have different dimension size.
;ListSetType(lac, "join")
;jac = lac[:]
;print(jac)

 ListSetType(lac, "cat")
 cac = lac[:]
 print(cac)

 labcd = [/a, b, c, d/]
 f = labc[1:2]
 print(f)


Hope this help.

Wei



On Wed, Jun 25, 2014 at 4:31 AM, Karl-Hermann Wieners <
karl-hermann.wieners@mpimet.mpg.de> wrote:

> Hi all,
>
> with (admittedly ancient) ncl 6.0.0, I had a script that collected data
> in a List object and then converted this List into an array using e.g.
> my_list = [/ 42, 43, 44 /]
> my_array = my_list[:]
>
> print(my_array)
> would then list an array with three elements.
>
> Now, with ncl 6.1.0 and better,
> print(my_array)
> shows a List object of 3 items
>
> But if I set the list type to "join",
> ListSetType(my_list, "join")
>
> print(my_array)
> shows a common array again, as in 6.0.0
>
> So - two and a half questions here:
>
> 1) Is the different typing of my_list[:] for "cat" and "join" lists
> expected behavior? What would be the rationale behind it?
>
> 2) If it turns out that both should return List objects, how will I be
> able to easily convert Lists to arrays?
>
> Best,
> Karl
> --
> Karl-Hermann Wieners
> Max-Planck-Institut für Meteorologie
> Bundesstraße 53
> 20146 Hamburg
> Germany
> phone: +49 40 41173 161
> email: karl-hermann.wieners@mpimet.mpg.de
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

Received on Wed Jun 25 10:54:40 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT