[ncl-talk] sort by attribute

Dennis Shea shea at ucar.edu
Sat Oct 19 14:21:54 MDT 2019


The attached  uses *dim_pqsort*
<http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_pqsort.shtml> to
perform a passive sort. The returned indices can be used to sort in
ascending or descending order.
---
*%> *ncl JingSu.att_sort.ncl
---
Variable: id
Type: integer
Total Size: 40 bytes
            10 values
Number of Dimensions: 1
Dimensions and sizes: [10]
Coordinates:
(0) 2
(1) 0
(2) 1
(3) 4
(4) 3
(5) 9
(6) 8
(7) 7
(8) 6
(9) 5
(0) ===
(0) 2   0.935907  0.935907  0.000000
(1) 0   0.906182  0.886948  0.185708
(2) 1   0.906182  0.886948 -0.185708
(3) 4   0.739727  0.681007 -0.288834
(4) 3   0.739727  0.681007  0.288834
(5) 9   0.617620  0.617620  0.000000
(6) 8   0.192471  0.192471  0.000000
(7) 7   0.123401  0.045457 -0.114723
(8) 6   0.123401  0.045457  0.114723
(9) 5   0.068725 -0.068725  0.000000


On Sat, Oct 19, 2019 at 11:35 AM Jing Sun via ncl-talk <ncl-talk at ucar.edu>
wrote:

> Dear NCL users,
>
> is that possible to sort the array by one of the attribute?
> For example, I want the variable evlr show in descending order of the
> attribute eigv_length.
>
> Variable: evlr
> Type: float
> Total Size: 1600 bytes
>             400 values
> Number of Dimensions: 1
> Dimensions and sizes: [10]
> Coordinates:
> Number Of Attributes: 5
>   eigright : <ARRAY of 100 elements>
>   eigleft : <ARRAY of 100 elements>
>   eigi : ( 0.1857084, -0.1857084,  0, 0.2888337, -0.2888337,  0,
> 0.1147234, -0.1147234,  0,  0 )
>   eigr : ( 0.8869482, 0.8869482, 0.9359075, 0.6810071, 0.6810071,
> -0.06872535, 0.0454572, 0.0454572, 0.192471, 0.6176199 )
>   eigv_length : ( 0.9061815, 0.9061815, 0.9359075, 0.7397267, 0.7397267,
> 0.06872535, 0.123401, 0.123401, 0.192471, 0.6176199 )
>
>  Thanks for your help in advance.
>
> Best regards,
> Jing
>
>
>
> _______________________________________________
> 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/20191019/98fe0f6f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: JingSu.att_sort.ncl
Type: application/octet-stream
Size: 1614 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20191019/98fe0f6f/attachment.obj>


More information about the ncl-talk mailing list