Data preprocessing
ocelot.cluster.cut_dataset(data_gaia, parameter_cuts, return_cut_stars=False, reset_index=True)
¤
A function for cutting a dataset based on certain requirements: either on allowed parameter ranges or based on geometric cuts (such as selecting a circle from the data.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_gaia
|
DataFrame
|
The data to apply the cuts to. |
required |
parameter_cuts
|
dict | None
|
A dictionary of lists or np.ndarrays of allowed [minimum, maximum] parameter ranges, in a style like: {"phot_g_mag": [-np.inf, 18]}, where np.inf can be used to ignore limits. Default: None |
required |
return_cut_stars
|
bool
|
Whether or not to also return a DataFrame containing only the stars that have been cut. Default: False |
False
|
reset_index
|
bool
|
Whether or not to reset the indexes on the data frames to be returned. May not be intended behaviour if you're planning on re-combining the two DataFrames later. Default: True |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame | tuple[DataFrame, DataFrame]
|
dataframe of cut stars. Returns two dataframes when return_cut_stars is True. |
ocelot.cluster.recenter_dataset(*args, center=None, center_type='icrs', pixel_id=None, rotate_frame=True, proper_motion=True, always_return_list=False, **user_healpy_kwargs)
¤
Recenter a dataset to a new center, either specified as a healpix pixel or as a user-specified central coordinate. This is particularly useful for clustering in in regions of coordinate space close to discontinuities, ensuring that longitudes and latitudes are weighted correctly even when using a Euclidean metric.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
DataFrame
|
Gaia-style dataframes to apply the transform to. |
()
|
center
|
tuple | list | ndarray | SkyCoord | None
|
Array of length 2 with the ra, dec co-ordinates of the new centre. Must be specified if pixel_id is not specified. Default: None |
None
|
center_type
|
str
|
Type of frame center is defined in. Must be acceptable by astropy.coordinates.SkyCoord. E.g. could be 'icrs' or 'galactic'. Default: 'icrs', i.e. center should be (ra, dec). |
'icrs'
|
pixel_id
|
int | None
|
If working with healpix pixels, this is the id of the central healpix pixel. Must be specified if center is not specified. Default: None |
None
|
rotate_frame
|
bool
|
If pixel_id is not None, then you can also ask to have the frame rotated. This will rotate the frame so that the boundaries of the quadrilateral pixel are roughly parallel to the latitude, longitude co-ordinate axes. Default: True |
True
|
proper_motion
|
bool
|
Whether or not to also make transformed proper motions. Default: True |
True
|
always_return_list
|
bool
|
For backwards-compatibility, we always return one DataFrame when only passed one. However, setting this to true will make it a one-element list of DataFrames. Default: False |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame | list[DataFrame]
|
input dataframes, but now with lat, lon, (pmlat, pmlon) keys for the centered data. |
ocelot.cluster.rescale_dataset(data_gaia, *args, columns_to_rescale=('ra', 'dec', 'pmra', 'pmdec', 'parallax'), column_weights=(1.0, 1.0, 1.0, 1.0, 1.0), scaling_type='robust', concatenate=True, return_scaler=False, **kwargs_for_scaler)
¤
A wrapper for sklearn's scaling methods that can automatically handle re-scaling data a number of different ways.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_gaia
|
DataFrame
|
The data to apply the scaling to. |
required |
*args
|
DataFrame
|
Additional dataframes of Gaia data to apply scaling to. |
()
|
columns_to_rescale
|
list | tuple
|
keys of the columns to re-scale. Should be in the final desired order! Default: ('ra', 'dec', 'pmra', 'pmdec', 'parallax') |
('ra', 'dec', 'pmra', 'pmdec', 'parallax')
|
column_weights
|
list | tuple
|
Linear weights to apply to each column after re-scaling, which will reduce their impact in nearest-neighbor calculations (see: Liu+19 for an example of this done with parallax). Default: (1., 1., 1., 1., 1.) |
(1.0, 1.0, 1.0, 1.0, 1.0)
|
scaling_type
|
(standard, robust)
|
Type of scaler to use, choose from: 'robust' (sklearn.preprocessing.RobustScaler) 'standard' (sklearn.preprocessing.StandardScaler) Robust scaling is more appropriate for data with outliers. Default: 'robust' |
'standard'
|
concatenate
|
bool
|
whether or not to join all rescaled arrays (assuming multiple args were specified) into one. Default: True, so only one np.array is returned. |
True
|
return_scaler
|
bool
|
Whether or not to also return the scaler object for future use. Default: False |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
a np.ndarray of shape (n_stars, n_columns) of the re-scaled data, or a list of separate arrays if concatenate=False and at least one arg was specified. |