20 LOG_LOGGER _log =
LOG_GET(
"jointcal.ConstrainedAstrometryModel");
25 template <
typename KeyType,
typename ValueType>
29 for (
auto const &i : map) {
43 ConstrainedAstrometryModel::ConstrainedAstrometryModel(
45 int chipOrder,
int visitOrder)
46 : _sky2TP(projectionHandler) {
52 for (
auto &
ccdImage : ccdImageList) {
56 auto visitp = _visitMap.find(visit);
57 if (visitp == _visitMap.end()) {
60 auto chipp = _chipMap.find(chip);
61 if (chipp == _chipMap.end()) {
64 if (radius2 < minRadius2) {
66 constrainedChip = chip;
76 std::make_shared<SimplePolyMapping>(shiftAndNormalize, pol * shiftAndNormalize.invert());
81 _chipMap.at(constrainedChip)->setToBeFit(
false);
84 for (
auto &
ccdImage : ccdImageList) {
91 if (_chipMap.find(chip) == _chipMap.end()) {
92 LOGLS_WARN(_log,
"Chip " << chip <<
" is missing in the reference exposure, expect troubles.");
94 _chipMap[chip] = std::make_shared<SimplePolyMapping>(norm,
GtransfoPoly(chipOrder));
97 std::make_unique<TwoTransfoMapping>(_chipMap[chip], _visitMap[visit]);
99 LOGLS_INFO(_log,
"Got " << _chipMap.size() <<
" chip mappings and " << _visitMap.size()
100 <<
" visit mappings; holding chip " << constrainedChip <<
" fixed.");
101 LOGLS_DEBUG(_log,
"CcdImage map has " << _mappings.size() <<
" mappings, with " 102 << _mappings.bucket_count() <<
" buckets and a load factor of " 103 << _mappings.load_factor());
107 return findMapping(ccdImage);
115 unsigned index = firstIndex;
116 if (whatToFit.
find(
"Distortions") == std::string::npos) {
117 LOGLS_ERROR(_log,
"assignIndices was called and Distortions is *not* in whatToFit");
121 _fittingChips = (whatToFit.
find(
"DistortionsChip") != std::string::npos);
122 _fittingVisits = (whatToFit.
find(
"DistortionsVisit") != std::string::npos);
124 if ((!_fittingChips) && (!_fittingVisits)) {
125 _fittingChips = _fittingVisits =
true;
128 for (
auto &i : _chipMap) {
129 i.second->setIndex(index);
130 index += i.second->getNpar();
133 for (
auto &i : _visitMap) {
134 i.second->setIndex(index);
135 index += i.second->getNpar();
138 for (
auto &i : _mappings) {
139 i.second->setWhatToFit(_fittingChips, _fittingVisits);
146 for (
auto &i : _chipMap) {
147 auto mapping = i.second.get();
148 mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
151 for (
auto &i : _visitMap) {
152 auto mapping = i.second.get();
153 mapping->offsetParams(delta.segment(mapping->getIndex(), mapping->getNpar()));
158 for (
auto i = _visitMap.begin(); i != _visitMap.end(); ++i) i->second->freezeErrorTransform();
159 for (
auto i = _chipMap.begin(); i != _chipMap.end(); ++i) i->second->freezeErrorTransform();
163 auto chipp = _chipMap.find(chip);
164 if (chipp == _chipMap.end()) {
166 errMsg <<
"No such chipId: " << chip <<
" among ";
167 outputMapKeys(_chipMap, errMsg);
171 return chipp->second->getTransfo();
178 for (
auto i = _visitMap.begin(); i != _visitMap.end(); ++i) res.
push_back(i->first);
183 auto visitp = _visitMap.find(visit);
184 if (visitp == _visitMap.end()) {
186 errMsg <<
"No such visitId: " << visit <<
" among ";
187 outputMapKeys(_visitMap, errMsg);
191 return visitp->second->getTransfo();
212 auto iwcToSkyMap = iwcToSkyWcs->getFrameDict()->getMapping(
"PIXELS",
"SKY");
213 auto skyFrame = iwcToSkyWcs->getFrameDict()->getFrame(
"SKY");
216 frameDict.
addFrame(
"PIXELS", *pixelsToFocal, focalFrame);
217 frameDict.
addFrame(
"FOCAL", *focalToIwc, iwcFrame);
218 frameDict.
addFrame(
"IWC", *iwcToSkyMap, *skyFrame);
219 return std::make_shared<afw::geom::SkyWcs>(frameDict);
223 auto i = _mappings.find(ccdImage.
getHashKey());
224 if (i == _mappings.end())
226 "ConstrainedAstrometryModel cannot find CcdImage " + ccdImage.
getName());
227 return i->second.get();
const std::shared_ptr< Gtransfo const > getSky2TP(CcdImage const &ccdImage) const
The mapping of sky coordinates (i.e.
VisitIdType getVisit() const
returns visit ID
implements the linear transformations (6 real coefficients).
unsigned assignIndices(std::string const &whatToFit, unsigned firstIndex)
Positions the various parameter sets into the parameter vector, starting at firstIndex.
void freezeErrorTransform()
From there on, measurement errors are propagated using the current transfos (and no longer evolve)...
std::string getName() const
Return the _name that identifies this ccdImage.
CameraSysPrefix const PIXELS
AngleUnit constexpr degrees
std::vector< VisitIdType > getVisits() const
Access to array of visits involved in the solution.
std::shared_ptr< afw::geom::SkyWcs > makeSkyWcs(CcdImage const &ccdImage) const
Make a SkyWcs that contains this model.
CcdIdType getCcdId() const
returns ccd ID
Gtransfo const & getVisitTransfo(VisitIdType const &visit) const
Access to mappings.
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)
void addFrame(int iframe, Mapping const &map, Frame const &frame) override
rectangle with sides parallel to axes.
Class for a simple mapping implementing a generic Gtransfo.
void offsetParams(Eigen::VectorXd const &Delta)
Dispaches the offsets after a fit step into the actual locations of parameters.
T dynamic_pointer_cast(T... args)
Gtransfo const & getChipTransfo(CcdIdType const chip) const
Access to mappings.
#define LSST_EXCEPT(type,...)
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) ...
a virtual (interface) class for geometric transformations.
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
#define LOGLS_DEBUG(logger, message)
Eigen::Matrix2d makeCdMatrix(Angle const &scale, Angle const &orientation=0 *degrees, bool flipX=false)
virtual class needed in the abstraction of the distortion model
CcdImageKey getHashKey() const
std::shared_ptr< afw::cameraGeom::Detector > getDetector() const
AstrometryMapping const * getMapping(CcdImage const &) const
Mapping associated to a given CcdImage.
Handler of an actual image from a single CCD.
CameraSys const FOCAL_PLANE
Frame const & getImageFrame() const
Frame in pixels.
#define LOGLS_ERROR(logger, message)
#define LOGLS_WARN(logger, message)