stdpipe.lcs module

class stdpipe.lcs.LCs[source]

Bases: object

Container for light-curve data vectors with spatial clustering utilities.

Stores user-provided per-detection vectors (e.g., ra/dec/flux/time) and groups detections into spatial clusters using a KDTree radius search. Clustering returns per-cluster centroids and member indices in self.lcs.

Methods

add(**kwargs)

Add per-detection vectors to the container.

cluster([sr, min_length, col_ra, col_dec, ...])

Spatially cluster the data vectors using ra/dec values stored in col_ra and col_dec.

Notes

  • add() broadcasts scalars to the length of the longest input vector.

  • cluster() refines centroids and can call an analyze(self, ids) callback per cluster.

  • Coordinate jitter is applied when building the KDTree to avoid degeneracy from repeated positions.

  • Clustering results are stored in self.lcs with keys: - x, y, z: centroid unit-vector coordinates. - ra, dec: centroid sky coordinates in degrees. - N: number of points per cluster. - ids: list of index arrays for member points in the container. - kd: KDTree built from centroid vectors for fast queries.

add(**kwargs)[source]

Add per-detection vectors to the container.

Each keyword defines a stored vector. Scalars are broadcast to the length of the longest input vector, and missing values are filled with None. This method may be called repeatedly to append new chunks of measurements (e.g., per-image batches) to the existing vectors.

Examples

>>> lcs = LCs()
>>> lcs.add(ra=[1, 2], dec=[3, 4], flux=10.0)
cluster(sr=0.0002777777777777778, min_length=None, col_ra='ra', col_dec='dec', verbose=True, analyze=None, N=1000, max_refine_iter=1)[source]

Spatially cluster the data vectors using ra/dec values stored in col_ra and col_dec.

Parameters:
srfloat, optional

Clustering radius in degrees.

min_lengthint or None, optional

Minimum number of points required to keep a cluster.

col_rastr, optional

Name of the RA column in stored vectors.

col_decstr, optional

Name of the Dec column in stored vectors.

verbosebool or callable, optional

Logging control, can be a print-like function.

analyzecallable or None, optional

Optional callback analyze(self, ids) called per accepted cluster. Any returned mapping entries are appended into self.lcs under their respective keys (one entry per cluster).

Nint, optional

Progress update interval in points.

max_refine_iterint, optional

Maximum number of centroid refinement iterations (default 1).