TableVStack¶
- class lsst.obs.base.TableVStack(capacity: int)¶
Bases:
object
A helper class for stacking astropy tables without having them all in memory at once.
- Parameters:
- capacity
int
Full size of the final table.
- capacity
Notes
Unlike
astropy.table.vstack
, this class requires all tables to have the exact same columns (it’s slightly more strict than even thejoin_type="exact"
argument toastropy.table.vstack
).Methods Summary
extend
(table[, extra_values])Add a single table to the stack.
from_handles
(handles)Construct from an iterable of
set_extra_values
(table, key, values, capacity)Set extra column values in a slice of a table.
vstack_handles
(handles[, extra_values, ...])Vertically stack tables represented by deferred dataset handles.
Methods Documentation
- extend(table: Table, extra_values: dict[str, Union[collections.abc.Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[bool | int | float | complex | str | bytes]]] | None = None) None ¶
Add a single table to the stack.
- Parameters:
- table
astropy.table.Table
An astropy table instance.
- extra_values
dict
Dict keyed by column name with an array-like of values to set for this table only.
- table
- classmethod from_handles(handles: Iterable[DeferredDatasetHandle]) Self ¶
- Construct from an iterable of
- Parameters:
- handles
Iterable
[lsst.daf.butler.DeferredDatasetHandle
] Iterable of handles. Must have a storage class that supports the “rowcount” component, which is all that will be fetched.
- handles
- Returns:
- vstack
TableVStack
An instance of this class, initialized with capacity equal to the sum of the rowcounts of all the given table handles.
- vstack
- classmethod set_extra_values(table: Table, key: str, values: Any, capacity: int, slicer: slice | None = None, validate: bool = True) None ¶
Set extra column values in a slice of a table.
- Parameters:
- table
astropy.table.Table
The table to set values for.
- key
str
The column key.
- values
Any
The value(s) to set. Can be a scalar.
- capacity
int
The size to initialize the column with, if it doesn’t exist yet.
- slicer
slice
orNone
, optional A slice to select values to update.
- validate
bool
, optional If True and the column already exists, will raise if the new values do not match the existing ones.
- table
- classmethod vstack_handles(handles: Iterable[DeferredDatasetHandle], extra_values: dict[int, dict[str, Union[collections.abc.Buffer, numpy._typing._array_like._SupportsArray[numpy.dtype[Any]], numpy._typing._nested_sequence._NestedSequence[numpy._typing._array_like._SupportsArray[numpy.dtype[Any]]], bool, int, float, complex, str, bytes, numpy._typing._nested_sequence._NestedSequence[bool | int | float | complex | str | bytes]]]] | None = None, kwargs_get: dict[str, Any] | None = None) Table ¶
Vertically stack tables represented by deferred dataset handles.
- Parameters:
- handles
Iterable
[lsst.daf.butler.DeferredDatasetHandle
] Iterable of handles. Must have the “ArrowAstropy” storage class and identical columns.
- extra_values
dict
Dictionary keyed by index of handle of additional values to pass to extend.
- kwargs_get
dict`[`str
,Any
] Keyword argument-value pairs to pass to handle.get().
- handles
- Returns:
- table
astropy.table.Table
Concatenated table with the same columns as each input table and the rows of all of them, or an empty table if there are no handles.
- table