LSSTApplications  17.0+11,17.0+34,17.0+56,17.0+57,17.0+59,17.0+7,17.0-1-g377950a+33,17.0.1-1-g114240f+2,17.0.1-1-g4d4fbc4+28,17.0.1-1-g55520dc+49,17.0.1-1-g5f4ed7e+52,17.0.1-1-g6dd7d69+17,17.0.1-1-g8de6c91+11,17.0.1-1-gb9095d2+7,17.0.1-1-ge9fec5e+5,17.0.1-1-gf4e0155+55,17.0.1-1-gfc65f5f+50,17.0.1-1-gfc6fb1f+20,17.0.1-10-g87f9f3f+1,17.0.1-11-ge9de802+16,17.0.1-16-ga14f7d5c+4,17.0.1-17-gc79d625+1,17.0.1-17-gdae4c4a+8,17.0.1-2-g26618f5+29,17.0.1-2-g54f2ebc+9,17.0.1-2-gf403422+1,17.0.1-20-g2ca2f74+6,17.0.1-23-gf3eadeb7+1,17.0.1-3-g7e86b59+39,17.0.1-3-gb5ca14a,17.0.1-3-gd08d533+40,17.0.1-30-g596af8797,17.0.1-4-g59d126d+4,17.0.1-4-gc69c472+5,17.0.1-6-g5afd9b9+4,17.0.1-7-g35889ee+1,17.0.1-7-gc7c8782+18,17.0.1-9-gc4bbfb2+3,w.2019.22
LSSTDataManagementBasePackage
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lsst::afw::table Namespace Reference

Namespaces

 aggregates
 
 aliasMap
 
 ampInfo
 
 arrays
 
 base
 
 baseColumnView
 
 catalogMatches
 
 detail
 
 exposure
 
 io
 
 match
 
 multiMatch
 
 python
 
 schema
 
 schemaMapper
 
 simple
 
 source
 
 testUtils
 

Classes

class  AliasMap
 Mapping class that holds aliases for a Schema. More...
 
class  AmpInfoRecord
 Geometry and electronic information about raw amplifier images. More...
 
class  AmpInfoTable
 Table of amplifier information (AmpInfoRecord records) More...
 
class  Array
 Tag types used to declare specialized field types. More...
 
class  ArrayKey
 A FunctorKey used to get or set a ndarray::Array from a sequence of scalar Keys. More...
 
class  BaseColumnView
 Column-wise view into a sequence of records that have been allocated contiguously. More...
 
class  BaseRecord
 Base class for all records. More...
 
class  BaseTable
 Base class for all tables. More...
 
class  BitsColumn
 A packed representation of a collection of Flag field columns. More...
 
class  BoxKey
 A FunctorKey used to get or set a lsst::geom::Box2I or Box2D from a (min, max) pair of PointKeys. More...
 
class  CatalogIterator
 Iterator class for CatalogT. More...
 
class  CatalogT
 A custom container class for records, based on std::vector. More...
 
class  CentroidSlotDefinition
 SlotDefinition specialization for centroids. More...
 
class  ColumnViewT
 
class  ConstReferenceFunctorKey
 Base class for objects that can return a const reference to part of a record, but are not a true Key. More...
 
class  CoordKey
 A FunctorKey used to get or set celestial coordinates from a pair of lsst::geom::Angle keys. More...
 
class  CovarianceMatrixKey
 
class  EllipseKey
 A FunctorKey used to get or set a geom::ellipses::Ellipse from an (xx,yy,xy,x,y) tuple of Keys. More...
 
class  ExposureCatalogT
 Custom catalog class for ExposureRecord/Table. More...
 
class  ExposureRecord
 Record class used to store exposure metadata. More...
 
class  ExposureTable
 Table class used to store exposure metadata. More...
 
struct  Field
 A description of a field in a table. More...
 
struct  FieldBase
 Field base class default implementation (used for numeric scalars and lsst::geom::Angle). More...
 
struct  FieldBase< Array< U > >
 Field base class specialization for arrays. More...
 
struct  FieldBase< Flag >
 Specialization for Flag fields. More...
 
struct  FieldBase< std::string >
 Field base class specialization for strings. More...
 
class  FluxSlotDefinition
 SlotDefinition specialization for fluxes. More...
 
class  FunctorKey
 Convenience base class that combines the OutputFunctorKey and InputFunctorKey. More...
 
class  IdFactory
 A polymorphic functor base class for generating record IDs for a table. More...
 
class  InputFunctorKey
 Base class for objects that can set a value on a record, but are not a true Key themselves. More...
 
class  Key
 A class used as a handle to a particular field in a table. More...
 
class  Key< Flag >
 Key specialization for Flag. More...
 
class  KeyBase
 A base class for Key that allows subfield keys to be extracted for some field types. More...
 
class  KeyBase< Array< U > >
 KeyBase specialization for Arrays. More...
 
class  KeyBase< Flag >
 A base class for Key that allows the underlying storage field to be extracted. More...
 
struct  Match
 Lightweight representation of a geometric match between two records. More...
 
class  MatchControl
 Pass parameters to algorithms that match list of sources. More...
 
class  OutputFunctorKey
 Base class for objects that can extract a value from a record, but are not a true Key themselves. More...
 
class  PersistableObjectColumnReader
 
class  PointKey
 A FunctorKey used to get or set a lsst::geom::Point from an (x,y) pair of int or double Keys. More...
 
class  QuadrupoleKey
 A FunctorKey used to get or set a geom::ellipses::Quadrupole from a tuple of constituent Keys. More...
 
class  ReferenceFunctorKey
 Base class for objects that can return a non-const reference to part of a record, but are not a true Key. More...
 
class  Schema
 Defines the fields and offsets for a table. More...
 
struct  SchemaItem
 A simple pair-like struct for mapping a Field (name and description) with a Key (used for actual data access). More...
 
class  SchemaMapper
 A mapping between the keys of two Schemas, used to copy data between them. More...
 
class  ShapeSlotDefinition
 SlotDefinition specialization for shapes. More...
 
class  SimpleRecord
 Record class that must contain a unique ID field and a celestial coordinate field. More...
 
class  SimpleTable
 Table class that must contain a unique ID field and a celestial coordinate field. More...
 
class  SlotDefinition
 Base class for helper classes that define slots on SourceTable/SourceRecord. More...
 
struct  SlotSuite
 An aggregate containing all of the current slots used in SourceTable. More...
 
class  SortedCatalogT
 Custom catalog class for record/table subclasses that are guaranteed to have an ID, and should generally be sorted by that ID. More...
 
class  SourceColumnViewT
 
class  SourceRecord
 Record class that contains measurements made on a single exposure. More...
 
class  SourceTable
 Table class that contains measurements made on a single exposure. More...
 
class  SubSchema
 A proxy type for name lookups in a Schema. More...
 

Typedefs

typedef PointKey< int > Point2IKey
 
typedef PointKey< double > Point2DKey
 
using Box2IKey = BoxKey< lsst::geom::Box2I >
 
using Box2DKey = BoxKey< lsst::geom::Box2D >
 
typedef ColumnViewT< ExposureRecordExposureColumnView
 
typedef ExposureCatalogT< ExposureRecordExposureCatalog
 
typedef ExposureCatalogT< ExposureRecord const > ConstExposureCatalog
 
typedef CatalogT< BaseRecordBaseCatalog
 
typedef CatalogT< BaseRecord const > ConstBaseCatalog
 
typedef ColumnViewT< SimpleRecordSimpleColumnView
 
typedef SortedCatalogT< SimpleRecordSimpleCatalog
 
typedef SortedCatalogT< SimpleRecord const > ConstSimpleCatalog
 
typedef SourceColumnViewT< SourceRecordSourceColumnView
 
typedef SortedCatalogT< SourceRecordSourceCatalog
 
typedef SortedCatalogT< SourceRecord const > ConstSourceCatalog
 
typedef ColumnViewT< AmpInfoRecordAmpInfoColumnView
 
typedef CatalogT< AmpInfoRecordAmpInfoCatalog
 
typedef CatalogT< AmpInfoRecord const > ConstAmpInfoCatalog
 
typedef Match< SimpleRecord, SimpleRecordSimpleMatch
 
typedef Match< SimpleRecord, SourceRecordReferenceMatch
 
typedef Match< SourceRecord, SourceRecordSourceMatch
 
typedef std::vector< SimpleMatchSimpleMatchVector
 
typedef std::vector< ReferenceMatchReferenceMatchVector
 
typedef std::vector< SourceMatchSourceMatchVector
 
typedef std::int64_t RecordId
 Type used for unique IDs for records. More...
 
typedef lsst::afw::detection::Footprint Footprint
 
typedef boost::mpl::vector< RecordId, std::uint16_t, std::int32_t, float, double, lsst::geom::Angle, std::uint8_tScalarFieldTypes
 An MPL vector of scalar field types. More...
 
typedef boost::mpl::vector< RecordId, std::uint16_t, std::int32_t, float, double, lsst::geom::Angle, std::uint8_t, Flag, std::string, Array< std::uint16_t >, Array< int >, Array< float >, Array< double >, Array< std::uint8_t > > FieldTypes
 An MPL vector of all field types. More...
 
typedef lsst::geom::Angle Angle
 
typedef lsst::geom::SpherePoint SpherePoint
 

Enumerations

enum  CoordinateType { CoordinateType::PIXEL, CoordinateType::CELESTIAL }
 Enum used to set units for geometric FunctorKeys. More...
 
enum  ReadoutCorner { LL, LR, UR, UL }
 Readout corner, in the frame of reference of the assembled image. More...
 
enum  SourceFitsFlags { SOURCE_IO_NO_FOOTPRINTS = 0x1, SOURCE_IO_NO_HEAVY_FOOTPRINTS = 0x2 }
 Bitflags to be passed to SourceCatalog::readFits and SourceCatalog::writeFits. More...
 

Functions

SourceMatchVector matchXy (SourceCatalog const &cat1, SourceCatalog const &cat2, double radius, MatchControl const &mc=MatchControl())
 Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between s1 and s2, in pixels, is at most radius. More...
 
SourceMatchVector matchXy (SourceCatalog const &cat, double radius, MatchControl const &mc=MatchControl())
 Compute all tuples (s1,s2,d) where s1 != s2, s1 and s2 both belong to cat, and d, the distance between s1 and s2, in pixels, is at most radius. More...
 
SourceMatchVector matchXy (SourceCatalog const &cat1, SourceCatalog const &cat2, double radius, bool closest)
 Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between s1 and s2, in pixels, is at most radius. More...
 
SourceMatchVector matchXy (SourceCatalog const &cat, double radius, bool symmetric)
 Compute all tuples (s1,s2,d) where s1 != s2, s1 and s2 both belong to cat, and d, the distance between s1 and s2, in pixels, is at most radius. More...
 
template<typename Cat1 , typename Cat2 >
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > matchRaDec (Cat1 const &cat1, Cat2 const &cat2, lsst::geom::Angle radius, MatchControl const &mc=MatchControl())
 Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between s1 and s2, is at most radius. More...
 
template<typename Cat >
std::vector< Match< typename Cat::Record, typename Cat::Record > > matchRaDec (Cat const &cat, lsst::geom::Angle radius, MatchControl const &mc=MatchControl())
 
template<typename Cat1 , typename Cat2 >
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > matchRaDec (Cat1 const &cat1, Cat2 const &cat2, lsst::geom::Angle radius, bool closest)
 Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between s1 and s2, is at most radius. More...
 
template<typename Cat >
std::vector< Match< typename Cat::Record, typename Cat::Record > > matchRaDec (Cat const &cat, lsst::geom::Angle radius, bool symmetric)
 Compute all tuples (s1,s2,d) where s1 != s2, s1 and s2 both belong to cat, and d, the distance between s1 and s2, is at most radius. More...
 
template<typename Record1 , typename Record2 >
BaseCatalog packMatches (std::vector< Match< Record1, Record2 > > const &matches)
 Return a table representation of a MatchVector that can be used to persist it. More...
 
template<typename Cat1 , typename Cat2 >
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > unpackMatches (BaseCatalog const &matches, Cat1 const &cat1, Cat2 const &cat2)
 Reconstruct a MatchVector from a BaseCatalog representation of the matches and a pair of catalogs. More...
 
template<typename ReferenceCollection >
void updateRefCentroids (geom::SkyWcs const &wcs, ReferenceCollection &refList)
 Update centroids in a collection of reference objects. More...
 
template<typename SourceCollection >
void updateSourceCoords (geom::SkyWcs const &wcs, SourceCollection &sourceList)
 Update sky coordinates in a collection of source objects. More...
 
 PYBIND11_MODULE (aggregates, mod)
 
 PYBIND11_MODULE (exposure, mod)
 
 PYBIND11_MODULE (match, mod)
 
 PYBIND11_MODULE (simple, mod)
 
 BOOST_PP_SEQ_FOR_EACH (INSTANTIATE_COLUMNVIEW_SCALAR, _, BOOST_PP_TUPLE_TO_SEQ(AFW_TABLE_SCALAR_FIELD_TYPE_N, AFW_TABLE_SCALAR_FIELD_TYPE_TUPLE)) BOOST_PP_SEQ_FOR_EACH(INSTANTIATE_COLUMNVIEW_ARRAY
 
std::ostreamoperator<< (std::ostream &os, BaseRecord const &record)
 
template SimpleMatchVector matchRaDec (SimpleCatalog const &, SimpleCatalog const &, lsst::geom::Angle, bool)
 
template SimpleMatchVector matchRaDec (SimpleCatalog const &, SimpleCatalog const &, lsst::geom::Angle, MatchControl const &)
 
template ReferenceMatchVector matchRaDec (SimpleCatalog const &, SourceCatalog const &, lsst::geom::Angle, bool)
 
template ReferenceMatchVector matchRaDec (SimpleCatalog const &, SourceCatalog const &, lsst::geom::Angle, MatchControl const &)
 
template SourceMatchVector matchRaDec (SourceCatalog const &, SourceCatalog const &, lsst::geom::Angle, bool)
 
template SourceMatchVector matchRaDec (SourceCatalog const &, SourceCatalog const &, lsst::geom::Angle, MatchControl const &)
 
template SimpleMatchVector matchRaDec (SimpleCatalog const &, lsst::geom::Angle, bool)
 
template SimpleMatchVector matchRaDec (SimpleCatalog const &, lsst::geom::Angle, MatchControl const &)
 
template SourceMatchVector matchRaDec (SourceCatalog const &, lsst::geom::Angle, bool)
 
template SourceMatchVector matchRaDec (SourceCatalog const &, lsst::geom::Angle, MatchControl const &)
 
template BaseCatalog packMatches (SimpleMatchVector const &)
 
template BaseCatalog packMatches (ReferenceMatchVector const &)
 
template BaseCatalog packMatches (SourceMatchVector const &)
 
template SimpleMatchVector unpackMatches (BaseCatalog const &, SimpleCatalog const &, SimpleCatalog const &)
 
template ReferenceMatchVector unpackMatches (BaseCatalog const &, SimpleCatalog const &, SourceCatalog const &)
 
template SourceMatchVector unpackMatches (BaseCatalog const &, SourceCatalog const &, SourceCatalog const &)
 
std::ostreamoperator<< (std::ostream &os, Schema const &schema)
 
template<typename RecordT , typename Catalog , typename T >
std::shared_ptr< RecordT > _Catalog_find (Catalog const &catalog, T const &value, Key< T > const &key)
 
template<typename Catalog , typename T >
int _Catalog_lower_bound (Catalog const &catalog, T const &value, Key< T > const &key)
 
template<typename Catalog , typename T >
int _Catalog_upper_bound (Catalog const &catalog, T const &value, Key< T > const &key)
 
template<typename Catalog , typename T >
std::pair< int, int > _Catalog_equal_range (Catalog const &catalog, T const &value, Key< T > const &key)
 

Variables

 _
 

Typedef Documentation

◆ AmpInfoCatalog

Definition at line 97 of file fwd.h.

◆ AmpInfoColumnView

Definition at line 95 of file fwd.h.

◆ Angle

Definition at line 33 of file misc.h.

◆ BaseCatalog

Definition at line 71 of file fwd.h.

◆ Box2DKey

Definition at line 202 of file aggregates.h.

◆ Box2IKey

Definition at line 201 of file aggregates.h.

◆ ConstAmpInfoCatalog

Definition at line 98 of file fwd.h.

◆ ConstBaseCatalog

Definition at line 73 of file fwd.h.

◆ ConstExposureCatalog

Definition at line 500 of file Exposure.h.

◆ ConstSimpleCatalog

Definition at line 80 of file fwd.h.

◆ ConstSourceCatalog

Definition at line 86 of file fwd.h.

◆ ExposureCatalog

Definition at line 499 of file Exposure.h.

◆ ExposureColumnView

Definition at line 498 of file Exposure.h.

◆ FieldTypes

An MPL vector of all field types.

Definition at line 54 of file types.h.

◆ Footprint

Definition at line 61 of file Source.h.

◆ Point2DKey

Definition at line 118 of file aggregates.h.

◆ Point2IKey

Definition at line 117 of file aggregates.h.

◆ RecordId

Type used for unique IDs for records.

FITS isn't fond of uint64, so we can save a lot of pain by using signed ints here unless we really need unsigned.

Definition at line 22 of file misc.h.

◆ ReferenceMatch

Definition at line 104 of file fwd.h.

◆ ReferenceMatchVector

Definition at line 108 of file fwd.h.

◆ ScalarFieldTypes

An MPL vector of scalar field types.

Definition at line 51 of file types.h.

◆ SimpleCatalog

Definition at line 79 of file fwd.h.

◆ SimpleColumnView

Definition at line 77 of file fwd.h.

◆ SimpleMatch

Definition at line 101 of file fwd.h.

◆ SimpleMatchVector

Definition at line 107 of file fwd.h.

◆ SourceCatalog

Definition at line 85 of file fwd.h.

◆ SourceColumnView

Definition at line 83 of file fwd.h.

◆ SourceMatch

Definition at line 105 of file fwd.h.

◆ SourceMatchVector

Definition at line 109 of file fwd.h.

◆ SpherePoint

Definition at line 35 of file misc.h.

Enumeration Type Documentation

◆ CoordinateType

Enum used to set units for geometric FunctorKeys.

Enumerator
PIXEL 
CELESTIAL 

Definition at line 277 of file aggregates.h.

◆ ReadoutCorner

Readout corner, in the frame of reference of the assembled image.

Enumerator
LL 
LR 
UR 
UL 

Definition at line 39 of file AmpInfo.h.

39  {
40  LL,
41  LR,
42  UR,
43  UL,
44 };

◆ SourceFitsFlags

Bitflags to be passed to SourceCatalog::readFits and SourceCatalog::writeFits.

Note that these flags may also be passed when reading/writing SourceCatalogs via the Butler, by passing a "flags" key/value pair as part of the data ID.

Enumerator
SOURCE_IO_NO_FOOTPRINTS 

Do not read/write footprints at all.

SOURCE_IO_NO_HEAVY_FOOTPRINTS 

Read/write heavy footprints as non-heavy footprints.

Definition at line 56 of file Source.h.

56  {
59 };
Read/write heavy footprints as non-heavy footprints.
Definition: Source.h:58
Do not read/write footprints at all.
Definition: Source.h:57

Function Documentation

◆ _Catalog_equal_range()

template<typename Catalog , typename T >
std::pair<int, int> lsst::afw::table::_Catalog_equal_range ( Catalog const &  catalog,
T const &  value,
Key< T > const &  key 
)

Definition at line 890 of file Catalog.h.

890  {
892  catalog.equal_range(value, key);
893  return std::pair<int, int>(p.first - catalog.begin(), p.second - catalog.begin());
894 }
Key< U > key
Definition: Schema.cc:281

◆ _Catalog_find()

template<typename RecordT , typename Catalog , typename T >
std::shared_ptr<RecordT> lsst::afw::table::_Catalog_find ( Catalog const &  catalog,
T const &  value,
Key< T > const &  key 
)

Definition at line 871 of file Catalog.h.

871  {
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 }
Key< U > key
Definition: Schema.cc:281

◆ _Catalog_lower_bound()

template<typename Catalog , typename T >
int lsst::afw::table::_Catalog_lower_bound ( Catalog const &  catalog,
T const &  value,
Key< T > const &  key 
)

Definition at line 880 of file Catalog.h.

880  {
881  return catalog.lower_bound(value, key) - catalog.begin();
882 }
Key< U > key
Definition: Schema.cc:281

◆ _Catalog_upper_bound()

template<typename Catalog , typename T >
int lsst::afw::table::_Catalog_upper_bound ( Catalog const &  catalog,
T const &  value,
Key< T > const &  key 
)

Definition at line 885 of file Catalog.h.

885  {
886  return catalog.upper_bound(value, key) - catalog.begin();
887 }
Key< U > key
Definition: Schema.cc:281

◆ BOOST_PP_SEQ_FOR_EACH()

lsst::afw::table::BOOST_PP_SEQ_FOR_EACH ( INSTANTIATE_COLUMNVIEW_SCALAR  ,
_  ,
BOOST_PP_TUPLE_TO_SEQ(AFW_TABLE_SCALAR_FIELD_TYPE_N, AFW_TABLE_SCALAR_FIELD_TYPE_TUPLE  
)

◆ matchRaDec() [1/14]

template<typename Cat1 , typename Cat2 >
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > lsst::afw::table::matchRaDec ( Cat1 const &  cat1,
Cat2 const &  cat2,
lsst::geom::Angle  radius,
MatchControl const &  mc = MatchControl() 
)

Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between s1 and s2, is at most radius.

If cat1 and cat2 are identical, then this call is equivalent to matchRaDec(cat1,radius). The match is performed in ra, dec space.

This is instantiated for Simple-Simple, Simple-Source, and Source-Source catalog combinations.

Parameters
cat1first catalog
cat2second catalog
radiusmatch radius
mchow to do the matching (obeys MatchControl::findOnlyClosest)

Definition at line 158 of file Match.cc.

161  {
162  typedef Match<typename Cat1::Record, typename Cat2::Record> MatchT;
163  std::vector<MatchT> matches;
164 
165  if (doSelfMatchIfSame(matches, cat1, cat2, radius)) return matches;
166 
167  if (radius < 0.0 || (radius > (45. * lsst::geom::degrees))) {
168  throw LSST_EXCEPT(pex::exceptions::RangeError, "match radius out of range (0 to 45 degrees)");
169  }
170  if (cat1.size() == 0 || cat2.size() == 0) {
171  return matches;
172  }
173  // setup match parameters
174  double const d2Limit = toUnitSphereDistanceSquared(radius);
175 
176  // Build position lists
177  size_t len1 = cat1.size();
178  size_t len2 = cat2.size();
179 
180  typedef RecordPos<typename Cat1::Record> Pos1;
181  typedef RecordPos<typename Cat2::Record> Pos2;
182  std::unique_ptr<Pos1[]> pos1(new Pos1[len1]);
183  std::unique_ptr<Pos2[]> pos2(new Pos2[len2]);
184  len1 = makeRecordPositions(cat1, pos1.get());
185  len2 = makeRecordPositions(cat2, pos2.get());
187 
188  for (size_t i = 0, start = 0; i < len1; ++i) {
189  double minDec = pos1[i].dec - radius.asRadians();
190  while (start < len2 && pos2[start].dec < minDec) {
191  ++start;
192  }
193  if (start == len2) {
194  break;
195  }
196  double maxDec = pos1[i].dec + radius.asRadians();
197  size_t closestIndex = -1; // Index of closest match (if any)
198  double d2Include = d2Limit; // Squared distance for inclusion of match
199  bool found = false; // Found anything?
200  size_t nMatches = 0; // Number of matches
201  for (size_t j = start; j < len2 && pos2[j].dec <= maxDec; ++j) {
202  double dx = pos1[i].x - pos2[j].x;
203  double dy = pos1[i].y - pos2[j].y;
204  double dz = pos1[i].z - pos2[j].z;
205  double d2 = dx * dx + dy * dy + dz * dz;
206  if (d2 < d2Include) {
207  if (mc.findOnlyClosest) {
208  d2Include = d2;
209  closestIndex = j;
210  found = true;
211  } else {
212  matches.push_back(MatchT(pos1[i].src, pos2[j].src, fromUnitSphereDistanceSquared(d2)));
213  }
214  ++nMatches;
215  }
216  }
217  if (mc.includeMismatches && nMatches == 0) {
218  matches.push_back(MatchT(pos1[i].src, nullRecord, NAN));
219  }
220  if (mc.findOnlyClosest && found) {
221  matches.push_back(
222  MatchT(pos1[i].src, pos2[closestIndex].src, fromUnitSphereDistanceSquared(d2Include)));
223  }
224  }
225  return matches;
226 }
constexpr double asRadians() const noexcept
Return an Angle&#39;s value in radians.
Definition: Angle.h:166
double dec
Definition: Match.cc:41
T push_back(T... args)
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:109
std::shared_ptr< RecordT > src
Definition: Match.cc:48
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
STL class.

◆ matchRaDec() [2/14]

template<typename Cat >
std::vector< Match< typename Cat::Record, typename Cat::Record > > lsst::afw::table::matchRaDec ( Cat const &  cat,
lsst::geom::Angle  radius,
MatchControl const &  mc = MatchControl() 
)
Parameters
catthe catalog to self-match
radiusmatch radius
mchow to do the matching (obeys MatchControl::symmetricMatch)

Definition at line 249 of file Match.cc.

251  {
252  typedef Match<typename Cat::Record, typename Cat::Record> MatchT;
253  std::vector<MatchT> matches;
254 
255  if (radius < 0.0 || radius > (45.0 * lsst::geom::degrees)) {
256  throw LSST_EXCEPT(pex::exceptions::RangeError, "match radius out of range (0 to 45 degrees)");
257  }
258  if (cat.size() == 0) {
259  return matches;
260  }
261  // setup match parameters
262  double const d2Limit = toUnitSphereDistanceSquared(radius);
263 
264  // Build position list
265  size_t len = cat.size();
266  typedef RecordPos<typename Cat::Record> Pos;
267  std::unique_ptr<Pos[]> pos(new Pos[len]);
268  len = makeRecordPositions(cat, pos.get());
269 
270  for (size_t i = 0; i < len; ++i) {
271  double maxDec = pos[i].dec + radius.asRadians();
272  for (size_t j = i + 1; j < len && pos[j].dec <= maxDec; ++j) {
273  double dx = pos[i].x - pos[j].x;
274  double dy = pos[i].y - pos[j].y;
275  double dz = pos[i].z - pos[j].z;
276  double d2 = dx * dx + dy * dy + dz * dz;
277  if (d2 < d2Limit) {
278  lsst::geom::Angle d = fromUnitSphereDistanceSquared(d2);
279  matches.push_back(MatchT(pos[i].src, pos[j].src, d));
280  if (mc.symmetricMatch) {
281  matches.push_back(MatchT(pos[j].src, pos[i].src, d));
282  }
283  }
284  }
285  }
286  return matches;
287 }
constexpr double asRadians() const noexcept
Return an Angle&#39;s value in radians.
Definition: Angle.h:166
A class representing an angle.
Definition: Angle.h:127
T push_back(T... args)
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:109
std::shared_ptr< RecordT > src
Definition: Match.cc:48
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
STL class.

◆ matchRaDec() [3/14]

template<typename Cat1 , typename Cat2 >
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > lsst::afw::table::matchRaDec ( Cat1 const &  cat1,
Cat2 const &  cat2,
lsst::geom::Angle  radius,
bool  closest 
)

Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between s1 and s2, is at most radius.

If cat1 and cat2 are identical, then this call is equivalent to matchRaDec(cat1,radius). The match is performed in ra, dec space.

Deprecated:
. Use the matchRaDec(..., MatchControl) version
Parameters
[in]cat1first catalog
[in]cat2second catalog
[in]radiusmatch radius
[in]closestif true then just return the closest match

This is instantiated for Simple-Simple, Simple-Source, and Source-Source catalog combinations.

Definition at line 147 of file Match.cc.

150  {
151  MatchControl mc;
152  mc.findOnlyClosest = closest;
153 
154  return matchRaDec(cat1, cat2, radius, mc);
155 }
template SourceMatchVector matchRaDec(SourceCatalog const &, lsst::geom::Angle, MatchControl const &)

◆ matchRaDec() [4/14]

template<typename Cat >
std::vector< Match< typename Cat::Record, typename Cat::Record > > lsst::afw::table::matchRaDec ( Cat const &  cat,
lsst::geom::Angle  radius,
bool  symmetric 
)

Compute all tuples (s1,s2,d) where s1 != s2, s1 and s2 both belong to cat, and d, the distance between s1 and s2, is at most radius.

The match is performed in ra, dec space.

Deprecated:
. Use the matchRaDec(..., MatchControl) version
Parameters
[in]catthe catalog to self-match
[in]radiusmatch radius
[in]symmetricif cat to true symmetric matches are produced: i.e. if (s1, s2, d) is reported, then so is (s2, s1, d).

This is instantiated for Simple and Source catalogs.

Definition at line 239 of file Match.cc.

241  {
242  MatchControl mc;
243  mc.symmetricMatch = symmetric;
244 
245  return matchRaDec(cat, radius, mc);
246 }
template SourceMatchVector matchRaDec(SourceCatalog const &, lsst::geom::Angle, MatchControl const &)

◆ matchRaDec() [5/14]

template SimpleMatchVector lsst::afw::table::matchRaDec ( SimpleCatalog const &  ,
SimpleCatalog const &  ,
lsst::geom::Angle  ,
bool   
)

◆ matchRaDec() [6/14]

template SimpleMatchVector lsst::afw::table::matchRaDec ( SimpleCatalog const &  ,
SimpleCatalog const &  ,
lsst::geom::Angle  ,
MatchControl const &   
)

◆ matchRaDec() [7/14]

template ReferenceMatchVector lsst::afw::table::matchRaDec ( SimpleCatalog const &  ,
SourceCatalog const &  ,
lsst::geom::Angle  ,
bool   
)

◆ matchRaDec() [8/14]

template ReferenceMatchVector lsst::afw::table::matchRaDec ( SimpleCatalog const &  ,
SourceCatalog const &  ,
lsst::geom::Angle  ,
MatchControl const &   
)

◆ matchRaDec() [9/14]

template SourceMatchVector lsst::afw::table::matchRaDec ( SourceCatalog const &  ,
SourceCatalog const &  ,
lsst::geom::Angle  ,
bool   
)

◆ matchRaDec() [10/14]

template SourceMatchVector lsst::afw::table::matchRaDec ( SourceCatalog const &  ,
SourceCatalog const &  ,
lsst::geom::Angle  ,
MatchControl const &   
)

◆ matchRaDec() [11/14]

template SimpleMatchVector lsst::afw::table::matchRaDec ( SimpleCatalog const &  ,
lsst::geom::Angle  ,
bool   
)

◆ matchRaDec() [12/14]

template SimpleMatchVector lsst::afw::table::matchRaDec ( SimpleCatalog const &  ,
lsst::geom::Angle  ,
MatchControl const &   
)

◆ matchRaDec() [13/14]

template SourceMatchVector lsst::afw::table::matchRaDec ( SourceCatalog const &  ,
lsst::geom::Angle  ,
bool   
)

◆ matchRaDec() [14/14]

template SourceMatchVector lsst::afw::table::matchRaDec ( SourceCatalog const &  ,
lsst::geom::Angle  ,
MatchControl const &   
)

◆ matchXy() [1/4]

SourceMatchVector lsst::afw::table::matchXy ( SourceCatalog const &  cat1,
SourceCatalog const &  cat2,
double  radius,
MatchControl const &  mc = MatchControl() 
)

Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between s1 and s2, in pixels, is at most radius.

If cat1 and cat2 are identical, then this call is equivalent to matchXy(cat1,radius). The match is performed in pixel space (2d cartesian).

Parameters
cat1first catalog
cat2second catalog
radiusmatch radius (pixels)
mchow to do the matching (obeys MatchControl::findOnlyClosest)

Definition at line 305 of file Match.cc.

306  {
307  if (&cat1 == &cat2) {
308  return matchXy(cat1, radius);
309  }
310  // setup match parameters
311  double const r2 = radius * radius;
312 
313  // copy and sort array of pointers on y
314  size_t len1 = cat1.size();
315  size_t len2 = cat2.size();
319  size_t n = 0;
320  for (SourceCatalog::const_iterator i(cat1.begin()), e(cat1.end()); i != e; ++i) {
321  if (std::isnan(i->getX()) || std::isnan(i->getY())) {
322  continue;
323  }
324  pos1[n] = i;
325  ++n;
326  }
327  len1 = n;
328  n = 0;
329  for (SourceCatalog::const_iterator i(cat2.begin()), e(cat2.end()); i != e; ++i) {
330  if (std::isnan(i->getX()) || std::isnan(i->getY())) {
331  continue;
332  }
333  pos2[n] = i;
334  ++n;
335  }
336  len2 = n;
337 
338  std::sort(pos1.get(), pos1.get() + len1, CmpRecordPtr());
339  std::sort(pos2.get(), pos2.get() + len2, CmpRecordPtr());
340 
341  SourceMatchVector matches;
342  for (size_t i = 0, start = 0; i < len1; ++i) {
343  double y = pos1[i]->getY();
344  double minY = y - radius;
345  while (start < len2 && pos2[start]->getY() < minY) {
346  ++start;
347  }
348  if (start == len2) {
349  break;
350  }
351  double x = pos1[i]->getX();
352  double maxY = y + radius;
353  double y2;
354  size_t closestIndex = -1; // Index of closest match (if any)
355  double r2Include = r2; // Squared radius for inclusion of match
356  bool found = false; // Found anything?
357  size_t nMatches = 0; // Number of matches
358  for (size_t j = start; j < len2 && (y2 = pos2[j]->getY()) <= maxY; ++j) {
359  double dx = x - pos2[j]->getX();
360  double dy = y - y2;
361  double d2 = dx * dx + dy * dy;
362  if (d2 < r2Include) {
363  if (mc.findOnlyClosest) {
364  r2Include = d2;
365  closestIndex = j;
366  found = true;
367  } else {
368  matches.push_back(SourceMatch(pos1[i], pos2[j], std::sqrt(d2)));
369  }
370  ++nMatches;
371  }
372  }
373  if (mc.includeMismatches && nMatches == 0) {
374  matches.push_back(SourceMatch(pos1[i], nullRecord, NAN));
375  }
376  if (mc.findOnlyClosest && found) {
377  matches.push_back(SourceMatch(pos1[i], pos2[closestIndex], std::sqrt(r2Include)));
378  }
379  }
380  return matches;
381 }
double y
Definition: Match.cc:43
double x
Definition: Match.cc:42
STL class.
T isnan(T... args)
SourceMatchVector matchXy(SourceCatalog const &cat1, SourceCatalog const &cat2, double radius, MatchControl const &mc=MatchControl())
Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between...
Definition: Match.cc:305
T sort(T... args)
T sqrt(T... args)
Match< SourceRecord, SourceRecord > SourceMatch
Definition: fwd.h:105
std::vector< SourceMatch > SourceMatchVector
Definition: fwd.h:109

◆ matchXy() [2/4]

SourceMatchVector lsst::afw::table::matchXy ( SourceCatalog const &  cat,
double  radius,
MatchControl const &  mc = MatchControl() 
)

Compute all tuples (s1,s2,d) where s1 != s2, s1 and s2 both belong to cat, and d, the distance between s1 and s2, in pixels, is at most radius.

The match is performed in pixel space (2d cartesian).

Parameters
catthe catalog to self-match
radiusmatch radius (pixels)
mchow to do the matching (obeys MatchControl::symmetricMatch)

Definition at line 390 of file Match.cc.

390  {
391  // setup match parameters
392  double const r2 = radius * radius;
393 
394  // copy and sort array of pointers on y
395  size_t len = cat.size();
397  size_t n = 0;
398  for (SourceCatalog::const_iterator i(cat.begin()), e(cat.end()); i != e; ++i) {
399  if (std::isnan(i->getX()) || std::isnan(i->getY())) {
400  continue;
401  }
402  pos[n] = i;
403  ++n;
404  }
405  len = n;
406 
407  std::sort(pos.get(), pos.get() + len, CmpRecordPtr());
408 
409  SourceMatchVector matches;
410  for (size_t i = 0; i < len; ++i) {
411  double x = pos[i]->getX();
412  double y = pos[i]->getY();
413  double maxY = y + radius;
414  double y2;
415  for (size_t j = i + 1; j < len && (y2 = pos[j]->getY()) <= maxY; ++j) {
416  double dx = x - pos[j]->getX();
417  double dy = y - y2;
418  double d2 = dx * dx + dy * dy;
419  if (d2 < r2) {
420  double d = std::sqrt(d2);
421  matches.push_back(SourceMatch(pos[i], pos[j], d));
422  if (mc.symmetricMatch) {
423  matches.push_back(SourceMatch(pos[j], pos[i], d));
424  }
425  }
426  }
427  }
428  return matches;
429 }
double y
Definition: Match.cc:43
double x
Definition: Match.cc:42
STL class.
T isnan(T... args)
T sort(T... args)
T sqrt(T... args)
Match< SourceRecord, SourceRecord > SourceMatch
Definition: fwd.h:105
std::vector< SourceMatch > SourceMatchVector
Definition: fwd.h:109

◆ matchXy() [3/4]

SourceMatchVector lsst::afw::table::matchXy ( SourceCatalog const &  cat1,
SourceCatalog const &  cat2,
double  radius,
bool  closest 
)

Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between s1 and s2, in pixels, is at most radius.

If cat1 and cat2 are identical, then this call is equivalent to matchXy(cat1,radius). The match is performed in pixel space (2d cartesian).

Deprecated:
Please use the matchXy(..., MatchControl const&) API
Parameters
[in]cat1first catalog
[in]cat2second catalog
[in]radiusmatch radius (pixels)
[in]closestif true then just return the closest match

Definition at line 298 of file Match.cc.

298  {
299  MatchControl mc;
300  mc.findOnlyClosest = closest;
301 
302  return matchXy(cat1, cat2, radius, mc);
303 }
SourceMatchVector matchXy(SourceCatalog const &cat1, SourceCatalog const &cat2, double radius, MatchControl const &mc=MatchControl())
Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between...
Definition: Match.cc:305

◆ matchXy() [4/4]

SourceMatchVector lsst::afw::table::matchXy ( SourceCatalog const &  cat,
double  radius,
bool  symmetric 
)

Compute all tuples (s1,s2,d) where s1 != s2, s1 and s2 both belong to cat, and d, the distance between s1 and s2, in pixels, is at most radius.

The match is performed in pixel space (2d cartesian).

Deprecated:
Please use the matchXy(..., MatchControl const&) API
Parameters
[in]catthe catalog to self-match
[in]radiusmatch radius (pixels)
[in]symmetricif cat to true symmetric matches are produced: i.e. if (s1, s2, d) is reported, then so is (s2, s1, d).

Definition at line 383 of file Match.cc.

383  {
384  MatchControl mc;
385  mc.symmetricMatch = symmetric;
386 
387  return matchXy(cat, radius, mc);
388 }
SourceMatchVector matchXy(SourceCatalog const &cat1, SourceCatalog const &cat2, double radius, MatchControl const &mc=MatchControl())
Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between...
Definition: Match.cc:305

◆ operator<<() [1/2]

std::ostream& lsst::afw::table::operator<< ( std::ostream os,
BaseRecord const &  record 
)

Definition at line 159 of file BaseRecord.cc.

159  {
160  record._stream(os);
161  return os;
162 }
std::ostream * os
Definition: Schema.cc:746

◆ operator<<() [2/2]

std::ostream& lsst::afw::table::operator<< ( std::ostream os,
Schema const &  schema 
)

Definition at line 751 of file Schema.cc.

751  {
752  os << "Schema(\n";
753  schema.forEach(Stream(&os));
754  for (auto iter = schema.getAliasMap()->begin(); iter != schema.getAliasMap()->end(); ++iter) {
755  os << " '" << iter->first << "'->'" << iter->second << "'\n";
756  }
757  return os << ")\n";
758 }
table::Schema schema
Definition: Camera.cc:161

◆ packMatches() [1/4]

template<typename Record1 , typename Record2 >
BaseCatalog lsst::afw::table::packMatches ( std::vector< Match< Record1, Record2 > > const &  matches)

Return a table representation of a MatchVector that can be used to persist it.

The schema of the returned object has "first" (RecordId), "second" (RecordID), and "distance" (double) fields.

Parameters
[in]matchesA std::vector of Match objects to convert to table form.

Definition at line 432 of file Match.cc.

432  {
433  Schema schema;
434  Key<RecordId> outKey1 = schema.addField<RecordId>("first", "ID for first source record in match.");
435  Key<RecordId> outKey2 = schema.addField<RecordId>("second", "ID for second source record in match.");
436  Key<double> keyD = schema.addField<double>("distance", "Distance between matches sources.");
437  BaseCatalog result(schema);
438  result.getTable()->preallocate(matches.size());
439  result.reserve(matches.size());
440  typedef typename std::vector<Match<Record1, Record2> >::const_iterator Iter;
441  for (Iter i = matches.begin(); i != matches.end(); ++i) {
442  std::shared_ptr<BaseRecord> record = result.addNew();
443  record->set(outKey1, i->first->getId());
444  record->set(outKey2, i->second->getId());
445  record->set(keyD, i->distance);
446  }
447  return result;
448 }
std::int64_t RecordId
Type used for unique IDs for records.
Definition: misc.h:22
CatalogT< BaseRecord > BaseCatalog
Definition: fwd.h:71
py::object result
Definition: schema.cc:418
T end(T... args)
table::Schema schema
Definition: Camera.cc:161
T size(T... args)
STL class.
T begin(T... args)

◆ packMatches() [2/4]

template BaseCatalog lsst::afw::table::packMatches ( SimpleMatchVector const &  )

◆ packMatches() [3/4]

template BaseCatalog lsst::afw::table::packMatches ( ReferenceMatchVector const &  )

◆ packMatches() [4/4]

template BaseCatalog lsst::afw::table::packMatches ( SourceMatchVector const &  )

◆ PYBIND11_MODULE() [1/4]

lsst::afw::table::PYBIND11_MODULE ( match  ,
mod   
)

Definition at line 84 of file match.cc.

84  {
85  py::class_<MatchControl> clsMatchControl(mod, "MatchControl");
86  clsMatchControl.def(py::init<>());
87  LSST_DECLARE_CONTROL_FIELD(clsMatchControl, MatchControl, findOnlyClosest);
88  LSST_DECLARE_CONTROL_FIELD(clsMatchControl, MatchControl, symmetricMatch);
89  LSST_DECLARE_CONTROL_FIELD(clsMatchControl, MatchControl, includeMismatches);
90 
91  declareMatch2<SimpleCatalog, SimpleCatalog>(mod, "Simple");
92  declareMatch2<SimpleCatalog, SourceCatalog>(mod, "Reference");
93  declareMatch2<SourceCatalog, SourceCatalog>(mod, "Source");
94  declareMatch1<SimpleCatalog>(mod);
95  declareMatch1<SourceCatalog>(mod);
96 
97  mod.def("matchXy", (SourceMatchVector(*)(SourceCatalog const &, SourceCatalog const &, double,
98  MatchControl const &))matchXy,
99  "cat1"_a, "cat2"_a, "radius"_a, "mc"_a = MatchControl());
100  mod.def("matchXy", (SourceMatchVector(*)(SourceCatalog const &, double, MatchControl const &))matchXy,
101  "cat"_a, "radius"_a, "mc"_a = MatchControl());
102  // The following are deprecated; consider changing the code instead of wrapping them:
103  // mod.def("matchXy",
104  // (SourceMatchVector (*)(SourceCatalog const &, SourceCatalog const &, double, bool))
105  // matchXy, "cat1"_a, "cat2"_a, "radius"_a, "closest"_a);
106  // mod.def("matchXy",
107  // (SourceMatchVector (*)(SourceCatalog const &, double, bool))
108  // &matchXy, "cat"_a, "radius"_a, "symmetric"_a);
109 }
SortedCatalogT< SourceRecord > SourceCatalog
Definition: fwd.h:85
SourceMatchVector matchXy(SourceCatalog const &cat1, SourceCatalog const &cat2, double radius, MatchControl const &mc=MatchControl())
Compute all tuples (s1,s2,d) where s1 belings to cat1, s2 belongs to cat2 and d, the distance between...
Definition: Match.cc:305
#define LSST_DECLARE_CONTROL_FIELD(WRAPPER, CLASS, NAME)
Macro used to wrap fields declared by LSST_CONTROL_FIELD using Pybind11.
Definition: python.h:43
std::vector< SourceMatch > SourceMatchVector
Definition: fwd.h:109

◆ PYBIND11_MODULE() [2/4]

lsst::afw::table::PYBIND11_MODULE ( simple  ,
mod   
)

Definition at line 86 of file simple.cc.

86  {
87  py::module::import("lsst.afw.coord"); // needed, but why? Perhaps can be removed after RFC-460
88  py::module::import("lsst.afw.table.base");
89  py::module::import("lsst.afw.table.idFactory");
90 
91  auto clsSimpleRecord = declareSimpleRecord(mod);
92  auto clsSimpleTable = declareSimpleTable(mod);
93  auto clsSimpleColumnView = table::python::declareColumnView<SimpleRecord>(mod, "Simple");
94  auto clsSimpleCatalog = table::python::declareSortedCatalog<SimpleRecord>(mod, "Simple");
95 
96  clsSimpleRecord.attr("Table") = clsSimpleTable;
97  clsSimpleRecord.attr("ColumnView") = clsSimpleColumnView;
98  clsSimpleRecord.attr("Catalog") = clsSimpleCatalog;
99  clsSimpleTable.attr("Record") = clsSimpleRecord;
100  clsSimpleTable.attr("ColumnView") = clsSimpleColumnView;
101  clsSimpleTable.attr("Catalog") = clsSimpleCatalog;
102  clsSimpleCatalog.attr("Record") = clsSimpleRecord;
103  clsSimpleCatalog.attr("Table") = clsSimpleTable;
104  clsSimpleCatalog.attr("ColumnView") = clsSimpleColumnView;
105 }

◆ PYBIND11_MODULE() [3/4]

lsst::afw::table::PYBIND11_MODULE ( exposure  ,
mod   
)

Definition at line 167 of file exposure.cc.

167  {
168  py::module::import("lsst.afw.table.simple");
169  py::module::import("lsst.afw.geom");
170  // afw.image and afw.detection cannot be imported due to circular dependencies
171 
172  auto clsExposureRecord = declareExposureRecord(mod);
173  auto clsExposureTable = declareExposureTable(mod);
174  auto clsExposureColumnView = table::python::declareColumnView<ExposureRecord>(mod, "Exposure");
175  auto clsExposureCatalog = declareExposureCatalog(mod);
176 
177  clsExposureRecord.attr("Table") = clsExposureTable;
178  clsExposureRecord.attr("ColumnView") = clsExposureColumnView;
179  clsExposureRecord.attr("Catalog") = clsExposureCatalog;
180  clsExposureTable.attr("Record") = clsExposureRecord;
181  clsExposureTable.attr("ColumnView") = clsExposureColumnView;
182  clsExposureTable.attr("Catalog") = clsExposureCatalog;
183  clsExposureCatalog.attr("Record") = clsExposureRecord;
184  clsExposureCatalog.attr("Table") = clsExposureTable;
185  clsExposureCatalog.attr("ColumnView") = clsExposureColumnView;
186 }

◆ PYBIND11_MODULE() [4/4]

lsst::afw::table::PYBIND11_MODULE ( aggregates  ,
mod   
)

Definition at line 183 of file aggregates.cc.

183  {
184  py::module::import("lsst.afw.geom.ellipses");
185  py::module::import("lsst.afw.table.base");
186  py::enum_<CoordinateType>(mod, "CoordinateType")
187  .value("PIXEL", CoordinateType::PIXEL)
188  .value("CELESTIAL", CoordinateType::CELESTIAL)
189  .export_values();
190 
191  declarePointKey<double>(mod, "2D");
192  declarePointKey<int>(mod, "2I");
193 
194  declareBoxKey<lsst::geom::Box2D>(mod, "2D");
195  declareBoxKey<lsst::geom::Box2I>(mod, "2I");
196 
197  declareCoordKey(mod);
198  declareQuadrupoleKey(mod);
199  declareEllipseKey(mod);
200 
201  declareCovarianceMatrixKey<float, 2>(mod, "2f");
202  declareCovarianceMatrixKey<float, 3>(mod, "3f");
203  declareCovarianceMatrixKey<float, 4>(mod, "4f");
204  declareCovarianceMatrixKey<float, Eigen::Dynamic>(mod, "Xf");
205  declareCovarianceMatrixKey<double, 2>(mod, "2d");
206  declareCovarianceMatrixKey<double, 3>(mod, "3d");
207  declareCovarianceMatrixKey<double, 4>(mod, "4d");
208  declareCovarianceMatrixKey<double, Eigen::Dynamic>(mod, "Xd");
209 }

◆ unpackMatches() [1/4]

template<typename Cat1 , typename Cat2 >
std::vector< Match< typename Cat1::Record, typename Cat2::Record > > lsst::afw::table::unpackMatches ( BaseCatalog const &  matches,
Cat1 const &  cat1,
Cat2 const &  cat2 
)

Reconstruct a MatchVector from a BaseCatalog representation of the matches and a pair of catalogs.

Note
The first and second catalog arguments must be sorted in ascending ID order on input; this will allow us to use binary search algorithms to find the records referred to by the match table.

If an ID cannot be found in the given tables, that pointer will be set to null in the returned match vector.

Parameters
[in]matchesA normalized BaseCatalog representation, as produced by packMatches.
[in]cat1A CatalogT containing the records used on the 'first' side of the match, sorted by ascending ID.
[in]cat2A CatalogT containing the records used on the 'second' side of the match, sorted by ascending ID. May be the same as first.

This is instantiated for Simple-Simple, Simple-Source, and Source-Source catalog combinations.

Definition at line 455 of file Match.cc.

457  {
458  LOG_LOGGER tableLog = LOG_GET("afw.table");
459  Key<RecordId> inKey1 = matches.getSchema()["first"];
460  Key<RecordId> inKey2 = matches.getSchema()["second"];
461  Key<double> keyD = matches.getSchema()["distance"];
462  if (!first.isSorted() || !second.isSorted())
463  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
464  "Catalogs passed to unpackMatches must be sorted.");
465  typedef Match<typename Cat1::Record, typename Cat2::Record> MatchT;
467  result.resize(matches.size());
468  typename std::vector<MatchT>::iterator j = result.begin();
469  for (BaseCatalog::const_iterator i = matches.begin(); i != matches.end(); ++i, ++j) {
470  typename Cat1::const_iterator k1 = first.find(i->get(inKey1));
471  typename Cat2::const_iterator k2 = second.find(i->get(inKey2));
472  if (k1 != first.end()) {
473  j->first = k1;
474  } else {
475  LOGLS_WARN(tableLog,
476  "Persisted match record with ID " << i->get(inKey1) << " not found in catalog 1.");
477  }
478  if (k2 != second.end()) {
479  j->second = k2;
480  } else {
481  LOGLS_WARN(tableLog,
482  "Persisted match record with ID " << i->get(inKey2) << " not found in catalog 2.");
483  }
484  j->distance = i->get(keyD);
485  }
486  return result;
487 }
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
Definition: Log.h:633
#define LOG_LOGGER
Definition: Log.h:688
py::object result
Definition: schema.cc:418
T resize(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition: Exception.h:48
T begin(T... args)
#define LOG_GET(logger)
Returns a Log object associated with logger.
Definition: Log.h:75

◆ unpackMatches() [2/4]

template SimpleMatchVector lsst::afw::table::unpackMatches ( BaseCatalog const &  ,
SimpleCatalog const &  ,
SimpleCatalog const &   
)

◆ unpackMatches() [3/4]

template ReferenceMatchVector lsst::afw::table::unpackMatches ( BaseCatalog const &  ,
SimpleCatalog const &  ,
SourceCatalog const &   
)

◆ unpackMatches() [4/4]

template SourceMatchVector lsst::afw::table::unpackMatches ( BaseCatalog const &  ,
SourceCatalog const &  ,
SourceCatalog const &   
)

◆ updateRefCentroids()

template<typename ReferenceCollection >
void lsst::afw::table::updateRefCentroids ( geom::SkyWcs const &  wcs,
ReferenceCollection &  refList 
)

Update centroids in a collection of reference objects.

Template Parameters
RefCollectionType of sequence of reference objects, e.g. lsst::afw::table::SimpleCatalog or std::vector<std::shared_ptr<lsst::afw::table::SimpleRecord>>
Parameters
[in]wcsWCS to map from sky to pixels
[in,out]refListCollection of reference objects. The schema must have three fields:
  • "coord": a field containing an ICRS lsst::afw::SpherePoint; this field is read
  • "centroid": a field containing lsst::geom::Point2D; this field is written
  • "hasCentroid": a flag; this field is written
Exceptions
lsst::pex::exceptions::NotFoundErrorif refList's schema does not have the required fields.

Definition at line 73 of file wcsUtils.cc.

73  {
74  if (refList.empty()) {
75  return;
76  }
77  auto const schema = getSchema(refList[0]);
78  CoordKey const coordKey(schema["coord"]);
79  Point2DKey const centroidKey(schema["centroid"]);
80  Key<Flag> const hasCentroidKey(schema["hasCentroid"]);
82  skyList.reserve(refList.size());
83  for (auto const &record : refList) {
84  skyList.emplace_back(getValue(record, coordKey));
85  }
86  std::vector<lsst::geom::Point2D> const pixelList = wcs.skyToPixel(skyList);
87  auto pixelPos = pixelList.cbegin();
88  for (auto &refObj : refList) {
89  setValue(refObj, centroidKey, *pixelPos);
90  setValue(refObj, hasCentroidKey, true);
91  ++pixelPos;
92  }
93 }
PointKey< double > Point2DKey
Definition: aggregates.h:118
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
table::Schema schema
Definition: Camera.cc:161
STL class.
T cbegin(T... args)
T reserve(T... args)
T emplace_back(T... args)

◆ updateSourceCoords()

template<typename SourceCollection >
void lsst::afw::table::updateSourceCoords ( geom::SkyWcs const &  wcs,
SourceCollection &  sourceList 
)

Update sky coordinates in a collection of source objects.

Template Parameters
SourceCollectionType of sequence of sources, e.g. lsst::afw::table::SourceCatalog or std::vector<std::shared_ptr<lsst::afw::table::SourceRecord>>
Parameters
[in]wcsWCS to map from pixels to sky
[in,out]sourceListCollection of sources. The schema must have two fields:
  • "slot_Centroid": a field containing lsst::geom::Point2D; this field is read
  • "coord": a field containing an ICRS lsst::afw::SpherePoint; this field is written
Exceptions
lsst::pex::exceptions::NotFoundErrorif refList's schema does not have the required fields.

Definition at line 96 of file wcsUtils.cc.

96  {
97  if (sourceList.empty()) {
98  return;
99  }
100  auto const schema = getSchema(sourceList[0]);
101  Point2DKey const centroidKey(schema["slot_Centroid"]);
102  CoordKey const coordKey(schema["coord"]);
104  pixelList.reserve(sourceList.size());
105  for (auto const &source : sourceList) {
106  pixelList.emplace_back(getValue(source, centroidKey));
107  }
108  std::vector<lsst::geom::SpherePoint> const skyList = wcs.pixelToSky(pixelList);
109  auto skyCoord = skyList.cbegin();
110  for (auto &source : sourceList) {
111  setValue(source, coordKey, *skyCoord);
112  ++skyCoord;
113  }
114 }
PointKey< double > Point2DKey
Definition: aggregates.h:118
table::Key< table::Array< std::uint8_t > > wcs
Definition: SkyWcs.cc:71
table::Schema schema
Definition: Camera.cc:161
const char * source()
Source function that allows astChannel to source from a Stream.
Definition: Stream.h:224
STL class.
T cbegin(T... args)
T reserve(T... args)
T emplace_back(T... args)

Variable Documentation

◆ _

lsst::afw::table::_

Definition at line 188 of file BaseColumnView.cc.