astronomy-commons/hats-tap

Translate nearest-neighbor searches from AQDL

オープン

#15 opened on 2025/12/01

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)Python (0 件のフォーク)auto 404
enhancementgood first issue

Repository metrics

Stars
 (1 個のスター)
PR merge metrics
 (平均マージ 2d 7h) (30d で 1 merged PR)

説明

Feature request

A query like this:

SELECT 
  o1.diaObjectId AS id1,
  o2.diaObjectId AS id2,
  DISTANCE(POINT('ICRS', o1.ra, o1.dec), POINT('ICRS', o2.ra, o2.dec)) AS d
FROM
  ppdb.DiaObject AS o1
JOIN
  ppdb.DiaObject AS o2 ON o1.diaObjectId <> o2.diaObjectId AND o1.validityStart = o2.validityStart
WHERE
  CONTAINS(POINT('ICRS', o1.ra, o1.dec), CIRCLE('ICRS', 186.84, 7.01, 0.05)) = 1
AND 
  DISTANCE(POINT('ICRS', o1.ra, o1.dec), POINT('ICRS', o2.ra, o2.dec)) < 0.02;

should be translated to:

from lsdb.core.crossmatch.bounded_kdtree_match import BoundedKdTreeCrossmatch
cone = ppdb.cone_search(ra=186.84, dec=7.01, radius_arcsec=0.05*3600)
xmatch = cone.crossmatch(ppdb, algorithm=BoundedKdTreeCrossmatch, min_radius_arcsec=1e-5, radius_arcsec=0.02*3600, suffixes=("_1", "_2"))
xmatch = xmatch[xmatch["validityStart_1"] == xmatch["validityStart_2"]]
compute(xmatch[["diaObjectId_1","diaObjectId_2","_dist_arcsec"]])

This is a difficult one, but it's possible, if the translator knows:

  1. Why o1 and o2 should be joined on ID in order to be equivalent to ppdb.
  2. That the DISTANCE constraint should be converted into radius_arcsec= (this should be done for existing crossmatch translation anyway, and should be its own issue).
  3. To do the validity-start match after the crossmatch. The way the ADQL is written, it would be reasonable to do that search first, but of course it's more efficient to do that post-crossmatch.

Before submitting Please check the following:

  • I have described the purpose of the suggested change, specifying what I need the enhancement to accomplish, i.e. what problem it solves.
  • I have included any relevant links, screenshots, environment information, and data relevant to implementing the requested feature, as well as pseudocode for how I want to access the new functionality.
  • If I have ideas for how the new feature could be implemented, I have provided explanations and/or pseudocode and/or task lists for the steps.

コントリビューターガイド