LSSTApplications  11.0-24-g0a022a1,15.0+8,15.0+9,15.0-1-g19261fa+1,15.0-1-g1eca518+10,15.0-1-g60afb23+8,15.0-1-g615e0bb,15.0-1-g6668b0b+5,15.0-1-g788a293+8,15.0-1-ga91101e+8,15.0-1-gae1598d+7,15.0-1-gc45031d+10,15.0-1-gd076f1f+8,15.0-1-gdf18595+1,15.0-1-gf4f1c34+7,15.0-18-g5f205baaa,15.0-2-g100d730+1,15.0-2-g18f3f21,15.0-2-g35685a8+1,15.0-2-g947dc0d+10,15.0-2-ge3d7f4b+1,15.0-2-gf38729e,15.0-3-g150fc43+9,15.0-3-g6f085af+1,15.0-3-g9103c06+7,15.0-3-ga03b4ca+10,15.0-3-gaec6799+5,15.0-3-gb7a597c+8,15.0-3-ge6a6747,15.0-4-g45f767a+7,15.0-4-g654b129+6,15.0-4-gff20472+11,15.0-5-g389937dc+6,15.0-5-ga70c291+1,15.0-6-gbad5ef12+1,15.0-6-ge2d9597+10
LSSTDataManagementBasePackage
Public Member Functions | List of all members
lsst::jointcal::SimplePolyModel Class Reference

this is the model used to fit independent CCDs, meaning that there is no instrument model. More...

#include <SimplePolyModel.h>

Inheritance diagram for lsst::jointcal::SimplePolyModel:
lsst::jointcal::AstrometryModel

Public Member Functions

 SimplePolyModel (CcdImageList const &ccdImageList, ProjectionHandler const *projectionHandler, bool initFromWCS, unsigned nNotFit=0, unsigned degree=3)
 Sky2TP is just a name, it can be anything. More...
 
 SimplePolyModel (SimplePolyModel const &)=delete
 No copy or move: there is only ever one instance of a given model (i.e.. per ccd+visit) More...
 
 SimplePolyModel (SimplePolyModel &&)=delete
 
SimplePolyModeloperator= (SimplePolyModel const &)=delete
 
SimplePolyModeloperator= (SimplePolyModel &&)=delete
 
const MappinggetMapping (CcdImage const &) const
 Mapping associated to a given CcdImage. More...
 
unsigned assignIndices (unsigned firstIndex, std::string const &whatToFit)
 Positions the various parameter sets into the parameter vector, starting at firstIndex. More...
 
void offsetParams (Eigen::VectorXd const &delta)
 Offset the parameters by the provided amounts. More...
 
const GtransfogetSky2TP (CcdImage const &ccdImage) const
 the mapping of sky coordinates (i.e. More...
 
virtual void freezeErrorTransform ()
 
Gtransfo const & getTransfo (CcdImage const &ccdImage) const
 Access to mappings. More...
 
std::shared_ptr< TanSipPix2RaDecproduceSipWcs (CcdImage const &ccdImage) const
 Cook up a SIP WCS. More...
 
 ~SimplePolyModel ()
 

Detailed Description

this is the model used to fit independent CCDs, meaning that there is no instrument model.

Definition at line 29 of file SimplePolyModel.h.

Constructor & Destructor Documentation

◆ SimplePolyModel() [1/3]

lsst::jointcal::SimplePolyModel::SimplePolyModel ( CcdImageList const &  ccdImageList,
ProjectionHandler const *  projectionHandler,
bool  initFromWCS,
unsigned  nNotFit = 0,
unsigned  degree = 3 
)

Sky2TP is just a name, it can be anything.

Definition at line 22 of file SimplePolyModel.cc.

24  : _sky2TP(projectionHandler)
25 
26 {
27  // from datacards (or default)
28  // unsigned degree = distortionDegree;
29  unsigned count = 0;
30 
31  for (auto i = ccdImageList.cbegin(); i != ccdImageList.cend(); ++i, ++count) {
32  const CcdImage &im = **i;
33  if (count < nNotFit) {
34  std::unique_ptr<SimpleGtransfoMapping> id(new SimpleGtransfoMapping(GtransfoIdentity()));
35  id->setIndex(-1); // non sense, because it has no parameters
36  _myMap[&im] = std::move(id);
37  } else
38  // Given how AssignIndices works, only the SimplePolyMapping's
39  // will actually be fitted, as nNotFit requests.
40  {
41  /* first check that there are enough measurements for the
42  requested polynomial degree */
43  size_t nObj = im.getCatalogForFit().size();
44  if (nObj == 0) {
45  LOGLS_WARN(_log, "Empty catalog from image: " << im.getName());
46  continue;
47  }
48  GtransfoPoly pol(degree);
49  if (pol.getDegree() > 0) // if not, it cannot be decreased
50  while (unsigned(pol.getNpar()) > 2 * nObj) pol.setDegree(pol.getDegree() - 1);
51  /* We have to center and normalize the coordinates so that
52  the fit matrix is not too ill-conditionned. Basically, x
53  and y in pixels are mapped to [-1,1]. When the
54  transformation of SimplePolyMapping transformation is
55  accessed, the combination of the normalization and the
56  fitted transformation is returned, so that the trick
57  remains hidden
58  */
59  const Frame &frame = im.getImageFrame();
60  GtransfoLin shiftAndNormalize = normalizeCoordinatesTransfo(frame);
61  if (initFromWcs) {
62  pol = GtransfoPoly(im.getPix2TangentPlane(), frame, degree);
63  pol = pol * shiftAndNormalize.invert();
64  }
65  _myMap[&im] =
66  std::unique_ptr<SimpleGtransfoMapping>(new SimplePolyMapping(shiftAndNormalize, pol));
67  }
68  }
69 }
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
Definition: Log.h:657
GtransfoLin normalizeCoordinatesTransfo(const Frame &frame)
Returns the transformation that maps the input frame along both axes to [-1,1].
Definition: Gtransfo.cc:725
table::Key< table::Array< int > > degree
Definition: PsfexPsf.cc:346
T move(T... args)
T count(T... args)
int id
Definition: CR.cc:155

◆ SimplePolyModel() [2/3]

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

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

◆ SimplePolyModel() [3/3]

lsst::jointcal::SimplePolyModel::SimplePolyModel ( SimplePolyModel &&  )
delete

◆ ~SimplePolyModel()

lsst::jointcal::SimplePolyModel::~SimplePolyModel ( )
inline

Definition at line 64 of file SimplePolyModel.h.

64 {};

Member Function Documentation

◆ assignIndices()

unsigned lsst::jointcal::SimplePolyModel::assignIndices ( unsigned  firstIndex,
std::string const &  whatToFit 
)
virtual

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

Implements lsst::jointcal::AstrometryModel.

Definition at line 79 of file SimplePolyModel.cc.

79  {
80  if (whatToFit.find("Distortions") == std::string::npos) {
81  LOGLS_ERROR(_log, "AssignIndices was called and Distortions is *not* in whatToFit.");
82  return 0;
83  }
84  unsigned index = firstIndex;
85  for (auto i = _myMap.begin(); i != _myMap.end(); ++i) {
86  SimplePolyMapping *p = dynamic_cast<SimplePolyMapping *>(&*(i->second));
87  if (!p) continue; // it should be GtransfoIdentity
88  p->setIndex(index);
89  index += p->getNpar();
90  }
91  return index;
92 }
T end(T... args)
T begin(T... args)
#define LOGLS_ERROR(logger, message)
Log a error-level message using an iostream-based interface.
Definition: Log.h:677

◆ freezeErrorTransform()

void lsst::jointcal::SimplePolyModel::freezeErrorTransform ( )
virtual

Implements lsst::jointcal::AstrometryModel.

Definition at line 101 of file SimplePolyModel.cc.

101  {
102  for (auto i = _myMap.begin(); i != _myMap.end(); ++i) i->second->freezeErrorTransform();
103 }
T end(T... args)
T begin(T... args)

◆ getMapping()

const Mapping * lsst::jointcal::SimplePolyModel::getMapping ( CcdImage const &  ) const
virtual

Mapping associated to a given CcdImage.

Implements lsst::jointcal::AstrometryModel.

Definition at line 71 of file SimplePolyModel.cc.

71  {
72  mapType::const_iterator i = _myMap.find(&ccdImage);
73  if (i == _myMap.cend())
74  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
75  "SimplePolyModel::GetMapping, never heard of CcdImage " + ccdImage.getName());
76  return (i->second.get());
77 }
T cend(T... args)
T find(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46

◆ getSky2TP()

const Gtransfo* lsst::jointcal::SimplePolyModel::getSky2TP ( CcdImage const &  ccdImage) const
inlinevirtual

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

54 { return _sky2TP->getSky2TP(ccdImage); }
virtual const Gtransfo * getSky2TP(const CcdImage &ccdImage) const =0

◆ getTransfo()

const Gtransfo & lsst::jointcal::SimplePolyModel::getTransfo ( CcdImage const &  ccdImage) const

Access to mappings.

Definition at line 105 of file SimplePolyModel.cc.

105  {
106  // return GetMapping(ccdImage)->Transfo(); // cannot do that
107  auto p = _myMap.find(&ccdImage);
108  if (p == _myMap.end())
109  throw LSST_EXCEPT(pex::exceptions::InvalidParameterError,
110  "SimplePolyModel::getTransfo, never heard of CcdImage " + ccdImage.getName());
111  return p->second->getTransfo();
112 }
T end(T... args)
T find(T... args)
#define LSST_EXCEPT(type,...)
Create an exception with a given type and message and optionally other arguments (dependent on the ty...
Definition: Exception.h:46

◆ offsetParams()

void lsst::jointcal::SimplePolyModel::offsetParams ( Eigen::VectorXd const &  delta)
virtual

Offset the parameters by the provided amounts.

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

Implements lsst::jointcal::AstrometryModel.

Definition at line 94 of file SimplePolyModel.cc.

94  {
95  for (auto &i : _myMap) {
96  auto mapping = i.second.get();
97  mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
98  }
99 }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ produceSipWcs()

std::shared_ptr< TanSipPix2RaDec > lsst::jointcal::SimplePolyModel::produceSipWcs ( CcdImage const &  ccdImage) const
virtual

Cook up a SIP WCS.

Implements lsst::jointcal::AstrometryModel.

Definition at line 114 of file SimplePolyModel.cc.

114  {
115  const GtransfoPoly &pix2Tp = dynamic_cast<const GtransfoPoly &>(getTransfo(ccdImage));
116  const TanRaDec2Pix *proj = dynamic_cast<const TanRaDec2Pix *>(getSky2TP(ccdImage));
117  if (!proj) return nullptr;
118 
119  const GtransfoLin &projLinPart = proj->getLinPart(); // should be the identity, but who knows? So, let us
120  // incorporate it into the pix2TP part.
121  GtransfoPoly wcsPix2Tp = GtransfoPoly(projLinPart.invert()) * pix2Tp;
122 
123  // compute a decent approximation, if higher order corrections get ignored
124  GtransfoLin cdStuff = wcsPix2Tp.linearApproximation(ccdImage.getImageFrame().getCenter());
125 
126  // wcsPix2TP = cdStuff*sip , so
127  GtransfoPoly sip = GtransfoPoly(cdStuff.invert()) * wcsPix2Tp;
128  Point tangentPoint(proj->getTangentPoint());
129  return std::make_shared<TanSipPix2RaDec>(cdStuff, tangentPoint, &sip);
130 }
const Gtransfo * getSky2TP(CcdImage const &ccdImage) const
the mapping of sky coordinates (i.e.
Gtransfo const & getTransfo(CcdImage const &ccdImage) const
Access to mappings.

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