49 template <
typename KeyType,
typename ValueType>
53 for (
auto const &i : map) {
67 ConstrainedAstrometryModel::ConstrainedAstrometryModel(
69 int chipOrder,
int visitOrder)
70 : _skyToTangentPlane(projectionHandler) {
76 for (
auto &
ccdImage : ccdImageList) {
80 auto visitp = _visitMap.find(visit);
81 if (visitp == _visitMap.end()) {
85 auto chipp = _chipMap.find(chip);
86 if (chipp == _chipMap.end()) {
89 if (radius2 < minRadius2) {
91 constrainedChip = chip;
101 _chipMap[chip] = std::make_shared<SimplePolyMapping>(shiftAndNormalize,
102 pol * shiftAndNormalize.inverted());
107 _chipMap.at(constrainedChip)->setToBeFit(
false);
110 for (
auto &
ccdImage : ccdImageList) {
117 if (_chipMap.find(chip) == _chipMap.end()) {
118 LOGLS_WARN(_log,
"Chip " << chip <<
" is missing in the reference exposure, expect troubles.");
124 std::make_unique<ChipVisitAstrometryMapping>(_chipMap[chip], _visitMap[visit]);
126 LOGLS_INFO(_log,
"Got " << _chipMap.size() <<
" chip mappings and " << _visitMap.size()
127 <<
" visit mappings; holding chip " << constrainedChip <<
" fixed (" 129 LOGLS_DEBUG(_log,
"CcdImage map has " << _mappings.size() <<
" mappings, with " 130 << _mappings.bucket_count() <<
" buckets and a load factor of " 131 << _mappings.load_factor());
135 return findMapping(ccdImage);
143 unsigned index = firstIndex;
144 if (whatToFit.
find(
"Distortions") == std::string::npos) {
145 LOGLS_ERROR(_log,
"assignIndices was called and Distortions is *not* in whatToFit");
149 _fittingChips = (whatToFit.
find(
"DistortionsChip") != std::string::npos);
150 _fittingVisits = (whatToFit.
find(
"DistortionsVisit") != std::string::npos);
152 if ((!_fittingChips) && (!_fittingVisits)) {
153 _fittingChips = _fittingVisits =
true;
156 for (
auto &i : _chipMap) {
157 i.second->setIndex(index);
158 index += i.second->getNpar();
161 for (
auto &i : _visitMap) {
162 i.second->setIndex(index);
163 index += i.second->getNpar();
166 for (
auto &i : _mappings) {
167 i.second->setWhatToFit(_fittingChips, _fittingVisits);
174 for (
auto &i : _chipMap) {
179 for (
auto &i : _visitMap) {
186 for (
auto i = _visitMap.begin(); i != _visitMap.end(); ++i) i->second->freezeErrorTransform();
187 for (
auto i = _chipMap.begin(); i != _chipMap.end(); ++i) i->second->freezeErrorTransform();
191 auto chipp = _chipMap.find(chip);
192 if (chipp == _chipMap.end()) {
194 errMsg <<
"No such chipId: " << chip <<
" among ";
195 outputMapKeys(_chipMap, errMsg);
199 return chipp->second->getTransform();
206 for (
auto i = _visitMap.begin(); i != _visitMap.end(); ++i) res.
push_back(i->first);
211 auto visitp = _visitMap.find(visit);
212 if (visitp == _visitMap.end()) {
214 errMsg <<
"No such visitId: " << visit <<
" among ";
215 outputMapKeys(_visitMap, errMsg);
219 return visitp->second->getTransform();
224 for (
auto &i : _chipMap) {
225 total += i.second->getNpar();
227 for (
auto &i : _visitMap) {
228 total += i.second->getNpar();
251 auto iwcToSkyMap = iwcToSkyWcs->getFrameDict()->getMapping(
"PIXELS",
"SKY");
252 auto skyFrame = iwcToSkyWcs->getFrameDict()->getFrame(
"SKY");
255 frameDict.
addFrame(
"PIXELS", *pixelsToFocal, focalFrame);
256 frameDict.
addFrame(
"FOCAL", *focalToIwc, iwcFrame);
258 return std::make_shared<afw::geom::SkyWcs>(frameDict);
262 auto i = _mappings.find(ccdImage.
getHashKey());
263 if (i == _mappings.end())
265 "ConstrainedAstrometryModel cannot find CcdImage " + ccdImage.
getName());
266 return i->second.get();
#define LOGLS_WARN(logger, message)
Log a warn-level message using an iostream-based interface.
unsigned assignIndices(std::string const &whatToFit, unsigned firstIndex) override
Positions the various parameter sets into the parameter vector, starting at firstIndex.
AstrometryTransform const & getVisitTransform(VisitIdType const &visit) const
Access to mappings.
VisitIdType getVisit() const
returns visit ID
std::string getName() const
Return the _name that identifies this ccdImage.
CameraSysPrefix const PIXELS
Nominal pixels on the detector (unbinned) This ignores manufacturing imperfections, "tree ring" distortions and all other such effects.
const std::shared_ptr< AstrometryTransform const > getSkyToTangentPlane(CcdImage const &ccdImage) const override
The mapping of sky coordinates (i.e.
std::vector< VisitIdType > getVisits() const
Access to array of visits involved in the solution.
CcdIdType getCcdId() const
returns ccd ID
AstrometryMapping const * getMapping(CcdImage const &) const override
Mapping associated to a given CcdImage.
LSST DM logging module built on log4cxx.
rectangle with sides parallel to axes.
AstrometryTransformLinear normalizeCoordinatesTransform(const Frame &frame)
Returns the transformation that maps the input frame along both axes to [-1,1].
#define LOGLS_DEBUG(logger, message)
Log a debug-level message using an iostream-based interface.
AngleUnit constexpr degrees
constant with units of degrees
A base class for image defects.
void addFrame(int iframe, Mapping const &map, Frame const &frame) override
Add a new Frame and an associated Mapping to this FrameSet so as to define a new coordinate system...
Frame is used to represent a coordinate system.
std::shared_ptr< afw::geom::SkyWcs > makeSkyWcs(CcdImage const &ccdImage) const override
Make a SkyWcs that contains this model.
void freezeErrorTransform() override
From there on, measurement errors are propagated using the current transforms (and no longer evolve)...
This one is the Tangent Plane (called gnomonic) projection (from celestial sphere to tangent plane) ...
T dynamic_pointer_cast(T... args)
#define LOGLS_INFO(logger, message)
Log a info-level message using an iostream-based interface.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
void offsetParams(Eigen::VectorXd const &Delta) override
Dispaches the offsets after a fit step into the actual locations of parameters.
Point in an unspecified spherical coordinate system.
int getTotalParameters() const override
Return the total number of parameters in this model.
AstrometryTransform const & getChipTransform(CcdIdType const chip) const
Access to mappings.
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
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.
Reports invalid arguments.
virtual class needed in the abstraction of the distortion model
CcdImageKey getHashKey() const
std::shared_ptr< afw::cameraGeom::Detector > getDetector() const
Handler of an actual image from a single CCD.
#define LOG_GET(logger)
Returns a Log object associated with logger.
A FrameSet whose frames can be referenced by domain name.
CameraSys const FOCAL_PLANE
Focal plane coordinates: Rectilinear x, y (and z when talking about the location of a detector) on th...
#define LOGLS_ERROR(logger, message)
Log a error-level message using an iostream-based interface.
Frame const & getImageFrame() const
Frame in pixels.