Skip to content

Commit

Permalink
Merge pull request #137 from lsst/tickets/DM-10302
Browse files Browse the repository at this point in the history
DM-10302 Change flux->instFlux
  • Loading branch information
parejkoj committed Sep 19, 2018
2 parents a49ff43 + 2673d7b commit 6a7bfb3
Show file tree
Hide file tree
Showing 21 changed files with 98 additions and 98 deletions.
2 changes: 1 addition & 1 deletion examples/measAlgTasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def run(display=False):
config.algorithms.names = ["base_SdssCentroid", "base_SdssShape", "base_CircularApertureFlux"]
config.algorithms["base_CircularApertureFlux"].radii = [1, 2, 4, 8, 16] # pixels

config.slots.instFlux = None
config.slots.gaussianFlux = None
config.slots.modelFlux = None
config.slots.psfFlux = None

Expand Down
4 changes: 2 additions & 2 deletions include/lsst/meas/algorithms/PsfCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class PsfCandidate : public afw::math::SpatialCellImageCandidate {
*
* @note Required method for use by SpatialCell
*/
double getCandidateRating() const { return _source->getPsfFlux(); }
double getCandidateRating() const { return _source->getPsfInstFlux(); }

/// Return the original Source
PTR(afw::table::SourceRecord) getSource() const { return _source; }
Expand Down Expand Up @@ -179,7 +179,7 @@ std::shared_ptr<PsfCandidate<PixelT>> makePsfCandidate(PTR(afw::table::SourceRec
const & source, ///< The detected Source
PTR(afw::image::Exposure<PixelT>)
image ///< The image wherein lies the object
) {
) {
return std::make_shared<PsfCandidate<PixelT>>(source, image);
}

Expand Down
6 changes: 3 additions & 3 deletions python/lsst/meas/algorithms/astrometrySourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def _getSchemaKeys(self, schema):
self.saturatedKey = schema["base_PixelFlags_flag_saturated"].asKey()

fluxPrefix = "slot_%sFlux_" % (self.config.sourceFluxType,)
self.fluxKey = schema[fluxPrefix + "flux"].asKey()
self.instFluxKey = schema[fluxPrefix + "instFlux"].asKey()
self.fluxFlagKey = schema[fluxPrefix + "flag"].asKey()
self.fluxErrKey = schema[fluxPrefix + "fluxErr"].asKey()
self.instFluxErrKey = schema[fluxPrefix + "instFluxErr"].asKey()

def _isMultiple(self, sourceCat):
"""Return True for each source that is likely multiple sources."""
Expand Down Expand Up @@ -146,7 +146,7 @@ def _goodSN(self, sourceCat):
return True
else:
with np.errstate(invalid="ignore"): # suppress NAN warnings
return sourceCat.get(self.fluxKey)/sourceCat.get(self.fluxErrKey) > self.config.minSnr
return sourceCat.get(self.instFluxKey)/sourceCat.get(self.instFluxErrKey) > self.config.minSnr

def _isUsable(self, sourceCat):
"""
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/meas/algorithms/dynamicDetection.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self, *args, **kwargs):
config = ForcedMeasurementTask.ConfigClass()
config.plugins.names = ['base_TransformedCentroid', 'base_PsfFlux', 'base_LocalBackground']
# We'll need the "centroid" and "psfFlux" slots
for slot in ("shape", "psfShape", "apFlux", "modelFlux", "instFlux", "calibFlux"):
for slot in ("shape", "psfShape", "apFlux", "modelFlux", "gaussianFlux", "calibFlux"):
setattr(config.slots, slot, None)
config.copyColumns = {}
self.skySchema = SourceTable.makeMinimalSchema()
Expand Down Expand Up @@ -118,9 +118,9 @@ def calculateThreshold(self, exposure, seed, sigma=None):
self.skyMeasurement.run(catalog, exposure, catalog, exposure.getWcs())

# Calculate new threshold
fluxes = catalog["base_PsfFlux_flux"]
fluxes = catalog["base_PsfFlux_instFlux"]
area = catalog["base_PsfFlux_area"]
bg = catalog["base_LocalBackground_flux"]
bg = catalog["base_LocalBackground_instFlux"]

good = (~catalog["base_PsfFlux_flag"] & ~catalog["base_LocalBackground_flag"] &
np.isfinite(fluxes) & np.isfinite(area) & np.isfinite(bg))
Expand All @@ -134,7 +134,7 @@ def calculateThreshold(self, exposure, seed, sigma=None):

lq, uq = np.percentile((fluxes - bg*area)[good], [25.0, 75.0])
stdevMeas = 0.741*(uq - lq)
medianError = np.median(catalog["base_PsfFlux_fluxErr"][good])
medianError = np.median(catalog["base_PsfFlux_instFluxErr"][good])
return Struct(multiplicative=medianError/stdevMeas, additive=bgMedian)

def detectFootprints(self, exposure, doSmooth=True, sigma=None, clearMask=True, expId=None):
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/meas/algorithms/matcherSourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def _getSchemaKeys(self, schema):
self.centroidFlagKey = schema["slot_Centroid_flag"].asKey()

fluxPrefix = "slot_%sFlux_" % (self.config.sourceFluxType,)
self.fluxField = fluxPrefix + "flux"
self.fluxKey = schema[fluxPrefix + "flux"].asKey()
self.fluxField = fluxPrefix + "instFlux"
self.fluxKey = schema[fluxPrefix + "instFlux"].asKey()
self.fluxFlagKey = schema[fluxPrefix + "flag"].asKey()
self.fluxErrKey = schema[fluxPrefix + "fluxErr"].asKey()
self.fluxErrKey = schema[fluxPrefix + "instFluxErr"].asKey()

def _isParent(self, sourceCat):
"""Return True for each source that is the parent source."""
Expand Down Expand Up @@ -124,7 +124,7 @@ def _isUsable(self, sourceCat):
For a source to be usable it must:
- have a valid centroid
- not be deblended
- have a valid flux (of the type specified in this object's constructor)
- have a valid instFlux (of the type specified in this object's constructor)
- have adequate signal-to-noise
"""
return self._hasCentroid(sourceCat) \
Expand Down Expand Up @@ -166,7 +166,7 @@ def _isUsable(self, sourceCat):
For a source to be usable it must:
- have a valid centroid
- not be deblended
- have a valid flux (of the type specified in this object's constructor)
- have a valid instFlux (of the type specified in this object's constructor)
- have adequate signal-to-noise
"""
result = MatcherSourceSelectorTask._isUsable(self, sourceCat)
Expand Down
14 changes: 7 additions & 7 deletions python/lsst/meas/algorithms/measureApCorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def __init__(self, name, schema):
@parma[in] name name of flux measurement algorithm, e.g. "base_PsfFlux"
@param[in,out] schema catalog schema containing the flux field
read: {name}_flux, {name}_fluxErr, {name}_flag
read: {name}_instFlux, {name}_instFluxErr, {name}_flag
added: apcorr_{name}_used
"""
self.flux = schema.find(name + "_flux").key
self.err = schema.find(name + "_fluxErr").key
self.flux = schema.find(name + "_instFlux").key
self.err = schema.find(name + "_instFluxErr").key
self.flag = schema.find(name + "_flag").key
self.used = schema.addField("apcorr_" + name + "_used", type="Flag",
doc="set if source was used in measuring aperture correction")
Expand Down Expand Up @@ -200,8 +200,8 @@ def run(self, exposure, catalog):
@return an lsst.pipe.base.Struct containing:
- apCorrMap: an aperture correction map (lsst.afw.image.ApCorrMap) that contains two entries
for each flux field:
- flux field (e.g. base_PsfFlux_flux): 2d model
- flux sigma field (e.g. base_PsfFlux_fluxErr): 2d model of error
- flux field (e.g. base_PsfFlux_instFlux): 2d model
- flux sigma field (e.g. base_PsfFlux_instFluxErr): 2d model of error
"""
bbox = exposure.getBBox()
import lsstDebug
Expand All @@ -218,8 +218,8 @@ def run(self, exposure, catalog):

# Outer loop over the fields we want to correct
for name, keys in self.toCorrect.items():
fluxName = name + "_flux"
fluxErrName = name + "_fluxErr"
fluxName = name + "_instFlux"
fluxErrName = name + "_instFluxErr"

# Create a more restricted subset with only the objects where the to-be-correct flux
# is not flagged.
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/meas/algorithms/objectSizeStarSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ObjectSizeStarSelectorConfig(BaseSourceSelectorTask.ConfigClass):
sourceFluxField = pexConfig.Field(
doc="Name of field in Source to use for flux measurement",
dtype=str,
default="base_GaussianFlux_flux",
default="base_GaussianFlux_instFlux",
)
widthStdAllowed = pexConfig.Field(
doc="Standard deviation of width allowed to be interpreted as good stars",
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/meas/algorithms/sourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class FluxLimit(BaseLimit):
the limit, and then the `apply` method can be used to identify sources
in the catalog that match the configured limit.
"""
fluxField = pexConfig.Field(dtype=str, default="slot_CalibFlux_flux",
fluxField = pexConfig.Field(dtype=str, default="slot_CalibFlux_instFlux",
doc="Name of the source flux field to use.")

def apply(self, catalog):
Expand Down Expand Up @@ -492,8 +492,8 @@ class ScienceSourceSelectorConfig(pexConfig.Config):
def setDefaults(self):
pexConfig.Config.setDefaults(self)
self.flags.bad = ["base_PixelFlags_flag_edge", "base_PixelFlags_flag_saturated", "base_PsfFlux_flags"]
self.signalToNoise.fluxField = "base_PsfFlux_flux"
self.signalToNoise.errField = "base_PsfFlux_fluxErr"
self.signalToNoise.fluxField = "base_PsfFlux_instFlux"
self.signalToNoise.errField = "base_PsfFlux_instFluxErr"


@pexConfig.registerConfigurable("science", sourceSelectorRegistry)
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/meas/algorithms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def showPsfCandidates(exposure, psfCellSet, psf=None, frame=None, normalize=True
lab = "%d chi^2 %.1f" % (objId, rchi2)
ctype = ds9.RED if cand.isBad() else ds9.GREEN
else:
lab = "%d flux %8.3g" % (objId, cand.getSource().getPsfFlux())
lab = "%d flux %8.3g" % (objId, cand.getSource().getPsfInstFlux())
ctype = ds9.GREEN

mos.append(im, lab, ctype)
Expand Down Expand Up @@ -772,11 +772,11 @@ def showPsfResiduals(exposure, sourceSet, magType="psf", scale=10, frame=None):

try:
if magType == "ap":
flux = s.getApFlux()
flux = s.getApInstFlux()
elif magType == "model":
flux = s.getModelFlux()
flux = s.getModelInstFlux()
elif magType == "psf":
flux = s.getPsfFlux()
flux = s.getPsfInstFlux()
else:
raise RuntimeError("Unknown flux type %s" % magType)

Expand Down Expand Up @@ -823,7 +823,7 @@ def saveSpatialCellSet(psfCellSet, fileName="foo.fits", frame=None):
md.set("YCENTER", cand.getYCenter())
md.set("BAD", cand.isBad())
md.set("AMPL", cand.getAmplitude())
md.set("FLUX", cand.getSource().getPsfFlux())
md.set("FLUX", cand.getSource().getPsfInstFlux())
md.set("CHI2", cand.getSource().getChi2())

im.writeFits(fileName, md, mode)
Expand Down
2 changes: 1 addition & 1 deletion src/ImagePsf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ double ImagePsf::doComputeApertureFlux(double radius, geom::Point2D const& posit
afw::geom::ellipses::Axes const axes(radius, radius);
base::ApertureFluxResult result = base::ApertureFluxAlgorithm::computeSincFlux(
image, afw::geom::ellipses::Ellipse(axes, center), base::ApertureFluxControl());
return result.flux;
return result.instFlux;
}

afw::geom::ellipses::Quadrupole ImagePsf::doComputeShape(geom::Point2D const& position,
Expand Down
18 changes: 9 additions & 9 deletions src/SpatialModelPsf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class SetPcaImageVisitor : public afw::math::CandidateVisitor {
imCandidate->getXCenter() % imCandidate->getYCenter()));
}

_imagePca->addImage(im, imCandidate->getSource()->getPsfFlux());
_imagePca->addImage(im, imCandidate->getSource()->getPsfInstFlux());
} catch (lsst::pex::exceptions::LengthError&) {
return;
}
Expand Down Expand Up @@ -161,7 +161,7 @@ template <typename ImageT>
std::vector<std::shared_ptr<ImageT>> offsetKernel(
afw::math::LinearCombinationKernel const& kernel, ///< the Kernel to offset
float dx, float dy ///< Offset to apply
) {
) {
afw::math::KernelList kernels = kernel.getKernelList(); // The Kernels that kernel adds together
unsigned int const nKernel = kernels.size(); // Number of kernel components
std::vector<std::shared_ptr<ImageT>> kernelImages(nKernel); // Images of each Kernel in kernels
Expand Down Expand Up @@ -200,7 +200,7 @@ createKernelFromPsfCandidates(
int const nStarPerCell, ///< max no. of stars per cell; <= 0 => infty
bool const constantWeight, ///< should each star have equal weight in the fit?
int const border ///< Border size for background subtraction
) {
) {
typedef typename afw::image::Image<PixelT> ImageT;
typedef typename afw::image::MaskedImage<PixelT> MaskedImageT;

Expand Down Expand Up @@ -354,7 +354,7 @@ std::pair<double, double> fitKernel(ModelImageT const& mImage, // The model ima
double lambda = 0.0, // floor for variance is lambda*data
bool detected = true, // only fit DETECTED pixels?
int const id = -1 // ID for this object; useful in debugging
) {
) {
assert(data.getDimensions() == mImage.getDimensions());
assert(id == id);
int const DETECTED = afw::image::Mask<>::getPlaneBitMask("DETECTED");
Expand Down Expand Up @@ -595,7 +595,7 @@ std::pair<bool, double> fitSpatialKernelFromPsfCandidates(
int const nStarPerCell, ///< max no. of stars per cell; <= 0 => infty
double const tolerance, ///< Tolerance; how close chi^2 should be to true minimum
double const lambda ///< floor for variance is lambda*data
) {
) {
int const nComponents = kernel->getNKernelParameters();
int const nSpatialParams = kernel->getNSpatialParameters();
//
Expand Down Expand Up @@ -880,7 +880,7 @@ std::pair<bool, double> fitSpatialKernelFromPsfCandidates(
int const nStarPerCell, ///< max no. of stars per cell; <= 0 => infty
double const tolerance, ///< Tolerance; how close chi^2 should be to true minimum
double const lambda ///< floor for variance is lambda*data
) {
) {
if (doNonLinearFit) {
return fitSpatialKernelFromPsfCandidates<PixelT>(kernel, psfCells, nStarPerCell, tolerance);
}
Expand Down Expand Up @@ -978,7 +978,7 @@ double subtractPsf(afw::detection::Psf const& psf, ///< the PSF to subtract
double x, ///< column position
double y, ///< row position
double psfFlux ///< object's PSF flux (if not NaN)
) {
) {
if (std::isnan(x + y)) {
return std::numeric_limits<double>::quiet_NaN();
}
Expand Down Expand Up @@ -1038,7 +1038,7 @@ std::pair<std::vector<double>, afw::math::KernelList> fitKernelParamsToImage(
afw::math::LinearCombinationKernel const& kernel, ///< the Kernel to fit
Image const& image, ///< the image to be fit
geom::Point2D const& pos ///< the position of the object
) {
) {
typedef afw::image::Image<afw::math::Kernel::Pixel> KernelT;

afw::math::KernelList kernels = kernel.getKernelList(); // the Kernels that kernel adds together
Expand Down Expand Up @@ -1106,7 +1106,7 @@ std::pair<std::shared_ptr<afw::math::Kernel>, std::pair<double, double>> fitKern
afw::math::LinearCombinationKernel const& kernel, ///< the Kernel to fit
Image const& image, ///< the image to be fit
geom::Point2D const& pos ///< the position of the object
) {
) {
std::pair<std::vector<double>, afw::math::KernelList> const fit =
fitKernelParamsToImage(kernel, image, pos);
std::vector<double> params = fit.first;
Expand Down

0 comments on commit 6a7bfb3

Please sign in to comment.