flystar.fit_velocity ==================== .. py:module:: flystar.fit_velocity Attributes ---------- .. autoapisummary:: flystar.fit_velocity.x Functions --------- .. autoapisummary:: flystar.fit_velocity.linear flystar.fit_velocity.linear_fit flystar.fit_velocity.calc_chi2 flystar.fit_velocity.fit_velocity Module Contents --------------- .. py:function:: linear(x, k, b) .. py:function:: linear_fit(x, y, sigma=None, absolute_sigma=True) Weighted linear regression (See https://en.wikipedia.org/wiki/Weighted_least_squares#Solution). Recommended for low-dimension, non-degenerate data. Otherwise, please use scipy.curve_fit. Parameters ---------- x : array-like x data y : array-like y data sigma : array-like, optional Weighted by 1/sigma**2. If not provided, weight = 1, by default None absolute_sigma : bool, optional If True (default), sigma is used in an absolute sense and the estimated parameter uncertainty reflects these absolute values. If False, only the relative magnitudes of the sigma values matter, by default True Returns ------- result : dictionary Dictionary with keys 'slope', 'e_slope', 'intercept', 'e_intercept', and 'chi2' if return_chi2=True. .. py:function:: calc_chi2(x, y, sigma, slope, intercept) .. py:function:: fit_velocity(startable, weighting='var', use_scipy=False, absolute_sigma=True, epoch_cols='all', art_star=False) Fit proper motion with weighted linear regression equations (see https://en.wikipedia.org/wiki/Weighted_least_squares#Solution). Assumes that all data are valid. Parameters ---------- startable : StarTable StarTable object weighting : str, optional Weighting by variance (1/ye**2) or standard deviation (1/ye), by default 'var' use_scipy : bool, optional Use scipy.curve_fit or flystar.fit_velocity.linear_fit, by default False absolute_sigma : bool, optional If True (default), sigma is used in an absolute sense and the estimated parameter uncertainty reflects these absolute values. If False, only the relative magnitudes of the sigma values matter, by default True epoch_cols : str or list of intergers, optional List of indicies of columns to use. If 'all', use all columns, by default 'all' art_star : bool, optional Artificial star catalog or not. If True, use startable['x'][:, epoch_ols, 1] as the location, by default False. Returns ------- result : pd.DataFrame Proper motion dataframe with keys vx, vxe, vy, vye, x0, x0e, y0, y0e Raises ------ ValueError If weighting is neither 'std' nor 'var' .. py:data:: x