-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This algorithm measures the flux in a circular aperture of diameter equal to some (configurable) multiple of the PSF FWHM. This is a port of work carried out on Hyper Suprime-Cam under ticket HSC-1295 (https://hsc-jira.astro.princeton.edu/jira/browse/HSC-1295),
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// -*- lsst-c++ -*- | ||
/* | ||
* LSST Data Management System | ||
* Copyright 2008-2016 AURA/LSST. | ||
* | ||
* This product includes software developed by the | ||
* LSST Project (http://www.lsst.org/). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the LSST License Statement and | ||
* the GNU General Public License along with this program. If not, | ||
* see <http://www.lsstcorp.org/LegalNotices/>. | ||
*/ | ||
|
||
#ifndef LSST_MEAS_BASE_ScaledApertureFlux_h_INCLUDED | ||
#define LSST_MEAS_BASE_ScaledApertureFlux_h_INCLUDED | ||
|
||
#include "lsst/afw/table.h" | ||
#include "lsst/afw/image/Exposure.h" | ||
#include "lsst/meas/base/Algorithm.h" | ||
#include "lsst/meas/base/FluxUtilities.h" | ||
#include "lsst/meas/base/FlagHandler.h" | ||
#include "lsst/meas/base/InputUtilities.h" | ||
#include "lsst/pex/config.h" | ||
|
||
namespace lsst { namespace meas { namespace base { | ||
|
||
class ScaledApertureFluxControl { | ||
public: | ||
LSST_CONTROL_FIELD( | ||
shiftKernel, std::string, | ||
"Warping kernel used to shift Sinc photometry coefficients to different center positions" | ||
); | ||
|
||
LSST_CONTROL_FIELD(scale, double, "Scaling factor of PSF FWHM for aperture radius."); | ||
ScaledApertureFluxControl() : shiftKernel("lanczos5"), scale(3.14) {} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
}; | ||
|
||
|
||
/** | ||
* @brief Measure the flux in an aperture scaled to the PSF. | ||
* | ||
* This algorithm performs a sinc aperture flux measurement where they size | ||
* of the aperture is determined by multiplying the FWHM of the PSF by the | ||
* scaling factor specified in the algorithm configuration. | ||
*/ | ||
class ScaledApertureFluxAlgorithm : public SimpleAlgorithm { | ||
public: | ||
|
||
typedef ScaledApertureFluxControl Control; | ||
typedef ApertureFluxResult Result; | ||
|
||
ScaledApertureFluxAlgorithm(Control const & control, std::string const & name, | ||
afw::table::Schema & schema); | ||
|
||
/** | ||
* Measure the scaled aperture flux on the given image. | ||
* | ||
* Python plugins will delegate to this method. | ||
* | ||
* @param[in,out] record Record used to save outputs and retrieve positions. | ||
* @param[in] exposure Image to be measured. | ||
*/ | ||
virtual void measure( | ||
This comment has been minimized.
Sorry, something went wrong.
SimonKrughoff
Contributor
|
||
afw::table::SourceRecord & measRecord, | ||
afw::image::Exposure<float> const & exposure | ||
) const; | ||
|
||
virtual void fail(afw::table::SourceRecord & measRecord, MeasurementError * error=NULL) const; | ||
|
||
private: | ||
Control _ctrl; | ||
FluxResultKey _fluxResultKey; | ||
FlagHandler _flagHandler; | ||
SafeCentroidExtractor _centroidExtractor; | ||
}; | ||
|
||
class ScaledApertureFluxTransform : public FluxTransform { | ||
This comment has been minimized.
Sorry, something went wrong.
SimonKrughoff
Contributor
|
||
public: | ||
typedef ScaledApertureFluxControl Control; | ||
ScaledApertureFluxTransform(Control const & ctrl, std::string const & name, | ||
afw::table::SchemaMapper & mapper); | ||
}; | ||
|
||
}}} // namespace lsst::meas::base | ||
|
||
#endif // !LSST_MEAS_BASE_ScaledApertureFlux_h_INCLUDED |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// -*- lsst-c++ -*- | ||
/* | ||
* LSST Data Management System | ||
* Copyright 2008-2016 AURA/LSST. | ||
* | ||
* This product includes software developed by the | ||
* LSST Project (http://www.lsst.org/). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the LSST License Statement and | ||
* the GNU General Public License along with this program. If not, | ||
* see <http://www.lsstcorp.org/LegalNotices/>. | ||
*/ | ||
|
||
#include "lsst/afw/table/Source.h" | ||
#include "lsst/meas/base/ApertureFlux.h" | ||
#include "lsst/meas/base/ScaledApertureFlux.h" | ||
#include "lsst/meas/base/SincCoeffs.h" | ||
#include "lsst/afw/detection/Psf.h" | ||
|
||
namespace lsst { namespace meas { namespace base { | ||
|
||
ScaledApertureFluxAlgorithm::ScaledApertureFluxAlgorithm( | ||
Control const & ctrl, | ||
std::string const & name, | ||
afw::table::Schema & schema | ||
) : _ctrl(ctrl), | ||
_fluxResultKey( | ||
FluxResultKey::addFields(schema, name, "flux derived from PSF-scaled aperture") | ||
), | ||
_centroidExtractor(schema, name) | ||
{ | ||
_flagHandler = FlagHandler::addFields(schema, name, | ||
ApertureFluxAlgorithm::getFlagDefinitions().begin(), | ||
ApertureFluxAlgorithm::getFlagDefinitions().end()); | ||
} | ||
|
||
void ScaledApertureFluxAlgorithm::measure( | ||
afw::table::SourceRecord & measRecord, | ||
afw::image::Exposure<float> const & exposure | ||
) const { | ||
afw::geom::Point2D const center = _centroidExtractor(measRecord, _flagHandler); | ||
double const radius = exposure.getPsf()->computeShape(center).getDeterminantRadius(); | ||
double const fwhm = 2.0*std::sqrt(2.0*std::log(2))*radius; | ||
double const size = _ctrl.scale*fwhm; | ||
afw::geom::ellipses::Axes const axes(size, size); | ||
|
||
// ApertureFluxAlgorithm::computeSincFlux requires an ApertureFluxControl as an | ||
// argument. All that it uses it for is to read the type of warping kernel. | ||
ApertureFluxControl apCtrl; | ||
apCtrl.shiftKernel = _ctrl.shiftKernel; | ||
|
||
Result result = ApertureFluxAlgorithm::computeSincFlux(exposure.getMaskedImage(), | ||
afw::geom::ellipses::Ellipse(axes, center), | ||
apCtrl); | ||
measRecord.set(_fluxResultKey, result); | ||
if (result.getFlag(ApertureFluxAlgorithm::FAILURE)) { | ||
_flagHandler.setValue(measRecord, ApertureFluxAlgorithm::FAILURE, true); | ||
} | ||
if (result.getFlag(ApertureFluxAlgorithm::APERTURE_TRUNCATED)) { | ||
_flagHandler.setValue(measRecord, ApertureFluxAlgorithm::APERTURE_TRUNCATED, true); | ||
} | ||
if (result.getFlag(ApertureFluxAlgorithm::SINC_COEFFS_TRUNCATED)) { | ||
_flagHandler.setValue(measRecord, ApertureFluxAlgorithm::SINC_COEFFS_TRUNCATED, true); | ||
} | ||
} | ||
|
||
void ScaledApertureFluxAlgorithm::fail(afw::table::SourceRecord & measRecord, | ||
MeasurementError * error) const { | ||
_flagHandler.handleFailure(measRecord, error); | ||
} | ||
|
||
ScaledApertureFluxTransform::ScaledApertureFluxTransform( | ||
Control const & ctrl, | ||
std::string const & name, | ||
afw::table::SchemaMapper & mapper | ||
) : | ||
FluxTransform{name, mapper} | ||
{ | ||
for (auto flag = ApertureFluxAlgorithm::getFlagDefinitions().begin() + 1; | ||
flag < ApertureFluxAlgorithm::getFlagDefinitions().end(); flag++) { | ||
mapper.addMapping(mapper.getInputSchema().find<afw::table::Flag>(name + "_" + flag->name).key); | ||
} | ||
} | ||
|
||
}}} // namespace lsst::meas::base |
Why is the default scale 3.14? Can you add a doc string explaining?