[ncl-talk] get index for A associated with B
Alan Brammer
abrammer at albany.edu
Wed Jun 10 14:18:11 MDT 2015
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/4a867d22/attachment.html
More information about the ncl-talk
mailing list