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

Laura Fowler laura at ucar.edu
Thu May 28 16:35:50 MDT 2020


Hi Huiping:
may be you need to add delete(TTnew) before the line:

delete(TTnew)
TTnew=y(ip,:,:,:);
printMinMax(TTnew,0)

since TTnew is originally a 4-dimensional array.
Laura




On Thu, May 28, 2020 at 4:23 PM YAN HUIPING via ncl-talk <ncl-talk at ucar.edu>
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> 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> 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
>>
>> 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
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk



-- 
!-------------------------------------------------------------------------------------------------------------
Laura D. Fowler

Mesoscale and Microscale Meteorology Division (MMM)
National Center for Atmospheric Research
P.O. Box 3000, Boulder CO 80307-3000

e-mail: laura at ucar.edu
phone: 303-497-1628

!-------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200528/67ac401f/attachment.html>


More information about the ncl-talk mailing list