17 LOG_LOGGER _log =
LOG_GET(
"jointcal.ConstrainedPolyModel");
30 ConstrainedPolyModel::ConstrainedPolyModel(
CcdImageList const &ccdImageList,
32 unsigned nNotFit,
int chipDegree,
int visitDegree)
33 : _sky2TP(projectionHandler)
37 for (
auto &
ccdImage : ccdImageList) {
41 auto visitp = _visitMap.
find(visit);
42 if (visitp == _visitMap.
end()) {
43 if (_visitMap.
size() == 0) {
51 auto chipp = _chipMap.
find(chip);
52 if (chipp == _chipMap.
end()) {
67 for (
auto &
ccdImage : ccdImageList) {
73 if (_chipMap.
find(chip) == _chipMap.
end()) {
74 LOGLS_WARN(_log,
"Chip " << chip <<
" is missing in the reference exposure, expect troubles.");
82 LOGLS_INFO(_log,
"Constructor got " << _chipMap.
size() <<
" chip mappings and " << _visitMap.
size()
83 <<
" visit mappings.");
89 mappingMapType::const_iterator i = _mappings.
find(&ccdImage);
90 if (i == _mappings.
end())
return nullptr;
91 return (i->second.get());
99 unsigned index = firstIndex;
100 if (whatToFit.
find(
"Distortions") == std::string::npos) {
101 LOGLS_ERROR(_log,
"assignIndices was called and Distortions is *not* in whatToFit");
105 _fittingChips = (whatToFit.
find(
"DistortionsChip") != std::string::npos);
106 _fittingVisits = (whatToFit.
find(
"DistortionsVisit") != std::string::npos);
108 if ((!_fittingChips) && (!_fittingVisits)) {
109 _fittingChips = _fittingVisits =
true;
112 for (
auto &i : _chipMap) {
113 i.second->setIndex(index);
114 index += i.second->getNpar();
117 for (
auto &i : _visitMap) {
118 i.second->setIndex(index);
119 index += i.second->getNpar();
122 for (
auto &i : _mappings) {
123 i.second->setWhatToFit(_fittingChips, _fittingVisits);
130 for (
auto &i : _chipMap) {
131 auto mapping = i.second.get();
132 mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
135 for (
auto &i : _visitMap) {
136 auto mapping = i.second.get();
137 mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
142 for (
auto i = _visitMap.
begin(); i != _visitMap.
end(); ++i) i->second->freezeErrorTransform();
143 for (
auto i = _chipMap.
begin(); i != _chipMap.
end(); ++i) i->second->freezeErrorTransform();
147 auto chipp = _chipMap.
find(chip);
148 if (chipp == _chipMap.
end()) {
150 errMsg <<
"No such chipId: '" << chip <<
"' found in chipMap of: " <<
this;
153 return chipp->second->getTransfo();
160 for (
auto i = _visitMap.
begin(); i != _visitMap.
end(); ++i) res.
push_back(i->first);
165 auto visitp = _visitMap.
find(visit);
166 if (visitp == _visitMap.
end()) {
168 errMsg <<
"No such visitId: '" << visit <<
"' found in visitMap of: " <<
this;
171 return visitp->second->getTransfo();
177 mapping = _mappings.
at(&ccdImage).
get();
180 <<
" not found in constrainedPolyModel mapping list.");
182 for (
auto const &i : _mappings) os << i.first <<
",";
183 LOGLS_ERROR(_log,
"Available CcdImages: " << os.str());
206 pix2Tp = t2_poly * t1;
217 << ccdImage.
getVisit() <<
": projection " 232 return std::make_shared<TanSipPix2RaDec>(cdStuff, tangentPoint, &sip);
VisitIdType getVisit() const
returns visit ID
implements the linear transformations (6 real coefficients).
void offsetParams(Eigen::VectorXd const &Delta)
Dispaches the offsets after a fit step into the actual locations of parameters.
virtual class needed in the abstraction of the distortion model
GtransfoLin invert() const
returns the inverse: T1 = T2.invert();
Mapping implementation for a polynomial transformation.
Gtransfo const & getVisitTransfo(VisitIdType const &visit) const
Access to mappings.
CcdIdType getCcdId() const
returns ccd ID
The mapping with two transfos in a row.
Gtransfo const * getPix2TangentPlane() const
Polynomial transformation class.
GtransfoLin normalizeCoordinatesTransfo(const Frame &frame)
Returns the transformation that maps the input frame along both axes to [-1,1].
#define LOGLS_INFO(logger, message)
rectangle with sides parallel to axes.
Class for a simple mapping implementing a generic Gtransfo.
std::shared_ptr< TanSipPix2RaDec > produceSipWcs(CcdImage const &ccdImage) const
Cook up a SIP WCS.
void freezeErrorTransform()
From there on, measurement errors are propagated using the current transfos (and no longer evolve)...
Point getTangentPoint() const
tangent point coordinates (degrees)
This is a virtual class that allows a lot of freedom in the choice of the projection from "Sky" (wher...
Point getCenter() const
Center of the frame.
A do-nothing transformation. It anyway has dummy routines to mimick a Gtransfo.
virtual GtransfoLin linearApproximation(const Point &where, const double step=0.01) const
linear (local) approximation.
std::vector< VisitIdType > getVisits() const
Access to array of visits involved in the solution.
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) ...
GtransfoLin getLinPart() const
The Linear part (corresponding to CD's and CRPIX's)
a virtual (interface) class for geometric transformations.
#define LOGLS_DEBUG(logger, message)
Mapping const * getMapping(CcdImage const &) const
Mapping associated to a given CcdImage.
const Gtransfo * getSky2TP(CcdImage const &ccdImage) const
The mapping of sky coordinates (i.e.
unsigned assignIndices(unsigned firstIndex, std::string const &whatToFit)
Positions the various parameter sets into the parameter vector, starting at firstIndex.
Handler of an actual image from a single CCD.
Gtransfo const & getTransfo1() const
access to transfos
Gtransfo const & getTransfo2() const
access to transfos
Frame const & getImageFrame() const
Frame in pixels.
#define LOGLS_ERROR(logger, message)
#define LOGLS_WARN(logger, message)
Gtransfo const & getChipTransfo(CcdIdType const chip) const
Access to mappings.