Skip to content

Commit

Permalink
Merge pull request #69 from lsst/tickets/DM-13272
Browse files Browse the repository at this point in the history
DM-13272 write tests for astrometryModel Wcs output
  • Loading branch information
parejkoj committed Apr 17, 2018
2 parents e2d9597 + 1582d36 commit ab4c137
Show file tree
Hide file tree
Showing 54 changed files with 1,814 additions and 1,315 deletions.
17 changes: 0 additions & 17 deletions include/lsst/jointcal/AstroUtils.h

This file was deleted.

2 changes: 1 addition & 1 deletion include/lsst/jointcal/AstrometryFit.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class AstrometryFit : public FitterBase {
void getIndicesOfMeasuredStar(MeasuredStar const &measuredStar,
std::vector<unsigned> &indices) const override;

Point transformFittedStar(FittedStar const &fittedStar, Gtransfo const *sky2TP,
Point transformFittedStar(FittedStar const &fittedStar, Gtransfo const &sky2TP,
Point const &refractionVector, double refractionCoeff, double mjd) const;

/// Compute the chi2 (per star or total, depending on which Chi2Accumulator is used) from one CcdImage.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -*- LSST-C++ -*-
#ifndef LSST_JOINTCAL_MAPPING_H
#define LSST_JOINTCAL_MAPPING_H
#ifndef LSST_JOINTCAL_ASTROMETRY_MAPPING_H
#define LSST_JOINTCAL_ASTROMETRY_MAPPING_H

#include <vector>
#include "lsst/jointcal/Eigenstuff.h"
Expand All @@ -12,7 +12,7 @@ class FatPoint;
class Point;

//! virtual class needed in the abstraction of the distortion model
class Mapping {
class AstrometryMapping {
public:
//! Number of parameters in total
virtual unsigned getNpar() const = 0;
Expand All @@ -21,7 +21,7 @@ class Mapping {
/// Expects that indices has enough space reserved.
virtual void getMappingIndices(std::vector<unsigned> &indices) const = 0;

//! Actually applies the mapping and evaluates the derivatives w.r.t the fitted parameters.
//! Actually applies the AstrometryMapping and evaluates the derivatives w.r.t the fitted parameters.
/*! This is grouped into a single call because for most models,
evaluating the derivatives w.r.T parameters is not much longer
than just transforming */
Expand All @@ -40,8 +40,8 @@ class Mapping {
double epsilon) const = 0;

//!
virtual ~Mapping(){};
virtual ~AstrometryMapping(){};
};
} // namespace jointcal
} // namespace lsst
#endif // LSST_JOINTCAL_MAPPING_H
#endif // LSST_JOINTCAL_ASTROMETRY_MAPPING_H
25 changes: 19 additions & 6 deletions include/lsst/jointcal/AstrometryModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include "lsst/jointcal/Gtransfo.h"
#include "lsst/jointcal/Eigenstuff.h"
#include "lsst/jointcal/Mapping.h"
#include "lsst/jointcal/AstrometryMapping.h"

namespace lsst {
namespace jointcal {
Expand All @@ -20,12 +20,15 @@ class Gtransfo;
the top of simplepolymodel.h */
class AstrometryModel {
public:
/// Return the number of parameters in the mapping of CcdImage
int getNpar(CcdImage const &ccdImage) const { return findMapping(ccdImage)->getNpar(); }

//! Mapping associated to a given CcdImage
virtual const Mapping *getMapping(CcdImage const &) const = 0;
virtual const AstrometryMapping *getMapping(CcdImage const &) const = 0;

//! Assign indices to parameters involved in mappings, starting at firstIndex. Returns the highest
//! assigned index.
virtual unsigned assignIndices(unsigned firstIndex, std::string const &whatToFit) = 0;
virtual unsigned assignIndices(std::string const &whatToFit, unsigned firstIndex) = 0;

//! Offset the parameters by the provided amounts.
/*! The shifts are applied according to the indices given in
Expand All @@ -35,15 +38,25 @@ class AstrometryModel {
//! The transformation used to project the positions of FittedStars.
/*! This defines the coordinate system into which the Mapping of
this Ccdimage maps the pixel coordinates. */
virtual const Gtransfo *getSky2TP(CcdImage const &ccdImage) const = 0;
virtual const std::shared_ptr<Gtransfo const> getSky2TP(CcdImage const &ccdImage) const = 0;

//! Cook up a SIP WCS.
virtual std::shared_ptr<TanSipPix2RaDec> produceSipWcs(CcdImage const &ccdImage) const = 0;
/**
* Make a SkyWcs that contains this model.
*
* @param ccdImage The exposure to create the SkyWcs for.
*
* @return SkyWcs containing this model.
*/
virtual std::shared_ptr<afw::geom::SkyWcs> makeSkyWcs(CcdImage const &ccdImage) const = 0;

//!
virtual void freezeErrorTransform() = 0;

virtual ~AstrometryModel(){};

protected:
/// Return a pointer to the mapping associated with this ccdImage.
virtual AstrometryMapping *findMapping(CcdImage const &ccdImage) const = 0;
};
} // namespace jointcal
} // namespace lsst
Expand Down
6 changes: 6 additions & 0 deletions include/lsst/jointcal/CcdImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ class CcdImage {
MeasuredStarList &getCatalogForFit() { return _catalogForFit; }
//@}

/// Clear the catalog for fitting and set it to a copy of the whole catalog.
void resetCatalogForFit() {
getCatalogForFit().clear();
getWholeCatalog().copyTo(getCatalogForFit());
}

/**
* @brief Sets the common tangent point and computes necessary transforms.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// -*- LSST-C++ -*-
#ifndef LSST_JOINTCAL_CONSTRAINED_POLY_MODEL_H
#define LSST_JOINTCAL_CONSTRAINED_POLY_MODEL_H
#ifndef LSST_JOINTCAL_CONSTRAINED_ASTROMETRY_MODEL_H
#define LSST_JOINTCAL_CONSTRAINED_ASTROMETRY_MODEL_H

#include "memory" // for std::*_ptr

Expand All @@ -11,7 +11,7 @@ class CcdImage;
#include "lsst/jointcal/AstrometryModel.h"
#include "lsst/jointcal/Gtransfo.h"
#include "lsst/jointcal/Frame.h"
#include "lsst/jointcal/SimplePolyMapping.h"
#include "lsst/jointcal/SimpleAstrometryMapping.h"
#include "lsst/jointcal/ProjectionHandler.h"
#include "lsst/jointcal/TwoTransfoMapping.h"
#include "lsst/jointcal/CcdImage.h"
Expand All @@ -28,26 +28,27 @@ namespace jointcal {
* required for this model is TwoTransfoMapping. This modeling of distortions
* is meant for a set of images from a single mosaic imager.
*/
class ConstrainedPolyModel : public AstrometryModel {
class ConstrainedAstrometryModel : public AstrometryModel {
public:
ConstrainedPolyModel(CcdImageList const &ccdImageList, ProjectionHandler const *projectionHandler,
bool initFromWCS, unsigned nNotFit = 0, int chipDegree = 3, int visitDegree = 2);
ConstrainedAstrometryModel(CcdImageList const &ccdImageList,
std::shared_ptr<ProjectionHandler const> projectionHandler, int chipOrder,
int visitOrder);

/// No copy or move: there is only ever one instance of a given model (i.e. per ccd+visit)
ConstrainedPolyModel(ConstrainedPolyModel const &) = delete;
ConstrainedPolyModel(ConstrainedPolyModel &&) = delete;
ConstrainedPolyModel &operator=(ConstrainedPolyModel const &) = delete;
ConstrainedPolyModel &operator=(ConstrainedPolyModel &&) = delete;
ConstrainedAstrometryModel(ConstrainedAstrometryModel const &) = delete;
ConstrainedAstrometryModel(ConstrainedAstrometryModel &&) = delete;
ConstrainedAstrometryModel &operator=(ConstrainedAstrometryModel const &) = delete;
ConstrainedAstrometryModel &operator=(ConstrainedAstrometryModel &&) = delete;

// The following routines are the interface to AstrometryFit
//!
Mapping const *getMapping(CcdImage const &) const;
AstrometryMapping const *getMapping(CcdImage const &) const;

/**
* Positions the various parameter sets into the parameter vector, starting at
* firstIndex.
*/
unsigned assignIndices(unsigned firstIndex, std::string const &whatToFit);
unsigned assignIndices(std::string const &whatToFit, unsigned firstIndex);

/**
* Dispaches the offsets after a fit step into the actual locations of
Expand Down Expand Up @@ -75,21 +76,24 @@ class ConstrainedPolyModel : public AstrometryModel {
* stars are reported) onto the Tangent plane (into which the pixel coordinates
* are transformed).
*/
const Gtransfo *getSky2TP(CcdImage const &ccdImage) const { return _sky2TP->getSky2TP(ccdImage); }
const std::shared_ptr<Gtransfo const> getSky2TP(CcdImage const &ccdImage) const {
return _sky2TP->getSky2TP(ccdImage);
}

std::shared_ptr<TanSipPix2RaDec> produceSipWcs(CcdImage const &ccdImage) const;
/// @copydoc AstrometryModel::makeSkyWcs
std::shared_ptr<afw::geom::SkyWcs> makeSkyWcs(CcdImage const &ccdImage) const;

private:
typedef std::map<const CcdImage *, std::unique_ptr<TwoTransfoMapping>> mappingMapType;
mappingMapType _mappings;
typedef std::map<CcdIdType, std::unique_ptr<SimpleGtransfoMapping>> chipMapType;
chipMapType _chipMap;
typedef std::map<VisitIdType, std::unique_ptr<SimpleGtransfoMapping>> visitMapType;
visitMapType _visitMap;
const ProjectionHandler *_sky2TP;
std::unordered_map<CcdImageKey, std::unique_ptr<TwoTransfoMapping>> _mappings;
std::map<CcdIdType, std::shared_ptr<SimpleGtransfoMapping>> _chipMap;
std::map<VisitIdType, std::shared_ptr<SimpleGtransfoMapping>> _visitMap;
const std::shared_ptr<ProjectionHandler const> _sky2TP;
bool _fittingChips, _fittingVisits;

/// @copydoc AstrometryModel::findMapping
AstrometryMapping *findMapping(CcdImage const &ccdImage) const;
};
} // namespace jointcal
} // namespace lsst

#endif // LSST_JOINTCAL_CONSTRAINED_POLY_MODEL_H
#endif // LSST_JOINTCAL_CONSTRAINED_ASTROMETRY_MODEL_H
4 changes: 2 additions & 2 deletions include/lsst/jointcal/ConstrainedPhotometryModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class ConstrainedPhotometryModel : public PhotometryModel {
* @param ccdImageList The list of CCDImages to construct the model for.
* @param focalPlaneBBox The bounding box of the camera's focal plane, defining the domain of the
* visit polynomial.
* @param[in] visitDegree The degree of the visit polynomial.
* @param[in] visitOrder The order of the visit polynomial.
*/
explicit ConstrainedPhotometryModel(CcdImageList const &ccdImageList,
afw::geom::Box2D const &focalPlaneBBox, int visitDegree = 7);
afw::geom::Box2D const &focalPlaneBBox, int visitOrder = 7);

/// No copy or move: there is only ever one instance of a given model (i.e. per ccd+visit)
ConstrainedPhotometryModel(ConstrainedPhotometryModel const &) = delete;
Expand Down
4 changes: 0 additions & 4 deletions include/lsst/jointcal/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
namespace lsst {
namespace jointcal {

typedef enum { WholeSizeFrame, ClippedSizeFrame } WhichFrame;

typedef enum { LargeFrame, SmallFrame } WhichTransformed;

//! rectangle with sides parallel to axes.
/*! when Frame's are used to define subparts of images, xMin and xMax refer
to the first and last pixels in the subimage */
Expand Down

0 comments on commit ab4c137

Please sign in to comment.