from_astropy

Contents

from_astropy#

from_astropy(table, *, ra_column: str | None = None, dec_column: str | None = None, lowest_order: int = 0, highest_order: int = 7, drop_empty_siblings: bool = True, partition_rows: int | None = None, partition_bytes: int | None = None, margin_order: int = -1, margin_threshold: float | None = 5.0, should_generate_moc: bool = True, moc_max_order: int = 10, use_pyarrow_types: bool = True, schema=None, flatten_tensors: bool = False, **kwargs)[source]#

Load a catalog from an Astropy Table.

Note that this is only suitable for small datasets (< 1million rows and < 1GB dataframe in-memory). If you need to deal with large datasets, consider using the hats-import package: https://hats-import.readthedocs.io/

Parameters:
tableastropy.table.Table

The Astropy Table (or QTable).

ra_columnstr, optional

The name of the right ascension column. By default, case-insensitive versions of ‘ra’ are detected.

dec_columnstr, optional

The name of the declination column. By default, case-insensitive versions of ‘dec’ are detected.

lowest_orderint, default 0

The lowest partition order. Defaults to 0.

highest_orderint, default 7

The highest partition order. Defaults to 7.

drop_empty_siblingsbool, default True

When determining final partitionining, if 3 of 4 pixels are empty, keep only the non-empty pixel

partition_rowsint or None, default None

The desired partition size, in number of rows. Only one of partition_rows or partition_bytes should be specified.

Note: partitioning is spatial (HEALPix-based). partition_rows is a best-effort target, and the resulting number of partitions is limited by highest_order and the sky footprint of your data.

partition_bytesint or None, default None

The desired partition size, in bytes. Only one of partition_rows or partition_bytes should be specified.

Note: as with partition_rows, this is a best-effort target for spatial (HEALPix-based) partitioning and is limited by highest_order.

margin_orderint, default -1

The order at which to generate the margin cache.

margin_thresholdfloat or None, default 5

The threshold (in arcseconds) for including sources in the margin cache. If None, and margin_order is specified, the margin cache will include all sources in the margin pixels.

should_generate_mocbool, default True

If True, generates a MOC for the catalog.

moc_max_orderint, default 10

The maximum order to use when generating the MOC.

use_pyarrow_typesbool, default True

If True, uses PyArrow backed types in the resulting catalog.

schemapa.Schema or None, default None

The arrow schema to create the catalog with. If None, the schema is automatically inferred from the DataFrame conversion of the table using pa.Schema.from_pandas.

flatten_tensorsbool, default False

If True, flattens multidimensional columns to 2D arrays in the resulting catalog.

**kwargs

Additional arguments to pass along to LSDB.from_dataframe.

Returns:
Catalog

The loaded catalog.

Examples

>>> from astropy.table import Table
>>> import lsdb
>>> data = {
...     "ra": [10.0, 20.0, 30.0],
...     "dec": [-10.0, -20.0, -30.0],
...     "magnitude": [15.0, 16.5, 14.2],
... }
>>> table = Table(data)
>>> catalog = lsdb.from_astropy(table, ra_column="ra", dec_column="dec")
>>> catalog.head()
                       ra   dec  magnitude
_healpix_29
1212933045629049957  10.0 -10.0       15.0
1176808107119886823  20.0 -20.0       16.5
2510306432296314470  30.0 -30.0       14.2