LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lsst::meas::algorithms::SizeMagnitudeStarSelector Class Reference

#include <SizeMagnitudeStarSelector.h>

Public Types

typedef float PixelT
 
typedef
lsst::afw::image::Exposure
< PixelT
Exposure
 
typedef lsst::afw::geom::PointD PointD
 
typedef lsst::pex::policy::Policy Policy
 
typedef
lsst::afw::table::SourceRecord 
SourceRecord
 
typedef
lsst::afw::table::SourceTable 
SourceTable
 
typedef
lsst::afw::table::SourceCatalog 
SourceCatalog
 
typedef
lsst::meas::algorithms::PsfCandidate
< PixelT
PsfCandidateT
 
typedef PsfCandidateT::PtrList PsfCandidateList
 

Public Member Functions

 SizeMagnitudeStarSelector (const Policy &policy)
 Create a size-magnitude star selector from a policy. More...
 
 ~SizeMagnitudeStarSelector ()
 Destructor. More...
 
PsfCandidateList selectStars (const Exposure &exposure, const SourceCatalog &sourceList, boost::shared_ptr< afw::table::ReferenceMatchVector const > matches=boost::shared_ptr< afw::table::ReferenceMatchVector const >()) const
 Find a set of stars from an input list of Sources. More...
 

Private Member Functions

double calculateSourceSize (const SourceRecord &source, const Exposure &exposure) const
 Calculates a robust size measurement for a source. More...
 
 SizeMagnitudeStarSelector (const SizeMagnitudeStarSelector &rhs)
 This class is not intended to be copied. More...
 
void operator= (const SizeMagnitudeStarSelector &rhs)
 

Private Attributes

boost::shared_ptr
< SizeMagnitudeStarSelectorImpl
pImpl
 

Detailed Description

Definition at line 49 of file SizeMagnitudeStarSelector.h.

Member Typedef Documentation

Definition at line 53 of file SizeMagnitudeStarSelector.h.

Definition at line 52 of file SizeMagnitudeStarSelector.h.

Definition at line 54 of file SizeMagnitudeStarSelector.h.

Definition at line 55 of file SizeMagnitudeStarSelector.h.

Definition at line 61 of file SizeMagnitudeStarSelector.h.

Definition at line 59 of file SizeMagnitudeStarSelector.h.

Definition at line 58 of file SizeMagnitudeStarSelector.h.

Definition at line 56 of file SizeMagnitudeStarSelector.h.

Definition at line 57 of file SizeMagnitudeStarSelector.h.

Constructor & Destructor Documentation

lsst::meas::algorithms::SizeMagnitudeStarSelector::SizeMagnitudeStarSelector ( const Policy policy)

Create a size-magnitude star selector from a policy.

Parameters
[in]policy:see policy/SizeMagnitudeStarSelectorDictionary.paf

Definition at line 58 of file SizeMagnitudeStarSelector.cc.

59 {
60  using shapelet::ConfigFile;
61 
62  // Convert Policy info into my ConfigFile format:
63  ConfigFile params;
64  params["minsize"] = policy.getDouble("minsize");
65  params["maxsize"] = policy.getDouble("maxsize");
66  params["logsize"] = policy.getBool("logsize");
67  params["minmag"] = policy.getDouble("minmag");
68  params["maxmag"] = policy.getDouble("maxmag");
69  params["starfrac"] = policy.getDouble("starfrac");
70  params["startn1"] = policy.getDouble("startn1");
71  params["fitorder"] = policy.getInt("fitorder");
72  params["fitsigclip"] = policy.getDouble("fitsigclip");
73  params["starsperbin"] = policy.getInt("starsperbin");
74  params["purityratio"] = policy.getDouble("purityratio");
75 
76  // The rest of these are just given defaults.
77  // In my experience, there is not much reason to make these
78  // run-time modifiable.
79  params["maxoutmag"] = params["maxmag"];
80  params["ndivx"] = 1;
81  params["ndivy"] = 1;
82  params["magstep1"] = 0.25;
83  params["magstep2"] = 0.1;
84  params["reject1"] = params["fitsigclip"];
85  params["reject2"] = params["fitsigclip"];
86  params["maxratio1"] = 3.0 * double(params["purityratio"]);
87  params["binsize1"] = 0.1;
88  params["minbinsize"] = 0.01;
89  params["miniter1"] = 3;
90  params["miniter2"] = 2;
91  params["startn2"] = 3 * int(params["startn1"]);
92  params["okvalcount"] = 2;
93  params["maxrms"] = 0.05;
94  params["maxrefititer"] = 5;
95 
96  pImpl = boost::shared_ptr<SizeMagnitudeStarSelectorImpl>(new SizeMagnitudeStarSelectorImpl(params, policy));
97 }
boost::shared_ptr< SizeMagnitudeStarSelectorImpl > pImpl
lsst::meas::algorithms::SizeMagnitudeStarSelector::~SizeMagnitudeStarSelector ( )
inline

Destructor.

Definition at line 73 of file SizeMagnitudeStarSelector.h.

73 {};
lsst::meas::algorithms::SizeMagnitudeStarSelector::SizeMagnitudeStarSelector ( const SizeMagnitudeStarSelector rhs)
private

This class is not intended to be copied.

Member Function Documentation

double lsst::meas::algorithms::SizeMagnitudeStarSelector::calculateSourceSize ( const SourceRecord source,
const Exposure exposure 
) const
private

Calculates a robust size measurement for a source.

This measures the 2nd order shapelet decomposition of the object, allowing the sigma to vary until the b11 term goes to zero. When this happens, the sigma is basically the best-fit Gaussian sigma. Also, this value of sigma gives the best S/N properties for the rest of the shapelet vector.

This size measurement has proven to be a good one to use for the size-magnitude star finder algorithm, since the size is very stable with stellar magnitude.

Note
This may not be necessary. Lupton says that there is already a similar measurement being done in the LSST stack. Should check if the existing values are ok for star finder algorithm. (I'm not sure which entry in Source they would be...) Therefore, this function may be a good candidate for a having its action be specifiable by a Policy parameter.

Definition at line 99 of file SizeMagnitudeStarSelector.cc.

102 {
103  double sigma = sqrt(source.getIxx() + source.getIyy());
104  if (!(sigma > 0.)) return -1.;
105  Shapelet shape(4, sigma);
106  double x = source.getX();
107  double y = source.getY();
108  PointD pos(x, y);
109  if (shape.measureFromImage(
110  source, pos, false, false, pImpl->getAperture(), exposure)) {
111  return shape.getSigma();
112  } else {
113  return -1.;
114  }
115 }
int y
boost::shared_ptr< SizeMagnitudeStarSelectorImpl > pImpl
afw::table::Key< double > sigma
Definition: GaussianPsf.cc:43
double x
void lsst::meas::algorithms::SizeMagnitudeStarSelector::operator= ( const SizeMagnitudeStarSelector rhs)
private
SizeMagnitudeStarSelector::PsfCandidateList lsst::meas::algorithms::SizeMagnitudeStarSelector::selectStars ( const Exposure exposure,
const SourceCatalog sourceList,
boost::shared_ptr< afw::table::ReferenceMatchVector const >  matches = boost::shared_ptr< afw::table::ReferenceMatchVector const>() 
) const

Find a set of stars from an input list of Sources.

This function uses an algorithm based on looking for a stellar locus in the size-magnitude diagram that has constant size.

It basically construct a histogram of counts with respect to size, starting with just the bright objects and then pushing down in magnitude until the stellar peak starts to bleed into the galaxies, at which point it stops.

Parameters
exposurethe exposure on which the sources are found
sourceListThe input list of sources to consider
matchesastrometric matches (ignored by this algorithm)

Definition at line 133 of file SizeMagnitudeStarSelector.cc.

137  {
138  pexLogging::Debug traceLog("meas.algorithms.SizeMagnitudeStarSelector"); // trace output goes here
139  const unsigned int MIN_OBJ_TO_TRY = 30;
140 
141  typedef Exposure::MaskedImageT MaskedImage;
142  std::vector<shapelet::PotentialStar*> maybeStars;
143 
144  // First get a list of potential stars
145  const int nSources = sourceList.size();
146  traceLog.debug<4>("%d candidate stars", nSources);
147  for (int i=0; i<nSources; ++i) {
148  double const x = sourceList[i].getX();
149  double const y = sourceList[i].getY();
150  double const size = calculateSourceSize(sourceList[i], exposure);
151  double const mag = calculateSourceMagnitude(sourceList[i], exposure);
152 
153  shapelet::Position pos(x, y);
154 
155  // Range checking
156  bool ok = true;
157  if (!pImpl->isOkSize(size)) {
158  ok = false;
159  }
160  if (ok && !pImpl->isOkMag(mag)) {
161  ok = false;
162  }
163  traceLog.debug<5>("i, x, y, size, mag = %d %.1f, %.1f %g %g: %d", i, x, y, size, mag, ok);
164 
165  if (ok) {
166  double logSize = pImpl->convertToLogSize(size);
167  maybeStars.push_back(new shapelet::PotentialStar(pos, mag, logSize, i, ""));
168  }
169  }
170  traceLog.debug<4>("Total potential stars = %d", maybeStars.size());
171  if (maybeStars.size() < MIN_OBJ_TO_TRY) {
172  // Too few objects for algorithm to have any chance of producing reasonable output.
174  str(boost::format("Only %d viable objects for star selection. "
175  "This algorithm needs at least %d objects to try to find stars")
176  % maybeStars.size() % MIN_OBJ_TO_TRY));
177 
178  return PsfCandidateList();
179  }
180 
181  // Run the actual algorithm
182  std::vector<shapelet::PotentialStar*> stars = pImpl->findStars(maybeStars);
183  traceLog.debug<4>("Identified %d stars", stars.size());
184 
185  // Convert the results into a PsfCandidateList
186  //MaskedImage::ConstPtr imagePtr = MaskedImage::ConstPtr(new MaskedImage(exposure.getMaskedImage(), false));
187  CONST_PTR(Exposure) expPtr = CONST_PTR(Exposure)(new Exposure(exposure, false));
188  PsfCandidateList psfCandidateList;
189  const int nStars = stars.size();
190  for (int k=0; k<nStars; ++k) {
191  if (pImpl->isOkOutputMag(stars[k]->getMag())) {
192  int i=stars[k]->getIndex();
193  PTR(PsfCandidateT) psfCandidate(new PsfCandidateT(
194  sourceList.get(i),
195  expPtr,
196  stars[k]->getPos().getX(),
197  stars[k]->getPos().getY()));
198  psfCandidateList.push_back(psfCandidate);
199  }
200  }
201 
202  return psfCandidateList;
203 }
int y
for(FootprintList::const_iterator ptr=feet->begin(), end=feet->end();ptr!=end;++ptr)
Definition: saturated.cc:82
boost::shared_ptr< SizeMagnitudeStarSelectorImpl > pImpl
static const int WARN
Definition: Log.h:177
#define PTR(...)
Definition: base.h:41
void log(int importance, const std::string &message, const lsst::daf::base::PropertySet &properties)
MaskedImage< ImageT, MaskT, VarianceT > MaskedImageT
Definition: Exposure.h:51
static Log & getDefaultLog()
double x
lsst::meas::algorithms::PsfCandidate< PixelT > PsfCandidateT
double calculateSourceSize(const SourceRecord &source, const Exposure &exposure) const
Calculates a robust size measurement for a source.
#define CONST_PTR(...)
Definition: base.h:47

Member Data Documentation

boost::shared_ptr<SizeMagnitudeStarSelectorImpl> lsst::meas::algorithms::SizeMagnitudeStarSelector::pImpl
private

Definition at line 126 of file SizeMagnitudeStarSelector.h.


The documentation for this class was generated from the following files: