[ncl-talk] getting a field in an a 2D array

Mary Haley haley at ucar.edu
Wed Apr 11 21:05:13 MDT 2018


Dear Lyndz,

I wrote an email answering your question about how to access rows and
columns of data, but then I realized that I'm not sure this is what you
really wanted.

It might be easier for you to read each column of data from the file
individually, and then sort the array(s) that you need.

Since it's not clear what you want to do with the sorted values, I created
an example that creates a sort vector for the "sn" column, and then it
prints both "sn" and "year" using this sort vector.

Since I was curious, I also plotted your data with different colored dots
for each of the unique categories, and different dots for each set of years.

If you are still not sure how to get the sorting you need, please reply
back to ncl-talk with more information about what you are trying to do.

Thanks

--Mary



On Tue, Apr 10, 2018 at 8:49 PM, Lyndz <olagueralyndonmark429 at gmail.com>
wrote:

>
> Dear NCL experts,
>
> I am trying to get a field in a 2D array after sorting. Is there a way to
> extract the "fourth column" (*(0,4) 198920 in the sample below)*, for
> example in the 2D array. I tried using the *str_get_field *function, but
> it does not work for this case.
>
> Any suggestion on how to do this correctly?
>
>
> These are the commands that I am using:
>
> filename="test.txt"
> test=readAsciiTable(filename,9,"float",1)
> i=dim_pqsort_n(test(:,0),1,0)
> Aout=test(i,:)
> print(Aout)
>
> Variable: Aout
> Type: float
> Total Size: 39528 bytes
>             9882 values
> Number of Dimensions: 2
> Dimensions and sizes: [1098] x [9]
> Coordinates:
> Number Of Attributes: 1
>   _FillValue : 9.96921e+36
> (0,0) 0
> (0,1) 26.1
> (0,2) 130
> (0,3) 40
> *(0,4) 198920*
> (0,5) 20
> (0,6) 1989
> (0,7) 8
> (0,8) 26
> (1,0) 0
> (1,1) 28.7
> (1,2) 122.9
>
>
> I'll appreciate any help.
>
>
> Sincerely,
>
> Lyndz
>
> _______________________________________________
> 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/20180411/34dfe9a8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: storm.000001.png
Type: image/png
Size: 198511 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180411/34dfe9a8/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: storm.000002.png
Type: image/png
Size: 184410 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180411/34dfe9a8/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: storm.ncl
Type: application/octet-stream
Size: 3851 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180411/34dfe9a8/attachment-0001.obj>


More information about the ncl-talk mailing list