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()) {
64 for (
auto &
ccdImage : ccdImageList) {
70 if (_chipMap.
find(chip) == _chipMap.
end()) {
71 LOGLS_WARN(_log,
"Chip " << chip <<
" is missing in the reference exposure, expect troubles.");
79 LOGLS_INFO(_log,
"Constructor got " << _chipMap.
size() <<
" chip mappings and " << _visitMap.
size()
80 <<
" visit mappings.");
86 mappingMapType::const_iterator i = _mappings.
find(&ccdImage);
87 if (i == _mappings.
end())
return nullptr;
88 return (i->second.get());
96 unsigned index = firstIndex;
97 if (whatToFit.
find(
"Distortions") == std::string::npos) {
98 LOGLS_ERROR(_log,
"assignIndices was called and Distortions is *not* in whatToFit");
102 _fittingChips = (whatToFit.
find(
"DistortionsChip") != std::string::npos);
103 _fittingVisits = (whatToFit.
find(
"DistortionsVisit") != std::string::npos);
105 if ((!_fittingChips) && (!_fittingVisits)) {
106 _fittingChips = _fittingVisits =
true;
109 for (
auto &i : _chipMap) {
110 i.second->setIndex(index);
111 index += i.second->getNpar();
114 for (
auto &i : _visitMap) {
115 i.second->setIndex(index);
116 index += i.second->getNpar();
119 for (
auto &i : _mappings) {
120 i.second->setWhatToFit(_fittingChips, _fittingVisits);
127 for (
auto &i : _chipMap) {
128 auto mapping = i.second.get();
129 mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
132 for (
auto &i : _visitMap) {
133 auto mapping = i.second.get();
134 mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
139 for (
auto i = _visitMap.
begin(); i != _visitMap.
end(); ++i) i->second->freezeErrorScales();
140 for (
auto i = _chipMap.
begin(); i != _chipMap.
end(); ++i) i->second->freezeErrorScales();
144 auto chipp = _chipMap.
find(chip);
145 if (chipp == _chipMap.
end()) {
147 errMsg <<
"No such chipId: '" << chip <<
"' found in chipMap of: " <<
this;
150 return chipp->second->getTransfo();
157 for (
auto i = _visitMap.
begin(); i != _visitMap.
end(); ++i) res.
push_back(i->first);
162 auto visitp = _visitMap.
find(visit);
163 if (visitp == _visitMap.
end()) {
165 errMsg <<
"No such visitId: '" << visit <<
"' found in visitMap of: " <<
this;
168 return visitp->second->getTransfo();
174 mapping = _mappings.
at(&ccdImage).
get();
177 <<
" not found in constrainedPolyModel mapping list.");
179 for (
auto const &i : _mappings) os << i.first <<
",";
180 LOGLS_ERROR(_log,
"Available CcdImages: " << os.str());
203 pix2Tp = t2_poly * t1;
214 << ccdImage.
getVisit() <<
": projection " 229 return std::make_shared<TanSipPix2RaDec>(cdStuff, tangentPoint, &sip);
#define LOGLS_WARN(logger, message)
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 * getPix2CommonTangentPlane() const
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].
rectangle with sides parallel to axes.
#define LOGLS_DEBUG(logger, message)
Class for a simple mapping implementing a generic Gtransfo.
std::shared_ptr< TanSipPix2RaDec > produceSipWcs(CcdImage const &ccdImage) const
Cook up a SIP WCS.
Point getTangentPoint() const
tangent point coordinates (in degrees)
This is a virtual class that allows a lot of freedom in the choice of the projection from "Sky" (wher...
#define LOGLS_INFO(logger, message)
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.
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.
Frame applyTransfo(const Frame &inputframe, const Gtransfo >ransfo, const WhichTransformed which)
Transform a Frame through a Transfo.
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
#define LOGLS_ERROR(logger, message)
Frame const & getImageFrame() const
Frame in pixels.
void freezeErrorScales()
From there on, measurement errors are propagated using the current transfos (and no longer evolve)...
Gtransfo const & getChipTransfo(CcdIdType const chip) const
Access to mappings.