[ncl-talk] Error subscript when using indices output from dim_pqsort to reorder another array

YAN HUIPING yanhp2009 at gmail.com
Thu May 28 16:34:27 MDT 2020


Also, I tried to use a simple array as the example on the website of the function, 
==============================
begin
  
x=(/(/2,1,3/),(/4,6,5/)/)
printVarSummary(x)
print(x)
ip=dim_pqsort(x,-2)
print(x)

printVarSummary(ip)

y=(/(/2,1,3/),(/4,6,5/)/)
y=y(ip,:)

print(y)
end
============================
The error message came again,

Variable: x
Type: integer
Total Size: 24 bytes
            6 values
Number of Dimensions: 2
Dimensions and sizes:	[2] x [3]
Coordinates: 


Variable: x
Type: integer
Total Size: 24 bytes
            6 values
Number of Dimensions: 2
Dimensions and sizes:	[2] x [3]
Coordinates: 
(0,0)	2
(0,1)	1
(0,2)	3
(1,0)	4
(1,1)	6
(1,2)	5


Variable: x
Type: integer
Total Size: 24 bytes
            6 values
Number of Dimensions: 2
Dimensions and sizes:	[2] x [3]
Coordinates: 
(0,0)	3
(0,1)	2
(0,2)	1
(1,0)	6
(1,1)	5
(1,2)	4

Variable: ip
Type: integer
Total Size: 24 bytes
            6 values
Number of Dimensions: 2
Dimensions and sizes:	[2] x [3]
Coordinates: 
fatal:Illegal subscript. Subscripts must be scalar or one dimensional vectors

fatal:["Execute.c":8640]:Execute: Error occurred at or near line 12 in file test.ncl


Thanks,
Huiping


> On May 29, 2020, at 6:23 AM, YAN HUIPING <yanhp2009 at gmail.com> wrote:
> 
> Hi,
> I post the message
> 
> 
> the ncl script:
> 
> ==========================================
> x=PPnew
> print(num(ismissing(x)))
> y=TTnew
> ip=dim_pqsort_n(x,-2,3)
> printVarSummary(x)
> printVarSummary(ip)
> printMinMax(ip,0)
> print(dimsizes(ip))
> 
> TTnew=y(ip,:,:,:);
> printMinMax(TTnew,0)
> =========================================
> 
> (0)	missing number 0
> 
> Variable: x
> Type: float
> Total Size: 31948800 bytes
>             7987200 values
> Number of Dimensions: 4
> Dimensions and sizes:	[time | 12] x [lat | 160] x [lon | 320] x [LEV | 13]
> Coordinates: 
>             time: [20160116.875..20161216.875]
>             lat: [89.14151942646112..-89.14151942646112]
>             lon: [   0..358.875]
>             LEV: [107500..5000]
> Number Of Attributes: 7
>   _FillValue :	1e+20
>   institution :	MPIMET
>   cell_methods :	time: mean
>   table :	128
>   code :	130
>   units :	K
>   long_name :	pressure
> 
> Variable: ip
> Type: integer
> Total Size: 31948800 bytes
>             7987200 values
> Number of Dimensions: 4
> Dimensions and sizes:	[12] x [160] x [320] x [13]
> Coordinates: 
> (0)	min=0   max=12
> (0)	12
> (1)	160
> (2)	320
> (3)	13
> fatal:Illegal subscript. Subscripts must be scalar or one dimensional vectors
> 
> ====================
> 
> Y has the same dimensions as X ([time | 12] x [lat | 160] x [lon | 320] x [LEV | 13]). And there is no missing value in X, but Y has some.
> 
> 
> Thus, I think there are some bugs here. Could you please help me look into it?
> 
> Thanks,
> Huiping
> 
> 
>> On May 29, 2020, at 1:21 AM, Dennis Shea <shea at ucar.edu <mailto:shea at ucar.edu>> wrote:
>> 
>> Whenever you encounter an error, you should add print statements to help you debug the issue.
>> 
>>   printVarSummary(x)                         ; overview of source variable
>>   print("-----")                                       ; visual break
>> 
>>   ip = dim_pqsort(x,-2)                          ;; descending order
>>   printVarSummary(ip)
>>   prinyMinMax(ip, 0)
>>   print("-----") 
>> 
>>   dim_ip = dimsizes(ip)
>>   print(dim_ip)
>>   print("-----")    
>> 
>>    y=y(ip,:,:,:)
>> =============================
>> Are there grid locations that contain all missing values? 
>> 
>> 
>> 
>> On Tue, May 26, 2020 at 6:36 PM YAN HUIPING via ncl-talk <ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>> wrote:
>> Hi,
>> I am using the function dim_pqsort to reorder an array with dimensions of (time,nlat, nlon, nlev) following the instructions https://www.ncl.ucar.edu/Document/Functions/Built-in/dim_pqsort.shtml <https://www.ncl.ucar.edu/Document/Functions/Built-in/dim_pqsort.shtml>
>> 
>> ip=dim_pqsort(x,-2);; descending order
>> y=y(ip,:,:,:)
>> 
>> However, there are error messages: “fatal:Illegal subscript. Subscripts must be scalar or one dimensional vectors”.
>> Ps: the version of NCL I used is 6.5.0
>> 
>> Could please help me on this problem?
>> 
>> Thanks,
>> Huiping
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200529/55743747/attachment.html>


More information about the ncl-talk mailing list