Skip to content

Commit

Permalink
Some additional changes Jim requested to hide PsfAttributes for DM-1067
Browse files Browse the repository at this point in the history
Also removed some changes to throws which are not part of this ticket
  • Loading branch information
pgee committed Sep 11, 2014
1 parent 87a03e7 commit 03423f7
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 109 deletions.
6 changes: 1 addition & 5 deletions include/lsst/meas/base/GaussianCentroid.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#ifndef LSST_MEAS_BASE_GaussianCentroid_h_INCLUDED
#define LSST_MEAS_BASE_GaussianCentroid_h_INCLUDED

#include <cmath>
#include <vector>
#include "lsst/pex/config.h"
#include "lsst/afw/image/Exposure.h"
#include "lsst/meas/base/Inputs.h"
Expand All @@ -35,7 +33,7 @@ namespace lsst { namespace meas { namespace base {

struct FittedModel {
enum { PEAK = 0, SKY, X0, Y0, SIGMA, NPARAM };

This comment has been minimized.

Copy link
@PaulPrice

PaulPrice Sep 16, 2014

Contributor

Whitespace changes.

enum {
BAD_GUESS = -11,
TOO_FEW = -12,
Expand Down Expand Up @@ -88,7 +86,6 @@ class GaussianCentroidAlgorithm {
* Inspect getFlagDefinitions() for more detailed explanations of each flag.
*/
enum FlagBits {
EDGE,

This comment has been minimized.

Copy link
@PaulPrice

PaulPrice Sep 16, 2014

Contributor

Why is the removal of this flag part of this commit?

NO_PEAK,
N_FLAGS
};
Expand All @@ -99,7 +96,6 @@ class GaussianCentroidAlgorithm {
*/
static boost::array<FlagDef,N_FLAGS> const & getFlagDefinitions() {
static boost::array<FlagDef,N_FLAGS> const flagDefs = {{
{"edge", "Near edge of image"},
{"noPeak", "Fitted Centroid has a negative peak"}
}};
return flagDefs;
Expand Down
39 changes: 39 additions & 0 deletions include/lsst/meas/base/PeakLikelihoodFlux.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,45 @@

namespace lsst { namespace meas { namespace base {

namespace {

This comment has been minimized.

Copy link
@PaulPrice

PaulPrice Sep 16, 2014

Contributor

Why include an anonymous namespace in a header file?

/************************************************************************************************************/
/**
* @class PsfAttributes
*
* A class to contain various attributes of the Psf
* - most notably, a width (1-D RMS size) to be used to
* make a single gaussian psf for fast convolution.
*
* \deprecated
* This class is deprecated in favour of virtual methods on Psf
*
* An example of the new API is:
* \code
* afwGeom::ellipses::Quadrupole shape = psf->computeShape();
* double const smoothingSigma = shape.getDeterminantRadius();
* \endcode
*/
class PsfAttributes {
public:
enum Method { ADAPTIVE_MOMENT, ///< Calculate width using adaptive Gaussian weights
FIRST_MOMENT, ///< Calculate width using \<r>
SECOND_MOMENT, ///< Calculate width using \<r^2>
NOISE_EQUIVALENT, ///< Calculate width as sqrt(n_eff/(4 pi))
BICKERTON ///< Weight \<r^2> by I^2 to avoid negative fluxes
};

PsfAttributes(CONST_PTR(lsst::afw::detection::Psf) psf, int const iX, int const iY);
PsfAttributes(CONST_PTR(lsst::afw::detection::Psf) psf, lsst::afw::geom::Point2I const& cen);

double computeGaussianWidth(Method how=ADAPTIVE_MOMENT) const;
double computeEffectiveArea() const;

private:
PTR(lsst::afw::image::Image<double>) _psfImage;
};

} // end of anonymous

/**
* @brief C++ control object for peak likelihood flux.
*
Expand Down
86 changes: 0 additions & 86 deletions include/lsst/meas/base/PsfAttributes.h

This file was deleted.

7 changes: 0 additions & 7 deletions src/GaussianCentroid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,6 @@ void GaussianCentroidAlgorithm::apply(
NO_PEAK
);
}
if (x < 0 || x >= image.getWidth() || y < 0 || y >= image.getHeight()) {
throw LSST_EXCEPT(
MeasurementError,
getFlagDefinitions()[EDGE].doc,
EDGE
);
}

result.x = lsst::afw::image::indexToPosition(image.getX0()) + fit.params[FittedModel::X0];
result.y = lsst::afw::image::indexToPosition(image.getY0()) + fit.params[FittedModel::Y0];
Expand Down
10 changes: 5 additions & 5 deletions src/GaussianFlux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace lsst { namespace meas { namespace base {
namespace { // anonymous

/************************************************************************************************************/

template<typename ImageT>
std::pair<double, double>
getGaussianFlux(
Expand Down Expand Up @@ -81,16 +81,16 @@ double getPsfFactor(lsst::afw::detection::Psf const & psf, afw::geom::Point2D co
typedef lsst::afw::detection::Psf::Image PsfImageT;
PTR(PsfImageT) psfImage; // the image of the PSF
PTR(PsfImageT) psfImageNoPad; // Unpadded image of PSF

This comment has been minimized.

Copy link
@PaulPrice

PaulPrice Sep 16, 2014

Contributor

Only whitespace changes in this file.

int const pad = 5;
try {
psfImageNoPad = psf.computeImage(center);

This comment has been minimized.

Copy link
@PaulPrice

PaulPrice Sep 16, 2014

Contributor

Bunch of whitespace changes.

psfImage = PTR(PsfImageT)(
new PsfImageT(psfImageNoPad->getDimensions() + lsst::afw::geom::Extent2I(2*pad))
);
lsst::afw::geom::BoxI middleBBox(lsst::afw::geom::Point2I(pad, pad), psfImageNoPad->getDimensions());

PTR(PsfImageT) middle(new PsfImageT(*psfImage, middleBBox, lsst::afw::image::LOCAL));
*middle <<= *psfImageNoPad;
} catch (lsst::pex::exceptions::Exception & e) {
Expand Down Expand Up @@ -124,7 +124,7 @@ void GaussianFluxAlgorithm::apply(
PTR(afw::detection::Psf const) psf = exposure.getPsf();
if (!psf) {
throw LSST_EXCEPT(
lsst::meas::base::MeasurementError,
MeasurementError,

This comment has been minimized.

Copy link
@PaulPrice

PaulPrice Sep 16, 2014

Contributor

Why is this name change part of this commit?

This comment has been minimized.

Copy link
@PaulPrice

PaulPrice Sep 16, 2014

Contributor

Oh, except this namespace change, which doesn't belong in this commit.

getFlagDefinitions()[NO_PSF].doc,
NO_PSF
);
Expand Down
45 changes: 44 additions & 1 deletion src/PeakLikelihoodFlux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,54 @@
#include "lsst/afw/geom.h"
#include "lsst/afw/image.h"
#include "lsst/afw/math.h"
#include "lsst/meas/base/PsfAttributes.h"

#include "lsst/meas/base/PeakLikelihoodFlux.h"

namespace lsst { namespace meas { namespace base {
namespace {
/**
* @brief Constructor for PsfAttributes
*/
PsfAttributes::PsfAttributes(
CONST_PTR(lsst::afw::detection::Psf) psf, ///< The psf whose attributes we want
int const iX, ///< the x position in the frame we want the attributes at
int const iY ///< the y position in the frame we want the attributes at
)
{
// N.b. (iX, iY) are ints so that we know this image is centered in the central pixel of _psfImage
_psfImage = psf->computeImage(afw::geom::PointD(iX, iY));
}

/**
* @brief Constructor for PsfAttributes
*/
PsfAttributes::PsfAttributes(
CONST_PTR(lsst::afw::detection::Psf) psf, ///< The psf whose attributes we want
lsst::afw::geom::Point2I const& cen ///< the position in the frame we want the attributes at
) :
// N.b. cen is a PointI so that we know this image is centered in the central pixel of _psfImage
_psfImage(psf->computeImage(afw::geom::PointD(cen)))
{
}

/**
* @brief Compute the effective area of the psf ( sum(I)^2/sum(I^2) )
*
*/
double PsfAttributes::computeEffectiveArea() const {

double sum = 0.0;
double sumsqr = 0.0;
for (int iY = 0; iY != _psfImage->getHeight(); ++iY) {
afw::image::Image<double>::x_iterator end = _psfImage->row_end(iY);
for (afw::image::Image<double>::x_iterator ptr = _psfImage->row_begin(iY); ptr != end; ++ptr) {
sum += *ptr;
sumsqr += (*ptr)*(*ptr);
}
}
return sum*sum/sumsqr;
}
} // end of anonymous

PeakLikelihoodFluxAlgorithm::ResultMapper PeakLikelihoodFluxAlgorithm::makeResultMapper(
afw::table::Schema & schema, std::string const & name, Control const & ctrl
Expand Down
5 changes: 0 additions & 5 deletions src/PsfFlux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ void PsfFluxAlgorithm::apply(
afw::geom::Box2I fitBBox = psfImage->getBBox(afw::image::PARENT);
fitBBox.clip(exposure.getBBox(afw::image::PARENT));
if (fitBBox != psfImage->getBBox(afw::image::PARENT)) {
throw LSST_EXCEPT(
MeasurementError,
getFlagDefinitions()[EDGE].doc,
EDGE
);
result.setFlag(EDGE);
}
afw::detection::Footprint fitRegion(fitBBox);
Expand Down

0 comments on commit 03423f7

Please sign in to comment.