flystar.startables ================== .. py:module:: flystar.startables Classes ------- .. autoapisummary:: flystar.startables.StarTable Module Contents --------------- .. py:class:: StarTable(*args, ref_list=0, **kwargs) Bases: :py:obj:`astropy.table.Table` A StarTable is an astropy.Table with stars matched from multiple starlists. Required table columns (input as keywords): ------------------------- name : 1D numpy.array with shape = N_stars List of unique names for each of the stars in the table. x : 2D numpy.array with shape = (N_stars, N_lists) Positions of N_stars in each of N_lists in the x dimension. y : 2D numpy.array with shape = (N_stars, N_lists) Positions of N_stars in each of N_lists in the y dimension. m : 2D numpy.array with shape = (N_stars, N_lists) Magnitudes of N_stars in each of N_lists. Optional table columns (input as keywords): ------------------------- xe : 2D numpy.array with shape = (N_stars, N_lists) Position uncertainties of N_stars in each of N_lists in the x dimension. ye : 2D numpy.array with shape = (N_stars, N_lists) Position uncertainties of N_stars in each of N_lists in the y dimension. me : 2D numpy.array with shape = (N_stars, N_lists) Magnitude uncertainties of N_stars in each of N_lists. ep_name : 2D numpy.array with shape = (N_stars, N_lists) Names in each epoch for each of N_stars in each of N_lists. This is useful for tracking purposes. corr : 2D numpy.array with shape = (N_stars, N_lists) Fitting correlation for each of N_stars in each of N_lists. Optional table meta data ------------------------- list_names : list of strings List of names, one for each of the starlists. list_times : list of integers or floats List of times/dates for each starlist. ref_list : int Specify which list is the reference list (if any). Examples -------------------------- t = startables.StarTable(name=name, x=x, y=y, m=m) # Access the data: print(t) print(t['name'][0:10]) # print the first 10 star names print(t['x'][0:10, 0]) # print x from the first epoch/list/column for the first 10 stars .. py:method:: add_starlist(**kwargs) Add data from a new list to an existing StarTable. Note, you can pass in the data via a StarList object or via a series of keywords with a 1D array on each. In either case, the number of stars must already match the existing number of stars in the StarTable. Example 1: Pass in data via StarList object. ---------- print(t['x'].shape) t.add_starlist(starlist=my_list) print(t['x'].shape) # Should be 1 column larger than before. Example 2: Pass in data via keywords and 1D arrays. t.add_starlist(x=x_new, y=y_new, m=m_new) .. py:method:: _add_list_data_from_starlist(starlist) .. py:method:: _add_list_data_from_keywords(**kwargs) .. py:method:: _set_invalid_list_values(col_name, col_idx) Set the contents of the specified column (in the 2D column objects) to an invalide value depending on the data type. .. py:method:: _set_invalid_star_values(col_name, row_idx) Set the contents of the specified rows (in the 2D column objects) to an invalide value depending on the data type. .. py:method:: _append_invalid_meta_values(key) For an existing meta keyword that is a list (already known), add an invalid value depending on the type. .. py:method:: get_starlist(list_index) Return a StarList object for the specified list_index or epoch. Parameters ---------- list_index : int The index of the list to fetch and return as a StarList object. .. py:method:: combine_lists_xym(weighted_xy=True, weighted_m=True, mask_lists=False, sigma=3) For x, y and m columns in the table, collapse along the lists direction. For 'x', 'y' this means calculating the average position with outlier rejection. Optionally, weight by the 'xe' and 'ye' individual uncertainties. Optionally, use sigma clipping. "mask_lists" is a list with the indices of starlists that are excluded from the combination. Also, count the number of times a star is found in starlists. .. py:method:: combine_lists(col_name_in, weights_col=None, mask_val=None, mask_lists=False, meta_add=True, ismag=False, sigma=3) For the specified column (col_name_in), collapse along the starlists direction and calculated the average value, with outlier rejection. Optionally, weight by a specified column (weights_col). Optionally, use sigma clipping. The final values are stored in a new column named 0 -- the mean (with outlier rejection) 0e -- the std (with outlier rejection) Masking of NaN values is also performed. "mask_lists" is a list with the indices of starlists that are excluded from the combination. A flag can be stored in the metadata to record if the average was weighted or not. .. py:method:: detections() Find where stars are detected. # .. py:method:: fit_velocities(weighting='var', use_scipy=True, absolute_sigma=True, bootstrap=0, fixed_t0=False, verbose=False, mask_val=None, mask_lists=False, show_progress=True) Fit velocities for all stars in the table and add to the columns 'vx', 'vxe', 'vy', 'vye', 'x0', 'x0e', 'y0', 'y0e'. Parameters ---------- weighting : str, optional Weight by variance 'var' or standard deviation 'std', by default 'var' use_scipy : bool, optional Use scipy.curve_fit (recommended for large number of epochs, but may return inf or nan) or analytic fitting from flystar.fit_velocity.linear_fit (recommended for a few epochs), by default True absolute_sigma : bool, optional Absolute sigma or not. See https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html for details, by default True bootstrap : int, optional Calculate uncertain using bootstraping or not, by default 0 fixed_t0 : bool or array-like, optional Fix the t0 in dt = time - t0 if user provides an array with the same length of the table, or automatically calculate t0 = np.average(time, weights=1/np.hypot(xe, ye)) if False, by default False verbose : bool, optional Output verbose information or not, by default False mask_val : float, optional Value that needs to be masked in the data, e.g. -100000, by default None mask_lists : list, optional Columns that needs to be masked, by default False show_progress : bool, optional Show progress bar or not, by default True Raises ------ ValueError If weighting is neither 'var' or 'std' KeyError If there's not time information in the table .. py:method:: fit_velocity_for_star(ss, weighting='var', use_scipy=True, absolute_sigma=True, bootstrap=False, fixed_t0=False, mask_val=None, mask_lists=False) .. py:method:: fit_velocities_all_detected(weighting='var', use_scipy=False, absolute_sigma=False, epoch_cols='all', mask_val=None, art_star=False, return_result=False) Fit velocities for stars detected in all epochs specified by epoch_cols. Criterion: xe/ye error > 0 and finite, x/y not masked. Parameters ---------- weighting : str, optional Variance weighting('var') or standard deviation weighting ('std'), by default 'var' use_scipy : bool, optional Use scipy.curve_fit or flystar.fit_velocity.fit_velocity, by default False absolute_sigma : bool, optional Absolute sigma or rescaled sigma, by default False epoch_cols : str or list of intergers, optional List of epoch column indices used for fitting velocity, by default 'all' mask_val : float, optional Values in x, y to be masked art_star : bool, optional Artificial star or observation star catalog. If artificial star, use 'det' column to select stars detected in all epochs, by default False return_result : bool, optional Return the velocity results or not, by default False Returns ------- vel_result : astropy Table Astropy Table with velocity results