LSSTApplications
19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
LSSTDataManagementBasePackage
|
Go to the documentation of this file.
2 #ifndef AFW_TABLE_Catalog_h_INCLUDED
3 #define AFW_TABLE_Catalog_h_INCLUDED
8 #include "boost/iterator/iterator_adaptor.hpp"
9 #include "boost/iterator/transform_iterator.hpp"
37 template <
typename BaseT>
38 class CatalogIterator :
public boost::iterator_adaptor<CatalogIterator<BaseT>, BaseT,
39 typename BaseT::value_type::element_type> {
43 template <
typename OtherBaseT>
49 template <
typename RecordT>
54 template <
typename RecordT>
56 *this->base() =
other;
62 typename BaseT::value_type::element_type& dereference()
const {
return **this->base(); }
96 template <
typename RecordT>
126 : _table(table), _internal() {}
141 template <
typename InputIterator>
143 : _table(table), _internal() {
160 template <
typename OtherRecordT>
166 if (&
other !=
this) {
167 _table =
other._table;
168 _internal =
other._internal;
184 (
boost::format(
"Mask array with %d elements applied to catalog with %d elements") %
191 for (; maskIter !=
mask.end(); ++maskIter, ++catIter) {
192 if (*maskIter)
result.push_back(catIter);
254 }
else if (
step < 0) {
280 N = (stop - start) /
step + (((stop - start) %
step) ? 1 : 0);
344 return io::FitsReader::apply<CatalogT>(filename, hdu, flags);
358 return io::FitsReader::apply<CatalogT>(manager, hdu, flags);
369 return io::FitsReader::apply<CatalogT>(fitsfile, flags);
381 "Cannot get a column view from a CatalogT<RecordT const> (as column views are always "
382 "non-const views).");
384 return ColumnView::make(_table,
begin(),
end());
429 if (n <= _internal.
size())
return;
430 _table->preallocate(n - _internal.
size());
439 _table->preallocate(n - old);
441 _internal[i] = _table->makeRecord();
469 template <
typename InputIterator>
470 void assign(InputIterator
first, InputIterator last,
bool deep =
false) {
512 template <
typename InputIterator>
514 _maybeReserve(pos,
first, last, deep,
517 while (
first != last) {
523 while (
first != last) {
525 assert(pos !=
end());
533 template <
typename InputIterator>
535 if (!_table->getSchema().contains(
mapper.getOutputSchema())) {
537 "SchemaMapper's output schema does not match catalog's schema");
539 _maybeReserve(pos,
first, last,
true,
541 while (
first != last) {
577 template <
typename T>
585 template <
typename Compare>
589 template <
typename T>
597 template <
typename Compare>
615 template <
typename T>
618 template <
typename T>
636 template <
typename T>
639 template <
typename T>
642 template <
typename T>
645 template <
typename T>
648 template <
typename T>
651 template <
typename T>
674 template <
typename InputIterator>
675 void _maybeReserve(
iterator& pos, InputIterator
first, InputIterator last,
bool deep,
677 if (deep) _table->preallocate(last -
first);
680 template <
typename InputIterator>
681 void _maybeReserve(
iterator pos, InputIterator
first, InputIterator last,
bool deep,
690 template <
typename RecordT,
typename T>
697 template <
typename RecordT,
typename Adaptee>
706 template <
typename RecordT,
typename T>
717 template <
typename RecordT>
718 template <
typename Compare>
722 if (empty())
return true;
726 for (; i != this->
end(); ++i) {
727 if (f(i, last))
return false;
733 template <
typename RecordT>
734 template <
typename Compare>
740 template <
typename RecordT>
741 template <
typename T>
747 template <
typename RecordT>
748 template <
typename T>
754 template <
typename RecordT>
755 template <
typename T>
760 typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>,
iterator> SearchIter;
763 if (i.base() ==
end() || *i != value)
return end();
767 template <
typename RecordT>
768 template <
typename T>
773 typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>,
const_iterator> SearchIter;
776 if (i.base() ==
end() || *i != value)
return end();
780 template <
typename RecordT>
781 template <
typename T>
786 typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>,
iterator> SearchIter;
791 template <
typename RecordT>
792 template <
typename T>
797 typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>,
const_iterator> SearchIter;
802 template <
typename RecordT>
803 template <
typename T>
808 typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>,
iterator> SearchIter;
813 template <
typename RecordT>
814 template <
typename T>
819 typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>,
const_iterator> SearchIter;
824 template <
typename RecordT>
825 template <
typename T>
830 typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>,
iterator> SearchIter;
836 template <
typename RecordT>
837 template <
typename T>
842 typedef boost::transform_iterator<detail::KeyExtractionFunctor<RecordT, T>,
const_iterator> SearchIter;
870 template <
typename RecordT,
typename Catalog,
typename T>
872 typename Catalog::const_iterator
iter = catalog.find(value,
key);
873 if (
iter == catalog.end()) {
879 template <
typename Catalog,
typename T>
881 return catalog.lower_bound(value,
key) - catalog.begin();
884 template <
typename Catalog,
typename T>
886 return catalog.upper_bound(value,
key) - catalog.begin();
889 template <
typename Catalog,
typename T>
892 catalog.equal_range(value,
key);
901 #endif // !AFW_TABLE_Catalog_h_INCLUDED
CatalogIterator< typename Internal::const_iterator > const_iterator
std::shared_ptr< RecordT > const get(size_type i) const
Return a pointer to the record at index i.
CatalogIterator & operator=(std::shared_ptr< RecordT > const &other) const
void swap(CatalogT &other) noexcept
Shallow swap of two catalogs.
static CatalogT readFits(fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU, int flags=0)
Read a FITS binary table from a RAM file.
CatalogT(CatalogT &&other)
void writeFits(fits::MemFileManager &manager, std::string const &mode="w", int flags=0) const
Write a FITS binary table to a RAM file.
bool empty() const
Return true if the catalog has no records.
const_iterator upper_bound(typename Field< T >::Value const &value, Key< T > const &key) const
CatalogT(Schema const &schema)
Construct a catalog from a schema, creating a table with Table::make(schema).
size_type max_size() const
Return the maximum number of elements allowed in a catalog.
Internal const & getInternal() const
const int DEFAULT_HDU
Specify that the default HDU should be read.
Internal::size_type size_type
CatalogIterator(CatalogIterator< OtherBaseT > const &other)
CatalogT copy() const
Deep-copy the catalog using a cloned table.
iterator erase(iterator pos)
Erase the record pointed to by pos, and return an iterator the next record.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
std::shared_ptr< RecordT > pointer
bool isContiguous() const
Return true if all records are contiguous.
reference operator[](size_type i) const
Return the record at index i.
Defines the fields and offsets for a table.
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Column-wise view into a sequence of records that have been allocated contiguously.
CatalogT(CatalogT< OtherRecordT > const &other)
Shallow copy constructor from a container containing a related record type.
Lifetime-management for memory that goes into FITS memory files.
Base class for all tables.
ColumnView getColumnView() const
Return a ColumnView of this catalog's records.
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.
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
const_iterator find(typename Field< T >::Value const &value, Key< T > const &key) const
size_type size() const
Return the number of elements in the catalog.
CatalogT< RecordT > subset(ndarray::Array< bool const, 1 > const &mask) const
Return the subset of a catalog corresponding to the True values of the given mask array.
iterator insert(iterator pos, Record const &r)
Insert a copy of the given record at the given position.
void push_back(Record const &r)
Add a copy of the given record to the end of the catalog.
int _Catalog_lower_bound(Catalog const &catalog, T const &value, Key< T > const &key)
Internal::difference_type difference_type
std::pair< iterator, iterator > equal_range(typename Field< T >::Value const &value, Key< T > const &key)
void set(size_type i, std::shared_ptr< RecordT > const &p)
Set the record at index i to a pointer.
void sort(Compare cmp)
Sort the catalog in-place by the field with the given predicate.
Reports attempts to exceed implementation-defined length limits for some classes.
CatalogIterator(BaseT const &base)
ItemVariant const * other
Base class for all records.
iterator find(typename Field< T >::Value const &value, Key< T > const &key)
Return an iterator to the record with the given value.
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
FastFinder::Iterator Iterator
std::pair< int, int > _Catalog_equal_range(Catalog const &catalog, T const &value, Key< T > const &key)
Reports errors in the logical structure of the program.
CatalogIterator< typename Internal::iterator > iterator
A mapping between the keys of two Schemas, used to copy data between them.
iterator insert(iterator pos, std::shared_ptr< RecordT > const &p)
Insert the given record at the given position without copying.
Schema getSchema() const
Return the schema associated with the catalog's table.
bool isSorted(Key< T > const &key) const
Return true if the catalog is in ascending order according to the given key.
A class used as a handle to a particular field in a table.
void clear()
Remove all records from the catalog.
Iterator class for CatalogT.
CatalogT(std::shared_ptr< Table > const &table, InputIterator first, InputIterator last, bool deep=false)
Construct a catalog from a table and an iterator range.
void pop_back()
Remove the last record in the catalog.
const_iterator end() const
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
static CatalogT readFits(std::string const &filename, int hdu=fits::DEFAULT_HDU, int flags=0)
Read a FITS binary table from a regular file.
Internal & getInternal()
Return a reference to the internal vector-of-shared_ptr.
CatalogT & operator=(CatalogT const &other)
Shallow assigment.
Record::ColumnView ColumnView
A base class for image defects.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
static CatalogT readFits(fits::Fits &fitsfile, int flags=0)
Read a FITS binary table from a file object already at the correct extension.
const_iterator lower_bound(typename Field< T >::Value const &value, Key< T > const &key) const
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 insert(iterator pos, InputIterator first, InputIterator last, bool deep=false)
Insert an iterator range into the table.
iterator upper_bound(typename Field< T >::Value const &value, Key< T > const &key)
Reports invalid arguments.
int _Catalog_upper_bound(Catalog const &catalog, T const &value, Key< T > const &key)
reference front() const
Return the first record.
const_iterator cend() const
void resize(size_type n)
Change the size of the catalog, removing or adding empty records as needed.
std::shared_ptr< RecordT > _Catalog_find(Catalog const &catalog, T const &value, Key< T > const &key)
bool isSorted(Compare cmp) const
Return true if the catalog is in ascending order according to the given predicate.
void writeFits(fits::Fits &fitsfile, int flags=0) const
Write a FITS binary table to an open file object.
bool operator()(std::shared_ptr< RecordT > const &a, std::shared_ptr< RecordT > const &b) const
T Value
the type returned by BaseRecord::get
bool operator()(RecordT const &a, RecordT const &b) const
CatalogT(std::shared_ptr< Table > const &table=std::shared_ptr< Table >())
Construct a catalog from a table (or nothing).
CatalogT & operator=(CatalogT &&other)
std::pair< const_iterator, const_iterator > equal_range(typename Field< T >::Value const &value, Key< T > const &key) const
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
void assign(InputIterator first, InputIterator last, bool deep=false)
Replace the contents of the table with an iterator range.
const_iterator begin() const
void push_back(std::shared_ptr< RecordT > const &p)
Add the given record to the end of the catalog without copying.
iterator begin()
Iterator access.
CatalogT< RecordT > subset(std::ptrdiff_t startd, std::ptrdiff_t stopd, std::ptrdiff_t step) const
Returns a shallow copy of a subset of this Catalog.
friend class boost::iterator_core_access
A custom container class for records, based on std::vector.
static void apply(OutputT &output, std::string const &mode, ContainerT const &container, int flags)
Driver for writing FITS files.
const_iterator cbegin() const
reference at(size_type i) const
Return the record at index i (throws std::out_of_range).
CatalogT(CatalogT const &other)
Shallow copy constructor.
size_type capacity() const
Return the capacity of the catalog.
reference back() const
Return the last record.
iterator lower_bound(typename Field< T >::Value const &value, Key< T > const &key)
Performed binary searches on sorted fields.
iterator erase(iterator first, iterator last)
Erase the records in the range [first, last).