SourceXtractorPlusPlus
1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Plugin
Psf
PsfTask.cpp
Go to the documentation of this file.
1
17
/*
18
* PsfTask.cpp
19
*
20
* Created on: Jun 25, 2018
21
* Author: Alejandro Alvarez Ayllon
22
*/
23
24
#include <numeric>
25
#include "
SEImplementation/Plugin/Psf/PsfProperty.h
"
26
#include "
SEImplementation/Plugin/MeasurementFrameGroupRectangle/MeasurementFrameGroupRectangle.h
"
27
#include "
SEImplementation/CheckImages/CheckImages.h
"
28
#include "
SEImplementation/Image/WriteableImageInterfaceTraits.h
"
29
#include "
SEImplementation/Plugin/Psf/PsfTask.h
"
30
31
namespace
SourceXtractor
{
32
33
static
double
getCoordX
(
SourceXtractor::SourceGroupInterface
& group,
unsigned
instance) {
34
auto
& measurement_frame_group = group.
getProperty
<
MeasurementFrameGroupRectangle
>(instance);
35
double
top_x = measurement_frame_group.
getTopLeft
().
m_x
;
36
return
top_x + measurement_frame_group.getWidth() / 2.;
37
}
38
39
static
double
getCoordY
(
SourceXtractor::SourceGroupInterface
& group,
unsigned
instance) {
40
auto
& measurement_frame_group = group.
getProperty
<
MeasurementFrameGroupRectangle
>(instance);
41
double
top_y = measurement_frame_group.
getTopLeft
().
m_y
;
42
return
top_y + measurement_frame_group.getHeight() / 2.;
43
}
44
45
std::map<std::string, PsfTask::ValueGetter>
PsfTask::component_value_getters
{
46
{
"X_IMAGE"
,
getCoordX
},
47
{
"Y_IMAGE"
,
getCoordY
},
48
{
"XWIN_IMAGE"
,
getCoordX
},
49
{
"YWIN_IMAGE"
,
getCoordY
},
50
{
"XPEAK_IMAGE"
,
getCoordX
},
51
{
"YPEAK_IMAGE"
,
getCoordY
},
52
{
"XMODEL_IMAGE"
,
getCoordX
},
53
{
"YMODEL_IMAGE"
,
getCoordY
}
54
};
55
56
PsfTask::PsfTask
(
unsigned
instance,
const
std::shared_ptr<Psf>
&vpsf)
57
:
m_instance
(instance),
m_vpsf
(vpsf) {
58
}
59
60
void
PsfTask::computeProperties
(
SourceXtractor::SourceGroupInterface
&group)
const
{
61
if
(
m_vpsf
!=
nullptr
) {
62
std::vector<double>
component_values;
63
64
for
(
auto
component :
m_vpsf
->getComponents()) {
65
component_values.
push_back
(
component_value_getters
[component](group,
m_instance
));
66
}
67
68
auto
psf =
m_vpsf
->getPsf(component_values);
69
// The result may not be normalized!
70
auto
psf_sum =
std::accumulate
(psf->getData().begin(), psf->getData().end(), 0.);
71
auto
psf_normalized =
VectorImage<SeFloat>::create
(*
MultiplyImage<SeFloat>::create
(psf, 1. / psf_sum));
72
group.
setIndexedProperty
<
PsfProperty
>(
m_instance
,
m_vpsf
->getPixelSampling(), psf_normalized);
73
74
// Check image
75
if
(group.
size
()) {
76
auto
check_image =
CheckImages::getInstance
().
getPsfImage
(
m_instance
);
77
if
(check_image) {
78
auto
x =
component_value_getters
[
"X_IMAGE"
](group,
m_instance
);
79
auto
y =
component_value_getters
[
"Y_IMAGE"
](group,
m_instance
);
80
81
ModelFitting::ImageTraits<ModelFitting::WriteableInterfaceTypePtr>::addImageToImage
(
82
check_image, psf_normalized,
m_vpsf
->getPixelSampling(), x, y);
83
}
84
}
85
}
else
{
86
group.
setIndexedProperty
<
PsfProperty
>(
m_instance
, 1.0,
nullptr
);
87
}
88
}
89
90
}
CheckImages.h
MeasurementFrameGroupRectangle.h
PsfProperty.h
PsfTask.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::MeasurementFrameGroupRectangle
Definition
MeasurementFrameGroupRectangle.h:33
SourceXtractor::MeasurementFrameGroupRectangle::getTopLeft
PixelCoordinate getTopLeft() const
Definition
MeasurementFrameGroupRectangle.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::PsfProperty
Definition
PsfProperty.h:32
SourceXtractor::PsfTask::m_instance
unsigned m_instance
Definition
PsfTask.h:44
SourceXtractor::PsfTask::m_vpsf
std::shared_ptr< Psf > m_vpsf
Definition
PsfTask.h:45
SourceXtractor::PsfTask::PsfTask
PsfTask(unsigned instance, const std::shared_ptr< Psf > &vpsf)
Definition
PsfTask.cpp:56
SourceXtractor::PsfTask::computeProperties
void computeProperties(SourceGroupInterface &source) const override
Computes one or more properties for the SourceGroup and/or the Sources it contains.
Definition
PsfTask.cpp:60
SourceXtractor::PsfTask::component_value_getters
static std::map< std::string, ValueGetter > component_value_getters
Definition
PsfTask.h:41
SourceXtractor::SourceGroupInterface
Defines the interface used to group sources.
Definition
SourceGroupInterface.h:38
SourceXtractor::SourceGroupInterface::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::SourceGroupInterface::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::SourceGroupInterface::size
virtual unsigned int size() const =0
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
SourceXtractor::PixelCoordinate::m_y
int m_y
Definition
PixelCoordinate.h:38
SourceXtractor::PixelCoordinate::m_x
int m_x
Definition
PixelCoordinate.h:38
std::vector
Generated by
1.14.0