LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
lsst::afw::table::ExposureCatalogT< RecordT > Class Template Reference

Custom catalog class for ExposureRecord/Table. More...

#include <Exposure.h>

Inheritance diagram for lsst::afw::table::ExposureCatalogT< RecordT >:
lsst::afw::table::SortedCatalogT< RecordT > lsst::afw::table::CatalogT< RecordT >

Public Types

typedef RecordT Record
 
typedef Record::Table Table
 
typedef Base::iterator iterator
 
typedef Base::const_iterator const_iterator
 
typedef Record::ColumnView ColumnView
 
typedef RecordT value_type
 
typedef RecordT & reference
 
typedef std::shared_ptr< RecordT > pointer
 
typedef Internal::size_type size_type
 
typedef Internal::difference_type difference_type
 

Public Member Functions

 ExposureCatalogT (std::shared_ptr< Table > const &table=std::shared_ptr< Table >())
 Construct a vector from a table (or nothing). More...
 
 ExposureCatalogT (Schema const &schema)
 Construct a vector from a schema, creating a table with Table::make(schema). More...
 
template<typename InputIterator >
 ExposureCatalogT (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 >
 ExposureCatalogT (ExposureCatalogT< OtherRecordT > const &other)
 Shallow copy constructor from a container containing a related record type. More...
 
 ExposureCatalogT (ExposureCatalogT const &)=default
 
 ExposureCatalogT (ExposureCatalogT &&)=default
 
ExposureCatalogToperator= (ExposureCatalogT const &)=default
 
ExposureCatalogToperator= (ExposureCatalogT &&)=default
 
 ~ExposureCatalogT ()=default
 
void writeFits (fits::Fits &fitsfile, std::shared_ptr< io::OutputArchive > archive, int flags=0) const
 Write a FITS binary table to an open file object. More...
 
void writeToArchive (io::OutputArchiveHandle &handle, bool ignoreUnpersistable=true) const
 Convenience output function for Persistables that contain an ExposureCatalog. More...
 
ExposureCatalogT< 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...
 
ExposureCatalogT subset (std::ptrdiff_t startd, std::ptrdiff_t stopd, std::ptrdiff_t step) const
 Shallow copy a subset of another ExposureCatalog. More...
 
ExposureCatalogT subsetContaining (lsst::geom::SpherePoint const &coord, bool includeValidPolygon=false) const
 Return a shallow subset of the catalog with only those records that contain the given point. More...
 
ExposureCatalogT subsetContaining (lsst::geom::Point2D const &point, geom::SkyWcs const &wcs, bool includeValidPolygon=false) const
 Return a shallow subset of the catalog with only those records that contain the given point. More...
 
bool isSorted () const
 Return true if the vector is in ascending ID order. 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...
 
void sort ()
 Sort the vector in-place by ID. 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...
 
std::shared_ptr< TablegetTable () const
 Return the table associated with the catalog. More...
 
Schema getSchema () const
 Return the schema associated with the catalog's table. More...
 
void writeFits (std::string const &filename, std::string const &mode="w", int flags=0) const
 Write a FITS binary table to a regular file. More...
 
void writeFits (fits::MemFileManager &manager, std::string const &mode="w", int flags=0) const
 Write a FITS binary table to a RAM file. More...
 
void writeFits (fits::Fits &fitsfile, int flags=0) const
 Write a FITS binary table to an open file object. More...
 
ColumnView getColumnView () const
 Return a ColumnView of this catalog's records. More...
 
bool isContiguous () const
 Return true if all records are contiguous. More...
 
bool empty () const
 Return true if the catalog has no records. More...
 
size_type size () const
 Return the number of elements in the catalog. More...
 
size_type max_size () const
 Return the maximum number of elements allowed in a catalog. More...
 
size_type capacity () const
 Return the capacity of the catalog. More...
 
void reserve (size_type n)
 Increase the capacity of the catalog to the given size. More...
 
void resize (size_type n)
 Change the size of the catalog, removing or adding empty records as needed. More...
 
reference operator[] (size_type i) const
 Return the record at index i. More...
 
reference at (size_type i) const
 Return the record at index i (throws std::out_of_range). More...
 
reference front () const
 Return the first record. More...
 
reference back () const
 Return the last record. More...
 
std::shared_ptr< RecordT > const get (size_type i) const
 Return a pointer to the record at index i. More...
 
void set (size_type i, std::shared_ptr< RecordT > const &p)
 Set the record at index i to a pointer. More...
 
template<typename InputIterator >
void assign (InputIterator first, InputIterator last, bool deep=false)
 Replace the contents of the table with an iterator range. More...
 
void push_back (Record const &r)
 Add a copy of the given record to the end of the catalog. More...
 
void push_back (std::shared_ptr< RecordT > const &p)
 Add the given record to the end of the catalog without copying. More...
 
std::shared_ptr< RecordT > addNew ()
 Create a new record, add it to the end of the catalog, and return a pointer to it. More...
 
void pop_back ()
 Remove the last record in the catalog. More...
 
CatalogT copy () const
 Deep-copy the catalog using a cloned table. More...
 
template<typename InputIterator >
void insert (iterator pos, InputIterator first, InputIterator last, bool deep=false)
 Insert an iterator range into the table. More...
 
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. More...
 
iterator insert (iterator pos, Record const &r)
 Insert a copy of the given record at the given position. More...
 
iterator insert (iterator pos, std::shared_ptr< RecordT > const &p)
 Insert the given record at the given position without copying. More...
 
iterator erase (iterator pos)
 Erase the record pointed to by pos, and return an iterator the next record. More...
 
iterator erase (iterator first, iterator last)
 Erase the records in the range [first, last). More...
 
void swap (CatalogT &other) noexcept
 Shallow swap of two catalogs. More...
 
void clear ()
 Remove all records from the catalog. More...
 
template<typename T >
std::pair< typename CatalogT< RecordT >::iterator, typename CatalogT< RecordT >::iteratorequal_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_iteratorequal_range (typename Field< T >::Value const &value, Key< T > const &key) const
 
iterator find (RecordId id)
 Return an iterator to the record with the given ID. More...
 
const_iterator find (RecordId id) const
 Return an iterator to the record with the given ID. 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
 Return an iterator to the record with the given value. More...
 
iterator begin ()
 Iterator access. More...
 
const_iterator begin () const
 Iterator access. More...
 
iterator end ()
 Iterator access. More...
 
const_iterator end () const
 Iterator access. More...
 
const_iterator cbegin () const
 Iterator access. More...
 
const_iterator cend () const
 Iterator access. More...
 
template<typename T >
iterator lower_bound (typename Field< T >::Value const &value, Key< T > const &key)
 Performed binary searches on sorted fields. More...
 
template<typename T >
const_iterator lower_bound (typename Field< T >::Value const &value, Key< T > const &key) const
 Performed binary searches on sorted fields. More...
 
template<typename T >
iterator upper_bound (typename Field< T >::Value const &value, Key< T > const &key)
 Performed binary searches on sorted fields. More...
 
template<typename T >
const_iterator upper_bound (typename Field< T >::Value const &value, Key< T > const &key) const
 Performed binary searches on sorted fields. More...
 
template<typename T >
std::pair< iterator, iteratorequal_range (typename Field< T >::Value const &value, Key< T > const &key)
 Performed binary searches on sorted fields. More...
 
template<typename T >
std::pair< const_iterator, const_iteratorequal_range (typename Field< T >::Value const &value, Key< T > const &key) const
 Performed binary searches on sorted fields. More...
 
InternalgetInternal ()
 Return a reference to the internal vector-of-shared_ptr. More...
 
Internal const & getInternal () const
 Return a reference to the internal vector-of-shared_ptr. More...
 

Static Public Member Functions

static ExposureCatalogT readFits (std::string const &filename, int hdu=fits::DEFAULT_HDU, int flags=0)
 Read a FITS binary table from a regular file. More...
 
static ExposureCatalogT readFits (fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU, int flags=0)
 Read a FITS binary table from a RAM file. More...
 
static ExposureCatalogT readFits (fits::Fits &fitsfile, int flags=0)
 Read a FITS binary table from a file object already at the correct extension. More...
 
static ExposureCatalogT readFits (fits::Fits &fitsfile, std::shared_ptr< io::InputArchive > archive, int flags=0)
 Read a FITS binary table from a file object already at the correct extension. More...
 
static ExposureCatalogT readFromArchive (io::InputArchive const &archive, BaseCatalog const &catalog)
 Convenience input function for Persistables that contain an ExposureCatalog. More...
 

Protected Member Functions

 ExposureCatalogT (Base const &other)
 

Detailed Description

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

Custom catalog class for ExposureRecord/Table.

We don't expect to subclass ExposureRecord/Table, so unlike other Catalogs we can (and do) define some ExposureCatalogT member functions in Exposure.cc where the explicit instantiation is done.

Definition at line 67 of file Exposure.h.

Member Typedef Documentation

◆ ColumnView

template<typename RecordT>
typedef Record::ColumnView lsst::afw::table::CatalogT< RecordT >::ColumnView
inherited

Definition at line 103 of file Catalog.h.

◆ const_iterator

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

Definition at line 319 of file Exposure.h.

◆ difference_type

template<typename RecordT>
typedef Internal::difference_type lsst::afw::table::CatalogT< RecordT >::difference_type
inherited

Definition at line 109 of file Catalog.h.

◆ iterator

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

Definition at line 318 of file Exposure.h.

◆ pointer

template<typename RecordT>
typedef std::shared_ptr<RecordT> lsst::afw::table::CatalogT< RecordT >::pointer
inherited

Definition at line 107 of file Catalog.h.

◆ Record

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

Definition at line 315 of file Exposure.h.

◆ reference

template<typename RecordT>
typedef RecordT& lsst::afw::table::CatalogT< RecordT >::reference
inherited

Definition at line 106 of file Catalog.h.

◆ size_type

template<typename RecordT>
typedef Internal::size_type lsst::afw::table::CatalogT< RecordT >::size_type
inherited

Definition at line 108 of file Catalog.h.

◆ Table

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

Definition at line 316 of file Exposure.h.

◆ value_type

template<typename RecordT>
typedef RecordT lsst::afw::table::CatalogT< RecordT >::value_type
inherited

Definition at line 105 of file Catalog.h.

Constructor & Destructor Documentation

◆ ExposureCatalogT() [1/7]

template<typename RecordT>
lsst::afw::table::ExposureCatalogT< RecordT >::ExposureCatalogT ( 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 327 of file Exposure.h.

327 : Base(table) {}

◆ ExposureCatalogT() [2/7]

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

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

Definition at line 330 of file Exposure.h.

330 : Base(schema) {}
table::Schema schema
Definition: Amplifier.cc:115

◆ ExposureCatalogT() [3/7]

template<typename RecordT>
template<typename InputIterator >
lsst::afw::table::ExposureCatalogT< RecordT >::ExposureCatalogT ( 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 343 of file Exposure.h.

345  : Base(table, first, last, deep) {}

◆ ExposureCatalogT() [4/7]

template<typename RecordT>
template<typename OtherRecordT >
lsst::afw::table::ExposureCatalogT< RecordT >::ExposureCatalogT ( ExposureCatalogT< 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 354 of file Exposure.h.

354 : Base(other) {}
ItemVariant const * other
Definition: Schema.cc:56

◆ ExposureCatalogT() [5/7]

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

◆ ExposureCatalogT() [6/7]

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

◆ ~ExposureCatalogT()

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

◆ ExposureCatalogT() [7/7]

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

Definition at line 485 of file Exposure.h.

485 : Base(other) {}
ItemVariant const * other
Definition: Schema.cc:56

Member Function Documentation

◆ addNew()

template<typename RecordT>
std::shared_ptr<RecordT> lsst::afw::table::CatalogT< RecordT >::addNew ( )
inlineinherited

Create a new record, add it to the end of the catalog, and return a pointer to it.

Definition at line 485 of file Catalog.h.

485  {
486  std::shared_ptr<RecordT> r = _table->makeRecord();
487  _internal.push_back(r);
488  return r;
489  }
T push_back(T... args)

◆ assign()

template<typename RecordT>
template<typename InputIterator >
void lsst::afw::table::CatalogT< RecordT >::assign ( InputIterator  first,
InputIterator  last,
bool  deep = false 
)
inlineinherited

Replace the contents of the table with an iterator range.

Delegates to insert(); look there for more information.

Definition at line 470 of file Catalog.h.

470  {
471  clear();
472  insert(end(), first, last, deep);
473  }
void insert(iterator pos, InputIterator first, InputIterator last, bool deep=false)
Insert an iterator range into the table.
Definition: Catalog.h:513
void clear()
Remove all records from the catalog.
Definition: Catalog.h:574
iterator end()
Iterator access.
Definition: Catalog.h:397

◆ at()

template<typename RecordT>
reference lsst::afw::table::CatalogT< RecordT >::at ( size_type  i) const
inlineinherited

Return the record at index i (throws std::out_of_range).

Definition at line 450 of file Catalog.h.

450 { return *_internal.at(i); }
T at(T... args)

◆ back()

template<typename RecordT>
reference lsst::afw::table::CatalogT< RecordT >::back ( ) const
inlineinherited

Return the last record.

Definition at line 456 of file Catalog.h.

456 { return *_internal.back(); }
T back(T... args)

◆ begin() [1/2]

template<typename RecordT>
iterator lsst::afw::table::CatalogT< RecordT >::begin ( )
inlineinherited

Iterator access.

See also
CatalogIterator

Definition at line 396 of file Catalog.h.

396 { return iterator(_internal.begin()); }
T begin(T... args)
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ begin() [2/2]

template<typename RecordT>
const_iterator lsst::afw::table::CatalogT< RecordT >::begin ( ) const
inlineinherited

Iterator access.

See also
CatalogIterator

Definition at line 398 of file Catalog.h.

398 { return const_iterator(_internal.begin()); }
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:111
T begin(T... args)

◆ capacity()

template<typename RecordT>
size_type lsst::afw::table::CatalogT< RecordT >::capacity ( ) const
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 420 of file Catalog.h.

420 { return _internal.size() + _table->getBufferSize(); }
T size(T... args)

◆ cbegin()

template<typename RecordT>
const_iterator lsst::afw::table::CatalogT< RecordT >::cbegin ( ) const
inlineinherited

Iterator access.

See also
CatalogIterator

Definition at line 400 of file Catalog.h.

400 { return begin(); }
iterator begin()
Iterator access.
Definition: Catalog.h:396

◆ cend()

template<typename RecordT>
const_iterator lsst::afw::table::CatalogT< RecordT >::cend ( ) const
inlineinherited

Iterator access.

See also
CatalogIterator

Definition at line 401 of file Catalog.h.

401 { return end(); }
iterator end()
Iterator access.
Definition: Catalog.h:397

◆ clear()

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::clear ( )
inlineinherited

Remove all records from the catalog.

Definition at line 574 of file Catalog.h.

574 { _internal.clear(); }
T clear(T... args)

◆ copy()

template<typename RecordT>
CatalogT lsst::afw::table::CatalogT< RecordT >::copy ( ) const
inlineinherited

Deep-copy the catalog using a cloned table.

Definition at line 495 of file Catalog.h.

495 { return CatalogT(getTable()->clone(), begin(), end(), true); }
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:114
iterator end()
Iterator access.
Definition: Catalog.h:397
CatalogT(std::shared_ptr< Table > const &table=std::shared_ptr< Table >())
Construct a catalog from a table (or nothing).
Definition: Catalog.h:125
iterator begin()
Iterator access.
Definition: Catalog.h:396

◆ empty()

template<typename RecordT>
bool lsst::afw::table::CatalogT< RecordT >::empty ( ) const
inlineinherited

Return true if the catalog has no records.

Definition at line 405 of file Catalog.h.

405 { return _internal.empty(); }
T empty(T... args)

◆ end() [1/2]

template<typename RecordT>
iterator lsst::afw::table::CatalogT< RecordT >::end ( )
inlineinherited

Iterator access.

See also
CatalogIterator

Definition at line 397 of file Catalog.h.

397 { return iterator(_internal.end()); }
T end(T... args)
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ end() [2/2]

template<typename RecordT>
const_iterator lsst::afw::table::CatalogT< RecordT >::end ( ) const
inlineinherited

Iterator access.

See also
CatalogIterator

Definition at line 399 of file Catalog.h.

399 { return const_iterator(_internal.end()); }
T end(T... args)
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:111

◆ equal_range() [1/4]

template<typename RecordT>
template<typename T >
std::pair<iterator, iterator> lsst::afw::table::CatalogT< RecordT >::equal_range ( typename Field< T >::Value const &  value,
Key< T > const &  key 
)
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.

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

◆ equal_range() [2/4]

template<typename RecordT>
template<typename T >
std::pair<const_iterator, const_iterator> lsst::afw::table::CatalogT< RecordT >::equal_range ( typename Field< T >::Value const &  value,
Key< T > const &  key 
) const
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.

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

◆ equal_range() [3/4]

template<typename RecordT>
template<typename T >
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 
)
inherited

Definition at line 827 of file Catalog.h.

827  {
828  detail::KeyExtractionFunctor<RecordT, T> f = {key};
829  // Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
830  typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, iterator> SearchIter;
832  std::equal_range(SearchIter(begin(), f), SearchIter(end(), f), value);
833  return std::make_pair(i.first.base(), i.second.base());
834 }
iterator end()
Iterator access.
Definition: Catalog.h:397
Key< U > key
Definition: Schema.cc:281
T make_pair(T... args)
iterator begin()
Iterator access.
Definition: Catalog.h:396
T equal_range(T... args)
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ equal_range() [4/4]

template<typename RecordT>
template<typename T >
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
inherited

Definition at line 839 of file Catalog.h.

839  {
840  detail::KeyExtractionFunctor<RecordT, T> f = {key};
841  // Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
842  typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, const_iterator> SearchIter;
844  std::equal_range(SearchIter(begin(), f), SearchIter(end(), f), value);
845  return std::make_pair(i.first.base(), i.second.base());
846 }
iterator end()
Iterator access.
Definition: Catalog.h:397
Key< U > key
Definition: Schema.cc:281
T make_pair(T... args)
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:111
iterator begin()
Iterator access.
Definition: Catalog.h:396
T equal_range(T... args)

◆ erase() [1/2]

template<typename RecordT>
iterator lsst::afw::table::CatalogT< RecordT >::erase ( iterator  pos)
inlineinherited

Erase the record pointed to by pos, and return an iterator the next record.

Definition at line 560 of file Catalog.h.

560 { return iterator(_internal.erase(pos.base())); }
T erase(T... args)
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ erase() [2/2]

template<typename RecordT>
iterator lsst::afw::table::CatalogT< RecordT >::erase ( iterator  first,
iterator  last 
)
inlineinherited

Erase the records in the range [first, last).

Definition at line 563 of file Catalog.h.

563  {
564  return iterator(_internal.erase(first.base(), last.base()));
565  }
T erase(T... args)
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ find() [1/4]

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

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.

77 { return this->find(id, Table::getIdKey()); }
iterator find(RecordId id)
Return an iterator to the record with the given ID.
Definition: SortedCatalog.h:77

◆ find() [2/4]

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

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 78 of file SortedCatalog.h.

78 { return this->find(id, Table::getIdKey()); }
iterator find(RecordId id)
Return an iterator to the record with the given ID.
Definition: SortedCatalog.h:77

◆ find() [3/4]

template<typename RecordT >
template<typename T >
CatalogT< RecordT >::iterator lsst::afw::table::CatalogT< RecordT >::find ( typename Field< T >::Value const &  value,
Key< T > const &  key 
)
inherited

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

757  {
758  detail::KeyExtractionFunctor<RecordT, T> f = {key};
759  // Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
760  typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, iterator> SearchIter;
761  // Use binary search for log n search; requires sorted table.
762  SearchIter i = std::lower_bound(SearchIter(begin(), f), SearchIter(end(), f), value);
763  if (i.base() == end() || *i != value) return end();
764  return i.base();
765 }
T lower_bound(T... args)
iterator end()
Iterator access.
Definition: Catalog.h:397
Key< U > key
Definition: Schema.cc:281
iterator begin()
Iterator access.
Definition: Catalog.h:396
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ find() [4/4]

template<typename RecordT >
template<typename T >
CatalogT< RecordT >::const_iterator lsst::afw::table::CatalogT< RecordT >::find ( typename Field< T >::Value const &  value,
Key< T > const &  key 
) const
inherited

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

770  {
771  detail::KeyExtractionFunctor<RecordT, T> f = {key};
772  // Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
773  typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, const_iterator> SearchIter;
774  // Use binary search for log n search; requires sorted table.
775  SearchIter i = std::lower_bound(SearchIter(begin(), f), SearchIter(end(), f), value);
776  if (i.base() == end() || *i != value) return end();
777  return i.base();
778 }
T lower_bound(T... args)
iterator end()
Iterator access.
Definition: Catalog.h:397
Key< U > key
Definition: Schema.cc:281
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:111
iterator begin()
Iterator access.
Definition: Catalog.h:396

◆ front()

template<typename RecordT>
reference lsst::afw::table::CatalogT< RecordT >::front ( ) const
inlineinherited

Return the first record.

Definition at line 453 of file Catalog.h.

453 { return *_internal.front(); }
T front(T... args)

◆ get()

template<typename RecordT>
std::shared_ptr<RecordT> const lsst::afw::table::CatalogT< RecordT >::get ( size_type  i) const
inlineinherited

Return a pointer to the record at index i.

Definition at line 459 of file Catalog.h.

459 { return _internal[i]; }

◆ getColumnView()

template<typename RecordT>
ColumnView lsst::afw::table::CatalogT< RecordT >::getColumnView ( ) const
inlineinherited

Return a ColumnView of this catalog's records.

Will throw RuntimeError if records are not contiguous.

Definition at line 377 of file Catalog.h.

377  {
379  throw LSST_EXCEPT(
380  pex::exceptions::LogicError,
381  "Cannot get a column view from a CatalogT<RecordT const> (as column views are always "
382  "non-const views).");
383  }
384  return ColumnView::make(_table, begin(), end());
385  }
iterator end()
Iterator access.
Definition: Catalog.h:397
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
iterator begin()
Iterator access.
Definition: Catalog.h:396

◆ getInternal() [1/2]

template<typename RecordT>
Internal& lsst::afw::table::CatalogT< RecordT >::getInternal ( )
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 669 of file Catalog.h.

669 { return _internal; }

◆ getInternal() [2/2]

template<typename RecordT>
Internal const& lsst::afw::table::CatalogT< RecordT >::getInternal ( ) const
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 670 of file Catalog.h.

670 { return _internal; }

◆ getSchema()

template<typename RecordT>
Schema lsst::afw::table::CatalogT< RecordT >::getSchema ( ) const
inlineinherited

Return the schema associated with the catalog's table.

Definition at line 117 of file Catalog.h.

117 { return _table->getSchema(); }

◆ getTable()

template<typename RecordT>
std::shared_ptr<Table> lsst::afw::table::CatalogT< RecordT >::getTable ( ) const
inlineinherited

Return the table associated with the catalog.

Definition at line 114 of file Catalog.h.

114 { return _table; }

◆ insert() [1/4]

template<typename RecordT>
template<typename InputIterator >
void lsst::afw::table::CatalogT< RecordT >::insert ( iterator  pos,
InputIterator  first,
InputIterator  last,
bool  deep = false 
)
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.

Definition at line 513 of file Catalog.h.

513  {
514  _maybeReserve(pos, first, last, deep,
516  if (deep) {
517  while (first != last) {
518  pos = insert(pos, *first);
519  ++pos;
520  ++first;
521  }
522  } else {
523  while (first != last) {
524  pos = insert(pos, first);
525  assert(pos != end());
526  ++pos;
527  ++first;
528  }
529  }
530  }
void insert(iterator pos, InputIterator first, InputIterator last, bool deep=false)
Insert an iterator range into the table.
Definition: Catalog.h:513
iterator end()
Iterator access.
Definition: Catalog.h:397

◆ insert() [2/4]

template<typename RecordT>
template<typename InputIterator >
void lsst::afw::table::CatalogT< RecordT >::insert ( SchemaMapper const &  mapper,
iterator  pos,
InputIterator  first,
InputIterator  last 
)
inlineinherited

Insert a range of records into the catalog by copying them with a SchemaMapper.

Definition at line 534 of file Catalog.h.

534  {
535  if (!_table->getSchema().contains(mapper.getOutputSchema())) {
536  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
537  "SchemaMapper's output schema does not match catalog's schema");
538  }
539  _maybeReserve(pos, first, last, true,
541  while (first != last) {
542  pos = insert(pos, _table->copyRecord(*first, mapper));
543  ++pos;
544  ++first;
545  }
546  }
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
void insert(iterator pos, InputIterator first, InputIterator last, bool deep=false)
Insert an iterator range into the table.
Definition: Catalog.h:513
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48

◆ insert() [3/4]

template<typename RecordT>
iterator lsst::afw::table::CatalogT< RecordT >::insert ( iterator  pos,
Record const &  r 
)
inlineinherited

Insert a copy of the given record at the given position.

Definition at line 549 of file Catalog.h.

549  {
550  std::shared_ptr<RecordT> p = _table->copyRecord(r);
551  return iterator(_internal.insert(pos.base(), p));
552  }
T insert(T... args)
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ insert() [4/4]

template<typename RecordT>
iterator lsst::afw::table::CatalogT< RecordT >::insert ( iterator  pos,
std::shared_ptr< RecordT > const &  p 
)
inlineinherited

Insert the given record at the given position without copying.

Definition at line 555 of file Catalog.h.

555  {
556  return iterator(_internal.insert(pos.base(), p));
557  }
T insert(T... args)
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ isContiguous()

template<typename RecordT>
bool lsst::afw::table::CatalogT< RecordT >::isContiguous ( ) const
inlineinherited

Return true if all records are contiguous.

Definition at line 388 of file Catalog.h.

388 { return ColumnView::isRangeContiguous(_table, begin(), end()); }
iterator end()
Iterator access.
Definition: Catalog.h:397
iterator begin()
Iterator access.
Definition: Catalog.h:396

◆ isSorted() [1/3]

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

Return true if the vector is in ascending ID order.

Definition at line 63 of file SortedCatalog.h.

63 { return this->isSorted(Table::getIdKey()); }
bool isSorted() const
Return true if the vector is in ascending ID order.
Definition: SortedCatalog.h:63

◆ isSorted() [2/3]

template<typename RecordT >
template<typename T >
bool lsst::afw::table::CatalogT< RecordT >::isSorted ( Key< T > const &  key) const
inherited

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

Definition at line 742 of file Catalog.h.

742  {
743  detail::KeyComparisonFunctor<RecordT, T> f = {key};
744  return isSorted(f);
745 }
bool isSorted(Key< T > const &key) const
Return true if the catalog is in ascending order according to the given key.
Definition: Catalog.h:742
Key< U > key
Definition: Schema.cc:281

◆ isSorted() [3/3]

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

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

719  {
721  detail::ComparisonAdaptor<RecordT, Compare> f = {cmp};
722  if (empty()) return true;
723  const_iterator last = this->begin();
724  const_iterator i = last;
725  ++i;
726  for (; i != this->end(); ++i) {
727  if (f(i, last)) return false;
728  last = i;
729  }
730  return true;
731 }
iterator end()
Iterator access.
Definition: Catalog.h:397
bool empty() const
Return true if the catalog has no records.
Definition: Catalog.h:405
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:111
iterator begin()
Iterator access.
Definition: Catalog.h:396

◆ lower_bound() [1/2]

template<typename RecordT >
template<typename T >
CatalogT< RecordT >::iterator lsst::afw::table::CatalogT< RecordT >::lower_bound ( typename Field< T >::Value const &  value,
Key< T > const &  key 
)
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.

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

Definition at line 782 of file Catalog.h.

783  {
784  detail::KeyExtractionFunctor<RecordT, T> f = {key};
785  // Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
786  typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, iterator> SearchIter;
787  SearchIter i = std::lower_bound(SearchIter(begin(), f), SearchIter(end(), f), value);
788  return i.base();
789 }
T lower_bound(T... args)
iterator end()
Iterator access.
Definition: Catalog.h:397
Key< U > key
Definition: Schema.cc:281
iterator begin()
Iterator access.
Definition: Catalog.h:396
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ lower_bound() [2/2]

template<typename RecordT >
template<typename T >
CatalogT< RecordT >::const_iterator lsst::afw::table::CatalogT< RecordT >::lower_bound ( typename Field< T >::Value const &  value,
Key< T > const &  key 
) const
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.

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

Definition at line 793 of file Catalog.h.

794  {
795  detail::KeyExtractionFunctor<RecordT, T> f = {key};
796  // Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
797  typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, const_iterator> SearchIter;
798  SearchIter i = std::lower_bound(SearchIter(begin(), f), SearchIter(end(), f), value);
799  return i.base();
800 }
T lower_bound(T... args)
iterator end()
Iterator access.
Definition: Catalog.h:397
Key< U > key
Definition: Schema.cc:281
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:111
iterator begin()
Iterator access.
Definition: Catalog.h:396

◆ max_size()

template<typename RecordT>
size_type lsst::afw::table::CatalogT< RecordT >::max_size ( ) const
inlineinherited

Return the maximum number of elements allowed in a catalog.

Definition at line 411 of file Catalog.h.

411 { return _internal.max_size(); }
T max_size(T... args)

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator[]()

template<typename RecordT>
reference lsst::afw::table::CatalogT< RecordT >::operator[] ( size_type  i) const
inlineinherited

Return the record at index i.

Definition at line 447 of file Catalog.h.

447 { return *_internal[i]; }

◆ pop_back()

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::pop_back ( )
inlineinherited

Remove the last record in the catalog.

Definition at line 492 of file Catalog.h.

492 { _internal.pop_back(); }
T pop_back(T... args)

◆ push_back() [1/2]

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::push_back ( Record const &  r)
inlineinherited

Add a copy of the given record to the end of the catalog.

Definition at line 476 of file Catalog.h.

476  {
477  std::shared_ptr<RecordT> p = _table->copyRecord(r);
478  _internal.push_back(p);
479  }
T push_back(T... args)

◆ push_back() [2/2]

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::push_back ( std::shared_ptr< RecordT > const &  p)
inlineinherited

Add the given record to the end of the catalog without copying.

Definition at line 482 of file Catalog.h.

482 { _internal.push_back(p); }
T push_back(T... args)

◆ readFits() [1/4]

template<typename RecordT>
static ExposureCatalogT lsst::afw::table::ExposureCatalogT< 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 386 of file Exposure.h.

387  {
388  return io::FitsReader::apply<ExposureCatalogT>(filename, hdu, flags);
389  }

◆ readFits() [2/4]

template<typename RecordT>
static ExposureCatalogT lsst::afw::table::ExposureCatalogT< 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 401 of file Exposure.h.

402  {
403  return io::FitsReader::apply<ExposureCatalogT>(manager, hdu, flags);
404  }

◆ readFits() [3/4]

template<typename RecordT>
static ExposureCatalogT lsst::afw::table::ExposureCatalogT< 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 413 of file Exposure.h.

413  {
414  return io::FitsReader::apply<ExposureCatalogT>(fitsfile, flags);
415  }

◆ readFits() [4/4]

template<typename RecordT>
static ExposureCatalogT lsst::afw::table::ExposureCatalogT< RecordT >::readFits ( fits::Fits fitsfile,
std::shared_ptr< io::InputArchive archive,
int  flags = 0 
)
inlinestatic

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

This overload reads nested Persistables from the given archive instead of loading a new archive from the HDUs following the catalog.

Definition at line 423 of file Exposure.h.

424  {
425  return io::FitsReader::apply<ExposureCatalogT>(fitsfile, flags, archive);
426  }

◆ readFromArchive()

template<typename RecordT >
ExposureCatalogT< RecordT > lsst::afw::table::ExposureCatalogT< RecordT >::readFromArchive ( io::InputArchive const &  archive,
BaseCatalog const &  catalog 
)
static

Convenience input function for Persistables that contain an ExposureCatalog.

Unlike the FITS read methods, this reader is not polymorphically aware - it always tries to create an ExposureTable rather than infer the type of table from the data.

Definition at line 456 of file Exposure.cc.

457  {
458  // Helper constructor will infer which components are available
459  // (effectively the version, but more flexible).
460  PersistenceHelper helper{catalog.getSchema()};
461  SchemaMapper mapper = helper.makeReadMapper(catalog.getSchema());
462  ExposureCatalogT<ExposureRecord> result(mapper.getOutputSchema());
463  result.reserve(catalog.size());
464  for (BaseCatalog::const_iterator i = catalog.begin(); i != catalog.end(); ++i) {
465  helper.readRecord(*i, *result.addNew(), mapper, archive);
466  }
467  return result;
468 }
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:111
py::object result
Definition: _schema.cc:429

◆ reserve()

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::reserve ( size_type  n)
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().

Definition at line 428 of file Catalog.h.

428  {
429  if (n <= _internal.size()) return;
430  _table->preallocate(n - _internal.size());
431  _internal.reserve(n);
432  }
T size(T... args)
T reserve(T... args)

◆ resize()

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::resize ( size_type  n)
inlineinherited

Change the size of the catalog, removing or adding empty records as needed.

Definition at line 435 of file Catalog.h.

435  {
436  size_type old = size();
437  _internal.resize(n);
438  if (old < n) {
439  _table->preallocate(n - old);
440  for (size_type i = old; i != n; ++i) {
441  _internal[i] = _table->makeRecord();
442  }
443  }
444  }
T resize(T... args)
Internal::size_type size_type
Definition: Catalog.h:108
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:408

◆ set()

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::set ( size_type  i,
std::shared_ptr< RecordT > const &  p 
)
inlineinherited

Set the record at index i to a pointer.

Definition at line 462 of file Catalog.h.

462 { _internal[i] = p; }

◆ size()

template<typename RecordT>
size_type lsst::afw::table::CatalogT< RecordT >::size ( ) const
inlineinherited

Return the number of elements in the catalog.

Definition at line 408 of file Catalog.h.

408 { return _internal.size(); }
T size(T... args)

◆ sort() [1/3]

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

Sort the vector in-place by ID.

Definition at line 66 of file SortedCatalog.h.

66 { this->sort(Table::getIdKey()); }
void sort()
Sort the vector in-place by ID.
Definition: SortedCatalog.h:66

◆ sort() [2/3]

template<typename RecordT >
template<typename T >
void lsst::afw::table::CatalogT< RecordT >::sort ( Key< T > const &  key)
inherited

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

Definition at line 749 of file Catalog.h.

749  {
750  detail::KeyComparisonFunctor<RecordT, T> f = {key};
751  return sort(f);
752 }
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
Definition: Catalog.h:749
Key< U > key
Definition: Schema.cc:281

◆ sort() [3/3]

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

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

735  {
736  detail::ComparisonAdaptor<RecordT, Compare> f = {cmp};
737  std::stable_sort(_internal.begin(), _internal.end(), f);
738 }
T stable_sort(T... args)
T end(T... args)
T begin(T... args)

◆ subset() [1/2]

template<typename RecordT>
ExposureCatalogT<RecordT> lsst::afw::table::ExposureCatalogT< 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 450 of file Exposure.h.

450  {
452  }
afw::table::Key< afw::table::Array< MaskPixelT > > mask
ExposureCatalogT(std::shared_ptr< Table > const &table=std::shared_ptr< Table >())
Construct a vector from a table (or nothing).
Definition: Exposure.h:327
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...

◆ subset() [2/2]

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

Shallow copy a subset of another ExposureCatalog.

Mostly here for use from python.

Definition at line 458 of file Exposure.h.

458  {
459  return ExposureCatalogT(Base::subset(startd, stopd, step));
460  }
ExposureCatalogT(std::shared_ptr< Table > const &table=std::shared_ptr< Table >())
Construct a vector from a table (or nothing).
Definition: Exposure.h:327
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...

◆ subsetContaining() [1/2]

template<typename RecordT >
ExposureCatalogT< RecordT > lsst::afw::table::ExposureCatalogT< RecordT >::subsetContaining ( lsst::geom::SpherePoint const &  coord,
bool  includeValidPolygon = false 
) const

Return a shallow subset of the catalog with only those records that contain the given point.

If includeValidPolygon is true we check that the point is within the validPolygon of those records which have one; if they don't, this argument is ignored.

See also
ExposureRecord::contains

Definition at line 471 of file Exposure.cc.

472  {
474  for (const_iterator i = this->begin(); i != this->end(); ++i) {
475  if (i->contains(coord, includeValidPolygon)) {
476  result.push_back(i);
477  }
478  }
479  return result;
480 }
ExposureCatalogT(std::shared_ptr< Table > const &table=std::shared_ptr< Table >())
Construct a vector from a table (or nothing).
Definition: Exposure.h:327
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:114
iterator end()
Iterator access.
Definition: Catalog.h:397
Base::const_iterator const_iterator
Definition: Exposure.h:319
iterator begin()
Iterator access.
Definition: Catalog.h:396
py::object result
Definition: _schema.cc:429

◆ subsetContaining() [2/2]

template<typename RecordT >
ExposureCatalogT< RecordT > lsst::afw::table::ExposureCatalogT< RecordT >::subsetContaining ( lsst::geom::Point2D const &  point,
geom::SkyWcs const &  wcs,
bool  includeValidPolygon = false 
) const

Return a shallow subset of the catalog with only those records that contain the given point.

If includeValidPolygon is true we check that the point is within the validPolygon of those records which have one; if they don't, this argument is ignored.

See also
ExposureRecord::contains

Definition at line 483 of file Exposure.cc.

485  {
487  for (const_iterator i = this->begin(); i != this->end(); ++i) {
488  if (i->contains(point, wcs, includeValidPolygon)) {
489  result.push_back(i);
490  }
491  }
492  return result;
493 }
ExposureCatalogT(std::shared_ptr< Table > const &table=std::shared_ptr< Table >())
Construct a vector from a table (or nothing).
Definition: Exposure.h:327
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:114
Key< int > wcs
Definition: Exposure.cc:64
iterator end()
Iterator access.
Definition: Catalog.h:397
Base::const_iterator const_iterator
Definition: Exposure.h:319
iterator begin()
Iterator access.
Definition: Catalog.h:396
py::object result
Definition: _schema.cc:429

◆ swap()

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::swap ( CatalogT< RecordT > &  other)
inlinenoexceptinherited

Shallow swap of two catalogs.

Definition at line 568 of file Catalog.h.

568  {
569  _table.swap(other._table);
570  _internal.swap(other._internal);
571  }
T swap(T... args)
ItemVariant const * other
Definition: Schema.cc:56

◆ upper_bound() [1/2]

template<typename RecordT >
template<typename T >
CatalogT< RecordT >::iterator lsst::afw::table::CatalogT< RecordT >::upper_bound ( typename Field< T >::Value const &  value,
Key< T > const &  key 
)
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.

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

Definition at line 804 of file Catalog.h.

805  {
806  detail::KeyExtractionFunctor<RecordT, T> f = {key};
807  // Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
808  typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, iterator> SearchIter;
809  SearchIter i = std::upper_bound(SearchIter(begin(), f), SearchIter(end(), f), value);
810  return i.base();
811 }
T upper_bound(T... args)
iterator end()
Iterator access.
Definition: Catalog.h:397
Key< U > key
Definition: Schema.cc:281
iterator begin()
Iterator access.
Definition: Catalog.h:396
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110

◆ upper_bound() [2/2]

template<typename RecordT >
template<typename T >
CatalogT< RecordT >::const_iterator lsst::afw::table::CatalogT< RecordT >::upper_bound ( typename Field< T >::Value const &  value,
Key< T > const &  key 
) const
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.

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

Definition at line 815 of file Catalog.h.

816  {
817  detail::KeyExtractionFunctor<RecordT, T> f = {key};
818  // Iterator adaptor that makes a CatalogT iterator work like an iterator over field values.
819  typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>, const_iterator> SearchIter;
820  SearchIter i = std::upper_bound(SearchIter(begin(), f), SearchIter(end(), f), value);
821  return i.base();
822 }
T upper_bound(T... args)
iterator end()
Iterator access.
Definition: Catalog.h:397
Key< U > key
Definition: Schema.cc:281
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:111
iterator begin()
Iterator access.
Definition: Catalog.h:396

◆ writeFits() [1/4]

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::writeFits ( std::string const &  filename,
std::string const &  mode = "w",
int  flags = 0 
) const
inlineinherited

Write a FITS binary table to a regular file.

Parameters
[in]filenameName of the file to write.
[in]mode"a" to append a new HDU, "w" to overwrite any existing file.
[in]flagsTable-subclass-dependent bitflags that control the details of how to read the catalogs. See e.g. SourceFitsFlags.

Definition at line 306 of file Catalog.h.

306  {
307  io::FitsWriter::apply(filename, mode, *this, flags);
308  }
static void apply(OutputT &output, std::string const &mode, ContainerT const &container, int flags)
Driver for writing FITS files.
Definition: FitsWriter.h:37

◆ writeFits() [2/4]

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::writeFits ( fits::MemFileManager manager,
std::string const &  mode = "w",
int  flags = 0 
) const
inlineinherited

Write a FITS binary table to a RAM file.

Parameters
[in,out]managerObject that manages the memory to write to.
[in]mode"a" to append a new HDU, "w" to overwrite any existing file.
[in]flagsTable-subclass-dependent bitflags that control the details of how to read the catalogs. See e.g. SourceFitsFlags.

Definition at line 318 of file Catalog.h.

318  {
319  io::FitsWriter::apply(manager, mode, *this, flags);
320  }
static void apply(OutputT &output, std::string const &mode, ContainerT const &container, int flags)
Driver for writing FITS files.
Definition: FitsWriter.h:37

◆ writeFits() [3/4]

template<typename RecordT>
void lsst::afw::table::CatalogT< RecordT >::writeFits ( fits::Fits fitsfile,
int  flags = 0 
) const
inlineinherited

Write a FITS binary table to an open file object.

Parameters
[in,out]fitsfileFits file object to write to.
[in]flagsTable-subclass-dependent bitflags that control the details of how to read the catalogs. See e.g. SourceFitsFlags.

Definition at line 329 of file Catalog.h.

329  {
330  io::FitsWriter::apply(fitsfile, *this, flags);
331  }
static void apply(OutputT &output, std::string const &mode, ContainerT const &container, int flags)
Driver for writing FITS files.
Definition: FitsWriter.h:37

◆ writeFits() [4/4]

template<typename RecordT>
void lsst::afw::table::ExposureCatalogT< RecordT >::writeFits ( fits::Fits fitsfile,
std::shared_ptr< io::OutputArchive archive,
int  flags = 0 
) const
inline

Write a FITS binary table to an open file object.

Instead of writing nested Persistables to an internal archive and appending it to the FITS file, this overload inserts nested Persistables into the given archive and does not save it, leaving it to the user to save it later.

Definition at line 371 of file Exposure.h.

371  {
372  std::shared_ptr<io::FitsWriter> writer = this->getTable()->makeFitsWriter(&fitsfile, archive, flags);
373  writer->write(*this);
374  }
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:114

◆ writeToArchive()

template<typename RecordT >
void lsst::afw::table::ExposureCatalogT< RecordT >::writeToArchive ( io::OutputArchiveHandle handle,
bool  ignoreUnpersistable = true 
) const

Convenience output function for Persistables that contain an ExposureCatalog.

Unlike writeFits, this saves main catalog to one of the tables within the archive, as part of a Persistable's set of catalogs, rather than saving it to a separate HDU not managed by the archive.

Definition at line 444 of file Exposure.cc.

444  {
445  PersistenceHelper helper{};
446  SchemaMapper mapper = helper.makeWriteMapper(this->getSchema());
447  BaseCatalog outputCat = handle.makeCatalog(mapper.getOutputSchema());
448  outputCat.reserve(this->size());
449  for (const_iterator i = this->begin(); i != this->end(); ++i) {
450  helper.writeRecord(*i, *outputCat.addNew(), mapper, handle, permissive);
451  }
452  handle.saveCatalog(outputCat);
453 }
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
Schema getSchema() const
Return the schema associated with the catalog&#39;s table.
Definition: Catalog.h:117
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
iterator end()
Iterator access.
Definition: Catalog.h:397
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
Definition: Catalog.h:428
Base::const_iterator const_iterator
Definition: Exposure.h:319
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:408
iterator begin()
Iterator access.
Definition: Catalog.h:396

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