query_catalog.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:specdb 作者: specdb 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号