LSST Applications g1635faa6d4+215bc75b8c,g1653933729+a8ce1bb630,g22ce9dc20b+d972d8df89,g28da252d5a+0fcf840c6d,g29321ee8c0+e558be0e74,g2bbee38e9b+9634bc57db,g2bc492864f+9634bc57db,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+9634bc57db,g35bb328faa+a8ce1bb630,g3a166c0a6a+9634bc57db,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+2a6f257a1d,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g7ab3e175f3+59ce30aec6,g80478fca09+f8b2ab54e1,g82479be7b0+ba9d578ff8,g858d7b2824+d972d8df89,g9125e01d80+a8ce1bb630,g9726552aa6+10f999ec6a,ga5288a1d22+630363936d,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gb9c6c11c1e+9553554aa7,gbd46683f8f+0c4209622a,gc28159a63d+9634bc57db,gcf0d15dbbd+2db122af0a,gda3e153d99+d972d8df89,gda6a2b7d83+2db122af0a,gdaeeff99f8+1711a396fd,ge2409df99d+d1dc2f3b25,ge33fd446bb+d972d8df89,ge79ae78c31+9634bc57db,gf0baf85859+147a0692ba,gf3967379c6+02b11634a5,w.2024.45
LSST Data Management Base Package
|
A custom container class for records, based on std::vector. More...
#include <Catalog.h>
Public Types | |
using | Record = RecordT |
using | Table = typename Record::Table |
using | ColumnView = typename Record::ColumnView |
using | reference = RecordT & |
using | pointer = std::shared_ptr<RecordT> |
using | size_type = typename Internal::size_type |
using | difference_type = typename Internal::difference_type |
using | iterator = CatalogIterator<typename Internal::iterator> |
using | const_iterator = CatalogIterator<typename Internal::const_iterator> |
Public Member Functions | |
std::shared_ptr< Table > | getTable () const |
Return the table associated with the catalog. | |
Schema | getSchema () const |
Return the schema associated with the catalog's table. | |
CatalogT (std::shared_ptr< Table > const &table=std::shared_ptr< Table >()) | |
Construct a catalog from a table (or nothing). | |
CatalogT (Schema const &schema) | |
Construct a catalog from a schema, creating a table with Table::make(schema). | |
template<typename InputIterator > | |
CatalogT (std::shared_ptr< Table > const &table, InputIterator first, InputIterator last, bool deep=false) | |
Construct a catalog from a table and an iterator range. | |
CatalogT (CatalogT const &other) | |
Shallow copy constructor. | |
CatalogT (CatalogT &&other) | |
~CatalogT ()=default | |
template<typename OtherRecordT > | |
CatalogT (CatalogT< OtherRecordT > const &other) | |
Shallow copy constructor from a container containing a related record type. | |
CatalogT & | operator= (CatalogT const &other) |
Shallow assigment. | |
CatalogT & | operator= (CatalogT &&other) |
CatalogT< RecordT > | subset (ndarray::Array< bool const, 1 > const &mask) const |
Return the subset of a catalog corresponding to the True values of the given mask array. | |
CatalogT< RecordT > | subset (std::ptrdiff_t startd, std::ptrdiff_t stopd, std::ptrdiff_t step) const |
Returns a shallow copy of a subset of this Catalog. | |
void | writeFits (std::string const &filename, std::string const &mode="w", int flags=0) const |
Write a FITS binary table to a regular file. | |
void | writeFits (fits::MemFileManager &manager, std::string const &mode="w", int flags=0) const |
Write a FITS binary table to a RAM file. | |
void | writeFits (fits::Fits &fitsfile, int flags=0) const |
Write a FITS binary table to an open file object. | |
ColumnView | getColumnView () const |
Return a ColumnView of this catalog's records. | |
bool | isContiguous () const |
Return true if all records are contiguous. | |
iterator | begin () |
Iterator access. | |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
bool | empty () const |
Return true if the catalog has no records. | |
size_type | size () const |
Return the number of elements in the catalog. | |
size_type | max_size () const |
Return the maximum number of elements allowed in a catalog. | |
size_type | capacity () const |
Return the capacity of the catalog. | |
void | reserve (size_type n) |
Increase the capacity of the catalog to the given size. | |
void | resize (size_type n) |
Change the size of the catalog, removing or adding empty records as needed. | |
reference | operator[] (size_type i) const |
Return the record at index i. | |
reference | at (size_type i) const |
Return the record at index i (throws std::out_of_range). | |
reference | front () const |
Return the first record. | |
reference | back () const |
Return the last record. | |
std::shared_ptr< RecordT > const | get (size_type i) const |
Return a pointer to the record at index i. | |
void | set (size_type i, std::shared_ptr< RecordT > const &p) |
Set the record at index i to a pointer. | |
template<typename InputIterator > | |
void | assign (InputIterator first, InputIterator last, bool deep=false) |
Replace the contents of the table with an iterator range. | |
void | push_back (Record const &r) |
Add a copy of the given record to the end of the catalog. | |
void | push_back (std::shared_ptr< RecordT > const &p) |
Add the given record to the end of the catalog without copying. | |
std::shared_ptr< RecordT > | addNew () |
Create a new record, add it to the end of the catalog, and return a pointer to it. | |
void | pop_back () |
Remove the last record in the catalog. | |
CatalogT | copy () const |
Deep-copy the catalog using a cloned table. | |
template<typename InputIterator > | |
void | insert (iterator pos, InputIterator first, InputIterator last, bool deep=false) |
Insert an iterator range into the table. | |
template<typename InputIterator > | |
void | insert (SchemaMapper const &mapper, iterator pos, InputIterator first, InputIterator last) |
Insert a range of records into the catalog by copying them with a SchemaMapper. | |
iterator | insert (iterator pos, Record const &r) |
Insert a copy of the given record at the given position. | |
iterator | insert (iterator pos, std::shared_ptr< RecordT > const &p) |
Insert the given record at the given position without copying. | |
iterator | erase (iterator pos) |
Erase the record pointed to by pos, and return an iterator the next record. | |
iterator | erase (iterator first, iterator last) |
Erase the records in the range [first, last). | |
void | swap (CatalogT &other) noexcept |
Shallow swap of two catalogs. | |
void | clear () |
Remove all records from the catalog. | |
template<typename T > | |
bool | isSorted (Key< T > const &key) const |
Return true if the catalog is in ascending order according to the given key. | |
template<typename Compare > | |
bool | isSorted (Compare cmp) const |
Return true if the catalog is in ascending order according to the given predicate. | |
template<typename T > | |
void | sort (Key< T > const &key) |
Sort the catalog in-place by the field with the given key. | |
template<typename Compare > | |
void | sort (Compare cmp) |
Sort the catalog in-place by the field with the given predicate. | |
template<typename T > | |
iterator | find (typename Field< T >::Value const &value, Key< T > const &key) |
Return an iterator to the record with the given value. | |
template<typename T > | |
const_iterator | find (typename Field< T >::Value const &value, Key< T > const &key) const |
template<typename T > | |
iterator | lower_bound (typename Field< T >::Value const &value, Key< T > const &key) |
Performed binary searches on sorted fields. | |
template<typename T > | |
const_iterator | lower_bound (typename Field< T >::Value const &value, Key< T > const &key) const |
template<typename T > | |
iterator | upper_bound (typename Field< T >::Value const &value, Key< T > const &key) |
template<typename T > | |
const_iterator | upper_bound (typename Field< T >::Value const &value, Key< T > const &key) const |
template<typename T > | |
std::pair< iterator, iterator > | equal_range (typename Field< T >::Value const &value, Key< T > const &key) |
template<typename T > | |
std::pair< const_iterator, const_iterator > | equal_range (typename Field< T >::Value const &value, Key< T > const &key) const |
Internal & | getInternal () |
Return a reference to the internal vector-of-shared_ptr. | |
Internal const & | getInternal () const |
template<typename T > | |
std::pair< typename CatalogT< RecordT >::iterator, typename CatalogT< RecordT >::iterator > | equal_range (typename Field< T >::Value const &value, Key< T > const &key) |
template<typename T > | |
std::pair< typename CatalogT< RecordT >::const_iterator, typename CatalogT< RecordT >::const_iterator > | equal_range (typename Field< T >::Value const &value, Key< T > const &key) const |
Static Public Member Functions | |
static CatalogT | readFits (std::string const &filename, int hdu=fits::DEFAULT_HDU, int flags=0) |
Read a FITS binary table from a regular file. | |
static CatalogT | readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU, int flags=0) |
Read a FITS binary table from a RAM file. | |
static CatalogT | readFits (fits::Fits &fitsfile, int flags=0) |
Read a FITS binary table from a file object already at the correct extension. | |
A custom container class for records, based on std::vector.
CatalogT wraps a std::vector<std::shared_ptr<RecordT>> in an interface that looks more like a std::vector<RecordT>; its iterators and accessors return references or const references, rather than pointers, making them easier to use. It also holds a table, which is used to allocate new records and determine the schema, but no checking is done to ensure that records added to the catalog use the same table or indeed have the same schema.
Because a CatalogT is holds shared_ptrs internally, many of its operations can be either shallow or deep, with new deep copies allocated by the catalog's table object. New records can be also be inserted by pointer (shallow) or by value (deep).
The constness of records is determined by the constness of the first template parameter to CatalogT; a container instance is always either const or non-const in that respect (like smart pointers). Also like smart pointers, const member functions (and by extension, const_iterators) do not allow the underlying pointers to be changed, while non-const member functions and iterators do.
CatalogT does not permit empty (null) pointers as elements. As a result, CatalogT has no resize member function.
CatalogT has a very different interface in Python; it mimics Python's list instead of C++'s std::vector. It is also considerably simpler, because it doesn't need to deal with iterator ranges or the distinction between references and shared_ptrs to records. See the Python docstring for more information.
using lsst::afw::table::CatalogT< RecordT >::ColumnView = typename Record::ColumnView |
using lsst::afw::table::CatalogT< RecordT >::const_iterator = CatalogIterator<typename Internal::const_iterator> |
using lsst::afw::table::CatalogT< RecordT >::difference_type = typename Internal::difference_type |
using lsst::afw::table::CatalogT< RecordT >::iterator = CatalogIterator<typename Internal::iterator> |
using lsst::afw::table::CatalogT< RecordT >::pointer = std::shared_ptr<RecordT> |
using lsst::afw::table::CatalogT< RecordT >::Record = RecordT |
using lsst::afw::table::CatalogT< RecordT >::reference = RecordT & |
using lsst::afw::table::CatalogT< RecordT >::size_type = typename Internal::size_type |
using lsst::afw::table::CatalogT< RecordT >::Table = typename Record::Table |
|
inlineexplicit |
|
inlineexplicit |
|
inline |
Construct a catalog from a table and an iterator range.
If deep is true, new records will be created using table->copyRecord before being inserted. If deep is false, records will be not be copied, but they must already be associated with the given table. The table itself is never deep-copied.
The iterator must dereference to a record reference or const reference rather than a pointer, but should be implicitly convertible to a record pointer as well (see CatalogIterator).
Definition at line 146 of file Catalog.h.
|
inline |
Definition at line 154 of file Catalog.h.
|
default |
|
inline |
Shallow copy constructor from a container containing a related record type.
This conversion only succeeds if OtherRecordT is convertible to RecordT and OtherTable is convertible to Table.
Definition at line 165 of file Catalog.h.
|
inline |
|
inline |
Replace the contents of the table with an iterator range.
Delegates to insert(); look there for more information.
|
inline |
Return the record at index i (throws std::out_of_range).
Definition at line 454 of file Catalog.h.
|
inline |
|
inline |
Iterator access.
Definition at line 400 of file Catalog.h.
|
inline |
Definition at line 402 of file Catalog.h.
|
inline |
Return the capacity of the catalog.
This is computed as the sum of the current size and the unallocated space in the table. It does not reflect the size of the internal vector, and hence cannot be used to judge when iterators may be invalidated.
Definition at line 424 of file Catalog.h.
|
inline |
|
inline |
|
inline |
|
inline |
Deep-copy the catalog using a cloned table.
Definition at line 499 of file Catalog.h.
|
inline |
|
inline |
|
inline |
std::pair< iterator, iterator > lsst::afw::table::CatalogT< RecordT >::equal_range | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) |
std::pair< typename CatalogT< RecordT >::iterator, typename CatalogT< RecordT >::iterator > lsst::afw::table::CatalogT< RecordT >::equal_range | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) |
Definition at line 849 of file Catalog.h.
std::pair< const_iterator, const_iterator > lsst::afw::table::CatalogT< RecordT >::equal_range | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) const |
std::pair< typename CatalogT< RecordT >::const_iterator, typename CatalogT< RecordT >::const_iterator > lsst::afw::table::CatalogT< RecordT >::equal_range | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) const |
Definition at line 861 of file Catalog.h.
|
inline |
CatalogT< RecordT >::iterator lsst::afw::table::CatalogT< RecordT >::find | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) |
Return an iterator to the record with the given value.
When the field being searched is not unique, which matching record will be returned is not defined. In these cases, lower_bound, upper_bound, or equal_range should be used instead.
In Python, this method returns a Record, not an iterator.
Returns end() if the Record cannot be found.
Definition at line 762 of file Catalog.h.
CatalogT< RecordT >::const_iterator lsst::afw::table::CatalogT< RecordT >::find | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) const |
Definition at line 783 of file Catalog.h.
|
inline |
|
inline |
|
inline |
Return a ColumnView of this catalog's records.
Will throw RuntimeError if records are not contiguous.
Definition at line 381 of file Catalog.h.
|
inline |
Return a reference to the internal vector-of-shared_ptr.
While in most cases it is more convenient to use the Catalog's iterators, which dereference directly to Record objects (and hence allow iter->method() rather than (**iter).method()), direct access to the underlying vector-of-shared_ptr is provided here to allow complete use of the C++ STL. In particular, in order to use a mutating STL algorithm on a Catalog in such a way that Records are shallow-copied (i.e. shared_ptr::operator= is invoked instead of Record::operator=), those algorithms should be called on the iterators of these internal containers. When an algorithm should be called in such a way that records are deep-copied, the regular Catalog iterators should be used.
Definition at line 675 of file Catalog.h.
|
inline |
|
inline |
|
inline |
|
inline |
Insert an iterator range into the table.
InputIterator must dereference to a record reference that is convertible to the record type held by the catalog, and must be implicitly convertible to a shared_ptr to a record.
If deep is true, new records will be created by calling copyRecord on the catalog's table. If deep is false, the new records will not be copied, but they must have been created with the catalog's table (note that a table may be shared by multiple catalogs).
If InputIterator models RandomAccessIterator (according to std::iterator_traits) and deep is true, table->preallocate will be used to ensure that the resulting records are contiguous in memory and can be used with ColumnView. To ensure this is the case for other iterator types, the user must preallocate the table manually.
|
inline |
Insert a copy of the given record at the given position.
|
inline |
|
inline |
Insert a range of records into the catalog by copying them with a SchemaMapper.
Definition at line 538 of file Catalog.h.
|
inline |
bool lsst::afw::table::CatalogT< RecordT >::isSorted | ( | Compare | cmp | ) | const |
Return true if the catalog is in ascending order according to the given predicate.
cmp(a, b) should return true if record a is less than record b, and false otherwise.
TODO: C++11 has an is_sorted function we should use when available.
Definition at line 725 of file Catalog.h.
bool lsst::afw::table::CatalogT< RecordT >::isSorted | ( | Key< T > const & | key | ) | const |
Return true if the catalog is in ascending order according to the given key.
Definition at line 748 of file Catalog.h.
CatalogT< RecordT >::iterator lsst::afw::table::CatalogT< RecordT >::lower_bound | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) |
Performed binary searches on sorted fields.
These methods perform binary searches analogous to the STL algorithms of the same name; they simply create a comparison functor using the given value and Key.
In Python, the lower_bound and upper_bound methods return the position of the result record in the catalog, and equal_range returns a Python slice object that defines the range.
Definition at line 804 of file Catalog.h.
CatalogT< RecordT >::const_iterator lsst::afw::table::CatalogT< RecordT >::lower_bound | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) const |
Definition at line 815 of file Catalog.h.
|
inline |
|
inline |
|
inline |
|
inline |
Add a copy of the given record to the end of the catalog.
|
inline |
|
inlinestatic |
Read a FITS binary table from a file object already at the correct extension.
[in] | fitsfile | Fits file object to read from. |
[in] | flags | Table-subclass-dependent bitflags that control the details of how to read the catalog. See e.g. SourceFitsFlags. |
Definition at line 372 of file Catalog.h.
|
inlinestatic |
Read a FITS binary table from a RAM file.
[in] | manager | Object that manages the memory to be read. |
[in] | hdu | Number of the "header-data unit" to read (where 0 is the Primary HDU). The default value of afw::fits::DEFAULT_HDU is interpreted as "the first HDU with NAXIS != 0". |
[in] | flags | Table-subclass-dependent bitflags that control the details of how to read the catalog. See e.g. SourceFitsFlags. |
Definition at line 361 of file Catalog.h.
|
inlinestatic |
Read a FITS binary table from a regular file.
[in] | filename | Name of the file to read. |
[in] | hdu | Number of the "header-data unit" to read (where 0 is the Primary HDU). The default value of afw::fits::DEFAULT_HDU is interpreted as "the first HDU with NAXIS != 0". |
[in] | flags | Table-subclass-dependent bitflags that control the details of how to read the catalog. See e.g. SourceFitsFlags. |
Definition at line 347 of file Catalog.h.
|
inline |
Increase the capacity of the catalog to the given size.
This can be used to guarantee that the catalog will be contiguous, but it only affects records constructed after reserve().
|
inline |
Change the size of the catalog, removing or adding empty records as needed.
Definition at line 439 of file Catalog.h.
|
inline |
|
inline |
void lsst::afw::table::CatalogT< RecordT >::sort | ( | Compare | cmp | ) |
void lsst::afw::table::CatalogT< RecordT >::sort | ( | Key< T > const & | key | ) |
Sort the catalog in-place by the field with the given key.
Definition at line 755 of file Catalog.h.
|
inline |
Return the subset of a catalog corresponding to the True values of the given mask array.
The returned array's records are shallow copies, and hence will not in general be contiguous.
Definition at line 184 of file Catalog.h.
|
inline |
Returns a shallow copy of a subset of this Catalog.
The arguments correspond to python's slice() syntax.
Definition at line 205 of file Catalog.h.
|
inlinenoexcept |
CatalogT< RecordT >::iterator lsst::afw::table::CatalogT< RecordT >::upper_bound | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) |
Definition at line 826 of file Catalog.h.
CatalogT< RecordT >::const_iterator lsst::afw::table::CatalogT< RecordT >::upper_bound | ( | typename Field< T >::Value const & | value, |
Key< T > const & | key ) const |
Definition at line 837 of file Catalog.h.
|
inline |
Write a FITS binary table to an open file object.
[in,out] | fitsfile | Fits file object to write to. |
[in] | flags | Table-subclass-dependent bitflags that control the details of how to read the catalogs. See e.g. SourceFitsFlags. |
Definition at line 333 of file Catalog.h.
|
inline |
Write a FITS binary table to a RAM file.
[in,out] | manager | Object that manages the memory to write to. |
[in] | mode | "a" to append a new HDU, "w" to overwrite any existing file. |
[in] | flags | Table-subclass-dependent bitflags that control the details of how to read the catalogs. See e.g. SourceFitsFlags. |
|
inline |
Write a FITS binary table to a regular file.
[in] | filename | Name of the file to write. |
[in] | mode | "a" to append a new HDU, "w" to overwrite any existing file. |
[in] | flags | Table-subclass-dependent bitflags that control the details of how to read the catalogs. See e.g. SourceFitsFlags. |