SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
FluxMeasurement.cpp
Go to the documentation of this file.
1
17/*
18 * FluxMeasurement.cpp
19 *
20 * Created on: Oct 19, 2018
21 * Author: Alejandro Alvarez
22 */
23
26
27namespace SourceXtractor {
28
30
37 centroid_x -= min_pixel.m_x;
38 centroid_y -= min_pixel.m_y;
39 auto mirror_x = 2 * centroid_x - pixel_x + 0.49999;
40 auto mirror_y = 2 * centroid_y - pixel_y + 0.49999;
41 if (img.isInside(mirror_x, mirror_y)) {
44 // mirror pixel is OK: take the value
46 }
47 }
48 return std::make_pair(0., 0.);
49}
50
54 bool use_symmetry) {
56
57 auto min_pixel = aperture->getMinPixel(centroid_x, centroid_y);
58 auto max_pixel = aperture->getMaxPixel(centroid_x, centroid_y);
59
60 // Skip if the full source is outside the frame
61 if (max_pixel.m_x < 0 || max_pixel.m_y < 0 || min_pixel.m_x >= img->getWidth() ||
62 min_pixel.m_y >= img->getHeight()) {
64 return measurement;
65 }
66
67 // Clip to the image and recenter centroid to the cut
68 if (min_pixel.clip(img->getWidth(), img->getHeight()))
70 if (max_pixel.clip(img->getWidth(), img->getHeight()))
72
73 // Cutout
74 auto img_cutout = img->getChunk(min_pixel, max_pixel);
75 auto var_cutout = variance_map->getChunk(min_pixel, max_pixel);
76
77 // iterate over the aperture pixels
78 for (int pixel_y = 0; pixel_y < img_cutout->getHeight(); pixel_y++) {
79 for (int pixel_x = 0; pixel_x < img_cutout->getWidth(); pixel_x++) {
82
83 // get the area coverage and continue if there is overlap
84 auto area = aperture->getArea(centroid_x, centroid_y, min_pixel.m_x + pixel_x,
85 min_pixel.m_y + pixel_y);
86 if (area == 0) {
87 continue;
88 }
89
90 measurement.m_total_area += area;
91
94 measurement.m_bad_area += 1;
95 if (use_symmetry) {
99 );
100 }
101 }
102 else {
105 }
106
107 measurement.m_flux += pixel_value * area;
108 measurement.m_variance += pixel_variance * area;
109 }
110 }
111
112 // check/set the bad area flag
113 bool is_biased = measurement.m_total_area > 0 && measurement.m_bad_area / measurement.m_total_area > BADAREA_THRESHOLD_APER;
115 return measurement;
116}
117
118} // end SourceXtractor
T make_pair(T... args)
const SeFloat BADAREA_THRESHOLD_APER
Definition Flagging.cpp:25
@ OUTSIDE
The object is completely outside of the measurement frame.
@ BOUNDARY
The object is truncated (too close to an image boundary)
@ BIASED
The object has bad pixels.
static std::tuple< SeFloat, SeFloat > getMirrorPixel(SeFloat centroid_x, SeFloat centroid_y, PixelCoordinate min_pixel, int pixel_x, int pixel_y, const ImageChunk< SeFloat > &img, const ImageChunk< SeFloat > &variance_map, SeFloat variance_threshold)
SeFloat32 SeFloat
Definition Types.h:32
FluxMeasurement measureFlux(const std::shared_ptr< Aperture > &aperture, SeFloat centroid_x, SeFloat centroid_y, const std::shared_ptr< Image< SeFloat > > &img, const std::shared_ptr< Image< SeFloat > > &variance_map, SeFloat variance_threshold, bool use_symmetry)
A pixel coordinate made of two integers m_x and m_y.
T tie(T... args)