-
Notifications
You must be signed in to change notification settings - Fork 1
Accelerated MotionModel that has passed all the testing functions! #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mm_rework
Are you sure you want to change the base?
Conversation
…ed absolute sigma in Linear model
…odel error calculations
… Update trans_positions
Update data fitting logic: Compare observed data points with model parameters. If n_obs < n_params, return fill value for the parameters and infinity for the uncertainties; Otherwise, calculate parameters normally. If n_obs = n_params and absolute_sigma=False, return infinity for uncertainties (Same behavior as scipy curve fit).
…motion models. Update fitting logic: Provide multiple motion models, use the available model with the most number of parameters to fit according to the observed data points (i.e., choose the model with n_obs >= n_params). Removed motion_model_input and default_motion_model for clarity.
…atch_pos at_time into model; Renamed get_ functions into calc_ functions
… and get_batch_pos_at_time into model; Replaced MotionModel.fit_motion_model with MotionModel.fit; Rewrote and accelerated StarTable.fit_velocities with StarTable.fit_motion_model
| edx = np.arange(n_obs, dtype=int) | ||
| # Precompute All Bootstrap Draws at Once | ||
| # Ensure there are enough unique points in each bootstrap sample | ||
| bdx_unique = np.stack([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the size of the bootstrap index arrays 2*n_params now? The previous version used the number of points in the full data set.
| fit_param_names = [] | ||
|
|
||
| # Number of fit parameters/required observations in each direction | ||
| n_params = int(np.ceil(len(fit_param_names) / 2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should confirm that this is adequate for other motion models that we intend to add in the future. It'll work for the current ones.
Major changes are:
n_obs >= n_param. By default,motion_models=[Empty, Fixed, Linear]inStarTable.fit_motion_model. Empty and Fixed are always added.downgradethe given ones if there are not enough observed points, untiln_obs >= n_param. Empty and Fixed are always added.default_motion_modelis now removed, as the actually used motion model is determined by the number of available epochs to fit and the list of provided models inmotion_models.motion_model_dictis now removed, and all the model-related parameters go intofixed_params_dict.t0is now optional and will be calculated as np.average(t, weights=1./np.hypot(xe, ye)) if not provided.get_star_position_at_timeandget_batch_star_positionsintoMotionModel.model, which is now fully vectorized and returns positions and uncertainties in shapes of(N_stars, N_times), or(N_stars,)whenN_times=1, or(N_times,)whenN_stars=1.StarTable.fit_motion_modelsignificantly forn_epochs < 300! Now achieving > 10,000 iterations per second for 5 epochs!Name Changes:
MotionModel.fit_motion_model->MotionModel.fitStarTable.fit_velocities->StarTable.fit_motion_modelMotionModel.get_star_position_at_time / get_batch_star_positions->MotionModel.model