[ncl-talk] populating lists with multidimensional arrays

Rick Brownrigg brownrig at ucar.edu
Wed Mar 2 22:24:40 MST 2016


Hi Will,

It looks like you've uncovered a bug, and it seems to relate to the
array-slicing in combination with the list. If I manually create a list
comprised of different sized arrays, it works:

    l = [/ (/ 1, 2, 3 /), (/ 4, 5, 6, 7, 8 /) /]
    print(l)

But if we take a condensed version of your example:
We get:

    ListAppend(Q,x(:,:2))
    print(Q)


    Variable: Q
    Type: list
    Total Size: 4 bytes
                1 values
    Number of Dimensions: 1
    Dimensions and sizes:   [1]
    Coordinates:
    Type: list <fifo>
    Total items: 0

which is clearly not right. I tried assigning the slice of the x-array to a
temporary variable and then appending the temp-var to the list, but that
does not work either.

I will file a bug-report ticket in the morning and take a look at what is
going on. I'm sorry that I don't have a good work-around offhand.

Rick


On Wed, Mar 2, 2016 at 7:56 PM, Will Hobbs <will.hobbs at utas.edu.au> wrote:

> Hi all
>
> My understanding from the documentation is that elements of an NCL list do
> not need to be the same size, but I am having trouble populating a list
> with arrays that are not the same size.
>
> Consider the following test case:
>
> P = NewList("fifo")           ;create new list
> Q = NewList("fifo")          ;another new list
> x = (/(/1,2,3/),(/4,5,6/)/)  ;a test array
>
> do i = 0, 2
>
> ListAppend(P,x)                 ;keep adding array 'x'
> ListAppend(Q,x(:,:i))       ;add a different sized subset of 'x'
>
> end do
>
> print(P)
>
> ;returns the following (expected)
> ;Variable: P
> ;Type: list
> ;Total Size: 4 bytes
> ;            1 values;
> ;Number of Dimensions: 1
> ;Dimensions and sizes:   [1]
> ;Coordinates:
> ;Type: list <fifo>
> ;Total items: 3
>
>
> print(Q)
> ;returns the following (an empty list)Variable: P
> Type: list
> Total Size: 4 bytes
>             1 values
> Number of Dimensions: 1
> Dimensions and sizes:   [1]
> Coordinates:
> Type: list <fifo>
> Total items: 0
>
> What am I missing here?
>
> Many thanks
>
> Will
>
>
>
> University of Tasmania Electronic Communications Policy (December, 2014).
> This email is confidential, and is for the intended recipient only.
> Access, disclosure, copying, distribution, or reliance on any of it by
> anyone outside the intended recipient organisation is prohibited and may be
> a criminal offence. Please delete if obtained in error and email
> confirmation to the sender. The views expressed in this email are not
> necessarily the views of the University of Tasmania, unless clearly
> intended otherwise.
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> 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/20160302/f85911dc/attachment.html 


More information about the ncl-talk mailing list