LSSTApplications  18.0.0+106,18.0.0+50,19.0.0,19.0.0+1,19.0.0+10,19.0.0+11,19.0.0+13,19.0.0+17,19.0.0+2,19.0.0-1-g20d9b18+6,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+6,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+9,19.0.0-1-g8c57eb9+6,19.0.0-1-gb5175dc+11,19.0.0-1-gdc0e4a7+9,19.0.0-1-ge272bc4+6,19.0.0-1-ge3aa853,19.0.0-10-g448f008b,19.0.0-12-g6990b2c,19.0.0-2-g0d9f9cd+11,19.0.0-2-g3d9e4fb2+11,19.0.0-2-g5037de4,19.0.0-2-gb96a1c4+3,19.0.0-2-gd955cfd+15,19.0.0-3-g2d13df8,19.0.0-3-g6f3c7dc,19.0.0-4-g725f80e+11,19.0.0-4-ga671dab3b+1,19.0.0-4-gad373c5+3,19.0.0-5-ga2acb9c+2,19.0.0-5-gfe96e6c+2,w.2020.01
LSSTDataManagementBasePackage
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...
 
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("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 }
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
Definition: Log.h:648
LOG_LOGGER _log
lsst.logging instance, to be created by a subclass so that messages have consistent name...
table::Key< int > id
Definition: Detector.cc:162
AstrometryTransformLinear normalizeCoordinatesTransform(const Frame &frame)
Returns the transformation that maps the input frame along both axes to [-1,1].
T move(T... args)
T count(T... args)
STL class.
#define LOG_GET(logger)
Returns a Log object associated with logger.
Definition: Log.h:75

◆ 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 104 of file SimpleAstrometryModel.h.

104 {};

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 }
LOG_LOGGER _log
lsst.logging instance, to be created by a subclass so that messages have consistent name...
#define LOGLS_ERROR(logger, message)
Log a error-level message using an iostream-based interface.
Definition: Log.h:668

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

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

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

135  {
136  return dynamic_cast<const SimplePolyMapping *>(findMapping(ccdImage))->getTransform();
137 }
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 139 of file SimpleAstrometryModel.cc.

139  {
140  auto proj = std::dynamic_pointer_cast<const TanRaDecToPixel>(getSkyToTangentPlane(ccdImage));
141  jointcal::Point tangentPoint(proj->getTangentPoint());
142 
143  auto polyMap = getTransform(ccdImage).toAstMap(ccdImage.getImageFrame());
144  ast::Frame pixelFrame(2, "Domain=PIXELS");
145  ast::Frame iwcFrame(2, "Domain=IWC");
146 
147  // make a basic SkyWcs and extract the IWC portion
148  auto iwcToSkyWcs = afw::geom::makeSkyWcs(
149  geom::Point2D(0, 0),
150  geom::SpherePoint(tangentPoint.x, tangentPoint.y, geom::degrees),
152  auto iwcToSkyMap = iwcToSkyWcs->getFrameDict()->getMapping("PIXELS", "SKY");
153  auto skyFrame = iwcToSkyWcs->getFrameDict()->getFrame("SKY");
154 
155  ast::FrameDict frameDict(pixelFrame, *polyMap, iwcFrame);
156  frameDict.addFrame("IWC", *iwcToSkyMap, *skyFrame);
157  return std::make_shared<afw::geom::SkyWcs>(frameDict);
158 }
AstrometryTransform const & getTransform(CcdImage const &ccdImage) const
Access to mappings.
A point in a plane.
Definition: Point.h:36
const std::shared_ptr< AstrometryTransform const > getSkyToTangentPlane(CcdImage const &ccdImage) const override
the mapping of sky coordinates (i.e.
AngleUnit constexpr degrees
constant with units of degrees
Definition: Angle.h:109
Frame is used to represent a coordinate system.
Definition: Frame.h:157
T dynamic_pointer_cast(T... args)
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition: SkyWcs.cc:506
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:138
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 FrameSet whose frames can be referenced by domain name.
Definition: FrameDict.h:67

◆ 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 const &  )
delete

◆ operator=() [2/2]

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

◆ 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 }
LOG_LOGGER _log
lsst.logging instance, to be created by a subclass so that messages have consistent name...
#define LOGLS_ERROR(logger, message)
Log a error-level message using an iostream-based interface.
Definition: Log.h:668
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 107 of file AstrometryModel.h.


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