SourceXtractorPlusPlus
1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Plugin
SourcePsf
SourcePsfTask.cpp
Go to the documentation of this file.
1
17
18
#include <numeric>
19
#include "
SEImplementation/Plugin/SourcePsf/SourcePsfProperty.h
"
20
#include "
SEImplementation/Plugin/MeasurementFramePixelCentroid/MeasurementFramePixelCentroid.h
"
21
#include "
SEImplementation/CheckImages/CheckImages.h
"
22
#include "
SEImplementation/Image/WriteableImageInterfaceTraits.h
"
23
#include "
SEImplementation/Plugin/SourcePsf/SourcePsfTask.h
"
24
25
namespace
SourceXtractor
{
26
27
static
double
getCoordX
(
SourceXtractor::SourceInterface
& source,
unsigned
instance) {
28
auto
& pixel_centroid = source.
getProperty
<
MeasurementFramePixelCentroid
>(instance);
29
return
pixel_centroid.
getCentroidX
();
30
}
31
32
static
double
getCoordY
(
SourceXtractor::SourceInterface
& source,
unsigned
instance) {
33
auto
& pixel_centroid = source.
getProperty
<
MeasurementFramePixelCentroid
>(instance);
34
return
pixel_centroid.
getCentroidY
();
35
}
36
37
std::map<std::string, SourcePsfTask::ValueGetter>
SourcePsfTask::component_value_getters
{
38
{
"X_IMAGE"
,
getCoordX
},
39
{
"Y_IMAGE"
,
getCoordY
},
40
{
"XWIN_IMAGE"
,
getCoordX
},
41
{
"YWIN_IMAGE"
,
getCoordY
},
42
{
"XPEAK_IMAGE"
,
getCoordX
},
43
{
"YPEAK_IMAGE"
,
getCoordY
},
44
{
"XMODEL_IMAGE"
,
getCoordX
},
45
{
"YMODEL_IMAGE"
,
getCoordY
}
46
};
47
48
void
SourcePsfTask::computeProperties
(
SourceXtractor::SourceInterface
&source)
const
{
49
if
(
m_vpsf
!=
nullptr
) {
50
std::vector<double>
component_values;
51
52
for
(
auto
component :
m_vpsf
->getComponents()) {
53
component_values.
push_back
(
component_value_getters
[component](source,
m_instance
));
54
}
55
56
std::shared_ptr<VectorImage<SeFloat>
> psf =
m_vpsf
->getPsf(component_values);
57
58
if
(
m_normalize_psf
) {
59
// The result may not be normalized!
60
auto
psf_sum =
std::accumulate
(psf->getData().begin(), psf->getData().end(), 0.);
61
psf =
VectorImage<SeFloat>::create
(*
MultiplyImage<SeFloat>::create
(psf, 1. / psf_sum));
62
}
63
source.
setIndexedProperty
<
SourcePsfProperty
>(
m_instance
,
m_vpsf
->getPixelSampling(), psf);
64
65
// Check image
66
auto
check_image =
CheckImages::getInstance
().
getPsfImage
(
m_instance
);
67
if
(check_image) {
68
auto
x =
component_value_getters
[
"X_IMAGE"
](source,
m_instance
);
69
auto
y =
component_value_getters
[
"Y_IMAGE"
](source,
m_instance
);
70
71
ModelFitting::ImageTraits<ModelFitting::WriteableInterfaceTypePtr>::addImageToImage
(
72
check_image, psf,
m_vpsf
->getPixelSampling(), x, y);
73
}
74
}
else
{
75
source.
setIndexedProperty
<
SourcePsfProperty
>(
m_instance
, 1.0,
nullptr
);
76
}
77
}
78
79
}
CheckImages.h
MeasurementFramePixelCentroid.h
SourcePsfProperty.h
SourcePsfTask.h
WriteableImageInterfaceTraits.h
std::accumulate
T accumulate(T... args)
SourceXtractor::CheckImages::getInstance
static CheckImages & getInstance()
Definition
CheckImages.h:160
SourceXtractor::CheckImages::getPsfImage
std::shared_ptr< WriteableImage< MeasurementImage::PixelType > > getPsfImage(unsigned int frame_number)
Definition
CheckImages.cpp:291
SourceXtractor::MeasurementFramePixelCentroid
Definition
MeasurementFramePixelCentroid.h:31
SourceXtractor::MeasurementFramePixelCentroid::getCentroidY
SeFloat getCentroidY() const
Y coordinate of centroid.
Definition
MeasurementFramePixelCentroid.h:50
SourceXtractor::MeasurementFramePixelCentroid::getCentroidX
SeFloat getCentroidX() const
X coordinate of centroid.
Definition
MeasurementFramePixelCentroid.h:45
SourceXtractor::ProcessedImage< T, MultiplyOperation< T > >::create
static std::shared_ptr< ProcessedImage< T, MultiplyOperation< T > > > create(std::shared_ptr< const Image< T > > image_a, std::shared_ptr< const Image< T > > image_b)
Definition
ProcessedImage.h:53
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition
SourceInterface.h:46
SourceXtractor::SourceInterface::setIndexedProperty
void setIndexedProperty(std::size_t index, Args... args)
Convenience template method to call setProperty() with a more user-friendly syntax.
Definition
SourceInterface.h:64
SourceXtractor::SourceInterface::getProperty
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
Definition
SourceInterface.h:57
SourceXtractor::SourcePsfProperty
Definition
SourcePsfProperty.h:26
SourceXtractor::SourcePsfTask::m_instance
unsigned m_instance
Definition
SourcePsfTask.h:40
SourceXtractor::SourcePsfTask::component_value_getters
static std::map< std::string, ValueGetter > component_value_getters
Definition
SourcePsfTask.h:37
SourceXtractor::SourcePsfTask::computeProperties
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition
SourcePsfTask.cpp:48
SourceXtractor::SourcePsfTask::m_vpsf
std::shared_ptr< Psf > m_vpsf
Definition
SourcePsfTask.h:41
SourceXtractor::SourcePsfTask::m_normalize_psf
bool m_normalize_psf
Definition
SourcePsfTask.h:42
SourceXtractor::VectorImage::create
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition
VectorImage.h:100
std::map
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::getCoordX
static double getCoordX(SourceXtractor::SourceGroupInterface &group, unsigned instance)
Definition
PsfTask.cpp:33
SourceXtractor::getCoordY
static double getCoordY(SourceXtractor::SourceGroupInterface &group, unsigned instance)
Definition
PsfTask.cpp:39
std::vector::push_back
T push_back(T... args)
std::shared_ptr
ModelFitting::ImageTraits::addImageToImage
static void addImageToImage(ImageType &image1, const ImageType &image2, double scale, double x, double y)
Definition
ImageInterfaceTraits.cpp:316
std::vector
Generated by
1.14.0