Repository navigation
Fix stale motion after single-epoch refits; require 4 epochs for Parallax - #36
Open
wei-lingfeng wants to merge 4 commits into
Open
wei-lingfeng wants to merge 4 commits into
wei-lingfeng wants to merge 4 commits into
Conversation
…llax In iterations after the first, update_ref_table_aggregates sends stars with at most one epoch to combine_lists_xym, which sets x0/y0 to that epoch's position but leaves t0 and the motion parameters from the previous fit (introduced in cea7916). predict_positions then moves the star with its old velocity from the old t0, misplacing it at every other epoch; with clustered epochs, stars stop matching and split into several reference rows. x0/y0 are now shifted so that the star's existing trajectory passes through the new position. t0 and the motion parameters are kept, so catalog velocities still apply; a Fixed star is unchanged. MotionModel gets min_epochs, the fewest epochs before the model is chosen (None means n_params), read through required_epochs(). Parallax sets it to 4, as mm_rework did: 3 epochs in one season cannot separate parallax from proper motion. Only model selection in StarTable.fit_motion_models uses it. OB150211 pass 1 with the notebook settings: stars detected in >= 6 of 12 epochs go from 4-9 on dev to 201-204 (mm_rework: 170-192). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MosaicSelfRef, MosaicToRef and StarTable.fit_motion_models take
min_epochs, a dict keyed by model name (e.g. {'Parallax': 3}), that sets
the fewest epochs before a model is chosen for that run only. The class
attribute stays as the default (4 for Parallax, n_params otherwise).
Unknown names and values below n_params raise. The aligners pass it to
every motion fit, including the bootstrap, and write it to the params log.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the x0/y0 shift with the behavior fit_motion_models has, and that flystar had before cea7916: a star with one valid epoch so far in an iteration comes out of the fast path Fixed at its measured position, with NaN motion parameters and infinite errors on them, until a second epoch gives it a motion again. Only models that fit_motion_models demotes outright (demote='always') are reset; Orbit keeps its elements, which are the starting point of its fit. Keeping the old motion (the shift) made the reference motions carry over from one iteration to the next. In a self-referenced loop, such as the Westerlund 1 pass 3 (MosaicToRef against the previous iteration's members), a smooth motion pattern is invisible to the polynomial transformations, so it then grows from iteration to iteration and the loop no longer converges. Dropping the motion, as before, anchors it. OB150211 pass 1 (Parallax + Linear, chi2, stars in >= 6 of 12 epochs): 202-203 with this change, 201-204 with the shift; median residual with gaia3 0.98 mas, against 2.0-2.4 mas with the shift. test_mosaic_fit_and_fixed_orbit_with_update_ref_orig: the moving Linear star no longer sets the transformations (use_in_trans=False), and the period check compares with the fit's error instead of requiring a value closer to the truth than the initial guess, which is 0.15 off against an error of about 0.8. It passes with both versions of the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes for
MosaicToRef/MosaicSelfRefruns that lost most of their matches ondevcompared withmm_rework(OB150211 pass 1).1. Stale motion after a single-epoch refit (introduced in cea7916). In iterations after the first,
update_ref_table_aggregatessends stars with at most one epoch tocombine_lists_xym, which setsx0/y0to that epoch's position but leaves the motion model,t0, and the motion parameters from the previous fit.predict_positionsthen moves the star with its old velocity from the oldt0, so it is misplaced at every other epoch. With clustered epochs, stars stop matching and split into several reference rows. Such a star now comes out asfit_motion_modelsleaves it, and as flystar did before cea7916: Fixed at its measured position, with NaN motion parameters, until a second epoch gives it a motion again. Models that can keep a star on its initial values (Orbit) are left alone.An earlier version of this PR instead shifted
x0/y0so the old trajectory passed through the new position. That keeps the reference motions from one iteration to the next. In a self-referenced loop (MosaicToRefagainst the previous iteration's stars), a smooth pattern in those motions is invisible to polynomial transformations, so it grew each iteration and the loop stopped converging (Westerlund 1 pass 3). Dropping the motion, as before cea7916, anchors it, so no extra frame constraint is needed.2. Parallax with 3 epochs.
MotionModelgets amin_epochsclass attribute: the default fewest epochs before the model is chosen (Nonemeansn_params).Parallaxsets it to 4, asmm_reworkdid; 3 epochs within one season cannot separate parallax from proper motion. A run overrides it with the newmin_epochsargument ofMosaicSelfRef,MosaicToRef, andStarTable.fit_motion_models, a dict keyed by model name, e.g.MosaicToRef(..., min_epochs={'Parallax': 3})to allow 3 epochs ({'Parallax': None}also meansn_params). The override applies to that run only, including the bootstrap, and is written to the params log. Unknown model names and values belown_paramsraise. Only model selection uses it.OB150211 pass 1, notebook settings (
motion_models=['Parallax', 'Linear'], chi2 matching), stars detected in >= 6 of 12 epochs:(ranges over the two
dr_tolschedules used.) Median residual of each detection from its star's fit, gaia3: 0.98 mas with this branch, 2.0-2.4 mas with the shift; gaia4: 1.00 mas with both.Tests:
test_refit_from_one_epoch_drops_stale_motion(fails ondev: 437 reference rows for 150 stars),test_parallax_requires_min_epochs,test_check_min_epochs, andtest_min_epochs_per_run.test_mosaic_fit_and_fixed_orbit_with_update_ref_origis adjusted: its moving Linear star no longer sets the transformations (use_in_trans=False), and the period check compares with the fit's error (the initial period is 0.15 off; the error is about 0.8). It passes with both versions of the fix. Full suite: 140 passed.CHANGES.rstupdated.