crossmatch

Contents

crossmatch#

lsdb.crossmatch(left: Catalog | NestedFrame | DataFrame, right: Catalog | NestedFrame | DataFrame, *, ra_column: str | None = None, dec_column: str | None = None, n_neighbors: int | None = None, radius_arcsec: float | None = None, min_radius_arcsec: float | None = None, algorithm: AbstractCrossmatchAlgorithm | None = None, output_catalog_name: str | None = None, require_right_margin: bool = False, how: Literal['inner', 'left', 'outer'] = 'inner', suffixes: tuple[str, str] | None = None, left_args: dict | None = None, right_args: dict | None = None, suffix_method: str | None = None, log_changes: bool = True) → Catalog[source]#

Perform a cross-match between two frames, two catalogs, a catalog and a frame, or a frame and a catalog.

See Catalog.crossmatch() for more information on cross-matching.

Parameters:
leftCatalog or npd.NestedFrame or pd.DataFrame

The left catalog or frame to crossmatch.

rightCatalog or npd.NestedFrame or pd.DataFrame

The right catalog or frame to crossmatch.

ra_columnstr or None, default None

The name of the right ascension column for both catalogs, if passing dataframes. Can be specified in the left_args or right_args dictionaries if left and right catalogs have different RA column names. Defaults to None, which will use the default column names “ra”, “Ra”, or “RA” if they exist in the DataFrame.

dec_columnstr or None, default None

The name of the declination column for both catalogs, if passing dataframes. Can be specified in the left_args or right_args dictionaries if left and right catalogs have different dec column names. Defaults to None, which will use the default column names “dec”, “Dec”, or “DEC” if they exist in the DataFrame.

n_neighborsint, default 1

The number of neighbors to find within each point.

radius_arcsecfloat, default 1.0

The threshold distance in arcseconds beyond which neighbors are not added.

min_radius_arcsecfloat, default 0.0

The threshold distance in arcseconds beyond which neighbors are added.

algorithmAbstractCrossmatchAlgorithm, default KDTreeCrossmatch

The crossmatch algorithm to use.

output_catalog_namestr or None, default None

The name of the output catalog.

require_right_marginbool, default False

Whether to require a right margin.

how{‘inner’, ‘left’, ‘outer’}, default ‘inner’

inner emits only matched row pairs; left also emits unmatched left rows; outer also emits unmatched rows from both catalogs, including sky covered only by the right catalog. outer requires margin caches on both catalogs (left threshold at least the matching radius, right at least twice). When passing dataframes, these margins are generated unless margin_threshold is given in left_args or right_args.

suffixestuple[str,str] or None, default None

Suffixes to append to overlapping column names.

left_argsdict or None, default None

Keyword arguments to pass to from_dataframe for the left catalog.

right_argsdict or None, default None

Keyword arguments to pass to from_dataframe for the right catalog.

suffix_methodstr or None, default “all_columns”

Method to use to add suffixes to columns. Options are:

  • “overlapping_columns”: only add suffixes to columns that are present in both catalogs

  • “all_columns”: add suffixes to all columns from both catalogs

Warning

This default will change to “overlapping_columns” in a future release.

log_changesbool, default True

If True, logs an info message for each column that is being renamed. This only applies when suffix_method is ‘overlapping_columns’.

Returns:
Catalog

A new catalog with the result of the crossmatch.