generate_data

Contents

generate_data#

lsdb.generate_data(n_base, n_layer, npartitions=1, seed=None, ra_range=(0.0, 360.0), dec_range=(-90, 90), search_region=None)[source]#

Generates a toy dataset.

The base layer always contains columns ra, dec, id, a, and b. Each nested layer contains columns t, flux, flux_error, band, and flux_err. When n_layer is an int the single layer is always named "nested"; pass a dict to use custom layer names.

Column reference:

  • ra, dec (float64): Sky position in degrees, drawn uniformly over the sphere within ra_range and dec_range (or the search region when provided).

  • id (int64): Unique random integer identifier per base row.

  • a (float64): Random float in [0, 1).

  • b (float64): Random float in [0, 2).

  • <layer>.t (float64): Time-like value in [0, 20).

  • <layer>.flux (float64): Flux value in [0, 100).

  • <layer>.flux_error (float64): Constant error 1.0.

  • <layer>.band (str): Filter band, one of "r" or "g".

  • <layer>.flux_err (float64): flux * 0.05.

Parameters:
n_baseint

The number of rows to generate for the base layer

n_layerint or dict

The number of rows per n_base row to generate for a nested layer. Alternatively, a dictionary of layer label, layer_size pairs may be specified to created multiple nested columns with custom sizing.

npartitions: int

The number of partitions to split the data into.

seedint

A seed to use for random generation of data

ra_rangetuple

A tuple of the min and max values for the ra column in degrees

dec_rangetuple

A tuple of the min and max values for the dec column in degrees

search_regionAbstractSearch

A search region to apply to the generated data. Currently supports the ConeSearch, BoxSearch, and PixelSearch regions. Note that if provided, this will override the ra_range and dec_range parameters.

Returns:
DataFrame

A Dask DataFrame wrapping the nested-pandas nestedframe partitions. Note that Dask DataFrames do not support nested columns, so the nested columns be largely inaccessible unless computed or loaded into a Catalog via lsdb.from_dataframe.

Examples

>>> from lsdb import generate_data
>>> nf = generate_data(10, 100)
>>> nf = generate_data(10, {"nested_a": 100, "nested_b": 200})

Constraining spatial ranges: >>> nf = generate_data(10, 100, ra_range=(0., 10.), dec_range=(-5., 0.))

Using a search region: >>> from lsdb import ConeSearch >>> nf = generate_data(10, 100, search_region=ConeSearch(5, 5, 1))