def cat_from_coords(self, coords, toler=0.5*u.arcsec, **kwargs):
""" Return a cut-out of the catalog matched to input coordinates
within a tolerance. Ordered by the input coordinate list.
Entries without a match are Null with ID<0.
Parameters
----------
coords : SkyCoord
Single or array
toler : Angle, optional
verbose : bool, optional
Returns
-------
matched_cat : Table
"""
# Generate the dummy table
if len(coords.shape) == 0:
ncoord = 1
else:
ncoord = coords.shape[0]
matched_cat = Table(np.repeat(np.zeros_like(self.cat[0]), ncoord))
# Grab IDs
IDs = self.match_coord(coords, toler=toler, **kwargs)
# Find rows in catalog
rows = match_ids(IDs, self.cat[self.idkey], require_in_match=False)
# Fill
gd_rows = rows >= 0
matched_cat[np.where(gd_rows)] = self.cat[rows[gd_rows]]
# Null the rest
matched_cat[self.idkey][np.where(~gd_rows)] = IDs[~gd_rows]
# Return
return matched_cat
评论列表
文章目录