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
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
lsst::jointcal::SimpleAstrometryModel Class Reference

A model where there is one independent transform per CcdImage. More...

#include <SimpleAstrometryModel.h>

Inheritance diagram for lsst::jointcal::SimpleAstrometryModel:
lsst::jointcal::AstrometryModel

Public Member Functions

 SimpleAstrometryModel (CcdImageList const &ccdImageList, std::shared_ptr< ProjectionHandler const > projectionHandler, bool initFromWCS, unsigned nNotFit=0, unsigned order=3)
 
 SimpleAstrometryModel (SimpleAstrometryModel const &)=delete
 No copy or move: there is only ever one instance of a given model (i.e.. per ccd+visit)
 
 SimpleAstrometryModel (SimpleAstrometryModel &&)=delete
 
SimpleAstrometryModeloperator= (SimpleAstrometryModel const &)=delete
 
SimpleAstrometryModeloperator= (SimpleAstrometryModel &&)=delete
 
const AstrometryMappinggetMapping (CcdImage const &) const override
 Mapping associated to a given CcdImage.
 
Eigen::Index assignIndices (std::string const &whatToFit, Eigen::Index firstIndex) override
 Positions the various parameter sets into the parameter vector, starting at firstIndex.
 
void offsetParams (Eigen::VectorXd const &delta) override
 Offset the parameters by the provided amounts (by -delta).
 
const std::shared_ptr< AstrometryTransform const > getSkyToTangentPlane (CcdImage const &ccdImage) const override
 the mapping of sky coordinates (i.e.
 
void freezeErrorTransform () override
 
std::size_t getTotalParameters () const override
 Return the total number of parameters in this model.
 
void print (std::ostream &out) const override
 Print a string representation of the contents of this mapping, for debugging.
 
AstrometryTransform const & getTransform (CcdImage const &ccdImage) const
 Access to mappings.
 
std::shared_ptr< afw::geom::SkyWcsmakeSkyWcs (CcdImage const &ccdImage) const override
 Make a SkyWcs that contains this model.
 
 ~SimpleAstrometryModel ()=default
 
std::size_t getNpar (CcdImage const &ccdImage) const
 Return the number of parameters in the mapping of CcdImage.
 
bool validate (CcdImageList const &ccdImageList, int ndof) const
 Return true if this is a "reasonable" model.
 

Protected Attributes

LOG_LOGGER _log
 lsst.logging instance, to be created by a subclass so that messages have consistent name.
 

Private Member Functions

AstrometryMappingfindMapping (CcdImage const &ccdImage) const override
 Return a pointer to the mapping associated with this ccdImage.
 

Detailed Description

A model where there is one independent transform per CcdImage.

This modeling of distortions can even accommodate images set mixing instruments

Parameters
ccdImageListThe exposures that will be fit.
projectionHandlerThe projection from "Sky" (where the "true" coordinates live) to "Tangent Plane" (where the fitting occurs).
initFromWCSInitialize the model parameters from the original exposure Wcs parameters?
nNotFitHow many exposure to hold fixed and not be fit? (the first n will be selected) .
orderThe polynomial order of each exposure's pixel-tangent plane mapping.

Definition at line 62 of file SimpleAstrometryModel.h.

Constructor & Destructor Documentation

◆ SimpleAstrometryModel() [1/3]

lsst::jointcal::SimpleAstrometryModel::SimpleAstrometryModel ( CcdImageList const & ccdImageList,
std::shared_ptr< ProjectionHandler const > projectionHandler,
bool initFromWCS,
unsigned nNotFit = 0,
unsigned order = 3 )

Definition at line 42 of file SimpleAstrometryModel.cc.

45 : AstrometryModel(LOG_GET("lsst.jointcal.SimpleAstrometryModel")),
46 _skyToTangentPlane(std::move(projectionHandler))
47
48{
50
51 for (auto i = ccdImageList.cbegin(); i != ccdImageList.cend(); ++i, ++count) {
52 const CcdImage &im = **i;
53 if (count < nNotFit) {
55 new SimpleAstrometryMapping(AstrometryTransformIdentity()));
56 id->setIndex(-1); // non sense, because it has no parameters
57 _myMap[im.getHashKey()] = std::move(id);
58 } else
59 // Given how AssignIndices works, only the SimplePolyMappings
60 // will actually be fitted, as nNotFit requests.
61 {
62 // first check that there are enough measurements for the requested polynomial order.
63 size_t nObj = im.getCatalogForFit().size();
64 if (nObj == 0) {
65 LOGLS_WARN(_log, "Empty catalog from image: " << im.getName());
66 continue;
67 }
68 AstrometryTransformPolynomial pol(order);
69 if (pol.getOrder() > 0) // if not, it cannot be decreased
70 {
71 while (pol.getNpar() > 2 * nObj) {
72 LOGLS_WARN(_log, "Reducing polynomial order from "
73 << pol.getOrder() << ", due to too few sources (" << nObj
74 << " vs. " << pol.getNpar() << " parameters)");
75 pol.setOrder(pol.getOrder() - 1);
76 }
77 }
78 /* We have to center and normalize the coordinates so that
79 the fit matrix is not too ill-conditionned. Basically, x
80 and y in pixels are mapped to [-1,1]. When the
81 transformation of SimplePolyMapping transformation is
82 accessed, the combination of the normalization and the
83 fitted transformation is returned, so that the trick
84 remains hidden
85 */
86 const Frame &frame = im.getImageFrame();
87 AstrometryTransformLinear shiftAndNormalize = normalizeCoordinatesTransform(frame);
88 if (initFromWcs) {
89 pol = AstrometryTransformPolynomial(im.getPixelToTangentPlane().get(), frame, order);
90 pol = pol * shiftAndNormalize.inverted();
91 }
92 _myMap[im.getHashKey()] =
93 std::unique_ptr<SimpleAstrometryMapping>(new SimplePolyMapping(shiftAndNormalize, pol));
94 }
95 }
96}
table::Key< int > id
Definition Detector.cc:162
#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
LOG_LOGGER _log
lsst.logging instance, to be created by a subclass so that messages have consistent name.
T count(T... args)
T move(T... args)
AstrometryTransformLinear normalizeCoordinatesTransform(const Frame &frame)
Returns the transformation that maps the input frame along both axes to [-1,1].
table::Key< int > order

◆ SimpleAstrometryModel() [2/3]

lsst::jointcal::SimpleAstrometryModel::SimpleAstrometryModel ( SimpleAstrometryModel const & )
delete

No copy or move: there is only ever one instance of a given model (i.e.. per ccd+visit)

◆ SimpleAstrometryModel() [3/3]

lsst::jointcal::SimpleAstrometryModel::SimpleAstrometryModel ( SimpleAstrometryModel && )
delete

◆ ~SimpleAstrometryModel()

lsst::jointcal::SimpleAstrometryModel::~SimpleAstrometryModel ( )
default

Member Function Documentation

◆ assignIndices()

Eigen::Index lsst::jointcal::SimpleAstrometryModel::assignIndices ( std::string const & whatToFit,
Eigen::Index firstIndex )
overridevirtual

Positions the various parameter sets into the parameter vector, starting at firstIndex.

Implements lsst::jointcal::AstrometryModel.

Definition at line 102 of file SimpleAstrometryModel.cc.

102 {
103 if (whatToFit.find("Distortions") == std::string::npos) {
104 LOGLS_ERROR(_log, "AssignIndices was called and Distortions is *not* in whatToFit.");
105 return 0;
106 }
107 Eigen::Index index = firstIndex;
108 for (auto & i : _myMap) {
109 auto *p = dynamic_cast<SimplePolyMapping *>(&*(i.second));
110 if (!p) continue; // it should be AstrometryTransformIdentity
111 p->setIndex(index);
112 index += p->getNpar();
113 }
114 return index;
115}
#define LOGLS_ERROR(logger, message)
Log a error-level message using an iostream-based interface.
Definition Log.h:679

◆ findMapping()

AstrometryMapping * lsst::jointcal::SimpleAstrometryModel::findMapping ( CcdImage const & ccdImage) const
overrideprivatevirtual

Return a pointer to the mapping associated with this ccdImage.

Implements lsst::jointcal::AstrometryModel.

Definition at line 171 of file SimpleAstrometryModel.cc.

171 {
172 auto i = _myMap.find(ccdImage.getHashKey());
173 if (i == _myMap.end())
174 throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
175 "SimpleAstrometryModel cannot find CcdImage " + ccdImage.getName());
176 return i->second.get();
177}
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Definition Exception.h:48

◆ freezeErrorTransform()

void lsst::jointcal::SimpleAstrometryModel::freezeErrorTransform ( )
overridevirtual

Implements lsst::jointcal::AstrometryModel.

Definition at line 124 of file SimpleAstrometryModel.cc.

124 {
125 for (auto &i : _myMap) i.second->freezeErrorTransform();
126}

◆ getMapping()

const AstrometryMapping * lsst::jointcal::SimpleAstrometryModel::getMapping ( CcdImage const & ) const
overridevirtual

Mapping associated to a given CcdImage.

Implements lsst::jointcal::AstrometryModel.

Definition at line 98 of file SimpleAstrometryModel.cc.

98 {
99 return findMapping(ccdImage);
100}
AstrometryMapping * findMapping(CcdImage const &ccdImage) const override
Return a pointer to the mapping associated with this ccdImage.

◆ getNpar()

std::size_t lsst::jointcal::AstrometryModel::getNpar ( CcdImage const & ccdImage) const
inlineinherited

Return the number of parameters in the mapping of CcdImage.

Definition at line 56 of file AstrometryModel.h.

56{ return findMapping(ccdImage)->getNpar(); }
virtual std::size_t getNpar() const =0
Number of parameters in total.
virtual AstrometryMapping * findMapping(CcdImage const &ccdImage) const =0
Return a pointer to the mapping associated with this ccdImage.

◆ getSkyToTangentPlane()

const std::shared_ptr< AstrometryTransform const > lsst::jointcal::SimpleAstrometryModel::getSkyToTangentPlane ( CcdImage const & ccdImage) const
inlineoverridevirtual

the mapping of sky coordinates (i.e.

the coordinate system in which fitted stars are reported) onto the Tangent plane (into which the pixel coordinates are transformed)

Implements lsst::jointcal::AstrometryModel.

Definition at line 87 of file SimpleAstrometryModel.h.

88 {
89 return _skyToTangentPlane->getSkyToTangentPlane(ccdImage);
90 }

◆ getTotalParameters()

std::size_t lsst::jointcal::SimpleAstrometryModel::getTotalParameters ( ) const
overridevirtual

Return the total number of parameters in this model.

Implements lsst::jointcal::AstrometryModel.

Definition at line 128 of file SimpleAstrometryModel.cc.

128 {
129 std::size_t total = 0;
130 for (auto &i : _myMap) {
131 total += i.second->getNpar();
132 }
133 return total;
134}

◆ getTransform()

const AstrometryTransform & lsst::jointcal::SimpleAstrometryModel::getTransform ( CcdImage const & ccdImage) const

Access to mappings.

Definition at line 147 of file SimpleAstrometryModel.cc.

147 {
148 return dynamic_cast<const SimplePolyMapping *>(findMapping(ccdImage))->getTransform();
149}
AstrometryTransform const & getTransform(CcdImage const &ccdImage) const
Access to mappings.

◆ makeSkyWcs()

std::shared_ptr< afw::geom::SkyWcs > lsst::jointcal::SimpleAstrometryModel::makeSkyWcs ( CcdImage const & ccdImage) const
overridevirtual

Make a SkyWcs that contains this model.

Parameters
ccdImageThe exposure to create the SkyWcs for.
Returns
SkyWcs containing this model.

Implements lsst::jointcal::AstrometryModel.

Definition at line 151 of file SimpleAstrometryModel.cc.

151 {
152 auto proj = std::dynamic_pointer_cast<const TanRaDecToPixel>(getSkyToTangentPlane(ccdImage));
153 jointcal::Point tangentPoint(proj->getTangentPoint());
154
155 auto polyMap = getTransform(ccdImage).toAstMap(ccdImage.getImageFrame());
156 ast::Frame pixelFrame(2, "Domain=PIXELS");
157 ast::Frame iwcFrame(2, "Domain=IWC");
158
159 // make a basic SkyWcs and extract the IWC portion
160 auto iwcToSkyWcs = afw::geom::makeSkyWcs(
161 geom::Point2D(0, 0), geom::SpherePoint(tangentPoint.x, tangentPoint.y, geom::degrees),
163 auto iwcToSkyMap = iwcToSkyWcs->getFrameDict()->getMapping("PIXELS", "SKY");
164 auto skyFrame = iwcToSkyWcs->getFrameDict()->getFrame("SKY");
165
166 ast::FrameDict frameDict(pixelFrame, *polyMap, iwcFrame);
167 frameDict.addFrame("IWC", *iwcToSkyMap, *skyFrame);
168 return std::make_shared<afw::geom::SkyWcs>(frameDict);
169}
A FrameSet whose frames can be referenced by domain name.
Definition FrameDict.h:67
Frame is used to represent a coordinate system.
Definition Frame.h:157
Point in an unspecified spherical coordinate system.
Definition SpherePoint.h:57
virtual std::shared_ptr< ast::Mapping > toAstMap(jointcal::Frame const &domain) const
Create an equivalent AST mapping for this transformation, including an analytic inverse if possible.
A point in a plane.
Definition Point.h:37
const std::shared_ptr< AstrometryTransform const > getSkyToTangentPlane(CcdImage const &ccdImage) const override
the mapping of sky coordinates (i.e.
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition SkyWcs.cc:521
Eigen::Matrix2d makeCdMatrix(lsst::geom::Angle const &scale, lsst::geom::Angle const &orientation=0 *lsst::geom::degrees, bool flipX=false)
Make a WCS CD matrix.
Definition SkyWcs.cc:133
AngleUnit constexpr degrees
constant with units of degrees
Definition Angle.h:110

◆ offsetParams()

void lsst::jointcal::SimpleAstrometryModel::offsetParams ( Eigen::VectorXd const & delta)
overridevirtual

Offset the parameters by the provided amounts (by -delta).

The shifts are applied according to the indices given in assignIndices.

Parameters
[in]deltavector of offsets to apply

Implements lsst::jointcal::AstrometryModel.

Definition at line 117 of file SimpleAstrometryModel.cc.

117 {
118 for (auto &i : _myMap) {
119 auto mapping = i.second.get();
120 mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
121 }
122}

◆ operator=() [1/2]

SimpleAstrometryModel & lsst::jointcal::SimpleAstrometryModel::operator= ( SimpleAstrometryModel && )
delete

◆ operator=() [2/2]

SimpleAstrometryModel & lsst::jointcal::SimpleAstrometryModel::operator= ( SimpleAstrometryModel const & )
delete

◆ print()

void lsst::jointcal::SimpleAstrometryModel::print ( std::ostream & out) const
overridevirtual

Print a string representation of the contents of this mapping, for debugging.

This string representation can be very verbose, as it contains all of the parameters of all of the transforms in this model.

Implements lsst::jointcal::AstrometryModel.

Definition at line 136 of file SimpleAstrometryModel.cc.

136 {
137 out << "SimpleAstrometryModel: " << _myMap.size() << " mappings" << std::endl;
138 out << *_skyToTangentPlane << std::endl;
139 out << "Sensor to sky transforms:" << std::endl;
140 for (auto &i : _myMap) {
141 out << i.first << std::endl;
142 out << *(i.second) << std::endl;
143 out << std::endl;
144 }
145}
T endl(T... args)

◆ validate()

bool lsst::jointcal::AstrometryModel::validate ( CcdImageList const & ccdImageList,
int ndof ) const
inherited

Return true if this is a "reasonable" model.

Parameters
ccdImageListThe ccdImages to test the model validity on.
ndofThe number of degrees of freedom in the fit, e.g. from Fitterbase.computeChi2().
Returns
True if the model is valid on all ccdImages.

Definition at line 30 of file AstrometryModel.cc.

30 {
31 bool check = true;
32 if (ndof < 0) {
33 check &= false;
34 LOGLS_ERROR(_log, "This model only has "
35 << ndof << " degrees of freedom, with " << getTotalParameters()
36 << " total parameters. Reduce the model complexity (e.g. polynomial order)"
37 " to better match the number of measured sources.");
38 }
39 return check;
40}
virtual std::size_t getTotalParameters() const =0
Return the total number of parameters in this model.

Member Data Documentation

◆ _log

LOG_LOGGER lsst::jointcal::AstrometryModel::_log
protectedinherited

lsst.logging instance, to be created by a subclass so that messages have consistent name.

Definition at line 117 of file AstrometryModel.h.


The documentation for this class was generated from the following files: