def coord_to_ID(self, coord, tol=0.5*u.arcsec, closest=True, **kwargs):
""" Convert an input coord to an ID if matched within a
given tolerance. If multiple sources are identified, return
the closest unless closest=False
Parameters
----------
coord : str or tuple or SkyCoord
See linetools.utils.radec_to_coord
Single coordinate
tol : Quantity
Angle
closest : bool, optional
If False, raise an error if multiple sources are within tol
Returns
-------
ID : int
ID of the closest source to the input coord
within the given tolerance
"""
# Catalog
ids = self.radial_search(coord, tol, **kwargs)
if len(ids) == 0:
warnings.warn("No sources found at your coordinate within tol={:g}. Returning None".format(tol))
return None, None
elif len(ids) > 1:
if closest:
warnings.warn("Found multiple sources in the catalog. Taking the closest one")
else:
raise IOError("Multiple sources within tol={:g}. Refine".format(tol))
# Finish
ID = ids[0]
return ID
评论列表
文章目录