LSST Applications g063fba187b+cac8b7c890,g0f08755f38+6aee506743,g1653933729+a8ce1bb630,g168dd56ebc+a8ce1bb630,g1a2382251a+b4475c5878,g1dcb35cd9c+8f9bc1652e,g20f6ffc8e0+6aee506743,g217e2c1bcf+73dee94bd0,g28da252d5a+1f19c529b9,g2bbee38e9b+3f2625acfc,g2bc492864f+3f2625acfc,g3156d2b45e+6e55a43351,g32e5bea42b+1bb94961c2,g347aa1857d+3f2625acfc,g35bb328faa+a8ce1bb630,g3a166c0a6a+3f2625acfc,g3e281a1b8c+c5dd892a6c,g3e8969e208+a8ce1bb630,g414038480c+5927e1bc1e,g41af890bb2+8a9e676b2a,g7af13505b9+809c143d88,g80478fca09+6ef8b1810f,g82479be7b0+f568feb641,g858d7b2824+6aee506743,g89c8672015+f4add4ffd5,g9125e01d80+a8ce1bb630,ga5288a1d22+2903d499ea,gb58c049af0+d64f4d3760,gc28159a63d+3f2625acfc,gcab2d0539d+b12535109e,gcf0d15dbbd+46a3f46ba9,gda6a2b7d83+46a3f46ba9,gdaeeff99f8+1711a396fd,ge79ae78c31+3f2625acfc,gef2f8181fd+0a71e47438,gf0baf85859+c1f95f4921,gfa517265be+6aee506743,gfa999e8aa5+17cd334064,w.2024.51
LSST Data Management Base Package
Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
lsst::afw::table Namespace Reference

Namespaces

namespace  _aggregates
 
namespace  _aliasMap
 
namespace  _arrays
 
namespace  _base
 
namespace  _baseColumnView
 
namespace  _exposure
 
namespace  _match
 
namespace  _schema
 
namespace  _schemaMapper
 
namespace  _simple
 
namespace  _source
 
namespace  catalogMatches
 
namespace  detail
 
namespace  io
 
namespace  multiMatch
 
namespace  python
 
namespace  testUtils
 

Classes

class  AliasMap
 Mapping class that holds aliases for a Schema. 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 Point3Keys. 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  CoordErrKey
 
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  Point3Key
 A FunctorKey used to get or set a lsst::geom::Point3 from an (x,y,z) tuple of int or double Keys. More...
 
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...
 
struct  TypeList
 

Typedefs

using Point2IKey = PointKey<int>
 
using Point2DKey = PointKey<double>
 
using Point3IKey = Point3Key<int>
 
using Point3DKey = Point3Key<double>
 
using Box2IKey = BoxKey<lsst::geom::Box2I>
 
using Box2DKey = BoxKey<lsst::geom::Box2D>
 
using ExposureColumnView = ColumnViewT<ExposureRecord>
 
using ExposureCatalog = ExposureCatalogT<ExposureRecord>
 
using ConstExposureCatalog = ExposureCatalogT<const ExposureRecord>
 
using BaseCatalog = CatalogT<BaseRecord>
 
using ConstBaseCatalog = CatalogT<const BaseRecord>
 
using SimpleColumnView = ColumnViewT<SimpleRecord>
 
using SimpleCatalog = SortedCatalogT<SimpleRecord>
 
using ConstSimpleCatalog = SortedCatalogT<const SimpleRecord>
 
using SourceColumnView = SourceColumnViewT<SourceRecord>
 
using SourceCatalog = SortedCatalogT<SourceRecord>
 
using ConstSourceCatalog = SortedCatalogT<const SourceRecord>
 
using AmpInfoColumnView = ColumnViewT<AmpInfoRecord>
 
using AmpInfoCatalog = CatalogT<AmpInfoRecord>
 
using ConstAmpInfoCatalog = CatalogT<const AmpInfoRecord>
 
using SimpleMatch = Match<SimpleRecord, SimpleRecord>
 
using ReferenceMatch = Match<SimpleRecord, SourceRecord>
 
using SourceMatch = Match<SourceRecord, SourceRecord>
 
using SimpleMatchVector = std::vector<SimpleMatch>
 
using ReferenceMatchVector = std::vector<ReferenceMatch>
 
using SourceMatchVector = std::vector<SourceMatch>
 
using RecordId = std::int64_t
 Type used for unique IDs for records.
 
using Angle = lsst::geom::Angle
 
using SpherePoint = lsst::geom::SpherePoint
 
using Footprint = lsst::afw::detection::Footprint
 
using FieldTypes = TypeList< 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> >
 A compile-time list of all field types.
 
using PyAliasMap = py::class_<AliasMap, std::shared_ptr<AliasMap>>
 
using PyIdFactory = py::class_<IdFactory, std::shared_ptr<IdFactory>>
 
using PySchemaMapper = py::class_<SchemaMapper, std::shared_ptr<SchemaMapper>>
 

Enumerations

enum class  CoordinateType { PIXEL , CELESTIAL }
 Enum used to set units for geometric FunctorKeys. 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

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)
 
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.
 
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.
 
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.
 
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 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.
 
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.
 
template<typename ReferenceCollection >
void updateRefCentroids (geom::SkyWcs const &wcs, ReferenceCollection &refList)
 Update centroids in a collection of reference objects.
 
template<typename SourceCollection >
void updateSourceCoords (geom::SkyWcs const &wcs, SourceCollection &sourceList, bool include_covariance=true)
 Update sky coordinates in a collection of source objects.
 
Eigen::Matrix2f calculateCoordCovariance (geom::SkyWcs const &wcs, lsst::geom::Point2D center, Eigen::Matrix2f err)
 Calculate covariance for sky coordinates.
 
void wrapAggregates (WrapperCollection &wrappers)
 
void wrapAliasMap (cpputils::python::WrapperCollection &wrappers)
 
void wrapArrays (WrapperCollection &wrappers)
 
void wrapBase (WrapperCollection &wrappers)
 
void wrapBaseColumnView (WrapperCollection &wrappers)
 
void wrapExposure (WrapperCollection &wrappers)
 
void wrapIdFactory (cpputils::python::WrapperCollection &wrappers)
 
void wrapMatch (WrapperCollection &wrappers)
 
void wrapSchema (WrapperCollection &wrappers)
 
void wrapSchemaMapper (WrapperCollection &wrappers)
 
void wrapSimple (WrapperCollection &wrappers)
 
void wrapSlots (WrapperCollection &wrappers)
 
void wrapSource (WrapperCollection &wrappers)
 
void wrapWcsUtils (WrapperCollection &)
 
 PYBIND11_MODULE (_table, 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<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)
 
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<typename Cat >
std::vector< Match< typename Cat::Record, typename Cat::Record > > matchRaDec (Cat const &cat, lsst::geom::Angle radius, bool symmetric)
 
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 &)
 
SourceMatchVector matchXy (SourceCatalog const &cat1, SourceCatalog const &cat2, double radius, bool closest)
 
SourceMatchVector matchXy (SourceCatalog const &cat, double radius, bool symmetric)
 
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)
 

Variables

 _
 

Typedef Documentation

◆ AmpInfoCatalog

Definition at line 97 of file fwd.h.

◆ AmpInfoColumnView

Definition at line 96 of file fwd.h.

◆ Angle

Definition at line 33 of file misc.h.

◆ BaseCatalog

Definition at line 72 of file fwd.h.

◆ Box2DKey

Definition at line 284 of file aggregates.h.

◆ Box2IKey

Definition at line 283 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 489 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 488 of file Exposure.h.

◆ ExposureColumnView

Definition at line 487 of file Exposure.h.

◆ FieldTypes

A compile-time list of all field types.

Definition at line 53 of file types.h.

◆ Footprint

Definition at line 57 of file Source.h.

◆ Point2DKey

Definition at line 120 of file aggregates.h.

◆ Point2IKey

Definition at line 119 of file aggregates.h.

◆ Point3DKey

Definition at line 200 of file aggregates.h.

◆ Point3IKey

Definition at line 199 of file aggregates.h.

◆ PyAliasMap

Definition at line 37 of file _aliasMap.cc.

◆ PyIdFactory

Definition at line 36 of file _idFactory.cc.

◆ PySchemaMapper

Definition at line 43 of file _schemaMapper.cc.

◆ 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 21 of file misc.h.

◆ ReferenceMatch

Definition at line 104 of file fwd.h.

◆ ReferenceMatchVector

Definition at line 108 of file fwd.h.

◆ SimpleCatalog

Definition at line 79 of file fwd.h.

◆ SimpleColumnView

Definition at line 78 of file fwd.h.

◆ SimpleMatch

Definition at line 103 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 84 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 34 of file misc.h.

Enumeration Type Documentation

◆ CoordinateType

Enum used to set units for geometric FunctorKeys.

Enumerator
PIXEL 
CELESTIAL 

Definition at line 364 of file aggregates.h.

◆ 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 52 of file Source.h.

52 {
55};
@ SOURCE_IO_NO_FOOTPRINTS
Do not read/write footprints at all.
Definition Source.h:53
@ SOURCE_IO_NO_HEAVY_FOOTPRINTS
Read/write heavy footprints as non-heavy footprints.
Definition Source.h:54

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

912 {
914 catalog.equal_range(value, key);
915 return std::pair<int, int>(p.first - catalog.begin(), p.second - catalog.begin());
916}

◆ _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 893 of file Catalog.h.

893 {
894 typename Catalog::const_iterator iter = catalog.find(value, key);
895 if (iter == catalog.end()) {
897 }
898 return iter; // n.b. CatalogIterator is explicitly convertible to shared_ptr
899}

◆ _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 902 of file Catalog.h.

902 {
903 return catalog.lower_bound(value, key) - catalog.begin();
904}

◆ _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 907 of file Catalog.h.

907 {
908 return catalog.upper_bound(value, key) - catalog.begin();
909}

◆ BOOST_PP_SEQ_FOR_EACH()

◆ calculateCoordCovariance()

Eigen::Matrix2f lsst::afw::table::calculateCoordCovariance ( geom::SkyWcs const & wcs,
lsst::geom::Point2D center,
Eigen::Matrix2f err )

Calculate covariance for sky coordinates.

Parameters
[in]wcsWCS to map from pixels to sky.
[in]centerThe object centroid.
[in]errCovariance matrix of the centroid.

Definition at line 95 of file wcsUtils.cc.

96 {
97 if (!std::isfinite(center.getX()) || !std::isfinite(center.getY())) {
98 return Eigen::Matrix2f::Constant(NAN);
99 }
100 // Get the derivative of the pixel-to-sky transformation, then use it to
101 // propagate the centroid uncertainty to coordinate uncertainty. Note that
102 // the calculation is done in arcseconds, then converted to radians in
103 // order to achieve higher precision.
104 const static double scale = 1.0 / 3600.0;
105 const static Eigen::Matrix2d cdMatrix{{scale, 0}, {0, scale}};
106
107 lsst::geom::SpherePoint skyCenter = wcs.pixelToSky(center);
108 auto localGnomonicWcs = geom::makeSkyWcs(center, skyCenter, cdMatrix);
109 auto measurementToLocalGnomonic = wcs.getTransform()->then(*localGnomonicWcs->getTransform()->inverted());
110
111 Eigen::Matrix2d localMatrix = measurementToLocalGnomonic->getJacobian(center);
112 Eigen::Matrix2f d = localMatrix.cast<float>() * scale * (lsst::geom::PI / 180.0);
113
114 Eigen::Matrix2f skyCov = d * err * d.transpose();
115
116 // Multiply by declination correction matrix in order to get sigma(RA) * cos(Dec) for the uncertainty
117 // in RA, and cov(RA, Dec) * cos(Dec) for the RA/Dec covariance:
118 float cosDec = std::cos(skyCenter.getDec().asRadians());
119 Eigen::Matrix2f decCorr{{cosDec, 0}, {0, 1.0}};
120 Eigen::Matrix2f skyCovCorr = decCorr * skyCov * decCorr;
121 return skyCovCorr;
122}
constexpr double asRadians() const noexcept
Return an Angle's value in radians.
Definition Angle.h:173
Point in an unspecified spherical coordinate system.
Definition SpherePoint.h:57
Angle getDec() const noexcept
Synonym for getLatitude.
T cos(T... args)
T isfinite(T... args)
double constexpr PI
The ratio of a circle's circumference to diameter.
Definition Angle.h:40

◆ matchRaDec() [1/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 )

Definition at line 239 of file Match.cc.

241 {
243 mc.symmetricMatch = symmetric;
244
245 return matchRaDec(cat, radius, mc);
246}
Tag types used to declare specialized field types.
Definition misc.h:31
Pass parameters to algorithms that match list of sources.
Definition Match.h:45
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...
Definition Match.cc:158

◆ 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 {
253 std::vector<MatchT> matches;
254
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 using Pos = RecordPos<typename Cat::Record>;
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}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48
std::shared_ptr< RecordT > src
Definition Match.cc:48
A class representing an angle.
Definition Angle.h:128
Reports when the result of an operation cannot be represented by the destination type.
Definition Runtime.h:115
AngleUnit constexpr degrees
constant with units of degrees
Definition Angle.h:110
T push_back(T... args)

◆ 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 )

Definition at line 147 of file Match.cc.

150 {
152 mc.findOnlyClosest = closest;
153
154 return matchRaDec(cat1, cat2, radius, mc);
155}

◆ matchRaDec() [4/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 {
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 using Pos1 = RecordPos<typename Cat1::Record>;
181 using Pos2 = RecordPos<typename Cat2::Record>;
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}
double dec
Definition Match.cc:41

◆ matchRaDec() [5/14]

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

◆ matchRaDec() [6/14]

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

◆ matchRaDec() [7/14]

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

◆ matchRaDec() [8/14]

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

◆ matchRaDec() [9/14]

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

◆ matchRaDec() [10/14]

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

◆ matchRaDec() [11/14]

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

◆ matchRaDec() [12/14]

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

◆ matchRaDec() [13/14]

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

◆ matchRaDec() [14/14]

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

◆ matchXy() [1/4]

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

Definition at line 383 of file Match.cc.

383 {
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

◆ 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
typename Base::const_iterator const_iterator
T isnan(T... args)
T sort(T... args)
T sqrt(T... args)

◆ matchXy() [3/4]

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

Definition at line 298 of file Match.cc.

298 {
300 mc.findOnlyClosest = closest;
301
302 return matchXy(cat1, cat2, radius, mc);
303}

◆ matchXy() [4/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}
std::vector< SourceMatch > SourceMatchVector
Definition fwd.h:109

◆ operator<<() [1/2]

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

Definition at line 158 of file BaseRecord.cc.

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

◆ operator<<() [2/2]

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

Definition at line 562 of file Schema.cc.

562 {
563 os << "Schema(\n";
564 schema.forEach(Stream(&os));
565 for (auto const &iter : *schema.getAliasMap()) {
566 os << " '" << iter.first << "'->'" << iter.second << "'\n";
567 }
568 return os << ")\n";
569}
table::Schema schema
Definition python.h:134

◆ packMatches() [1/4]

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

◆ packMatches() [2/4]

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

◆ packMatches() [3/4]

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

◆ packMatches() [4/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 {
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.");
438 result.getTable()->preallocate(matches.size());
439 result.reserve(matches.size());
440 using Iter = typename std::vector<Match<Record1, Record2>>::const_iterator;
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}
py::object result
Definition _schema.cc:429
T begin(T... args)
Defines the fields and offsets for a table.
Definition Schema.h:51
T end(T... args)
T size(T... args)

◆ PYBIND11_MODULE()

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

Definition at line 52 of file _table.cc.

52 {
53 WrapperCollection wrappers(mod, "lsst.afw.table");
54 wrapAliasMap(wrappers);
55 wrapSchema(wrappers);
56 wrapSchemaMapper(wrappers);
57 wrapBaseColumnView(wrappers);
58 wrapBase(wrappers);
59 wrapIdFactory(wrappers);
60 wrapArrays(wrappers);
61 wrapAggregates(wrappers);
62 wrapSlots(wrappers);
63 wrapSimple(wrappers);
64 wrapSource(wrappers);
65 wrapExposure(wrappers);
66 wrapMatch(wrappers);
67 wrapWcsUtils(wrappers);
68 wrappers.finish();
69}
A helper class for subdividing pybind11 module across multiple translation units (i....
Definition python.h:242
void wrapSchema(WrapperCollection &wrappers)
Definition _schema.cc:539
void wrapArrays(WrapperCollection &wrappers)
Definition _arrays.cc:101
void wrapSlots(WrapperCollection &wrappers)
Definition _slots.cc:70
void wrapMatch(WrapperCollection &wrappers)
Definition _match.cc:89
void wrapAggregates(WrapperCollection &wrappers)
void wrapSource(WrapperCollection &wrappers)
Definition _source.cc:182
void wrapIdFactory(cpputils::python::WrapperCollection &wrappers)
Definition _idFactory.cc:38
void wrapBaseColumnView(WrapperCollection &wrappers)
void wrapBase(WrapperCollection &wrappers)
Definition _base.cc:175
void wrapSchemaMapper(WrapperCollection &wrappers)
void wrapSimple(WrapperCollection &wrappers)
Definition _simple.cc:92
void wrapAliasMap(cpputils::python::WrapperCollection &wrappers)
Definition _aliasMap.cc:39

◆ unpackMatches() [1/4]

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

◆ unpackMatches() [2/4]

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

◆ unpackMatches() [3/4]

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

◆ unpackMatches() [4/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("lsst.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())
464 "Catalogs passed to unpackMatches must be sorted.");
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:659
#define LOG_GET(logger)
Returns a Log object associated with logger.
Definition Log.h:75
#define LOG_LOGGER
Definition Log.h:714
Reports invalid arguments.
Definition Runtime.h:66
T resize(T... args)

◆ 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}
T emplace_back(T... args)
T reserve(T... args)

◆ updateSourceCoords()

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

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
[in]include_covarianceUpdate coordinate uncertainty using the centroid uncertainty.
Exceptions
lsst::pex::exceptions::NotFoundErrorif refList's schema does not have the required fields.

Definition at line 125 of file wcsUtils.cc.

125 {
126 if (sourceList.empty()) {
127 return;
128 }
129 auto const schema = getSchema(sourceList[0]);
130 Point2DKey const centroidKey(schema["slot_Centroid"]);
131 CovarianceMatrixKey<float, 2> const centroidErrKey(schema["slot_Centroid"], {"x", "y"});
132 CoordKey const coordKey(schema["coord"]);
134 pixelList.reserve(sourceList.size());
136 skyErrList.reserve(sourceList.size());
137
138 for (auto const &source : sourceList) {
139 lsst::geom::Point2D center = getValue(source, centroidKey);
140 pixelList.emplace_back(center);
141 if (include_covariance) {
142 auto err = getValue(source, centroidErrKey);
143 Eigen::Matrix2f skyCov = calculateCoordCovariance(wcs, center, err);
144 skyErrList.emplace_back(skyCov);
145 }
146 }
147
148 std::vector<lsst::geom::SpherePoint> const skyList = wcs.pixelToSky(pixelList);
149 auto skyCoord = skyList.cbegin();
150 auto skyErr = skyErrList.cbegin();
151 for (auto &source : sourceList) {
152 setValue(source, coordKey, *skyCoord);
153 if (include_covariance) {
154 CoordKey::ErrorKey const coordErrKey = CoordKey::getErrorKey(schema);
155 setValue(source, coordErrKey, *skyErr);
156 }
157 ++skyCoord;
158 ++skyErr;
159 }
160}

◆ wrapAggregates()

void lsst::afw::table::wrapAggregates ( WrapperCollection & wrappers)

Definition at line 225 of file _aggregates.cc.

225 {
226 // TODO: uncomment once afw.geom uses WrapperCollection
227 // wrappers.addSignatureDependency("lsst.afw.geom.ellipses");
228
229 wrappers.wrapType(py::enum_<CoordinateType>(wrappers.module, "CoordinateType"), [](auto &mod, auto &enm) {
230 enm.value("PIXEL", CoordinateType::PIXEL);
231 enm.value("CELESTIAL", CoordinateType::CELESTIAL);
232 enm.export_values();
233 });
234
235 declarePointKey<double>(wrappers, "2D");
236 declarePointKey<int>(wrappers, "2I");
237 declarePoint3Key<double>(wrappers, "D");
238 declarePoint3Key<int>(wrappers, "I");
239
240 declareBoxKey<lsst::geom::Box2D>(wrappers, "2D");
241 declareBoxKey<lsst::geom::Box2I>(wrappers, "2I");
242
243 declareCoordKey(wrappers);
244 declareQuadrupoleKey(wrappers);
245 declareEllipseKey(wrappers);
246
255}
PyType wrapType(PyType cls, ClassWrapperCallback function, bool setModuleName=true)
Add a type (class or enum) wrapper, deferring method and other attribute definitions until finish() i...
Definition python.h:391

◆ wrapAliasMap()

void lsst::afw::table::wrapAliasMap ( cpputils::python::WrapperCollection & wrappers)

Definition at line 39 of file _aliasMap.cc.

39 {
40 wrappers.wrapType(PyAliasMap(wrappers.module, "AliasMap"), [](auto &mod, auto &cls) {
41 cls.def(py::init<>());
42 cls.def(py::init<AliasMap const &>());
43
44 cls.def("__len__", &AliasMap::size);
45 cls.def("empty", &AliasMap::empty);
46 cls.def("apply", &AliasMap::apply, "name"_a);
47 cls.def("get", &AliasMap::get, "alias"_a);
48 cls.def("__getitem__", &AliasMap::get, "alias"_a);
49 cls.def("set", &AliasMap::set, "alias"_a, "target"_a);
50 cls.def("__setitem__", &AliasMap::set);
51 cls.def("erase", &AliasMap::erase, "alias"_a);
52 cls.def("__delitem__", &AliasMap::erase, "alias"_a);
53 cls.def("__eq__", [](AliasMap &self, AliasMap &other) { return self == other; });
54 cls.def("__ne__", [](AliasMap &self, AliasMap &other) { return self != other; });
55 cls.def("contains", &AliasMap::contains, "other"_a);
56 cls.def("__contains__", &AliasMap::contains);
57 cls.def("items", [](AliasMap &self) { return py::make_iterator(self.begin(), self.end()); },
58 py::keep_alive<0, 1>());
59 });
60}
Mapping class that holds aliases for a Schema.
Definition AliasMap.h:36
py::class_< AliasMap, std::shared_ptr< AliasMap > > PyAliasMap
Definition _aliasMap.cc:37

◆ wrapArrays()

void lsst::afw::table::wrapArrays ( WrapperCollection & wrappers)

Definition at line 101 of file _arrays.cc.

101 {
102 declareArrayKey<float>(wrappers, "F");
103 declareArrayKey<double>(wrappers, "D");
104}

◆ wrapBase()

void lsst::afw::table::wrapBase ( WrapperCollection & wrappers)

Definition at line 175 of file _base.cc.

175 {
176 wrappers.addSignatureDependency("lsst.daf.base");
177
178 auto clsBaseTable = declareBaseTable(wrappers);
179 auto clsBaseRecord = declareBaseRecord(wrappers);
180 auto clsBaseCatalog = table::python::declareCatalog<BaseRecord>(wrappers, "Base");
181 auto clsBaseColumnView = table::python::declareColumnView<BaseRecord>(wrappers, "Base");
182
183 clsBaseRecord.attr("Table") = clsBaseTable;
184 clsBaseRecord.attr("ColumnView") = clsBaseColumnView;
185 clsBaseRecord.attr("Catalog") = clsBaseCatalog;
186 clsBaseTable.attr("Record") = clsBaseRecord;
187 clsBaseTable.attr("ColumnView") = clsBaseColumnView;
188 clsBaseTable.attr("Catalog") = clsBaseCatalog;
189 clsBaseCatalog.attr("Record") = clsBaseRecord;
190 clsBaseCatalog.attr("Table") = clsBaseTable;
191 clsBaseCatalog.attr("ColumnView") = clsBaseColumnView;
192}
void addSignatureDependency(std::string const &name)
Indicate an external module that provides a type used in function/method signatures.
Definition python.h:357

◆ wrapBaseColumnView()

void lsst::afw::table::wrapBaseColumnView ( WrapperCollection & wrappers)

Definition at line 128 of file _baseColumnView.cc.

128 {
129 declareBaseColumnView(wrappers);
130 declareBitsColumn(wrappers);
131}

◆ wrapExposure()

void lsst::afw::table::wrapExposure ( WrapperCollection & wrappers)

Definition at line 176 of file _exposure.cc.

176 {
177 // wrappers.addSignatureDependency("lsst.afw.geom");
178 // TODO: afw.geom, afw.image, and afw.detection cannot be imported due to
179 // circular dependencies until at least afw.image uses WrapperCollection
180 // in DM-20703
181
183 auto clsExposureTable = declareExposureTable(wrappers);
184 auto clsExposureColumnView = table::python::declareColumnView<ExposureRecord>(wrappers, "Exposure");
186
187 clsExposureRecord.attr("Table") = clsExposureTable;
188 clsExposureRecord.attr("ColumnView") = clsExposureColumnView;
189 clsExposureRecord.attr("Catalog") = clsExposureCatalog;
190 clsExposureTable.attr("Record") = clsExposureRecord;
191 clsExposureTable.attr("ColumnView") = clsExposureColumnView;
192 clsExposureTable.attr("Catalog") = clsExposureCatalog;
193 clsExposureCatalog.attr("Record") = clsExposureRecord;
194 clsExposureCatalog.attr("Table") = clsExposureTable;
195 clsExposureCatalog.attr("ColumnView") = clsExposureColumnView;
196}

◆ wrapIdFactory()

void lsst::afw::table::wrapIdFactory ( cpputils::python::WrapperCollection & wrappers)

Definition at line 38 of file _idFactory.cc.

38 {
39 wrappers.wrapType(PyIdFactory(wrappers.module, "IdFactory"), [](auto& mod, auto& cls) {
40 cls.def("__call__", &IdFactory::operator());
41 cls.def("notify", &IdFactory::notify, "id"_a);
42 cls.def("clone", &IdFactory::clone);
43 cls.def_static("makeSimple", IdFactory::makeSimple);
44 cls.def_static("makeSource", IdFactory::makeSource, "expId"_a, "reserved"_a);
45 cls.def_static("computeReservedFromMaxBits", IdFactory::computeReservedFromMaxBits, "maxBits"_a);
46 });
47}
py::class_< IdFactory, std::shared_ptr< IdFactory > > PyIdFactory
Definition _idFactory.cc:36

◆ wrapMatch()

void lsst::afw::table::wrapMatch ( WrapperCollection & wrappers)

Definition at line 89 of file _match.cc.

89 {
90 wrappers.wrapType(py::class_<MatchControl>(wrappers.module, "MatchControl"), [](auto &mod, auto &cls) {
91 cls.def(py::init<>());
92 LSST_DECLARE_CONTROL_FIELD(cls, MatchControl, findOnlyClosest);
93 LSST_DECLARE_CONTROL_FIELD(cls, MatchControl, symmetricMatch);
94 LSST_DECLARE_CONTROL_FIELD(cls, MatchControl, includeMismatches);
95 });
96
102
103 wrappers.wrap([](auto &mod) {
104 mod.def("matchXy",
105 (SourceMatchVector(*)(SourceCatalog const &, SourceCatalog const &, double,
106 MatchControl const &))matchXy,
107 "cat1"_a, "cat2"_a, "radius"_a, "mc"_a = MatchControl());
108 mod.def("matchXy", (SourceMatchVector(*)(SourceCatalog const &, double, MatchControl const &))matchXy,
109 "cat"_a, "radius"_a, "mc"_a = MatchControl());
110 });
111}
void wrap(WrapperCallback function)
Add a set of wrappers without defining a class.
Definition python.h:369

◆ wrapSchema()

void lsst::afw::table::wrapSchema ( WrapperCollection & wrappers)

Definition at line 539 of file _schema.cc.

539 {
540 // We'll add instantiations of Field, Key, and SchemaItem to these private
541 // dicts, and then in schemaContinued.py we'll add them to a TemplateMeta
542 // ABC.
543 auto &mod = wrappers.module;
544 mod.attr("_Field") = py::dict();
545 mod.attr("_Key") = py::dict();
546 mod.attr("_SchemaItem") = py::dict();
547
552 declareSchemaType<float>(wrappers);
561 declareSchemaType<Flag>(wrappers);
562
563 declareSchema(wrappers);
564 declareSubSchema(wrappers);
565}

◆ wrapSchemaMapper()

void lsst::afw::table::wrapSchemaMapper ( WrapperCollection & wrappers)

Definition at line 55 of file _schemaMapper.cc.

55 {
56 wrappers.wrapType(PySchemaMapper(wrappers.module, "SchemaMapper"), [](auto &mod, auto &cls) {
57 cls.def(py::init<>());
58 cls.def(py::init<Schema const &, Schema const &>());
59 cls.def(py::init<Schema const &, bool>(), "input"_a, "shareAliasMap"_a = false);
60
61 cls.def("getInputSchema", &SchemaMapper::getInputSchema);
62 cls.def("getOutputSchema", &SchemaMapper::getOutputSchema);
63 cls.def("editOutputSchema", &SchemaMapper::editOutputSchema,
64 py::return_value_policy::reference_internal);
65 cls.def("addMinimalSchema", &SchemaMapper::addMinimalSchema, "minimal"_a, "doMap"_a = true);
66 cls.def_static("removeMinimalSchema", &SchemaMapper::removeMinimalSchema);
67 cls.def_static("join", &SchemaMapper::join, "inputs"_a, "prefixes"_a = std::vector<std::string>());
68
69 declareSchemaMapperOverloads<std::uint8_t>(cls, "B");
70 declareSchemaMapperOverloads<std::uint16_t>(cls, "U");
71 declareSchemaMapperOverloads<std::int32_t>(cls, "I");
72 declareSchemaMapperOverloads<std::int64_t>(cls, "L");
73 declareSchemaMapperOverloads<float>(cls, "F");
74 declareSchemaMapperOverloads<double>(cls, "D");
75 declareSchemaMapperOverloads<std::string>(cls, "String");
76 declareSchemaMapperOverloads<lsst::geom::Angle>(cls, "Angle");
77 declareSchemaMapperOverloads<lsst::afw::table::Flag>(cls, "Flag");
78 declareSchemaMapperOverloads<lsst::afw::table::Array<std::uint8_t>>(cls, "ArrayB");
79 declareSchemaMapperOverloads<lsst::afw::table::Array<std::uint16_t>>(cls, "ArrayU");
80 declareSchemaMapperOverloads<lsst::afw::table::Array<int>>(cls, "ArrayI");
81 declareSchemaMapperOverloads<lsst::afw::table::Array<float>>(cls, "ArrayF");
82 declareSchemaMapperOverloads<lsst::afw::table::Array<double>>(cls, "ArrayD");
83 });
84}
py::class_< SchemaMapper, std::shared_ptr< SchemaMapper > > PySchemaMapper

◆ wrapSimple()

void lsst::afw::table::wrapSimple ( WrapperCollection & wrappers)

Definition at line 92 of file _simple.cc.

92 {
93 auto clsSimpleRecord = declareSimpleRecord(wrappers);
94 auto clsSimpleTable = declareSimpleTable(wrappers);
95 auto clsSimpleColumnView = table::python::declareColumnView<SimpleRecord>(wrappers, "Simple");
96 auto clsSimpleCatalog = table::python::declareSortedCatalog<SimpleRecord>(wrappers, "Simple");
97
98 clsSimpleRecord.attr("Table") = clsSimpleTable;
99 clsSimpleRecord.attr("ColumnView") = clsSimpleColumnView;
100 clsSimpleRecord.attr("Catalog") = clsSimpleCatalog;
101 clsSimpleTable.attr("Record") = clsSimpleRecord;
102 clsSimpleTable.attr("ColumnView") = clsSimpleColumnView;
103 clsSimpleTable.attr("Catalog") = clsSimpleCatalog;
104 clsSimpleCatalog.attr("Record") = clsSimpleRecord;
105 clsSimpleCatalog.attr("Table") = clsSimpleTable;
106 clsSimpleCatalog.attr("ColumnView") = clsSimpleColumnView;
107}

◆ wrapSlots()

void lsst::afw::table::wrapSlots ( WrapperCollection & wrappers)

Definition at line 70 of file _slots.cc.

70 {
71 // TODO: uncomment once afw.geom uses WrapperCollection
72 // wrappers.addSignatureDependency("lsst.afw.geom.ellipses");
73
74 declareSlotDefinition(wrappers);
78}

◆ wrapSource()

void lsst::afw::table::wrapSource ( WrapperCollection & wrappers)

Definition at line 182 of file _source.cc.

182 {
183 // TODO: uncomment once afw.geom uses WrapperCollection
184 // wrappers.addSignatureDependency("lsst.afw.geom.ellipses");
185
186 // SourceFitsFlags enum values are used as integer masks, so wrap as attributes instead of an enum
187 // static_cast is required to avoid an import error (py::cast and py::int_ do not work by themselves
188 // and are not required with the static_cast)
189 auto &mod = wrappers.module;
190 mod.attr("SOURCE_IO_NO_FOOTPRINTS") = static_cast<int>(SourceFitsFlags::SOURCE_IO_NO_FOOTPRINTS);
191 mod.attr("SOURCE_IO_NO_HEAVY_FOOTPRINTS") =
192 static_cast<int>(SourceFitsFlags::SOURCE_IO_NO_HEAVY_FOOTPRINTS);
193
194 auto clsSourceRecord = declareSourceRecord(wrappers);
195 auto clsSourceTable = declareSourceTable(wrappers);
197 auto clsSourceCatalog = table::python::declareSortedCatalog<SourceRecord>(wrappers, "Source");
198
199 clsSourceRecord.attr("Table") = clsSourceTable;
200 clsSourceRecord.attr("ColumnView") = clsSourceColumnView;
201 clsSourceRecord.attr("Catalog") = clsSourceCatalog;
202 clsSourceTable.attr("Record") = clsSourceRecord;
203 clsSourceTable.attr("ColumnView") = clsSourceColumnView;
204 clsSourceTable.attr("Catalog") = clsSourceCatalog;
205 clsSourceCatalog.attr("Record") = clsSourceRecord;
206 clsSourceCatalog.attr("Table") = clsSourceTable;
207 clsSourceCatalog.attr("ColumnView") = clsSourceColumnView;
208}

◆ wrapWcsUtils()

void lsst::afw::table::wrapWcsUtils ( WrapperCollection & wrappers)

Variable Documentation

◆ _

lsst::afw::table::_

Definition at line 198 of file BaseColumnView.cc.