SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
GrowthCurveResampledTask.cpp
Go to the documentation of this file.
1
17
18#include <MathUtils/interpolation/interpolation.h>
19
23
24using namespace Euclid::MathUtils;
25using namespace Euclid::NdArray;
26
27namespace SourceXtractor {
28
30 : m_instances{instances}, m_nsamples{nsamples} {}
31
34 std::vector<double> step_sizes(m_instances.size());
35
36 for (size_t i = 0; i < m_instances.size(); ++i) {
37 auto& growth_curve_prop = source.getProperty<GrowthCurve>(m_instances[i]);
38 auto& growth_curve = growth_curve_prop.getCurve();
39 auto step_size = growth_curve_prop.getStepSize();
40 auto new_step_size = growth_curve_prop.getMax() / m_nsamples;
41 step_sizes[i] = new_step_size;
42
43 std::vector<double> steps(growth_curve.size());
44 for (size_t s = 0; s < steps.size(); ++s) {
45 steps[s] = (s + 1) * step_size;
46 }
47
48 auto interpolated = interpolate(steps, growth_curve, InterpolationType::LINEAR, true);
49 for (size_t s = 0; s < m_nsamples; ++s) {
50 data.at(i, s) = (*interpolated)((s + 1) * new_step_size);
51 }
52 }
53 source.setProperty<GrowthCurveResampled>(std::move(data), std::move(step_sizes));
54}
55
56} // end of namespace SourceXtractor
T & at(const std::vector< size_t > &coords)
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
GrowthCurveResampledTask(const std::vector< unsigned > &instances, size_t nsamples)
const std::vector< double > & getCurve() const
Definition GrowthCurve.h:38
The SourceInterface is an abstract "source" that has properties attached to it.
const PropertyType & getProperty(unsigned int index=0) const
Convenience template method to call getProperty() with a more user-friendly syntax.
T move(T... args)
ELEMENTS_API std::unique_ptr< Function > interpolate(const std::vector< double > &x, const std::vector< double > &y, InterpolationType type, bool extrapolate=false)
T size(T... args)