[AstroPy] search_around_sky

Evert Rol evert.rol at gmail.com
Tue Nov 3 20:34:22 EST 2015

Stefano, if I understand you correctly, you have:

    index2, index1, d2d, d3d = coord1.search_around_sky(coord2, maxsep)

and you want to find "~index2" and "~index1" (which, of course, don't exist like that).

I actually assume you want to find the *coordinates* of the non-matched sources, not the indices. But both can be done.
There's no simple one-liner that I know of, but creating a boolean mask is simple and useful to have around anyway (since a boolean mask can be simply inverted, unlike a array of indices).

    ind1 = np.unique(index1)
    mask = np.ones(len(coord1), dtype=np.bool)
    mask[ind1] = False
    nonmatched_coord1 = coord1[mask]
    nonmatched_ind1 = np.arange(len(coord1))[mask]

and similar for coord2.

I'm using np.unique to filter multiple matched objects. It's not really necessary here, but more as an ease of mind. (Otherwise you'd just be setting some values in the mask to False twice.)
The last line is to get the indices, and essentially coord1[nonmatched_ind1] == nonmatched_coord1 .


> Hello everybody,
> I am using "search_around_sky" to match two list of sources, and it works fine.
> Is there, however, a simple way to have the indices in the two input coordinate lists of the non-matched objects?
> Thanks, and my apologies if the issue has already been discussed in the past.
> Stefano
> _______________________________________________
> AstroPy mailing list
> AstroPy at scipy.org
> https://mail.scipy.org/mailman/listinfo/astropy

More information about the AstroPy mailing list