SourceCatalog¶
- class lsst.afw.table.SourceCatalog¶
Bases:
_SourceCatalogBase
Attributes Summary
a column view of the catalog
Methods Summary
addNew
()append
(record)asAstropy
([cls, copy, unviewable])Return an astropy.table.Table (or subclass thereof) view into this catalog.
between
(*args, **kwargs)Overloaded function.
capacity
(self)cast
(type_[, deep])Return a copy of the catalog with the given type.
clear
()copy
([deep])Copy a catalog (default is not a deep copy).
equal_range
(*args, **kwargs)Overloaded function.
extend
(iterable[, deep, mapper])Append all records in the given iterable to the catalog.
extract
(*patterns, **kwds)Extract a dictionary of {<name>: <column-array>} in which the field names match the given shell-style glob pattern(s).
find
(self, value[, key])getChildren
(parent, *args)Return the subset of self for which the parent field equals the given value.
getSchema
(self)getTable
(self)insert
(key, value)isContiguous
(self)isSorted
(self[, key])lower_bound
(*args, **kwargs)Overloaded function.
readFits
(*args, **kwargs)Overloaded function.
reserve
(self, arg0)resize
(self, arg0)set
(self, arg0, arg1)sort
(self[, key])subset
(*args, **kwargs)Overloaded function.
upper_bound
(*args, **kwargs)Overloaded function.
writeFits
(*args, **kwargs)Overloaded function.
Attributes Documentation
- columns¶
a column view of the catalog
- dtype = 'Source'¶
- schema¶
- table¶
Methods Documentation
- addNew()¶
- append(record)¶
- asAstropy(cls=None, copy=False, unviewable='copy')¶
Return an astropy.table.Table (or subclass thereof) view into this catalog.
- Parameters:
- cls
Table subclass to use;
None
impliesastropy.table.Table
itself. Useastropy.table.QTable
to get Quantity columns.- copybool, optional
If
True
, copy data from the LSST catalog to the astropy table. Not copying is usually faster, but can keep memory from being freed if columns are later removed from the Astropy view.- unviewable
str
, optional One of the following options (which is ignored if copy=`True` ), indicating how to handle field types (
str
andFlag
) for which views cannot be constructed:‘copy’ (default): copy only the unviewable fields.
‘raise’: raise ValueError if unviewable fields are present.
‘skip’: do not include unviewable fields in the Astropy Table.
- Returns:
- cls
astropy.table.Table
Astropy view into the catalog.
- cls
- Raises:
- ValueError
Raised if the
unviewable
option is not a known value, or if the option is ‘raise’ and an uncopyable field is found.
- between(*args, **kwargs)¶
Overloaded function.
between(self: lsst.afw.table._SourceCatalogBase, arg0: int, arg1: int, arg2: lsst.afw.table.KeyI) -> slice
between(self: lsst.afw.table._SourceCatalogBase, arg0: int, arg1: int, arg2: lsst.afw.table.KeyL) -> slice
between(self: lsst.afw.table._SourceCatalogBase, arg0: float, arg1: float, arg2: lsst.afw.table.KeyF) -> slice
between(self: lsst.afw.table._SourceCatalogBase, arg0: float, arg1: float, arg2: lsst.afw.table.KeyD) -> slice
between(self: lsst.afw.table._SourceCatalogBase, arg0: lsst::geom::Angle, arg1: lsst::geom::Angle, arg2: lsst.afw.table.KeyAngle) -> slice
- cast(type_, deep=False)¶
Return a copy of the catalog with the given type.
- clear()¶
- copy(deep=False)¶
Copy a catalog (default is not a deep copy).
- equal_range(*args, **kwargs)¶
Overloaded function.
equal_range(self: lsst.afw.table._SourceCatalogBase, arg0: int, arg1: lsst.afw.table.KeyI) -> slice
equal_range(self: lsst.afw.table._SourceCatalogBase, arg0: int, arg1: lsst.afw.table.KeyL) -> slice
equal_range(self: lsst.afw.table._SourceCatalogBase, arg0: float, arg1: lsst.afw.table.KeyF) -> slice
equal_range(self: lsst.afw.table._SourceCatalogBase, arg0: float, arg1: lsst.afw.table.KeyD) -> slice
equal_range(self: lsst.afw.table._SourceCatalogBase, arg0: lsst::geom::Angle, arg1: lsst.afw.table.KeyAngle) -> slice
- extend(iterable, deep=False, mapper=None)¶
Append all records in the given iterable to the catalog.
- extract(*patterns, **kwds)¶
Extract a dictionary of {<name>: <column-array>} in which the field names match the given shell-style glob pattern(s).
Any number of glob patterns may be passed (including none); the result will be the union of all the result of each glob considered separately.
Note that extract(“*”, copy=True) provides an easy way to transform a catalog into a set of writeable contiguous NumPy arrays.
This routines unpacks
Flag
columns into full boolean arrays. String fields are silently ignored.- Parameters:
- patternsArray of
str
List of glob patterns to use to select field names.
- kwds
dict
Dictionary of additional keyword arguments. May contain:
items
list
The result of a call to self.schema.extract(); this will be used instead of doing any new matching, and allows the pattern matching to be reused to extract values from multiple records. This keyword is incompatible with any position arguments and the regex, sub, and ordered keyword arguments.
where
array index expressionAny expression that can be passed as indices to a NumPy array, including slices, boolean arrays, and index arrays, that will be used to index each column array. This is applied before arrays are copied when copy is True, so if the indexing results in an implicit copy no unnecessary second copy is performed.
copy
bool
If True, the returned arrays will be contiguous copies rather than strided views into the catalog. This ensures that the lifetime of the catalog is not tied to the lifetime of a particular catalog, and it also may improve the performance if the array is used repeatedly. Default is False. Copies are always made if the catalog is noncontiguous, but if
copy=False
these set as read-only to ensure code does not assume they are views that could modify the original catalog.regex
str
orre
patternA regular expression to be used in addition to any glob patterns passed as positional arguments. Note that this will be compared with re.match, not re.search.
sub
str
A replacement string (see re.MatchObject.expand) used to set the dictionary keys of any fields matched by regex.
ordered
bool
If True, a collections.OrderedDict will be returned instead of a standard dict, with the order corresponding to the definition order of the Schema. Default is False.
- patternsArray of
- Returns:
- d
dict
Dictionary of extracted name-column array sets.
- d
- Raises:
- ValueError
Raised if a list of
items
is supplied with additional keywords.
- getChildren(parent, *args)¶
Return the subset of self for which the parent field equals the given value.
In order for this method to return the correct result, it must be sorted by parent (i.e. self.isSorted(SourceTable.getParentKey()) must be True). This is naturally the case with SourceCatalogs produced by the detection and deblending tasks, but it may not be true when concatenating multiple such catalogs.
Additional Catalogs or sequences whose elements correspond in order to the records of self (i.e.
zip(self, *args)
is valid) will be subset using the same slice object used on self, and these subsets will be returned along with the subset of self.- Parameters:
- Returns:
- childrena single iterable of
SourceRecord
Children sources if
parent
is of typeint
, or a generator yielding aSourceRecord`s Children sources for each parent if ``parent`
is aniterable
.
- childrena single iterable of
- Raises:
- AssertionError
Raised if the catalog is not sorted by the parent key.
Notes
Each call to this function checks if the catalog is sorted, which is of O(n) complexity, while fetching the children is of O(log n). To minimize the computational overhead, it is preferable to prepare an iterable of parent ids for which the children need to be fetched and pass the iterable as
parent
.
- getColumnView()¶
- getSchema(self: lsst.afw.table._SourceCatalogBase) lsst.afw.table.Schema ¶
- getTable(self: lsst.afw.table._SourceCatalogBase) lsst.afw.table.SourceTable ¶
- insert(key, value)¶
- lower_bound(*args, **kwargs)¶
Overloaded function.
lower_bound(self: lsst.afw.table._SourceCatalogBase, arg0: int, arg1: lsst.afw.table.KeyI) -> int
lower_bound(self: lsst.afw.table._SourceCatalogBase, arg0: int, arg1: lsst.afw.table.KeyL) -> int
lower_bound(self: lsst.afw.table._SourceCatalogBase, arg0: float, arg1: lsst.afw.table.KeyF) -> int
lower_bound(self: lsst.afw.table._SourceCatalogBase, arg0: float, arg1: lsst.afw.table.KeyD) -> int
lower_bound(self: lsst.afw.table._SourceCatalogBase, arg0: lsst::geom::Angle, arg1: lsst.afw.table.KeyAngle) -> int
- static readFits(*args, **kwargs)¶
Overloaded function.
readFits(filename: str, hdu: int = -2147483648, flags: int = 0) -> lsst.afw.table.SourceCatalog
readFits(manager: lsst.afw.fits._fits.MemFileManager, hdu: int = -2147483648, flags: int = 0) -> lsst.afw.table.SourceCatalog
- set(self: lsst.afw.table._SourceCatalogBase, arg0: int, arg1: lsst.afw.table.SourceRecord) None ¶
- subset(*args, **kwargs)¶
Overloaded function.
subset(self: lsst.afw.table.SourceCatalog, arg0: numpy.ndarray) -> lsst.afw.table.SourceCatalog
subset(self: lsst.afw.table.SourceCatalog, arg0: int, arg1: int, arg2: int) -> lsst.afw.table.SourceCatalog
- upper_bound(*args, **kwargs)¶
Overloaded function.
upper_bound(self: lsst.afw.table._SourceCatalogBase, arg0: int, arg1: lsst.afw.table.KeyI) -> int
upper_bound(self: lsst.afw.table._SourceCatalogBase, arg0: int, arg1: lsst.afw.table.KeyL) -> int
upper_bound(self: lsst.afw.table._SourceCatalogBase, arg0: float, arg1: lsst.afw.table.KeyF) -> int
upper_bound(self: lsst.afw.table._SourceCatalogBase, arg0: float, arg1: lsst.afw.table.KeyD) -> int
upper_bound(self: lsst.afw.table._SourceCatalogBase, arg0: lsst::geom::Angle, arg1: lsst.afw.table.KeyAngle) -> int
- writeFits(*args, **kwargs)¶
Overloaded function.
writeFits(self: lsst.afw.table._SourceCatalogBase, filename: str, mode: str = ‘w’, flags: int = 0) -> None
writeFits(self: lsst.afw.table._SourceCatalogBase, manager: lsst.afw.fits._fits.MemFileManager, mode: str = ‘w’, flags: int = 0) -> None