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
Catalog.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 #ifndef AFW_TABLE_Catalog_h_INCLUDED
3 #define AFW_TABLE_Catalog_h_INCLUDED
4 
5 #include <type_traits>
6 #include <vector>
7 
8 #include "boost/iterator/iterator_adaptor.hpp"
9 #include "boost/iterator/transform_iterator.hpp"
10 
11 #include "lsst/base.h"
12 #include "lsst/pex/exceptions.h"
13 #include "lsst/afw/fitsDefaults.h"
14 #include "lsst/afw/table/fwd.h"
18 
19 namespace lsst {
20 namespace afw {
21 namespace table {
22 
37 template <typename BaseT>
38 class CatalogIterator : public boost::iterator_adaptor<CatalogIterator<BaseT>, BaseT,
39  typename BaseT::value_type::element_type> {
40 public:
42 
43  template <typename OtherBaseT>
45  : CatalogIterator::iterator_adaptor_(other.base()) {}
46 
47  explicit CatalogIterator(BaseT const& base) : CatalogIterator::iterator_adaptor_(base) {}
48 
49  template <typename RecordT>
50  operator std::shared_ptr<RecordT>() const {
51  return *this->base();
52  }
53 
54  template <typename RecordT>
56  *this->base() = other;
57  return *this;
58  }
59 
60 private:
62  typename BaseT::value_type::element_type& dereference() const { return **this->base(); }
63 };
64 
96 template <typename RecordT>
97 class CatalogT {
99 
100 public:
101  typedef RecordT Record;
102  typedef typename Record::Table Table;
103  typedef typename Record::ColumnView ColumnView;
104 
105  typedef RecordT value_type;
106  typedef RecordT& reference;
108  typedef typename Internal::size_type size_type;
109  typedef typename Internal::difference_type difference_type;
112 
114  std::shared_ptr<Table> getTable() const { return _table; }
115 
117  Schema getSchema() const { return _table->getSchema(); }
118 
126  : _table(table), _internal() {}
127 
129  explicit CatalogT(Schema const& schema) : _table(Table::make(schema)), _internal() {}
130 
141  template <typename InputIterator>
142  CatalogT(std::shared_ptr<Table> const& table, InputIterator first, InputIterator last, bool deep = false)
143  : _table(table), _internal() {
144  insert(end(), first, last, deep);
145  }
146 
148  CatalogT(CatalogT const& other) : _table(other._table), _internal(other._internal) {}
149  // Delegate to copy constructor for backward compatibility
151 
152  ~CatalogT() = default;
153 
160  template <typename OtherRecordT>
162  : _table(other.getTable()), _internal(other.begin().base(), other.end().base()) {}
163 
166  if (&other != this) {
167  _table = other._table;
168  _internal = other._internal;
169  }
170  return *this;
171  }
172  // Delegate to copy assignment for backward compatibility
173  CatalogT& operator=(CatalogT&& other) { return *this = other; }
174 
180  CatalogT<RecordT> subset(ndarray::Array<bool const, 1> const& mask) const {
181  if (size_type(mask.size()) != size()) {
182  throw LSST_EXCEPT(
184  (boost::format("Mask array with %d elements applied to catalog with %d elements") %
185  mask.size() % size())
186  .str());
187  }
190  const_iterator catIter = begin();
191  for (; maskIter != mask.end(); ++maskIter, ++catIter) {
192  if (*maskIter) result.push_back(catIter);
193  }
194  return result;
195  }
196 
202  /* Python's slicing syntax is weird and wonderful.
203 
204  Both the "start" and "stop" indices can be negative, which means the
205  abs() of the index less than the size; [-1] means the last item.
206  Moreover, it's possible to have a negative index less than -len(); it
207  will get clipped. That is in fact one way to slice *backward* through
208  the array *and* include element 0;
209 
210  >>> range(10)[5:-20:-1]
211  [5, 4, 3, 2, 1, 0]
212 
213  The clipping tests in this function look more complicated than they
214  need to be, but that is partly because there are some weird edge cases.
215 
216  Also, ptrdiff_t vs size_t introduces some annoying complexity. Note
217  that the args are "startd"/"stopd" (not "start"/"stop").
218 
219  There is a fairly complete set of tests in tests/ticket2026.py; if you
220  try to simplify this function, be sure they continue to pass.
221  */
222  size_type S = size();
223  size_type start, stop = 0;
224  // Python doesn't allow step == 0
225  if (step == 0) {
226  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError, "Step cannot be zero");
227  }
228  // Basic negative indexing rule: first add size
229  if (startd < 0) {
230  startd += S;
231  }
232  if (stopd < 0) {
233  stopd += S;
234  }
235  // Start gets clipped to zero; stop does not (yet).
236  if (startd < 0) {
237  startd = 0;
238  }
239  // Now start is non-negative, so can cast to size_t.
240  start = (size_type)startd;
241  if (start > S) {
242  start = S;
243  }
244  if (step > 0) {
245  // When stepping forward, stop gets clipped at zero,
246  // so is non-negative and can get cast to size_t.
247  if (stopd < 0) {
248  stopd = 0;
249  }
250  stop = (size_type)stopd;
251  if (stop > S) {
252  stop = S;
253  }
254  } else if (step < 0) {
255  // When stepping backward, stop gets clipped at -1 so that slices
256  // including 0 are possible.
257  if (stopd < 0) {
258  stopd = -1;
259  }
260  }
261 
262  if (((step > 0) && (start >= stop)) || ((step < 0) && ((std::ptrdiff_t)start <= stopd))) {
263  // Empty range
264  return CatalogT<RecordT>(getTable(), begin(), begin());
265  }
266 
267  if (step == 1) {
268  // Use the iterator-based constructor for this simple case
269  assert(start >= 0);
270  assert(stop > 0);
271  assert(start < S);
272  assert(stop <= S);
273  return CatalogT<RecordT>(getTable(), begin() + start, begin() + stop);
274  }
275 
276  // Build a new CatalogT and copy records into it.
278  size_type N = 0;
279  if (step >= 0) {
280  N = (stop - start) / step + (((stop - start) % step) ? 1 : 0);
281  } else {
282  N = (size_t)((stopd - (std::ptrdiff_t)start) / step +
283  (((stopd - (std::ptrdiff_t)start) % step) ? 1 : 0));
284  }
285  cat.reserve(N);
286  if (step >= 0) {
287  for (size_type i = start; i < stop; i += step) {
288  cat.push_back(get(i));
289  }
290  } else {
291  for (std::ptrdiff_t i = (std::ptrdiff_t)start; i > stopd; i += step) {
292  cat.push_back(get(i));
293  }
294  }
295  return cat;
296  }
297 
306  void writeFits(std::string const& filename, std::string const& mode = "w", int flags = 0) const {
307  io::FitsWriter::apply(filename, mode, *this, flags);
308  }
309 
318  void writeFits(fits::MemFileManager& manager, std::string const& mode = "w", int flags = 0) const {
319  io::FitsWriter::apply(manager, mode, *this, flags);
320  }
321 
329  void writeFits(fits::Fits& fitsfile, int flags = 0) const {
330  io::FitsWriter::apply(fitsfile, *this, flags);
331  }
332 
343  static CatalogT readFits(std::string const& filename, int hdu = fits::DEFAULT_HDU, int flags = 0) {
344  return io::FitsReader::apply<CatalogT>(filename, hdu, flags);
345  }
346 
357  static CatalogT readFits(fits::MemFileManager& manager, int hdu = fits::DEFAULT_HDU, int flags = 0) {
358  return io::FitsReader::apply<CatalogT>(manager, hdu, flags);
359  }
360 
368  static CatalogT readFits(fits::Fits& fitsfile, int flags = 0) {
369  return io::FitsReader::apply<CatalogT>(fitsfile, flags);
370  }
371 
379  throw LSST_EXCEPT(
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  }
386 
388  bool isContiguous() const { return ColumnView::isRangeContiguous(_table, begin(), end()); }
389 
391 
396  iterator begin() { return iterator(_internal.begin()); }
397  iterator end() { return iterator(_internal.end()); }
398  const_iterator begin() const { return const_iterator(_internal.begin()); }
399  const_iterator end() const { return const_iterator(_internal.end()); }
400  const_iterator cbegin() const { return begin(); }
401  const_iterator cend() const { return end(); }
403 
405  bool empty() const { return _internal.empty(); }
406 
408  size_type size() const { return _internal.size(); }
409 
411  size_type max_size() const { return _internal.max_size(); }
412 
420  size_type capacity() const { return _internal.size() + _table->getBufferSize(); }
421 
428  void reserve(size_type n) {
429  if (n <= _internal.size()) return;
430  _table->preallocate(n - _internal.size());
431  _internal.reserve(n);
432  }
433 
435  void resize(size_type n) {
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  }
445 
447  reference operator[](size_type i) const { return *_internal[i]; }
448 
450  reference at(size_type i) const { return *_internal.at(i); }
451 
453  reference front() const { return *_internal.front(); }
454 
456  reference back() const { return *_internal.back(); }
457 
459  std::shared_ptr<RecordT> const get(size_type i) const { return _internal[i]; }
460 
462  void set(size_type i, std::shared_ptr<RecordT> const& p) { _internal[i] = p; }
463 
469  template <typename InputIterator>
470  void assign(InputIterator first, InputIterator last, bool deep = false) {
471  clear();
472  insert(end(), first, last, deep);
473  }
474 
476  void push_back(Record const& r) {
477  std::shared_ptr<RecordT> p = _table->copyRecord(r);
478  _internal.push_back(p);
479  }
480 
482  void push_back(std::shared_ptr<RecordT> const& p) { _internal.push_back(p); }
483 
486  std::shared_ptr<RecordT> r = _table->makeRecord();
487  _internal.push_back(r);
488  return r;
489  }
490 
492  void pop_back() { _internal.pop_back(); }
493 
495  CatalogT copy() const { return CatalogT(getTable()->clone(), begin(), end(), true); }
496 
512  template <typename InputIterator>
513  void insert(iterator pos, InputIterator first, InputIterator last, bool deep = false) {
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  }
531 
533  template <typename InputIterator>
534  void insert(SchemaMapper const& mapper, iterator pos, InputIterator first, InputIterator last) {
535  if (!_table->getSchema().contains(mapper.getOutputSchema())) {
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  }
547 
549  iterator insert(iterator pos, Record const& r) {
550  std::shared_ptr<RecordT> p = _table->copyRecord(r);
551  return iterator(_internal.insert(pos.base(), p));
552  }
553 
556  return iterator(_internal.insert(pos.base(), p));
557  }
558 
560  iterator erase(iterator pos) { return iterator(_internal.erase(pos.base())); }
561 
564  return iterator(_internal.erase(first.base(), last.base()));
565  }
566 
568  void swap(CatalogT& other) noexcept {
569  _table.swap(other._table);
570  _internal.swap(other._internal);
571  }
572 
574  void clear() { _internal.clear(); }
575 
577  template <typename T>
578  bool isSorted(Key<T> const& key) const;
579 
585  template <typename Compare>
586  bool isSorted(Compare cmp) const;
587 
589  template <typename T>
590  void sort(Key<T> const& key);
591 
597  template <typename Compare>
598  void sort(Compare cmp);
599 
601 
615  template <typename T>
616  iterator find(typename Field<T>::Value const& value, Key<T> const& key);
617 
618  template <typename T>
619  const_iterator find(typename Field<T>::Value const& value, Key<T> const& key) const;
621 
623 
636  template <typename T>
637  iterator lower_bound(typename Field<T>::Value const& value, Key<T> const& key);
638 
639  template <typename T>
640  const_iterator lower_bound(typename Field<T>::Value const& value, Key<T> const& key) const;
641 
642  template <typename T>
643  iterator upper_bound(typename Field<T>::Value const& value, Key<T> const& key);
644 
645  template <typename T>
646  const_iterator upper_bound(typename Field<T>::Value const& value, Key<T> const& key) const;
647 
648  template <typename T>
650 
651  template <typename T>
653  Key<T> const& key) const;
655 
657 
669  Internal& getInternal() { return _internal; }
670  Internal const& getInternal() const { return _internal; }
672 
673 private:
674  template <typename InputIterator>
675  void _maybeReserve(iterator& pos, InputIterator first, InputIterator last, bool deep,
677  if (deep) _table->preallocate(last - first);
678  }
679 
680  template <typename InputIterator>
681  void _maybeReserve(iterator pos, InputIterator first, InputIterator last, bool deep,
683 
684  std::shared_ptr<Table> _table;
685  Internal _internal;
686 };
687 
688 namespace detail {
689 
690 template <typename RecordT, typename T>
692  bool operator()(RecordT const& a, RecordT const& b) const { return a.get(key) < b.get(key); }
693 
695 };
696 
697 template <typename RecordT, typename Adaptee>
700  return adaptee(*a, *b);
701  }
702 
703  Adaptee adaptee;
704 };
705 
706 template <typename RecordT, typename T>
708  typedef typename Field<T>::Value result_type;
709 
710  result_type operator()(RecordT const& r) const { return r.get(key); }
711 
713 };
714 
715 } // namespace detail
716 
717 template <typename RecordT>
718 template <typename Compare>
719 bool CatalogT<RecordT>::isSorted(Compare cmp) const {
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 }
732 
733 template <typename RecordT>
734 template <typename Compare>
735 void CatalogT<RecordT>::sort(Compare cmp) {
737  std::stable_sort(_internal.begin(), _internal.end(), f);
738 }
739 
740 template <typename RecordT>
741 template <typename T>
744  return isSorted(f);
745 }
746 
747 template <typename RecordT>
748 template <typename T>
751  return sort(f);
752 }
753 
754 template <typename RecordT>
755 template <typename T>
757  Key<T> const& 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 }
766 
767 template <typename RecordT>
768 template <typename T>
770  Key<T> const& key) const {
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 }
779 
780 template <typename RecordT>
781 template <typename T>
783  Key<T> const& 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 }
790 
791 template <typename RecordT>
792 template <typename T>
794  typename Field<T>::Value const& value, Key<T> const& key) const {
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 }
801 
802 template <typename RecordT>
803 template <typename T>
805  Key<T> const& 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 }
812 
813 template <typename RecordT>
814 template <typename T>
816  typename Field<T>::Value const& value, Key<T> const& key) const {
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 }
823 
824 template <typename RecordT>
825 template <typename T>
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 }
835 
836 template <typename RecordT>
837 template <typename T>
839 CatalogT<RecordT>::equal_range(typename Field<T>::Value const& value, Key<T> const& key) const {
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 }
847 
849 
870 template <typename RecordT, typename Catalog, typename T>
871 std::shared_ptr<RecordT> _Catalog_find(Catalog const& catalog, T const& value, Key<T> const& key) {
872  typename Catalog::const_iterator iter = catalog.find(value, key);
873  if (iter == catalog.end()) {
874  return std::shared_ptr<RecordT>();
875  }
876  return iter; // n.b. CatalogIterator is explicitly convertible to shared_ptr
877 }
878 
879 template <typename Catalog, typename T>
880 int _Catalog_lower_bound(Catalog const& catalog, T const& value, Key<T> const& key) {
881  return catalog.lower_bound(value, key) - catalog.begin();
882 }
883 
884 template <typename Catalog, typename T>
885 int _Catalog_upper_bound(Catalog const& catalog, T const& value, Key<T> const& key) {
886  return catalog.upper_bound(value, key) - catalog.begin();
887 }
888 
889 template <typename Catalog, typename T>
890 std::pair<int, int> _Catalog_equal_range(Catalog const& catalog, T const& value, Key<T> const& key) {
892  catalog.equal_range(value, key);
893  return std::pair<int, int>(p.first - catalog.begin(), p.second - catalog.begin());
894 }
895 
897 } // namespace table
898 } // namespace afw
899 } // namespace lsst
900 
901 #endif // !AFW_TABLE_Catalog_h_INCLUDED
schema
table::Schema schema
Definition: Amplifier.cc:115
lsst::afw::table::CatalogT::const_iterator
CatalogIterator< typename Internal::const_iterator > const_iterator
Definition: Catalog.h:111
lsst::afw::table::CatalogT::get
std::shared_ptr< RecordT > const get(size_type i) const
Return a pointer to the record at index i.
Definition: Catalog.h:459
lsst::afw::table::CatalogT::end
iterator end()
Definition: Catalog.h:397
lsst::afw::table::CatalogIterator::operator=
CatalogIterator & operator=(std::shared_ptr< RecordT > const &other) const
Definition: Catalog.h:55
lsst::afw::table::detail::KeyComparisonFunctor::key
Key< T > key
Definition: Catalog.h:694
lsst::afw::table::CatalogT::swap
void swap(CatalogT &other) noexcept
Shallow swap of two catalogs.
Definition: Catalog.h:568
lsst::afw::table::CatalogT::readFits
static CatalogT readFits(fits::MemFileManager &manager, int hdu=fits::DEFAULT_HDU, int flags=0)
Read a FITS binary table from a RAM file.
Definition: Catalog.h:357
std::vector::resize
T resize(T... args)
lsst::afw::table::CatalogT::CatalogT
CatalogT(CatalogT &&other)
Definition: Catalog.h:150
SchemaMapper.h
lsst::afw::table::CatalogT::writeFits
void writeFits(fits::MemFileManager &manager, std::string const &mode="w", int flags=0) const
Write a FITS binary table to a RAM file.
Definition: Catalog.h:318
lsst::afw::table::CatalogT::empty
bool empty() const
Return true if the catalog has no records.
Definition: Catalog.h:405
lsst::afw::table::detail::ComparisonAdaptor
Definition: Catalog.h:698
lsst::afw::table::detail::KeyExtractionFunctor::key
Key< T > key
Definition: Catalog.h:712
lsst::afw::table::CatalogT::upper_bound
const_iterator upper_bound(typename Field< T >::Value const &value, Key< T > const &key) const
Definition: Catalog.h:815
std::string
STL class.
std::shared_ptr< RecordT >
lsst::afw::table::CatalogT::CatalogT
CatalogT(Schema const &schema)
Construct a catalog from a schema, creating a table with Table::make(schema).
Definition: Catalog.h:129
lsst::afw::table::CatalogT::max_size
size_type max_size() const
Return the maximum number of elements allowed in a catalog.
Definition: Catalog.h:411
lsst::afw::table::CatalogT::getInternal
Internal const & getInternal() const
Definition: Catalog.h:670
lsst::afw::fits::DEFAULT_HDU
const int DEFAULT_HDU
Specify that the default HDU should be read.
Definition: fitsDefaults.h:18
lsst::afw::table::CatalogT::size_type
Internal::size_type size_type
Definition: Catalog.h:108
std::pair
std::vector::reserve
T reserve(T... args)
lsst::afw::table::CatalogIterator::CatalogIterator
CatalogIterator(CatalogIterator< OtherBaseT > const &other)
Definition: Catalog.h:44
lsst::afw::table::CatalogT::copy
CatalogT copy() const
Deep-copy the catalog using a cloned table.
Definition: Catalog.h:495
lsst::afw::table::CatalogT::erase
iterator erase(iterator pos)
Erase the record pointed to by pos, and return an iterator the next record.
Definition: Catalog.h:560
lsst::afw::fits::Fits
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:297
std::vector
STL class.
std::vector::size
T size(T... args)
lsst::afw::table::CatalogT::pointer
std::shared_ptr< RecordT > pointer
Definition: Catalog.h:107
lsst::afw::table::CatalogT::isContiguous
bool isContiguous() const
Return true if all records are contiguous.
Definition: Catalog.h:388
lsst::afw::table::CatalogT::operator[]
reference operator[](size_type i) const
Return the record at index i.
Definition: Catalog.h:447
lsst::afw::table._match.first
first
Definition: _match.py:74
lsst::afw
Definition: imageAlgorithm.dox:1
std::random_access_iterator_tag
fwd.h
lsst::afw::table::Schema
Defines the fields and offsets for a table.
Definition: Schema.h:50
lsst::afw::table._base.Catalog
Definition: _base.py:88
std::vector::back
T back(T... args)
lsst::afw::table::CatalogT::~CatalogT
~CatalogT()=default
lsst.pex.config.history.format
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:174
lsst::afw::table::BaseColumnView
Column-wise view into a sequence of records that have been allocated contiguously.
Definition: BaseColumnView.h:83
lsst::afw::table::CatalogT::CatalogT
CatalogT(CatalogT< OtherRecordT > const &other)
Shallow copy constructor from a container containing a related record type.
Definition: Catalog.h:161
lsst::afw::fits::MemFileManager
Lifetime-management for memory that goes into FITS memory files.
Definition: fits.h:121
lsst::afw::table::BaseTable
Base class for all tables.
Definition: BaseTable.h:61
mask
afw::table::Key< afw::table::Array< MaskPixelT > > mask
Definition: HeavyFootprint.cc:217
lsst::afw::table::detail::KeyExtractionFunctor::operator()
result_type operator()(RecordT const &r) const
Definition: Catalog.h:710
lsst::afw::table::CatalogT::getColumnView
ColumnView getColumnView() const
Return a ColumnView of this catalog's records.
Definition: Catalog.h:377
std::vector::front
T front(T... args)
lsst::afw::table::CatalogT::insert
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.
Definition: Catalog.h:534
lsst::afw::table::CatalogT::Record
RecordT Record
Definition: Catalog.h:101
end
int end
Definition: BoundedField.cc:105
std::vector::clear
T clear(T... args)
lsst::afw::table::CatalogT::reserve
void reserve(size_type n)
Increase the capacity of the catalog to the given size.
Definition: Catalog.h:428
lsst::afw::table::CatalogT::find
const_iterator find(typename Field< T >::Value const &value, Key< T > const &key) const
Definition: Catalog.h:769
lsst::afw::table::CatalogIterator::CatalogIterator
CatalogIterator()
Definition: Catalog.h:41
std::vector::push_back
T push_back(T... args)
lsst::afw::table::CatalogT::size
size_type size() const
Return the number of elements in the catalog.
Definition: Catalog.h:408
lsst::afw::table::CatalogT::subset
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.
Definition: Catalog.h:180
lsst::afw::table::CatalogT::insert
iterator insert(iterator pos, Record const &r)
Insert a copy of the given record at the given position.
Definition: Catalog.h:549
lsst::afw::table::CatalogT::push_back
void push_back(Record const &r)
Add a copy of the given record to the end of the catalog.
Definition: Catalog.h:476
lsst::afw::table::_Catalog_lower_bound
int _Catalog_lower_bound(Catalog const &catalog, T const &value, Key< T > const &key)
Definition: Catalog.h:880
lsst::afw::table::CatalogT::difference_type
Internal::difference_type difference_type
Definition: Catalog.h:109
std::vector::at
T at(T... args)
lsst::afw::table::CatalogT::equal_range
std::pair< iterator, iterator > equal_range(typename Field< T >::Value const &value, Key< T > const &key)
base.h
lsst::afw::table::detail::KeyComparisonFunctor
Definition: Catalog.h:691
lsst::afw::table::CatalogT::set
void set(size_type i, std::shared_ptr< RecordT > const &p)
Set the record at index i to a pointer.
Definition: Catalog.h:462
std::iterator_traits
fitsDefaults.h
lsst::afw::table::CatalogT::sort
void sort(Compare cmp)
Sort the catalog in-place by the field with the given predicate.
Definition: Catalog.h:735
lsst.pex::exceptions::LengthError
Reports attempts to exceed implementation-defined length limits for some classes.
Definition: Runtime.h:76
FitsReader.h
lsst::afw::table::CatalogIterator::CatalogIterator
CatalogIterator(BaseT const &base)
Definition: Catalog.h:47
other
ItemVariant const * other
Definition: Schema.cc:56
lsst::afw::table::BaseRecord
Base class for all records.
Definition: BaseRecord.h:31
lsst::afw::table::CatalogT::find
iterator find(typename Field< T >::Value const &value, Key< T > const &key)
Return an iterator to the record with the given value.
Definition: Catalog.h:756
step
int const step
Definition: BoundedField.cc:102
lsst::afw::table::CatalogT::getTable
std::shared_ptr< Table > getTable() const
Return the table associated with the catalog.
Definition: Catalog.h:114
lsst::afw::table::detail::KeyExtractionFunctor::result_type
Field< T >::Value result_type
Definition: Catalog.h:708
lsst::jointcal::Iterator
FastFinder::Iterator Iterator
Definition: FastFinder.cc:178
lsst::afw::table::_Catalog_equal_range
std::pair< int, int > _Catalog_equal_range(Catalog const &catalog, T const &value, Key< T > const &key)
Definition: Catalog.h:890
lsst.pex::exceptions::LogicError
Reports errors in the logical structure of the program.
Definition: Runtime.h:46
lsst::afw::table::CatalogT::iterator
CatalogIterator< typename Internal::iterator > iterator
Definition: Catalog.h:110
lsst::afw::table::SchemaMapper
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
lsst::afw::table::CatalogT::insert
iterator insert(iterator pos, std::shared_ptr< RecordT > const &p)
Insert the given record at the given position without copying.
Definition: Catalog.h:555
lsst::afw::table::CatalogT::getSchema
Schema getSchema() const
Return the schema associated with the catalog's table.
Definition: Catalog.h:117
lsst::afw::table::CatalogT::isSorted
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
lsst::afw::table::Key
A class used as a handle to a particular field in a table.
Definition: fwd.h:45
lsst::afw::table::CatalogT::clear
void clear()
Remove all records from the catalog.
Definition: Catalog.h:574
std::vector::erase
T erase(T... args)
lsst::afw::table::CatalogIterator
Iterator class for CatalogT.
Definition: Catalog.h:39
lsst::afw::table::CatalogT::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.
Definition: Catalog.h:142
lsst::afw::table::CatalogT::pop_back
void pop_back()
Remove the last record in the catalog.
Definition: Catalog.h:492
lsst::afw::table::CatalogT::end
const_iterator end() const
Definition: Catalog.h:399
std::vector::pop_back
T pop_back(T... args)
lsst::afw::table::CatalogT::sort
void sort(Key< T > const &key)
Sort the catalog in-place by the field with the given key.
Definition: Catalog.h:749
lsst::afw::table::CatalogT::readFits
static CatalogT readFits(std::string const &filename, int hdu=fits::DEFAULT_HDU, int flags=0)
Read a FITS binary table from a regular file.
Definition: Catalog.h:343
std::vector::max_size
T max_size(T... args)
std::upper_bound
T upper_bound(T... args)
lsst::afw::table::CatalogT::getInternal
Internal & getInternal()
Return a reference to the internal vector-of-shared_ptr.
Definition: Catalog.h:669
result
py::object result
Definition: _schema.cc:429
lsst::afw::table::CatalogT::operator=
CatalogT & operator=(CatalogT const &other)
Shallow assigment.
Definition: Catalog.h:165
b
table::Key< int > b
Definition: TransmissionCurve.cc:467
lsst::afw::table::CatalogT::ColumnView
Record::ColumnView ColumnView
Definition: Catalog.h:103
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
LSST_EXCEPT
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
lsst::afw::table::CatalogT::readFits
static CatalogT readFits(fits::Fits &fitsfile, int flags=0)
Read a FITS binary table from a file object already at the correct extension.
Definition: Catalog.h:368
std::shared_ptr::swap
T swap(T... args)
lsst::afw::table::CatalogT::lower_bound
const_iterator lower_bound(typename Field< T >::Value const &value, Key< T > const &key) const
Definition: Catalog.h:793
lsst::afw::table::CatalogT::writeFits
void writeFits(std::string const &filename, std::string const &mode="w", int flags=0) const
Write a FITS binary table to a regular file.
Definition: Catalog.h:306
lsst::afw::table::CatalogT::insert
void insert(iterator pos, InputIterator first, InputIterator last, bool deep=false)
Insert an iterator range into the table.
Definition: Catalog.h:513
std::equal_range
T equal_range(T... args)
lsst::afw::table::CatalogT::reference
RecordT & reference
Definition: Catalog.h:106
std::lower_bound
T lower_bound(T... args)
std::is_const
lsst::afw::table::CatalogT::upper_bound
iterator upper_bound(typename Field< T >::Value const &value, Key< T > const &key)
Definition: Catalog.h:804
lsst.pex::exceptions::InvalidParameterError
Reports invalid arguments.
Definition: Runtime.h:66
lsst::afw::table::_Catalog_upper_bound
int _Catalog_upper_bound(Catalog const &catalog, T const &value, Key< T > const &key)
Definition: Catalog.h:885
lsst::afw::table::CatalogT::front
reference front() const
Return the first record.
Definition: Catalog.h:453
lsst::afw::table::CatalogT::cend
const_iterator cend() const
Definition: Catalog.h:401
lsst::afw::table::detail::KeyExtractionFunctor
Definition: Catalog.h:707
a
table::Key< int > a
Definition: TransmissionCurve.cc:466
std::vector::begin
T begin(T... args)
std::vector::insert
T insert(T... args)
key
Key< U > key
Definition: Schema.cc:281
lsst::afw::table::CatalogT::resize
void resize(size_type n)
Change the size of the catalog, removing or adding empty records as needed.
Definition: Catalog.h:435
lsst::afw::table::_Catalog_find
std::shared_ptr< RecordT > _Catalog_find(Catalog const &catalog, T const &value, Key< T > const &key)
Definition: Catalog.h:871
lsst::afw::table::CatalogT::isSorted
bool isSorted(Compare cmp) const
Return true if the catalog is in ascending order according to the given predicate.
Definition: Catalog.h:719
std::ptrdiff_t
lsst::afw::table::CatalogT::writeFits
void writeFits(fits::Fits &fitsfile, int flags=0) const
Write a FITS binary table to an open file object.
Definition: Catalog.h:329
mapper
SchemaMapper * mapper
Definition: SchemaMapper.cc:78
std::vector::empty
T empty(T... args)
lsst::afw::table::detail::ComparisonAdaptor::operator()
bool operator()(std::shared_ptr< RecordT > const &a, std::shared_ptr< RecordT > const &b) const
Definition: Catalog.h:699
lsst::afw::table::FieldBase::Value
T Value
the type returned by BaseRecord::get
Definition: FieldBase.h:44
lsst::afw::table::detail::KeyComparisonFunctor::operator()
bool operator()(RecordT const &a, RecordT const &b) const
Definition: Catalog.h:692
lsst::afw::table::CatalogT::CatalogT
CatalogT(std::shared_ptr< Table > const &table=std::shared_ptr< Table >())
Construct a catalog from a table (or nothing).
Definition: Catalog.h:125
lsst::afw::table::CatalogT::operator=
CatalogT & operator=(CatalogT &&other)
Definition: Catalog.h:173
std::make_pair
T make_pair(T... args)
std::vector::end
T end(T... args)
FitsWriter.h
lsst::afw::table::CatalogT::equal_range
std::pair< const_iterator, const_iterator > equal_range(typename Field< T >::Value const &value, Key< T > const &key) const
lsst::afw::table::CatalogT::addNew
std::shared_ptr< RecordT > addNew()
Create a new record, add it to the end of the catalog, and return a pointer to it.
Definition: Catalog.h:485
lsst::afw::table::CatalogT::assign
void assign(InputIterator first, InputIterator last, bool deep=false)
Replace the contents of the table with an iterator range.
Definition: Catalog.h:470
lsst::afw::table::CatalogT::begin
const_iterator begin() const
Definition: Catalog.h:398
lsst::afw::table::CatalogT::push_back
void push_back(std::shared_ptr< RecordT > const &p)
Add the given record to the end of the catalog without copying.
Definition: Catalog.h:482
std::stable_sort
T stable_sort(T... args)
lsst::afw::table::CatalogT::begin
iterator begin()
Iterator access.
Definition: Catalog.h:396
lsst::afw::table::detail::ComparisonAdaptor::adaptee
Adaptee adaptee
Definition: Catalog.h:703
lsst::afw::table::CatalogT::subset
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.
Definition: Catalog.h:201
lsst::afw::table::CatalogIterator::iterator_core_access
friend class boost::iterator_core_access
Definition: Catalog.h:61
lsst::afw::table::CatalogT
A custom container class for records, based on std::vector.
Definition: Catalog.h:97
lsst::afw::image.slicing.clone
clone
Definition: slicing.py:257
astshim.fitsChanContinued.iter
def iter(self)
Definition: fitsChanContinued.py:88
lsst::afw::table::CatalogT::Table
Record::Table Table
Definition: Catalog.h:102
lsst::afw::table::io::FitsWriter::apply
static void apply(OutputT &output, std::string const &mode, ContainerT const &container, int flags)
Driver for writing FITS files.
Definition: FitsWriter.h:37
lsst::afw::table::CatalogT::cbegin
const_iterator cbegin() const
Definition: Catalog.h:400
lsst::afw::table::CatalogT::at
reference at(size_type i) const
Return the record at index i (throws std::out_of_range).
Definition: Catalog.h:450
lsst::afw::table::CatalogT::CatalogT
CatalogT(CatalogT const &other)
Shallow copy constructor.
Definition: Catalog.h:148
lsst::afw::table::CatalogT::capacity
size_type capacity() const
Return the capacity of the catalog.
Definition: Catalog.h:420
lsst::afw::table::CatalogT::value_type
RecordT value_type
Definition: Catalog.h:105
lsst::afw::table::CatalogT::back
reference back() const
Return the last record.
Definition: Catalog.h:456
exceptions.h
lsst::afw::table::CatalogT::lower_bound
iterator lower_bound(typename Field< T >::Value const &value, Key< T > const &key)
Performed binary searches on sorted fields.
Definition: Catalog.h:782
lsst::afw::table::CatalogT::erase
iterator erase(iterator first, iterator last)
Erase the records in the range [first, last).
Definition: Catalog.h:563