LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Protected Attributes | 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, const 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) More...
 
 SimpleAstrometryModel (SimpleAstrometryModel &&)=delete
 
SimpleAstrometryModeloperator= (SimpleAstrometryModel const &)=delete
 
SimpleAstrometryModeloperator= (SimpleAstrometryModel &&)=delete
 
const AstrometryMappinggetMapping (CcdImage const &) const override
 Mapping associated to a given CcdImage. More...
 
Eigen::Index assignIndices (std::string const &whatToFit, Eigen::Index firstIndex) override
 Positions the various parameter sets into the parameter vector, starting at firstIndex. More...
 
void offsetParams (Eigen::VectorXd const &delta) override
 Offset the parameters by the provided amounts (by -delta). More...
 
const std::shared_ptr< AstrometryTransform const > getSkyToTangentPlane (CcdImage const &ccdImage) const override
 the mapping of sky coordinates (i.e. More...
 
void freezeErrorTransform () override
 
std::size_t getTotalParameters () const override
 Return the total number of parameters in this model. More...
 
void print (std::ostream &out) const override
 Print a string representation of the contents of this mapping, for debugging. More...
 
AstrometryTransform const & getTransform (CcdImage const &ccdImage) const
 Access to mappings. More...
 
std::shared_ptr< afw::geom::SkyWcsmakeSkyWcs (CcdImage const &ccdImage) const override
 Make a SkyWcs that contains this model. More...
 
 ~SimpleAstrometryModel ()
 
std::size_t getNpar (CcdImage const &ccdImage) const
 Return the number of parameters in the mapping of CcdImage. More...
 
bool validate (CcdImageList const &ccdImageList, int ndof) const
 Return true if this is a "reasonable" model. More...
 

Protected Attributes

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

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,
const std::shared_ptr< ProjectionHandler const >  projectionHandler,
bool  initFromWCS,
unsigned  nNotFit = 0,
unsigned  order = 3 
)

Definition at line 41 of file SimpleAstrometryModel.cc.

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

Definition at line 106 of file SimpleAstrometryModel.h.

106 {};

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 101 of file SimpleAstrometryModel.cc.

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

◆ freezeErrorTransform()

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

Implements lsst::jointcal::AstrometryModel.

Definition at line 123 of file SimpleAstrometryModel.cc.

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

◆ getMapping()

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

Mapping associated to a given CcdImage.

Implements lsst::jointcal::AstrometryModel.

Definition at line 97 of file SimpleAstrometryModel.cc.

97  {
98  return findMapping(ccdImage);
99 }

◆ 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 55 of file AstrometryModel.h.

55 { 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 127 of file SimpleAstrometryModel.cc.

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

◆ getTransform()

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

Access to mappings.

Definition at line 146 of file SimpleAstrometryModel.cc.

146  {
147  return dynamic_cast<const SimplePolyMapping *>(findMapping(ccdImage))->getTransform();
148 }
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 150 of file SimpleAstrometryModel.cc.

150  {
151  auto proj = std::dynamic_pointer_cast<const TanRaDecToPixel>(getSkyToTangentPlane(ccdImage));
152  jointcal::Point tangentPoint(proj->getTangentPoint());
153 
154  auto polyMap = getTransform(ccdImage).toAstMap(ccdImage.getImageFrame());
155  ast::Frame pixelFrame(2, "Domain=PIXELS");
156  ast::Frame iwcFrame(2, "Domain=IWC");
157 
158  // make a basic SkyWcs and extract the IWC portion
159  auto iwcToSkyWcs = afw::geom::makeSkyWcs(
160  geom::Point2D(0, 0), geom::SpherePoint(tangentPoint.x, tangentPoint.y, geom::degrees),
162  auto iwcToSkyMap = iwcToSkyWcs->getFrameDict()->getMapping("PIXELS", "SKY");
163  auto skyFrame = iwcToSkyWcs->getFrameDict()->getFrame("SKY");
164 
165  ast::FrameDict frameDict(pixelFrame, *polyMap, iwcFrame);
166  frameDict.addFrame("IWC", *iwcToSkyMap, *skyFrame);
167  return std::make_shared<afw::geom::SkyWcs>(frameDict);
168 }
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
constexpr AngleUnit degrees
constant with units of degrees
Definition: Angle.h:109

◆ 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 116 of file SimpleAstrometryModel.cc.

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

◆ 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 135 of file SimpleAstrometryModel.cc.

135  {
136  out << "SimpleAstrometryModel: " << _myMap.size() << " mappings" << std::endl;
137  out << *_skyToTangentPlane << std::endl;
138  out << "Sensor to sky transforms:" << std::endl;
139  for (auto &i : _myMap) {
140  out << i.first << std::endl;
141  out << *(i.second) << std::endl;
142  out << std::endl;
143  }
144 }
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 116 of file AstrometryModel.h.


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