Bayesian detection of point-like sources in sets of dithered frames.
First, construct a SignificanceMap
assuming a point-like source on a grid in x,y,wavelength on sky. Use ProjectorSet
to obtain the resolution elements on the CCDs in the dither set that are affected and compute their significance.
Then, segment the SignificanceMap
using an ImSegmenter
. For the segments with point-like morphology, go ahead and construct a full model of a point-like source and compare against the data in a chi2-sense.
PointSourceDetector::PointSourceDetector | ( | const DitherEnvironment & | DE | ) | [inline] |
void PointSourceDetector::detect | ( | ) |
Run the detection process for point sources: Compute the significance map, segment it, and compare the segments against point source models. Output catalog and cutout images.
References computeSignificanceMap(), DE_, DetectOptions::dump_segments, ImageSegmenter::expand(), DetectOptions::expand_sigma, g, DitherEnvironment::get_detect_parameters(), get_optimizer_strategy(), optimizeSegments(), placePointSourceModels(), DetectOptions::read_psigma, ImageSegmenter::segment(), DetectOptions::sigma, DetectOptions::xdetect_file, and DetectOptions::xdetect_size.
Referenced by main().
SignificanceMap PointSourceDetector::computeSignificanceMap | ( | ) | const [protected] |
Compute the significance map for a set of dithes by testing for the presence of a point source on coarse grid on sky and wavelength. The significance map contains the significance for a detection above the null-hypothesis that there's nothing there. Only the total amount of flux is tested, not the compatibility with a point source on sky or the CCD.
Compute the significance map for a set of dithes by testing for the presence of a point source on coarse grid on sky and wavelength. The significance map contains the significance for a detection above the null-hypothesis that there's nothing there. Only the total amount of flux is tested (the compatibility with point source on-sky), not the compatibility with a point source on the CCD. The latter is done in optimizeForChi2()
.
References PointSource::DetectionData::ap_sigma, DetectOptions::aperture, SignificanceMap::clear(), compute_sigma(), PointSource::dd, DE_, PointSource::debug_reselem_list(), DetectOptions::dump_segments, DetectOptions::dump_sigma, ProjectorSet::findResElemsForPointSourceInAperture(), g, DitherEnvironment::get_detect_parameters(), DitherEnvironment::get_grid_limits(), DitherEnvironment::get_output_basename(), DitherEnvironment::get_projector_set(), SkySampleLimits::index_to_l(), SkySampleLimits::index_to_x(), SkySampleLimits::index_to_y(), PointSource::DetectionData::l, SkySampleLimits::lmax, SkySampleLimits::lmin, SkySampleLimits::lstep, SkySampleLimits::nlstep, SkySampleLimits::nxstep, SkySampleLimits::nystep, P, DetectOptions::psf_size, SignificanceMap::set_sigma(), DetectOptions::sigma, SignificanceMap::write_significance_map(), SkySampleLimits::x_to_index(), DetectOptions::xdetect_file, SkySampleLimits::xmax, SkySampleLimits::xmin, PointSource::DetectionData::xs, SkySampleLimits::xstep, SkySampleLimits::ymax, SkySampleLimits::ymin, PointSource::DetectionData::ys, and SkySampleLimits::ystep.
Referenced by detect().
void PointSourceDetector::optimizeSegments | ( | list< ImSegment > & | segments, | |
const optimizerStrategy | opt | |||
) | [protected] |
Iterate over a segment list and for each segment, find the optimal point-source position and wavelength by comparing a full point-source model to the pixel fluxes making up the ResElems
in the ImSegment
.
References back_to_flambda(), DE_, detection_criteria(), dontOptimize, ImSegment::evalgood(), SkySampleLimits::findex_to_l(), SkySampleLimits::findex_to_x(), SkySampleLimits::findex_to_y(), ImSegment::fwhmzz_, g, generatePointSource(), DitherEnvironment::get_detect_parameters(), DitherEnvironment::get_grid_limits(), DitherEnvironment::get_output_basename(), ImSegment::icx_, ImSegment::icy_, ImSegment::icz_, ImSegment::id_, SkySampleLimits::lmin, log_detection(), log_outflux(), log_photometry(), SkySampleLimits::lstep, SkySampleLimits::lstep_fine, optimizeModelOnGrid(), optimizeModelWithSimplex(), photometry(), DitherEnvironment::write_cmd_line(), writeCutout(), and SkySampleLimits::xstep_fine.
Referenced by detect().
PointSource PointSourceDetector::optimizeModelOnGrid | ( | const ImSegment & | s, | |
std::ostream & | out, | |||
const optimizerStrategy | opt | |||
) | [protected] |
Find the optimal point-source model for a given ImSegment
by finding the optimal chi2 or Sigma on a fine grid in the neighborhood of the maximum intensity of the ImSegment
References PointSource::DetectionData::ap_sigma, PointSource::DetectionData::chi2_w, PointSource::DetectionData::dataflux, PointSource::dd, DE_, DetectOptions::dump_laes, DetectOptions::fwhm_sample_radius, ImSegment::fwhmxy_, ImSegment::fwhmzz_, g, generatePointSource(), DitherEnvironment::get_detect_parameters(), DitherEnvironment::get_grid_limits(), ImSegment::icx_, ImSegment::icy_, ImSegment::icz_, ImSegment::id_, SkySampleLimits::lmin, log_detection(), SkySampleLimits::lstep, SkySampleLimits::lstep_fine, PointSource::DetectionData::modflux, nline_, optimizeForSigma, DetectOptions::sigma, SkySampleLimits::xmin, SkySampleLimits::xstep, SkySampleLimits::xstep_fine, SkySampleLimits::ymin, and SkySampleLimits::ystep.
Referenced by optimizeSegments().
PointSource PointSourceDetector::optimizeModelWithSimplex | ( | const ImSegment & | s, | |
std::ostream & | out, | |||
const optimizerStrategy | opt | |||
) | [protected] |
Find the optimal point-source model for a given ImSegment
by simplex minimization of chi2 or Sigma in the neighborhood of the maximum intensity of the ImSegment
References a, DE_, SkySampleLimits::findex_to_l(), SkySampleLimits::findex_to_x(), SkySampleLimits::findex_to_y(), ImSegment::fwhmxy_, ImSegment::fwhmzz_, generatePointSource(), DitherEnvironment::get_grid_limits(), ImSegment::icx_, ImSegment::icy_, ImSegment::icz_, Amoeba< Func >::initialize_y(), SkySampleLimits::lstep, nline_, Amoeba< Func >::optimize(), OptimizePointSource, SkySampleLimits::xstep, and SkySampleLimits::ystep.
Referenced by optimizeSegments().
void PointSourceDetector::placePointSourceModels | ( | void | ) | [protected] |
Calculate chi2 for point-source models at a list of {x,y,lambda} on sky. No optimization is carried out. The list of positions are read from the cross-detection file.
Calculate chi2 for a point-source model at a list of {x,y,lambda} on sky. No optimization is carried out. The list of positions are read from the cross-detection file.
References DE_, g, generatePointSource(), DitherEnvironment::get_detect_parameters(), log_detection(), log_photometry(), nline_, DetectOptions::outputname, photometry(), DetectOptions::simsrc, DitherEnvironment::write_cmd_line(), DetectOptions::write_cutouts, writeCutout(), and DetectOptions::xdetect_file.
Referenced by detect().
PointSource PointSourceDetector::generatePointSource | ( | const float | source_x, | |
const float | source_y, | |||
const float | source_l | |||
) | const [protected] |
Fill in a struct
LAE with the full point-source model at sky position {x,y,lambda} and compute the chi2 for that model.
Fill in a struct
PointSource with the full point-source model at sky position {x,y,lambda} and compute the chi2 for that model.
References DetectOptions::aperture, compute_chi2(), compute_chi2_stacked(), compute_probabilities(), compute_sigma(), PointSource::dd, DE_, equivalent_width(), ProjectorSet::fillInPointSourceModel(), ProjectorSet::findResElemsForPointSourceInAperture(), DitherEnvironment::get_detect_parameters(), DitherEnvironment::get_projector_set(), PointSource::DetectionData::l, normalize_model(), P, PointSource::PointSourceModel, DetectOptions::psf_size, PointSource::DetectionData::xs, and PointSource::DetectionData::ys.
Referenced by optimizeModelOnGrid(), optimizeModelWithSimplex(), optimizeSegments(), and placePointSourceModels().
MArray< float, 2 > PointSourceDetector::make_image | ( | const PointSource & | data | ) | const [protected] |
Create an Image of all fibers exceeding g.flux_thresh drawing the model image, the data and the errors. px and py are the size of the PSF in pixels.
Create an Image of all fibers exceeding detect_pars_.flux_thresh drawing the model image, the data and the errors. px and py are the size of the PSF in pixels.
References PooledList< T >::begin(), consider_res_elem(), count_res_elems(), PointSource::dd, DE_, PooledList< T >::end(), PointSource::DetectionData::fdat_fmod, Pixel::flux, VFrame::get_distortion(), VFrame::get_fibermodel(), FiberModel::get_single_fiberflux(), DitherEnvironment::get_vframe(), ResElem::npix(), ResElem::p, PointSource::PointSourceModel, PointSource::px, PointSource::py, ResElem::tu, vframes_, Pixel::x, ResElem::x, Pixel::y, and ResElem::y.
Referenced by writeCutout().
void PointSourceDetector::make_image_header | ( | const PointSource & | data, | |
FitsHeader & | h | |||
) | const [protected] |
References __LEFTSPECTGR__, __xsize__, __ysize__, PointSource::DetectionData::ap_sigma, DetectOptions::aperture, ResElem::apfrac, PooledList< T >::begin(), PointSource::DetectionData::chi2, PointSource::DetectionData::chi2_s, PointSource::DetectionData::chi2_w, consider_res_elem(), PointSource::DetectionData::cont, ResElem::cont, PointSource::DetectionData::dataflux, PointSource::dd, DE_, detect_pars_, ResElem::dflux, ResElem::dfluxe, PooledList< T >::end(), PointSource::DetectionData::eqw, ResElem::ext, ResElem::f, PointSource::DetectionData::fb_sigma, PointSource::DetectionData::fdat_fmod, PointSource::DetectionData::gammq, PointSource::DetectionData::gammq_s, DitherEnvironment::get_datafile(), VFrame::get_distortion(), ifu::get_fiberd(), Projector::get_ifu(), DitherEnvironment::get_seeing(), DitherEnvironment::get_vframe(), ProjectorSet::getProjector(), PointSource::DetectionData::l, Distortion::map_xy_wavelength_fast(), ResElem::mflux, PointSource::DetectionData::modflux, P_, PointSource::PointSourceModel, PointSource::px, PointSource::py, ResElem::x, PointSource::DetectionData::xs, ResElem::xsky, ResElem::y, PointSource::DetectionData::ys, and ResElem::ysky.
Referenced by writeCutout().
void PointSourceDetector::writeCutout | ( | const PointSource & | best_PointSource, | |
const int | id | |||
) | const [protected] |
References PointSource::DetectionData::ap_sigma, PointSource::DetectionData::chi2, PointSource::DetectionData::chi2_s, PointSource::DetectionData::chi2_w, PointSource::DetectionData::cont, PointSource::dd, DE_, PointSource::DetectionData::eqw, DitherEnvironment::get_output_basename(), PointSource::DetectionData::l, make_image(), make_image_header(), PointSource::DetectionData::modflux, DitherEnvironment::write_cmd_line(), PointSource::DetectionData::xs, and PointSource::DetectionData::ys.
Referenced by optimizeSegments(), and placePointSourceModels().
bool PointSourceDetector::consider_res_elem | ( | const ResElem & | res | ) | const [inline, protected] |
check the properties of a resolution element to see if it should be dropped or included in the calculation of sigma, chi2, ...
References ResElem::apfrac, detect_pars_, DetectOptions::flux_thresh, and ResElem::ignore.
Referenced by compute_chi2(), compute_chi2_stacked(), compute_sigma(), count_res_elems(), equivalent_width(), make_image(), make_image_header(), normalize_model(), and photometry().
bool PointSourceDetector::detection_criteria | ( | const PointSource & | data | ) | const [protected] |
Check if a significant detection passes some criteria making it a good PointSource candidate
References PointSource::DetectionData::ap_sigma, DetectOptions::chi, PointSource::DetectionData::chi2, PointSource::DetectionData::chi2_w, DetectOptions::chi_w, PointSource::dd, detect_pars_, DetectOptions::eqw, PointSource::DetectionData::eqw, DetectOptions::flux, PointSource::DetectionData::modflux, and DetectOptions::sigma.
Referenced by optimizeSegments().
float PointSourceDetector::get_normflux | ( | float | value, | |
int | x, | |||
int | y | |||
) | const [protected] |
Referenced by compute_chi2().
void PointSourceDetector::normalize_model | ( | PointSource & | data | ) | const [protected] |
compute best-fit normalization of model to data, also calculate and update total measured flux and its error in the ResElems
References PooledList< T >::begin(), consider_res_elem(), PointSource::dd, ResElem::dflux, ResElem::dfluxe, PooledList< T >::end(), ResElem::f, PointSource::DetectionData::fdat_fmod, Pixel::flux, ProjectorSet::get_fiber_x(), ProjectorSet::get_fiber_y(), ResElem::npix(), ResElem::p, P_, PointSource::PointSourceModel, ResElem::tu, vframes_, Pixel::x, ResElem::xsky, Pixel::y, and ResElem::ysky.
Referenced by generatePointSource().
void PointSourceDetector::compute_chi2 | ( | PointSource & | data | ) | const [protected] |
compute best fit chisquare and flux value of tested PointSource Input:
References ResElem::apfrac, PooledList< T >::begin(), PointSource::DetectionData::chi2, PointSource::DetectionData::chi2_w, consider_res_elem(), PointSource::DetectionData::dataflux, PointSource::dd, PointSource::DetectionData::deg_f, ResElem::dflux, ResElem::dfluxe, PooledList< T >::end(), ResElem::ext, PointSource::DetectionData::fdat_fmod, Pixel::flux, PointSource::DetectionData::fluxfrac, get_normflux(), ResElem::mflux, PointSource::DetectionData::modflux, ResElem::npix(), ResElem::p, PointSource::PointSourceModel, ResElem::tu, vframes_, Pixel::x, and Pixel::y.
Referenced by generatePointSource().
void PointSourceDetector::compute_chi2_stacked | ( | PointSource & | data | ) | const [protected] |
compute best fit chisquare and flux value of tested PointSource using a stacked image Input:
References ResElem::apfrac, PooledList< T >::begin(), PointSource::DetectionData::chi2_s, consider_res_elem(), PointSource::dd, PointSource::DetectionData::deg_f_s, PooledList< T >::end(), PointSource::DetectionData::fdat_fmod, Pixel::flux, ResElem::npix(), ResElem::p, PointSource::PointSourceModel, PointSource::px, PointSource::py, ResElem::tu, vframes_, Pixel::x, ResElem::x, Pixel::y, and ResElem::y.
Referenced by generatePointSource().
void PointSourceDetector::compute_sigma | ( | PointSource & | data | ) | const [protected] |
compute significance of detection of tested PointSource also set ignore flag in res elements that have continuum detections Input:
compute significance of detection at a given location on the sky (and wavelength).
Input:
This is a hot-spot in the detection code. Performance needs to be monitored/improved.
References PointSource::DetectionData::ap_sigma, ResElem::apfrac, PooledList< T >::begin(), consider_res_elem(), PointSource::DetectionData::cont, ResElem::cont, PointSource::DetectionData::dcont, PointSource::dd, PooledList< T >::end(), PointSource::DetectionData::fb_sigma, ResElem::npix(), ResElem::p, PointSource::PointSourceModel, ResElem::tf, ResElem::tu, vframes_, ResElem::x, Pixel::x, and Pixel::y.
Referenced by computeSignificanceMap(), and generatePointSource().
void PointSourceDetector::compute_probabilities | ( | PointSource & | data | ) | const [protected] |
compute probabilities also set ignore flag in res elements that have continuum detections Input:
References PointSource::DetectionData::chi2, PointSource::DetectionData::chi2_s, PointSource::dd, PointSource::DetectionData::deg_f, PointSource::DetectionData::deg_f_s, gammq(), PointSource::DetectionData::gammq, and PointSource::DetectionData::gammq_s.
Referenced by generatePointSource().
void PointSourceDetector::equivalent_width | ( | PointSource & | data | ) | const [protected] |
compute the equivalent width Input:
compute the equivalent width Input:
References ResElem::apfrac, PooledList< T >::begin(), c, consider_res_elem(), PointSource::DetectionData::cont, PointSource::dd, DE_, PooledList< T >::end(), PointSource::DetectionData::eqw, ResElem::ext, VFrame::get_cont(), VFrame::get_distortion(), Projector::get_vframe(), DitherEnvironment::get_vframe(), Distortion::get_wavelength_boundaries(), ProjectorSet::getProjector(), ResElem::mflux, ResElem::npix(), ResElem::p, P_, PointSource::PointSourceModel, ResElem::tf, ResElem::tu, vframes_, Pixel::x, ResElem::x, Pixel::y, and ResElem::y.
Referenced by generatePointSource().
void PointSourceDetector::photometry | ( | PointSource & | data | ) | const [protected] |
do photometry on a detected point source detection
Input:
Note: Contrary to the name this routine currently only calculates the light center
perform weighted aperture photometry on a detected point source
Input:
References ResElem::apfrac, PooledList< T >::begin(), consider_res_elem(), PointSource::dd, DE_, PointSource::PhotometryData::dwflux, PooledList< T >::end(), PointSource::DetectionData::fluxfrac, PointSource::PhotometryData::fluxfrac, VFrame::get_cont(), DitherEnvironment::get_fluxnorm(), DitherEnvironment::get_vframe(), PointSource::PhotometryData::l, ResElem::l, ResElem::npix(), ResElem::p, PointSource::pd, PointSource::PointSourceModel, ResElem::tf, ResElem::tu, vframes_, PointSource::PhotometryData::wflux, PointSource::PhotometryData::x, ResElem::x, Pixel::x, ResElem::xsky, PointSource::PhotometryData::y, Pixel::y, and ResElem::ysky.
Referenced by optimizeSegments(), and placePointSourceModels().
int PointSourceDetector::count_res_elems | ( | const PointSource & | data | ) | const [protected] |
count the resolution elements in a PointSource
References PooledList< T >::begin(), consider_res_elem(), PooledList< T >::end(), and PointSource::PointSourceModel.
Referenced by make_image().
void PointSourceDetector::log_detection | ( | std::ostream & | out, | |
const int | sid, | |||
const PointSource & | ps | |||
) | [protected] |
Write data for the current model canididate to a log file (the .det file)
Write data for the current model candidate to a log file (the detect_line.dat file)
References PointSource::dd, and nline_.
Referenced by optimizeModelOnGrid(), optimizeSegments(), and placePointSourceModels().
void PointSourceDetector::log_photometry | ( | std::ostream & | out, | |
const int | sid, | |||
const PointSource & | ps | |||
) | [protected] |
Write photometry for the current model candidate to a detect_phot.dat file
References PointSource::pd.
Referenced by optimizeSegments(), and placePointSourceModels().
float PointSourceDetector::back_to_flambda | ( | const float | photcount, | |
const float | tint, | |||
const float | lam | |||
) | [protected] |
References c.
Referenced by optimizeSegments().
void PointSourceDetector::log_outflux | ( | std::ostream & | out, | |
const float | pxx, | |||
const float | pyy, | |||
const float | photcount, | |||
const float | photdcount, | |||
const float | photflux, | |||
const float | photdflux | |||
) | [protected] |
Referenced by optimizeSegments().
PointSourceDetector::optimizerStrategy PointSourceDetector::get_optimizer_strategy | ( | const DetectOptions & | g | ) | [protected] |
References dontOptimize, DetectOptions::optimize, optimizeForChi2, and optimizeForSigma.
Referenced by detect().
friend class OptimizePointSource [friend] |
Referenced by optimizeModelWithSimplex().
const DitherEnvironment& PointSourceDetector::DE_ [protected] |
const DetectOptions& PointSourceDetector::detect_pars_ [protected] |
Referenced by consider_res_elem(), detection_criteria(), and make_image_header().
const ProjectorSet& PointSourceDetector::P_ [protected] |
Referenced by equivalent_width(), make_image_header(), and normalize_model().
const vector<VFrame >& PointSourceDetector::vframes_ [protected] |
Referenced by compute_chi2(), compute_chi2_stacked(), compute_sigma(), equivalent_width(), make_image(), normalize_model(), and photometry().
int PointSourceDetector::nline_ [protected] |
Referenced by log_detection(), optimizeModelOnGrid(), optimizeModelWithSimplex(), and placePointSourceModels().