LSST Applications g063fba187b+fee0456c91,g0f08755f38+ea96e5a5a3,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+90257ff92a,g20f6ffc8e0+ea96e5a5a3,g217e2c1bcf+937a289c59,g28da252d5a+daa7da44eb,g2bbee38e9b+253935c60e,g2bc492864f+253935c60e,g3156d2b45e+6e55a43351,g32e5bea42b+31359a2a7a,g347aa1857d+253935c60e,g35bb328faa+a8ce1bb630,g3a166c0a6a+253935c60e,g3b1af351f3+a8ce1bb630,g3e281a1b8c+c5dd892a6c,g414038480c+416496e02f,g41af890bb2+afe91b1188,g599934f4f4+0db33f7991,g7af13505b9+e36de7bce6,g80478fca09+da231ba887,g82479be7b0+a4516e59e3,g858d7b2824+ea96e5a5a3,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+bc6ab8dfbd,gb58c049af0+d64f4d3760,gc28159a63d+253935c60e,gcab2d0539d+3f2b72788c,gcf0d15dbbd+4ea9c45075,gda6a2b7d83+4ea9c45075,gdaeeff99f8+1711a396fd,ge79ae78c31+253935c60e,gef2f8181fd+3031e3cf99,gf0baf85859+c1f95f4921,gfa517265be+ea96e5a5a3,gfa999e8aa5+17cd334064,w.2024.50
LSST Data Management Base Package
|
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID. More...
#include <SortedCatalog.h>
Public Types | |
using | Record = RecordT |
using | Table = typename Record::Table |
using | iterator = typename Base::iterator |
using | const_iterator = typename Base::const_iterator |
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 |
Public Member Functions | |
SortedCatalogT (SortedCatalogT const &)=default | |
SortedCatalogT (SortedCatalogT &&)=default | |
SortedCatalogT & | operator= (SortedCatalogT const &)=default |
SortedCatalogT & | operator= (SortedCatalogT &&)=default |
~SortedCatalogT ()=default | |
bool | isSorted () const |
Return true if the vector is in ascending ID order. | |
void | sort () |
Sort the vector in-place by ID. | |
iterator | find (RecordId id) |
Return an iterator to the record with the given ID. | |
const_iterator | find (RecordId id) const |
SortedCatalogT (std::shared_ptr< Table > const &table=std::shared_ptr< Table >()) | |
Construct a vector from a table (or nothing). | |
SortedCatalogT (Schema const &schema) | |
Construct a vector from a schema, creating a table with Table::make(schema). | |
template<typename InputIterator > | |
SortedCatalogT (std::shared_ptr< Table > const &table, InputIterator first, InputIterator last, bool deep=false) | |
Construct a vector from a table and an iterator range. | |
template<typename OtherRecordT > | |
SortedCatalogT (SortedCatalogT< OtherRecordT > const &other) | |
Shallow copy constructor from a container containing a related record type. | |
SortedCatalogT< 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. | |
SortedCatalogT | subset (std::ptrdiff_t startd, std::ptrdiff_t stopd, std::ptrdiff_t step) const |
Shallow copy a subset of another SortedCatalog. | |
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 |
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. | |
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. | |
const_iterator | begin () const |
iterator | end () |
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 > | |
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 |
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 |
Internal & | getInternal () |
Return a reference to the internal vector-of-shared_ptr. | |
Internal const & | getInternal () const |
Static Public Member Functions | |
static SortedCatalogT | readFits (std::string const &filename, int hdu=fits::DEFAULT_HDU, int flags=0) |
Read a FITS binary table from a regular file. | |
static SortedCatalogT | readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU, int flags=0) |
Read a FITS binary table from a RAM file. | |
static SortedCatalogT | readFits (fits::Fits &fitsfile, int flags=0) |
Read a FITS binary table from a file object already at the correct extension. | |
Protected Member Functions | |
SortedCatalogT (Base const &other) | |
Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID.
For a record/table pair to be used with SortedCatalogT, the table class must provide a static getIdKey() member function that returns the key to the ID field.
Definition at line 42 of file SortedCatalog.h.
|
inherited |
using lsst::afw::table::SortedCatalogT< RecordT >::const_iterator = typename Base::const_iterator |
Definition at line 50 of file SortedCatalog.h.
|
inherited |
using lsst::afw::table::SortedCatalogT< RecordT >::iterator = typename Base::iterator |
Definition at line 49 of file SortedCatalog.h.
|
inherited |
using lsst::afw::table::SortedCatalogT< RecordT >::Record = RecordT |
Definition at line 46 of file SortedCatalog.h.
|
inherited |
|
inherited |
using lsst::afw::table::SortedCatalogT< RecordT >::Table = typename Record::Table |
Definition at line 47 of file SortedCatalog.h.
|
default |
|
default |
|
default |
|
inlineexplicit |
Construct a vector from a table (or nothing).
A vector with no table is considered invalid; a valid table must be assigned to it before it can be used.
Definition at line 87 of file SortedCatalog.h.
|
inlineexplicit |
Construct a vector from a schema, creating a table with Table::make(schema).
Definition at line 90 of file SortedCatalog.h.
|
inline |
Construct a vector 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 103 of file SortedCatalog.h.
|
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 114 of file SortedCatalog.h.
|
inlineexplicitprotected |
Definition at line 174 of file SortedCatalog.h.
|
inlineinherited |
|
inlineinherited |
Replace the contents of the table with an iterator range.
Delegates to insert(); look there for more information.
Definition at line 474 of file Catalog.h.
|
inlineinherited |
Return the record at index i (throws std::out_of_range).
Definition at line 454 of file Catalog.h.
|
inlineinherited |
|
inlineinherited |
Iterator access.
Definition at line 400 of file Catalog.h.
|
inlineinherited |
Definition at line 402 of file Catalog.h.
|
inlineinherited |
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.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Deep-copy the catalog using a cloned table.
Definition at line 499 of file Catalog.h.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inherited |
|
inherited |
Definition at line 849 of file Catalog.h.
|
inherited |
|
inherited |
Definition at line 861 of file Catalog.h.
|
inlineinherited |
|
inline |
Return an iterator to the record with the given ID.
Returns end() if the Record cannot be found.
Definition at line 77 of file SortedCatalog.h.
|
inline |
Definition at line 78 of file SortedCatalog.h.
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 622 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 625 of file Catalog.h.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Return a ColumnView of this catalog's records.
Will throw RuntimeError if records are not contiguous.
Definition at line 381 of file Catalog.h.
|
inlineinherited |
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.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
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.
|
inlineinherited |
Insert a copy of the given record at the given position.
|
inlineinherited |
|
inlineinherited |
Insert a range of records into the catalog by copying them with a SchemaMapper.
Definition at line 538 of file Catalog.h.
|
inlineinherited |
|
inline |
Return true if the vector is in ascending ID order.
Definition at line 63 of file SortedCatalog.h.
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 590 of file Catalog.h.
|
inherited |
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.
|
inherited |
Definition at line 815 of file Catalog.h.
|
inlineinherited |
|
default |
|
default |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Add a copy of the given record to the end of the catalog.
|
inlineinherited |
|
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 152 of file SortedCatalog.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 140 of file SortedCatalog.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 126 of file SortedCatalog.h.
|
inlineinherited |
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().
|
inlineinherited |
Change the size of the catalog, removing or adding empty records as needed.
Definition at line 439 of file Catalog.h.
|
inlineinherited |
|
inlineinherited |
|
inline |
Sort the vector in-place by ID.
Definition at line 66 of file SortedCatalog.h.
void lsst::afw::table::CatalogT< RecordT >::sort | ( | Compare | cmp | ) |
Sort the catalog in-place by the field with the given predicate.
cmp(a, b) should return true if record a is less than record b, and false otherwise.
Definition at line 602 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 161 of file SortedCatalog.h.
|
inline |
Shallow copy a subset of another SortedCatalog.
Mostly here for use from python.
Definition at line 169 of file SortedCatalog.h.
|
inlinenoexceptinherited |
|
inherited |
Definition at line 826 of file Catalog.h.
|
inherited |
Definition at line 837 of file Catalog.h.
|
inlineinherited |
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.
|
inlineinherited |
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. |
|
inlineinherited |
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. |