lsst.afw  21.0.0-8-gd9c33f4a0+ec3713772a
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
lsst::afw::table::SortedCatalogT< RecordT > Class Template Reference

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

typedef RecordT Record
 
typedef Record::Table Table
 
typedef Base::iterator iterator
 
typedef Base::const_iterator const_iterator
 

Public Member Functions

 SortedCatalogT (SortedCatalogT const &)=default
 
 SortedCatalogT (SortedCatalogT &&)=default
 
SortedCatalogToperator= (SortedCatalogT const &)=default
 
SortedCatalogToperator= (SortedCatalogT &&)=default
 
 ~SortedCatalogT ()=default
 
bool isSorted () const
 Return true if the vector is in ascending ID order. More...
 
void sort ()
 Sort the vector in-place by ID. More...
 
iterator find (RecordId id)
 Return an iterator to the record with the given ID. More...
 
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). More...
 
 SortedCatalogT (Schema const &schema)
 Construct a vector from a schema, creating a table with Table::make(schema). More...
 
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. More...
 
template<typename OtherRecordT >
 SortedCatalogT (SortedCatalogT< OtherRecordT > const &other)
 Shallow copy constructor from a container containing a related record type. More...
 
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. More...
 
SortedCatalogT subset (std::ptrdiff_t startd, std::ptrdiff_t stopd, std::ptrdiff_t step) const
 Shallow copy a subset of another SortedCatalog. More...
 
template<typename T >
bool isSorted (Key< T > const &key) const
 Return true if the catalog is in ascending order according to the given key. More...
 
template<typename Compare >
bool isSorted (Compare cmp) const
 Return true if the catalog is in ascending order according to the given predicate. More...
 
template<typename T >
void sort (Key< T > const &key)
 Sort the catalog in-place by the field with the given key. More...
 
template<typename Compare >
void sort (Compare cmp)
 Sort the catalog in-place by the field with the given predicate. More...
 
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. More...
 
template<typename T >
const_iterator find (typename Field< T >::Value const &value, Key< T > const &key) 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. More...
 
static SortedCatalogT readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU, int flags=0)
 Read a FITS binary table from a RAM file. More...
 
static SortedCatalogT readFits (fits::Fits &fitsfile, int flags=0)
 Read a FITS binary table from a file object already at the correct extension. More...
 

Protected Member Functions

 SortedCatalogT (Base const &other)
 

Detailed Description

template<typename RecordT>
class lsst::afw::table::SortedCatalogT< RecordT >

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.

Member Typedef Documentation

◆ const_iterator

template<typename RecordT >
typedef Base::const_iterator lsst::afw::table::SortedCatalogT< RecordT >::const_iterator

Definition at line 50 of file SortedCatalog.h.

◆ iterator

template<typename RecordT >
typedef Base::iterator lsst::afw::table::SortedCatalogT< RecordT >::iterator

Definition at line 49 of file SortedCatalog.h.

◆ Record

template<typename RecordT >
typedef RecordT lsst::afw::table::SortedCatalogT< RecordT >::Record

Definition at line 46 of file SortedCatalog.h.

◆ Table

template<typename RecordT >
typedef Record::Table lsst::afw::table::SortedCatalogT< RecordT >::Table

Definition at line 47 of file SortedCatalog.h.

Constructor & Destructor Documentation

◆ SortedCatalogT() [1/7]

template<typename RecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( SortedCatalogT< RecordT > const &  )
default

◆ SortedCatalogT() [2/7]

template<typename RecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( SortedCatalogT< RecordT > &&  )
default

◆ ~SortedCatalogT()

template<typename RecordT >
lsst::afw::table::SortedCatalogT< RecordT >::~SortedCatalogT ( )
default

◆ SortedCatalogT() [3/7]

template<typename RecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( std::shared_ptr< Table > const &  table = std::shared_ptr<Table>())
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.

◆ SortedCatalogT() [4/7]

template<typename RecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( Schema const &  schema)
inlineexplicit

Construct a vector from a schema, creating a table with Table::make(schema).

Definition at line 90 of file SortedCatalog.h.

◆ SortedCatalogT() [5/7]

template<typename RecordT >
template<typename InputIterator >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( std::shared_ptr< Table > const &  table,
InputIterator  first,
InputIterator  last,
bool  deep = false 
)
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.

◆ SortedCatalogT() [6/7]

template<typename RecordT >
template<typename OtherRecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( SortedCatalogT< OtherRecordT > const &  other)
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.

◆ SortedCatalogT() [7/7]

template<typename RecordT >
lsst::afw::table::SortedCatalogT< RecordT >::SortedCatalogT ( Base const &  other)
inlineexplicitprotected

Definition at line 174 of file SortedCatalog.h.

Member Function Documentation

◆ find() [1/4]

template<typename RecordT >
iterator lsst::afw::table::SortedCatalogT< RecordT >::find ( RecordId  id)
inline

Return an iterator to the record with the given ID.

Note
The vector must be sorted in ascending ID order before calling find (i.e. isSorted() must be true).

Returns end() if the Record cannot be found.

Definition at line 77 of file SortedCatalog.h.

◆ find() [2/4]

template<typename RecordT >
const_iterator lsst::afw::table::SortedCatalogT< RecordT >::find ( RecordId  id) const
inline

Definition at line 78 of file SortedCatalog.h.

◆ find() [3/4]

template<typename RecordT >
template<typename T >
CatalogT< RecordT >::iterator lsst::afw::table::CatalogT< RecordT >::find ( typename T  )

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.

Note
The catalog must be sorted in ascending order according to the given key before calling find (i.e. isSorted(key) must be true).

Returns end() if the Record cannot be found.

Definition at line 616 of file Catalog.h.

◆ find() [4/4]

template<typename RecordT >
template<typename T >
CatalogT< RecordT >::const_iterator lsst::afw::table::CatalogT< RecordT >::find ( typename T  )

Definition at line 619 of file Catalog.h.

◆ isSorted() [1/3]

template<typename RecordT >
bool lsst::afw::table::SortedCatalogT< RecordT >::isSorted ( ) const
inline

Return true if the vector is in ascending ID order.

Definition at line 63 of file SortedCatalog.h.

◆ isSorted() [2/3]

template<typename RecordT >
template<typename Compare >
bool lsst::afw::table::CatalogT< RecordT >::isSorted ( typename Compare  )

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 586 of file Catalog.h.

◆ isSorted() [3/3]

template<typename RecordT >
template<typename T >
bool lsst::afw::table::CatalogT< RecordT >::isSorted ( typename T  )

Return true if the catalog is in ascending order according to the given key.

Definition at line 578 of file Catalog.h.

◆ operator=() [1/2]

template<typename RecordT >
SortedCatalogT& lsst::afw::table::SortedCatalogT< RecordT >::operator= ( SortedCatalogT< RecordT > &&  )
default

◆ operator=() [2/2]

template<typename RecordT >
SortedCatalogT& lsst::afw::table::SortedCatalogT< RecordT >::operator= ( SortedCatalogT< RecordT > const &  )
default

◆ readFits() [1/3]

template<typename RecordT >
static SortedCatalogT lsst::afw::table::SortedCatalogT< RecordT >::readFits ( fits::Fits fitsfile,
int  flags = 0 
)
inlinestatic

Read a FITS binary table from a file object already at the correct extension.

Parameters
[in]fitsfileFits file object to read from.
[in]flagsTable-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.

◆ readFits() [2/3]

template<typename RecordT >
static SortedCatalogT lsst::afw::table::SortedCatalogT< RecordT >::readFits ( fits::MemFileManager manager,
int  hdu = fits::DEFAULT_HDU,
int  flags = 0 
)
inlinestatic

Read a FITS binary table from a RAM file.

Parameters
[in]managerObject that manages the memory to be read.
[in]hduNumber 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]flagsTable-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.

◆ readFits() [3/3]

template<typename RecordT >
static SortedCatalogT lsst::afw::table::SortedCatalogT< RecordT >::readFits ( std::string const &  filename,
int  hdu = fits::DEFAULT_HDU,
int  flags = 0 
)
inlinestatic

Read a FITS binary table from a regular file.

Parameters
[in]filenameName of the file to read.
[in]hduNumber 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]flagsTable-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.

◆ sort() [1/3]

template<typename RecordT >
void lsst::afw::table::SortedCatalogT< RecordT >::sort ( )
inline

Sort the vector in-place by ID.

Definition at line 66 of file SortedCatalog.h.

◆ sort() [2/3]

template<typename RecordT >
template<typename Compare >
void lsst::afw::table::CatalogT< RecordT >::sort ( typename Compare  )

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 598 of file Catalog.h.

◆ sort() [3/3]

template<typename RecordT >
template<typename T >
void lsst::afw::table::CatalogT< RecordT >::sort ( typename T  )

Sort the catalog in-place by the field with the given key.

Definition at line 590 of file Catalog.h.

◆ subset() [1/2]

template<typename RecordT >
SortedCatalogT<RecordT> lsst::afw::table::SortedCatalogT< RecordT >::subset ( ndarray::Array< bool const, 1 > const &  mask) const
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.

◆ subset() [2/2]

template<typename RecordT >
SortedCatalogT lsst::afw::table::SortedCatalogT< RecordT >::subset ( std::ptrdiff_t  startd,
std::ptrdiff_t  stopd,
std::ptrdiff_t  step 
) const
inline

Shallow copy a subset of another SortedCatalog.

Mostly here for use from python.

Definition at line 169 of file SortedCatalog.h.


The documentation for this class was generated from the following files: