Yes, dim_pqsort_n does solve the problem.  If your theory on how the 
function works is correct, it's a change from previous ncl versions 
(this wasn't a problem before). 
In any case, it's been fixed using the new version of the function.
Thanks for the feedback,
Melissa
Dennis Shea wrote:
> Consider
>
>    pv22 = dim_pqsort(b2(nlsd|:,time|:),2)
>
> I *think* that NCL creates a temporary variable [say, "q"].
> This temporary variable which contains reordered "b2"
> is sorted correctly. However, the temporary variable
> "q" is not being placed back into the *original* variable
> "b2" address space.
>
> I have not tested but I speculate that using dim_pqsort_n
> will fix the problem
>
>    pv22 = dim_pqsort_n(b2, 2, 0)
>
> Good Luck
>
>
>
> Rick Brownrigg wrote:
>> Hi Melissa,
>>
>> Curiously, if the reordered b2 is assigned to a variable first, and  
>> then dim_pqsort is called on that variable, things seem to work (see  
>> below).  I know this doesn't answer your question directly nor 
>> explain  any change in behavior.  I will try to find out more.
>>
>> Had you upgraded to a new NCL version since your scripts were  
>> originally developed?
>>
>> Rick
>>
>> ...
>> b2!0 = "time"
>> b2!1 = "nlsd"
>> foo=b2(nlsd|:,time|:)
>> print(foo)
>>
>> Variable: foo
>> Type: float
>> Total Size: 32 bytes
>>              8 values
>> Number of Dimensions: 2
>> Dimensions and sizes:    [nlsd | 4] x [time | 2]
>> Coordinates:
>> Number Of Attributes: 1
>>    _FillValue :    -999
>> (0,0)    54
>> (0,1)    98
>> (1,0)    -999
>> (1,1)     5
>> (2,0)     3
>> (2,1)    34
>> (3,0)    455
>> (3,1)     0
>> ;;pv22 = dim_pqsort(b2(nlsd|:,time|:),2)
>> pv22 = dim_pqsort(foo, 2)
>> ;;print(b2)
>> print(foo)
>>
>> Variable: foo
>> Type: float
>> Total Size: 32 bytes
>>              8 values
>> Number of Dimensions: 2
>> Dimensions and sizes:    [nlsd | 4] x [time | 2]
>> Coordinates:
>> Number Of Attributes: 1
>>    _FillValue :    -999
>> (0,0)    54
>> (0,1)    98
>> (1,0)    -999
>> (1,1)     5
>> (2,0)     3
>> (2,1)    34
>> (3,0)     0
>> (3,1)    455
>>
>>
>>
>> On Sep 17, 2009, at 1:18 PM, Melissa Bukovsky wrote:
>>
>>> Hi,
>>>
>>> I have a handful of scripts that started failing recently (or giving
>>> very strange output).  They used to work fine with the same  
>>> dataset.  I
>>> finally think I've figured out why, but the answer doesn't seem to  
>>> make
>>> sense to me.  I narrowed down the problem to the dim_pqsort function.
>>> It seems that it doesn't sort the input variable if I use named
>>> dimensions to reorder the input array anymore.  Is this not supported
>>> with this function anymore?  There is still an example on the function
>>> page using it.  dim_pqsort_n solves this problem, but that requires
>>> finding and replacing dim_pqsort in a number of my functions.
>>>
>>> Instead of attaching my lengthy scripts, a command line test of the
>>> problem with comments added is pasted below.  If I'm wrong about  
>>> this or
>>> doing something wrong, please let me know.
>>>
>>> Thanks,
>>>
>>> Melissa
>>>
>>>
>>> /fs/home/bukovsky/ncl/phd/my_ncl_funct % ncl
>>> Copyright (C) 1995-2009 - All Rights Reserved
>>> University Corporation for Atmospheric Research
>>> NCAR Command Language Version 5.1.1
>>> The use of this software is governed by a License Agreement.
>>> See http://www.ncl.ucar.edu/ for more details.
>>> ncl 0> a = (/54,67,8,23,45,654,77/)
>>> ncl 1> b = a
>>> ncl 3> pv = dim_pqsort(a,2)
>>> ncl 4> print(a)
>>>
>>> Variable: a
>>> Type: integer
>>> Total Size: 28 bytes
>>>            7 values
>>> Number of Dimensions: 1
>>> Dimensions and sizes:   [7]
>>> Coordinates:
>>> (0)     8
>>> (1)     23
>>> (2)     45
>>> (3)     54
>>> (4)     67
>>> (5)     77
>>> (6)     654
>>> ;NO PROBLEM WITH A 1D ARRAY, TRY A 2D...
>>>
>>> ncl 5> a2 = new( (/2,4/),float)
>>> ncl 6> print(a2)
>>>
>>> Variable: a2
>>> Type: float
>>> Total Size: 32 bytes
>>>            8 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes:   [2] x [4]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>  _FillValue :  -999
>>> (0,0)   -999
>>> (0,1)   -999
>>> (0,2)   -999
>>> (0,3)   -999
>>> (1,0)   -999
>>> (1,1)   -999
>>> (1,2)   -999
>>> (1,3)   -999
>>>
>>> ncl 8> a2(0,0) = 54
>>> ncl 9> a2(0,2) = 3
>>> ncl 10> a2(0,3) = 455
>>> ncl 12> a2(1,0) = 98
>>> ncl 13> a2(1,1) = 5
>>> ncl 14> a2(1,2) = 34
>>> ncl 15> a2(1,3) = 0
>>> ncl 16> b2 = a2            ;save a2
>>> ncl 17> c2 = a2            ;save a2 again
>>> ncl 18> print(a2)
>>>
>>> ;ORIGINAL 2D ARRAY
>>> Variable: a2
>>> Type: float
>>> Total Size: 32 bytes
>>>            8 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes:   [2] x [4]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>  _FillValue :  -999
>>> (0,0)   54
>>> (0,1)   -999
>>> (0,2)    3
>>> (0,3)   455
>>> (1,0)   98
>>> (1,1)    5
>>> (1,2)   34
>>> (1,3)    0
>>> ncl 19> pv2 = dim_pqsort(a2,2)
>>> ncl 20> print(a2)
>>>
>>> ;SORTING IT WITHOUT REORDERING THE DIMENSIONS WORKED...
>>> Variable: a2
>>> Type: float
>>> Total Size: 32 bytes
>>>            8 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes:   [2] x [4]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>  _FillValue :  -999
>>> (0,0)   -999
>>> (0,1)    3
>>> (0,2)   54
>>> (0,3)   455
>>> (1,0)    0
>>> (1,1)    5
>>> (1,2)   34
>>> (1,3)   98
>>>
>>> ;TRY AGAIN REORDERING WITH NAMED DIMS...
>>> ncl 21> b2!0 = "time"
>>> ncl 22> b2!1 = "nlsd"
>>> ncl 23> pv22 = dim_pqsort(b2(nlsd|:,time|:),2)
>>> ncl 24> print(b2)
>>>
>>> ;B2 2D ARRAY SORTED, BUT IT DIDN'T WORK (THERE IS NO DIFFERENCE 
>>> FROM  THE
>>> ORIGINAL)
>>> Variable: b2
>>> Type: float
>>> Total Size: 32 bytes
>>>            8 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes:   [time | 2] x [nlsd | 4]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>  _FillValue :  -999
>>> (0,0)   54
>>> (0,1)   -999
>>> (0,2)    3
>>> (0,3)   455
>>> (1,0)   98
>>> (1,1)    5
>>> (1,2)   34
>>> (1,3)    0
>>> ncl 25> print(c2)
>>>
>>> ;C2 IS STILL THE ORIGINAL (TO COMPARE ABOVE)
>>> Variable: c2
>>> Type: float
>>> Total Size: 32 bytes
>>>            8 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes:   [2] x [4]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>  _FillValue :  -999
>>> (0,0)   54
>>> (0,1)   -999
>>> (0,2)    3
>>> (0,3)   455
>>> (1,0)   98
>>> (1,1)    5
>>> (1,2)   34
>>> (1,3)    0
>>>
>>> ;SORT DIMINSION 0 USING dim_pqsort_n NOW
>>> ncl 26> pv5 = dim_pqsort_n(b2,2,0)
>>> ncl 27> print(b2)
>>>
>>> ;THIS TIME IT WORKED
>>> Variable: b2
>>> Type: float
>>> Total Size: 32 bytes
>>>            8 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes:   [time | 2] x [nlsd | 4]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>  _FillValue :  -999
>>> (0,0)   54
>>> (0,1)   -999
>>> (0,2)    3
>>> (0,3)    0
>>> (1,0)   98
>>> (1,1)    5
>>> (1,2)   34
>>> (1,3)   455
>>>
>>> ;TO SEE THIS MORE EASILY
>>> ncl 28> print(b2(nlsd|:,time|:))
>>>
>>> Variable: b2 (subsection)
>>> Type: float
>>> Total Size: 32 bytes
>>>            8 values
>>> Number of Dimensions: 2
>>> Dimensions and sizes:   [nlsd | 4] x [time | 2]
>>> Coordinates:
>>> Number Of Attributes: 1
>>>  _FillValue :  -999
>>> (0,0)   54
>>> (0,1)   98
>>> (1,0)   -999
>>> (1,1)    5
>>> (2,0)    3
>>> (2,1)   34
>>> (3,0)    0
>>> (3,1)   455
>>>
>>> ;THIS IS A PROBLEM WITH 3D ARRAYS TOO, BUT I CUT THAT PART OUT (THOUGH
>>> THAT IS WHAT THE ORIGINAL PROBLEM WAS WITH)
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Sep 17 2009 - 15:25:35 MDT
This archive was generated by hypermail 2.2.0 : Fri Sep 18 2009 - 15:36:15 MDT