Skip to content

DM-54923: Allow AP association to fall back to second-best match#358

Merged
isullivan merged 5 commits into
mainfrom
tickets/DM-54923
Jun 26, 2026
Merged

DM-54923: Allow AP association to fall back to second-best match#358
isullivan merged 5 commits into
mainfrom
tickets/DM-54923

Conversation

@isullivan

Copy link
Copy Markdown
Contributor

No description provided.

@isullivan isullivan force-pushed the tickets/DM-54923 branch 2 times, most recently from 5bbfa70 to 94c2635 Compare May 21, 2026 20:07

@ebellm ebellm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor comments

obj_dec = dia_objects["dec"].to_numpy()[obj_idx]

# Wrap RA difference to (-180, 180].
dra = ((src_ra - obj_ra) + 180.0) % 360.0 - 180.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason to do this offset? doesn't it have the same boundary problems, just in a different location? I think we need dra to be correct even at ra=180

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to make the comment more clear. This adds 180, does the mod 360, then subtracts the 180 offset back off. This makes sure that the difference is never greater than +/-180.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course! Sorry, wasn't thinking carefully enough

var_ra = np.maximum(var_ra, sigma_floor_sq_deg)
var_dec = np.maximum(var_dec, sigma_floor_sq_deg)

chi2 = dra*dra/var_ra + ddec*ddec/var_dec

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
chi2 = dra*dra/var_ra + ddec*ddec/var_dec
chi2 = dra**2./var_ra + ddec**2./var_dec

if (self._has_position_errors(dia_sources)
and self._has_position_errors(dia_objects)):
scores = self._position_nll(dia_sources, dia_objects, src_idx, obj_idx)
# ``max_dist`` is the sole association gate: every candidate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ultimately we want to replace this with actual probabilistic association (a la NWAY) rather than using a hard max_dist cut. But no objections for now.

…s are present

The associator previously ranked candidate matches by chord distance only
and accepted any pair within a fixed 1" cap, ignoring per-source and
per-object positional uncertainties entirely.
When the uncertainty columns are missing or contain no usable values, the
score reverts to the kd-tree chord distance (the previous behavior).
The previous matcher considered only each DIASource's single nearest
DIAObject. When two sources competed for the same object, the loser
would be unassociated and triggered a new DIAObject even if a viable
second-best candidate was nearby.
…sociations

This avoids the case where a further diaObject with worse coordinate errors has a lower chi-squared than a nearby diaObject with tight errors.
@isullivan isullivan merged commit d691909 into main Jun 26, 2026
4 checks passed
@isullivan isullivan deleted the tickets/DM-54923 branch June 26, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants