Re: usage of get1Dindex function ...

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 27 2010 - 13:02:07 MDT

Hi Ufuk

Actually the "get1Dindex" fuction notes the following:

"The input arguments should contain only unique values. Duplicate
entries will lead to a fatal error."

I ahve attached a script that contains an example.
It also (I think) illustrates an error in your
original script. The fact that subscripts are repeated means that
the reurn size might be different ... thay are!!!.

Good luck

On 04/27/2010 12:22 PM, u.utku.turuncoglu@be.itu.edu.tr wrote:
> Hi,
>
> I wrote the following procedure to sort x,y coordinate pair based on
> selected one. The opt controls the behavior of the sort procedure. If the
> value is equal to 1 then, it sorts the x values and match the correct y
> with it.
>
> undef("sort_xy")
> procedure sort_xy(x:numeric, y:numeric, opt:numeric)
> local x_old, y_old, x_ind, y_ind
> begin
> ;--- sort x ---
> if (opt .eq. 1) then
> x_old = x
> qsort(x)
> x_ind = get1Dindex(x_old, x)
> y_old = y
> y = y(x_ind)
> ;--- sort y ---
> else
> y_old = y
> qsort(y)
> y_ind = get1Dindex(y_old, y)
> x_old = x
> x = x(y_ind)
> end if
> end
>
> when i run this procedure,
>
> xxx = (/ 3, 5, 2, 10, 6, 4, 3 /)
> yyy = (/ 1, 8, 4, 3 , 7, 6, 2 /)
> sort_xy(xxx, yyy, 1)
>
> it gives the "fatal:Dimension sizes on right hand side of assignment do
> not match dimension sizes of left hand side" error in the "get1Dindex"
> call line. The dimension of the arrays y_old and y or x_old and x is same
> and the second argument is sorted. I could not find the source of problem.
> Is there any special requirement to use "get1Dindex" function? How can i
> solve it?
>
> Thanks,
>
> --ufuk
>
>

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================


_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Tue Apr 27 13:02:14 2010

This archive was generated by hypermail 2.1.8 : Thu Apr 29 2010 - 08:05:27 MDT