[ncl-talk] get index for A associated with B

Xi Chang xi.chang01 at gmail.com
Wed Jun 10 14:30:14 MDT 2015


HI Alan,

Thanks, and I knew that. The problem is that I have  file A containts
repeatation years that make this function does not work properly, an
example:

ncl 7> A = (/1990,1997,1999,2002,2002,2005,2010,2010/)

ncl 8> B = (/1993,1997,2002,2004/)

ncl 9>

ncl 10> A_ind = get1Dindex(A,B)

fatal:Dimension sizes on right hand side of assignment do not match
dimension sizes of left hand side

fatal:Execute: Error occurred at or near line 1242 in file
$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl


fatal:Execute: Error occurred at or near line 10

It seeems like this function does not allow repeatation of the year. any
suggestion?>

Chang





On Wed, Jun 10, 2015 at 10:18 PM, Alan Brammer <abrammer at albany.edu> wrote:

> Take look at get1Dindex linked below.  It should do what you want. Below
> are a few quick example lines I threw together to get the matching indices
> for both A and B.
>
> https://www.ncl.ucar.edu/Document/Functions/Contributed/get1Dindex.shtml
>
>
>
> e.g.
>
> A = (/1990,1997,1999,2002,2005,2010/)
>
> B = (/1993,1997,2002,2004/)
>
>
> A_ind = get1Dindex(A,B)        ;; array size B of where A is in B, Fill if
> not in B
> A_ind_nm = A_ind(ind(.not.ismissing(A_ind))) ;; get rid of missing elements
> Ca = A(A_ind_nm)                 ;; probably want an error check in case
> there are no overlaps.
>
>
> B_ind = get1Dindex(B,A)        ;; array size B of where A is in B, Fill if
> not in B
> B_ind_nm = B_ind(ind(.not.ismissing(B_ind))) ;; get rid of missing elements
> Cb = B(B_ind_nm)                 ;; probably want an error check in case
> there are no overlaps.
>
>
> Gd Luck.
>
> Alan.
>
>
> On 10 June 2015 at 15:33, Xi Chang <xi.chang01 at gmail.com> wrote:
>
>> Hallo all,
>>
>> Anyone can give me a hint how to get list of index for A which is
>> associated with B,
>> for illustration:
>>
>> file A containts :
>> -1990
>> -1997
>> -1999
>> -2002
>>
>> file B
>> -1993
>> -1997
>> -2002
>> -2005
>>
>> and in the end, will produce file C which only containts:
>> -1997
>> -2002
>>
>> I cant do it mannually becaise the time series are too long..
>> any suggestion for a  clean alogirhtm?
>>
>> Thanks
>> Chang
>>
>> _______________________________________________
>> 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/20150610/4b0165b9/attachment.html 


More information about the ncl-talk mailing list