SourceXtractorPlusPlus  0.15
Please provide a description of the project.
GrowthCurveResampledTask.cpp
Go to the documentation of this file.
1 
19 
23 
24 using namespace Euclid::MathUtils;
25 using namespace Euclid::NdArray;
26 
27 namespace SourceXtractor {
28 
29 GrowthCurveResampledTask::GrowthCurveResampledTask(const std::vector<unsigned>& instances, size_t nsamples)
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
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
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)
constexpr double s
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)