LSSTApplications  19.0.0-14-gb0260a2+72efe9b372,20.0.0+7927753e06,20.0.0+8829bf0056,20.0.0+995114c5d2,20.0.0+b6f4b2abd1,20.0.0+bddc4f4cbe,20.0.0-1-g253301a+8829bf0056,20.0.0-1-g2b7511a+0d71a2d77f,20.0.0-1-g5b95a8c+7461dd0434,20.0.0-12-g321c96ea+23efe4bbff,20.0.0-16-gfab17e72e+fdf35455f6,20.0.0-2-g0070d88+ba3ffc8f0b,20.0.0-2-g4dae9ad+ee58a624b3,20.0.0-2-g61b8584+5d3db074ba,20.0.0-2-gb780d76+d529cf1a41,20.0.0-2-ged6426c+226a441f5f,20.0.0-2-gf072044+8829bf0056,20.0.0-2-gf1f7952+ee58a624b3,20.0.0-20-geae50cf+e37fec0aee,20.0.0-25-g3dcad98+544a109665,20.0.0-25-g5eafb0f+ee58a624b3,20.0.0-27-g64178ef+f1f297b00a,20.0.0-3-g4cc78c6+e0676b0dc8,20.0.0-3-g8f21e14+4fd2c12c9a,20.0.0-3-gbd60e8c+187b78b4b8,20.0.0-3-gbecbe05+48431fa087,20.0.0-38-ge4adf513+a12e1f8e37,20.0.0-4-g97dc21a+544a109665,20.0.0-4-gb4befbc+087873070b,20.0.0-4-gf910f65+5d3db074ba,20.0.0-5-gdfe0fee+199202a608,20.0.0-5-gfbfe500+d529cf1a41,20.0.0-6-g64f541c+d529cf1a41,20.0.0-6-g9a5b7a1+a1cd37312e,20.0.0-68-ga3f3dda+5fca18c6a4,20.0.0-9-g4aef684+e18322736b,w.2020.45
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...
 
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("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 }

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

◆ 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(); }

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

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

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

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

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:
lsst::geom::degrees
constexpr AngleUnit degrees
constant with units of degrees
Definition: Angle.h:109
std::move
T move(T... args)
lsst::jointcal::AstrometryModel::findMapping
virtual AstrometryMapping * findMapping(CcdImage const &ccdImage) const =0
Return a pointer to the mapping associated with this ccdImage.
LOG_GET
#define LOG_GET(logger)
Definition: Log.h:75
ast::FrameDict
A FrameSet whose frames can be referenced by domain name.
Definition: FrameDict.h:67
LOGLS_ERROR
#define LOGLS_ERROR(logger, message)
Definition: Log.h:668
lsst::jointcal::AstrometryModel::AstrometryModel
AstrometryModel(LOG_LOGGER log)
Definition: AstrometryModel.h:52
LOGLS_WARN
#define LOGLS_WARN(logger, message)
Definition: Log.h:648
ast::Frame
Frame is used to represent a coordinate system.
Definition: Frame.h:157
id
table::Key< int > id
Definition: Detector.cc:162
lsst::jointcal::normalizeCoordinatesTransform
AstrometryTransformLinear normalizeCoordinatesTransform(const Frame &frame)
Returns the transformation that maps the input frame along both axes to [-1,1].
Definition: AstrometryTransform.cc:833
lsst::jointcal::AstrometryModel::_log
LOG_LOGGER _log
lsst.logging instance, to be created by a subclass so that messages have consistent name.
Definition: AstrometryModel.h:116
lsst::jointcal::AstrometryModel::getTotalParameters
virtual std::size_t getTotalParameters() const =0
Return the total number of parameters in this model.
std::endl
T endl(T... args)
lsst::afw::geom::makeCdMatrix
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
lsst::geom::Point< double, 2 >
lsst::jointcal::SimpleAstrometryModel::getSkyToTangentPlane
const std::shared_ptr< AstrometryTransform const > getSkyToTangentPlane(CcdImage const &ccdImage) const override
the mapping of sky coordinates (i.e.
Definition: SimpleAstrometryModel.h:87
std::count
T count(T... args)
lsst::jointcal::Point
A point in a plane.
Definition: Point.h:36
lsst::afw::geom::makeSkyWcs
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition: SkyWcs.cc:526
std::size_t
lsst::geom::SpherePoint
Point in an unspecified spherical coordinate system.
Definition: SpherePoint.h:57
std::unique_ptr
STL class.
lsst::jointcal::AstrometryTransform::toAstMap
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.
Definition: AstrometryTransform.h:189
lsst::jointcal::SimpleAstrometryModel::getTransform
AstrometryTransform const & getTransform(CcdImage const &ccdImage) const
Access to mappings.
Definition: SimpleAstrometryModel.cc:146
lsst::jointcal::AstrometryMapping::getNpar
virtual std::size_t getNpar() const =0
Number of parameters in total.