flystar.startables
Classes
A StarTable is an astropy.Table with stars matched from multiple starlists. |
Module Contents
- class flystar.startables.StarTable(*args, ref_list=0, **kwargs)
Bases:
astropy.table.TableA StarTable is an astropy.Table with stars matched from multiple starlists.
Required table columns (input as keywords):
- name1D numpy.array with shape = N_stars
List of unique names for each of the stars in the table.
- x2D numpy.array with shape = (N_stars, N_lists)
Positions of N_stars in each of N_lists in the x dimension.
- y2D numpy.array with shape = (N_stars, N_lists)
Positions of N_stars in each of N_lists in the y dimension.
- m2D numpy.array with shape = (N_stars, N_lists)
Magnitudes of N_stars in each of N_lists.
Optional table columns (input as keywords):
- xe2D numpy.array with shape = (N_stars, N_lists)
Position uncertainties of N_stars in each of N_lists in the x dimension.
- ye2D numpy.array with shape = (N_stars, N_lists)
Position uncertainties of N_stars in each of N_lists in the y dimension.
- me2D numpy.array with shape = (N_stars, N_lists)
Magnitude uncertainties of N_stars in each of N_lists.
- ep_name2D 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.
- corr2D 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_nameslist of strings
List of names, one for each of the starlists.
- list_timeslist of integers or floats
List of times/dates for each starlist.
- ref_listint
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
- 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)
- _add_list_data_from_starlist(starlist)
- _add_list_data_from_keywords(**kwargs)
- _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.
- _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.
- _append_invalid_meta_values(key)
For an existing meta keyword that is a list (already known), add an invalid value depending on the type.
- get_starlist(list_index)
Return a StarList object for the specified list_index or epoch.
Parameters
- list_indexint
The index of the list to fetch and return as a StarList object.
- 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.
- 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 <col_name_in>0 – the mean (with outlier rejection) <col_name_in>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.
- detections()
Find where stars are detected. #
- 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
- weightingstr, optional
Weight by variance ‘var’ or standard deviation ‘std’, by default ‘var’
- use_scipybool, 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_sigmabool, optional
Absolute sigma or not. See https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html for details, by default True
- bootstrapint, optional
Calculate uncertain using bootstraping or not, by default 0
- fixed_t0bool 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
- verbosebool, optional
Output verbose information or not, by default False
- mask_valfloat, optional
Value that needs to be masked in the data, e.g. -100000, by default None
- mask_listslist, optional
Columns that needs to be masked, by default False
- show_progressbool, 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
- fit_velocity_for_star(ss, weighting='var', use_scipy=True, absolute_sigma=True, bootstrap=False, fixed_t0=False, mask_val=None, mask_lists=False)
- 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
- weightingstr, optional
Variance weighting(‘var’) or standard deviation weighting (‘std’), by default ‘var’
- use_scipybool, optional
Use scipy.curve_fit or flystar.fit_velocity.fit_velocity, by default False
- absolute_sigmabool, optional
Absolute sigma or rescaled sigma, by default False
- epoch_colsstr or list of intergers, optional
List of epoch column indices used for fitting velocity, by default ‘all’
- mask_valfloat, optional
Values in x, y to be masked
- art_starbool, optional
Artificial star or observation star catalog. If artificial star, use ‘det’ column to select stars detected in all epochs, by default False
- return_resultbool, optional
Return the velocity results or not, by default False
Returns
- vel_resultastropy Table
Astropy Table with velocity results