44Schema getSchema(std::shared_ptr<const BaseRecord>
const record) {
return record->getSchema(); }
47template <
typename Key>
49 return record.get(key);
53template <
typename Key>
54inline typename Key::Value getValue(std::shared_ptr<const BaseRecord>
const record,
Key const &key) {
55 return record->
get(key);
59template <
typename Key>
61 record.set(key, value);
65template <
typename Key>
66inline void setValue(std::shared_ptr<SimpleRecord> record,
Key const &key,
typename Key::Value const &value) {
67 record->set(key, value);
72template <
typename ReferenceCollection>
74 if (refList.empty()) {
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) {
87 auto pixelPos = pixelList.
cbegin();
88 for (
auto &refObj : refList) {
89 setValue(refObj, centroidKey, *pixelPos);
90 setValue(refObj, hasCentroidKey,
true);
96 Eigen::Matrix2f err) {
98 return Eigen::Matrix2f::Constant(NAN);
104 const static double scale = 1.0 / 3600.0;
105 const static Eigen::Matrix2d cdMatrix{{scale, 0}, {0, scale}};
109 auto measurementToLocalGnomonic = wcs.
getTransform()->then(*localGnomonicWcs->getTransform()->inverted());
111 Eigen::Matrix2d localMatrix = measurementToLocalGnomonic->getJacobian(center);
112 Eigen::Matrix2f d = localMatrix.cast<
float>() * scale * (
lsst::geom::PI / 180.0);
114 Eigen::Matrix2f skyCov = d * err * d.transpose();
121template <
typename SourceCollection>
123 if (sourceList.empty()) {
126 auto const schema = getSchema(sourceList[0]);
127 Point2DKey const centroidKey(schema[
"slot_Centroid"]);
129 CoordKey const coordKey(schema[
"coord"]);
131 pixelList.
reserve(sourceList.size());
133 skyErrList.
reserve(sourceList.size());
135 for (
auto const &source : sourceList) {
138 if (include_covariance) {
139 auto err = getValue(source, centroidErrKey);
146 auto skyCoord = skyList.
cbegin();
147 auto skyErr = skyErrList.
cbegin();
148 for (
auto &source : sourceList) {
149 setValue(source, coordKey, *skyCoord);
150 if (include_covariance) {
152 setValue(source, coordErrKey, *skyErr);
164 bool include_covariance);
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
lsst::geom::SpherePoint pixelToSky(lsst::geom::Point2D const &pixel) const
Compute sky position(s) from pixel position(s)
std::shared_ptr< const TransformPoint2ToSpherePoint > getTransform() const
Get a TransformPoint2ToSpherePoint that transforms pixels to sky in the forward direction and sky to ...
lsst::geom::Point2D skyToPixel(lsst::geom::SpherePoint const &sky) const
Compute pixel position(s) from sky position(s)
Base class for all records.
A FunctorKey used to get or set celestial coordinates from a pair of lsst::geom::Angle keys.
CovarianceMatrixKey< float, 2 > ErrorKey
static ErrorKey getErrorKey(Schema const &schema)
A class used as a handle to a particular field in a table.
Defines the fields and offsets for a table.
Record class that must contain a unique ID field and a celestial coordinate field.
T emplace_back(T... args)
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
SortedCatalogT< SimpleRecord > SimpleCatalog
void updateRefCentroids(geom::SkyWcs const &wcs, ReferenceCollection &refList)
Update centroids in a collection of reference objects.
Eigen::Matrix2f calculateCoordCovariance(geom::SkyWcs const &wcs, lsst::geom::Point2D center, Eigen::Matrix2f err)
Calculate covariance for sky coordinates.
void updateSourceCoords(geom::SkyWcs const &wcs, SourceCollection &sourceList, bool include_covariance=true)
Update sky coordinates in a collection of source objects.
SortedCatalogT< SourceRecord > SourceCatalog
PointKey< double > Point2DKey
Point< double, 2 > Point2D
T Value
the type returned by BaseRecord::get