Skip to content
Snippets Groups Projects
Commit 61a057e9 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

Refactor

parent caa30f38
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,8 @@ public: ...@@ -51,6 +51,8 @@ public:
dec.clear(); dec.clear();
} }
Direction operator[](size_t i) const { return Direction(ra[i], dec[i]); }
size_t Size() const { return ra.size(); } size_t Size() const { return ra.size(); }
SmartVector<double> ra; SmartVector<double> ra;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#ifndef DPPP_GAUSSIANSOURCE_H #ifndef DPPP_GAUSSIANSOURCE_H
#define DPPP_GAUSSIANSOURCE_H #define DPPP_GAUSSIANSOURCE_H
#include "PointSource.h" #include <PointSource.h>
namespace dp3 { namespace dp3 {
namespace base { namespace base {
...@@ -15,7 +15,7 @@ namespace base { ...@@ -15,7 +15,7 @@ namespace base {
/// @{ /// @{
class GaussianSource : public PointSource { class GaussianSource : public dp3::base::PointSource {
public: public:
typedef std::shared_ptr<GaussianSource> Ptr; typedef std::shared_ptr<GaussianSource> Ptr;
typedef std::shared_ptr<const GaussianSource> ConstPtr; typedef std::shared_ptr<const GaussianSource> ConstPtr;
...@@ -23,6 +23,9 @@ public: ...@@ -23,6 +23,9 @@ public:
GaussianSource(const Direction &direction); GaussianSource(const Direction &direction);
GaussianSource(const Direction &direction, const Stokes &stokes, GaussianSource(const Direction &direction, const Stokes &stokes,
size_t beam_id = 0); size_t beam_id = 0);
GaussianSource(const Direction &direction, const Spectrum &spectrum,
double position_angle, bool is_position_angle_absolute,
double minor_axis, double major_axis, size_t beam_id = 0);
/// Set position angle in radians. The position angle is the smallest angle /// Set position angle in radians. The position angle is the smallest angle
/// between the major axis and North, measured positively North over East. /// between the major axis and North, measured positively North over East.
......
...@@ -38,6 +38,23 @@ public: ...@@ -38,6 +38,23 @@ public:
PointSourceCollection::Reserve(new_size); PointSourceCollection::Reserve(new_size);
} }
GaussianSource operator[](size_t i) const {
return GaussianSource(direction_vector[i], spectrums[i], beam_id[i],
position_angle[i], major_axis[i], minor_axis[i],
position_angle_is_absolute[i]);
}
std::unique_ptr<GaussianSourceCollection> SelectBeamID(size_t beam_id) {
auto selected = std::make_unique<GaussianSourceCollection>();
for (size_t i = 0; i < Size(); ++i) {
if (this->beam_id[i] == beam_id) {
selected->Add(operator[](i));
}
}
return std::move(selected);
}
SmartVector<double> position_angle; SmartVector<double> position_angle;
SmartVector<double> major_axis; SmartVector<double> major_axis;
SmartVector<double> minor_axis; SmartVector<double> minor_axis;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "Direction.h" #include "Direction.h"
#include "Spectrum.h" #include "Spectrum.h"
#include "Stokes.h" #include "Stokes.h"
#include "StokesVector.h"
#include <memory> #include <memory>
#include <set> #include <set>
namespace dp3 { namespace dp3 {
...@@ -28,6 +27,8 @@ public: ...@@ -28,6 +27,8 @@ public:
PointSource(const Direction &direction, const Stokes &stokes, PointSource(const Direction &direction, const Stokes &stokes,
const size_t beam_id = 0); const size_t beam_id = 0);
PointSource(const Direction &direction, const Spectrum &stokes,
const size_t beam_id = 0);
const Direction &GetDirection() const { return direction_; } const Direction &GetDirection() const { return direction_; }
void SetDirection(const Direction &position); void SetDirection(const Direction &position);
...@@ -37,8 +38,7 @@ public: ...@@ -37,8 +38,7 @@ public:
const Spectrum &GetSpectrum() const { return spectrum_; } const Spectrum &GetSpectrum() const { return spectrum_; }
Stokes GetStokes(double freq) const; Stokes GetStokes(double freq) const;
const Stokes &GetStokes() const { return stokes_; } const Stokes &GetStokes() const { return spectrum_.GetReferenceFlux(); }
const StokesVector &GetStokesVector() const { return stokes_vector_; }
const size_t &GetBeamId() const { return beam_id_; } const size_t &GetBeamId() const { return beam_id_; }
void SetBeamId(size_t beam_id) { beam_id_ = beam_id; } void SetBeamId(size_t beam_id) { beam_id_ = beam_id; }
...@@ -54,19 +54,7 @@ public: ...@@ -54,19 +54,7 @@ public:
protected: protected:
Direction direction_; Direction direction_;
Spectrum spectrum_; Spectrum spectrum_;
StokesVector stokes_vector_;
Stokes stokes_;
size_t beam_id_; size_t beam_id_;
// FIXME: remove the following declerations.
// They are not needed anymore, but are kept for
// backward compatibility for the tests.
double reference_frequency_;
std::vector<double> spectral_terms_;
double polarizated_fraction_;
double polarization_angle_;
double rotation_measure_;
bool has_rotation_measure_;
bool has_logarithmic_si_;
}; };
/// @} /// @}
...@@ -77,18 +65,10 @@ void PointSource::SetSpectralTerms(double refFreq, bool isLogarithmic, T first, ...@@ -77,18 +65,10 @@ void PointSource::SetSpectralTerms(double refFreq, bool isLogarithmic, T first,
// FIXME: the following four statements can be removed later. // FIXME: the following four statements can be removed later.
// They are not needed anymore, but are kept for // They are not needed anymore, but are kept for
// backward compatibility for the tests. // backward compatibility for the tests.
reference_frequency_ = refFreq;
has_logarithmic_si_ = isLogarithmic;
spectral_terms_.clear();
spectral_terms_.insert(spectral_terms_.begin(), first, last);
auto new_terms = xt::adapt(std::vector<double>(first, last));
spectrum_.SetSpectralTerms(
refFreq, isLogarithmic,
xt::concatenate(xt::xtuple(spectrum_.GetSpectralTerms(), new_terms), 0));
}
spectrum_.SetSpectralTerms(refFreq, isLogarithmic,
xt::adapt(std::vector<double>(first, last)));
};
} // namespace base } // namespace base
} // namespace dp3 } // namespace dp3
......
...@@ -22,15 +22,12 @@ using PointSource = dp3::base::PointSource; ...@@ -22,15 +22,12 @@ using PointSource = dp3::base::PointSource;
class PointSourceCollection : public ObjectCollection<PointSource> { class PointSourceCollection : public ObjectCollection<PointSource> {
public: public:
Directions direction_vector; Directions direction_vector;
std::vector<StokesVector> spectrum_vector;
std::vector<Spectrum> spectrums; std::vector<Spectrum> spectrums;
std::vector<size_t> beam_id; std::vector<size_t> beam_id;
std::set<size_t> beam_ids; std::set<size_t> beam_ids;
StokesVector stokes_vector;
void Add(const PointSource &point_source) { void Add(const PointSource &point_source) {
direction_vector.Add(point_source.GetDirection()); direction_vector.Add(point_source.GetDirection());
stokes_vector.Add(point_source.GetStokes());
spectrums.push_back(point_source.GetSpectrum()); spectrums.push_back(point_source.GetSpectrum());
beam_id.push_back(point_source.GetBeamId()); beam_id.push_back(point_source.GetBeamId());
beam_ids.insert(point_source.GetBeamId()); beam_ids.insert(point_source.GetBeamId());
...@@ -38,20 +35,32 @@ public: ...@@ -38,20 +35,32 @@ public:
void Reserve(size_t new_size) { void Reserve(size_t new_size) {
direction_vector.Reserve(new_size); direction_vector.Reserve(new_size);
stokes_vector.Reserve(new_size);
spectrums.reserve(new_size); spectrums.reserve(new_size);
beam_id.reserve(new_size); beam_id.reserve(new_size);
} }
void Clear() { void Clear() {
PointSourceCollection::Clear();
direction_vector.Clear(); direction_vector.Clear();
spectrum_vector.clear();
spectrums.clear(); spectrums.clear();
beam_id.clear(); beam_id.clear();
beam_ids.clear(); beam_ids.clear();
} }
PointSource operator[](size_t i) const {
return PointSource(direction_vector[i], spectrums[i], beam_id[i]);
}
std::unique_ptr<PointSourceCollection> SelectBeamID(size_t beam_id) {
auto selected = std::make_unique<PointSourceCollection>();
for (size_t i = 0; i < Size(); ++i) {
if (this->beam_id[i] == beam_id) {
selected->Add(operator[](i));
}
}
return std::move(selected);
}
size_t Size() const { return direction_vector.Size(); } size_t Size() const { return direction_vector.Size(); }
}; };
......
...@@ -86,7 +86,7 @@ inline void spectrum(const PointSource &component, size_t nChannel, ...@@ -86,7 +86,7 @@ inline void spectrum(const PointSource &component, size_t nChannel,
/// @{ /// @{
/** /**
* @brief Simulator to compute visibilities given a sky model * @brief Predict class to compute visibilities given a sky model
* *
* This class computes visibilities given model components in the sky. * This class computes visibilities given model components in the sky.
* Effectively, it evaluates the equation: * Effectively, it evaluates the equation:
...@@ -126,6 +126,11 @@ public: ...@@ -126,6 +126,11 @@ public:
xt::xtensor<dcomplex, 3> &buffer) const; xt::xtensor<dcomplex, 3> &buffer) const;
void run(PredictPlanExec &plan, const GaussianSourceCollection &sources, void run(PredictPlanExec &plan, const GaussianSourceCollection &sources,
xt::xtensor<dcomplex, 3> &buffer) const; xt::xtensor<dcomplex, 3> &buffer) const;
void run(PredictPlanExec &plan, const GaussianSourceCollection &sources,
xt::xtensor<dcomplex, 4> &buffer) const;
void run(PredictPlanExec &plan, const PointSourceCollection &sources,
xt::xtensor<dcomplex, 4> &buffer) const;
}; };
/// @} /// @}
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <Stokes.h> #include <Stokes.h>
#include <StokesVector.h> #include <StokesVector.h>
#include <casacore/casa/BasicSL/Constants.h> #include <casacore/casa/BasicSL/Constants.h>
#include <complex> #include <complex>
#include <xtensor/xcomplex.hpp> #include <xtensor/xcomplex.hpp>
...@@ -91,7 +90,7 @@ public: ...@@ -91,7 +90,7 @@ public:
return has_logarithmic_spectral_index_; return has_logarithmic_spectral_index_;
} }
bool HasSpectralTerms() const { return spectral_terms_.size() > 0; } bool HasSpectralTerms() const { return spectral_terms_.size() > 0; }
bool HasRotationMeasure() const { return has_rotation_measure_; }
void SetPolarization(double angle, double factor) { void SetPolarization(double angle, double factor) {
polarization_angle_ = angle; polarization_angle_ = angle;
polarization_factor_ = factor; polarization_factor_ = factor;
...@@ -207,7 +206,6 @@ private: ...@@ -207,7 +206,6 @@ private:
return EvaluatePolynomial(x, parameters) * x; return EvaluatePolynomial(x, parameters) * x;
} }
private:
Stokes reference_flux_; Stokes reference_flux_;
xt::xtensor<double, 1> spectral_terms_; xt::xtensor<double, 1> spectral_terms_;
......
...@@ -20,6 +20,16 @@ GaussianSource::GaussianSource(const Direction &direction, const Stokes &stokes, ...@@ -20,6 +20,16 @@ GaussianSource::GaussianSource(const Direction &direction, const Stokes &stokes,
: PointSource(direction, stokes, beam_id), position_angle_(0.0), : PointSource(direction, stokes, beam_id), position_angle_(0.0),
is_position_angle_absolute_(true), major_axis_(0.0), minor_axis_(0.0) {} is_position_angle_absolute_(true), major_axis_(0.0), minor_axis_(0.0) {}
GaussianSource::GaussianSource(const Direction &direction,
const Spectrum &spectrum, double position_angle,
bool is_position_angle_absolute,
double minor_axis, double major_axis,
size_t beam_id)
: PointSource(direction, spectrum, beam_id),
position_angle_(position_angle),
is_position_angle_absolute_(is_position_angle_absolute),
major_axis_(major_axis), minor_axis_(minor_axis) {}
void GaussianSource::SetPositionAngle(double angle) { position_angle_ = angle; } void GaussianSource::SetPositionAngle(double angle) { position_angle_ = angle; }
void GaussianSource::SetMajorAxis(double fwhm) { major_axis_ = fwhm; } void GaussianSource::SetMajorAxis(double fwhm) { major_axis_ = fwhm; }
......
...@@ -18,13 +18,14 @@ namespace base { ...@@ -18,13 +18,14 @@ namespace base {
PointSource::PointSource(const Direction &position, const Stokes &stokes, PointSource::PointSource(const Direction &position, const Stokes &stokes,
const size_t beam_id) const size_t beam_id)
: direction_(position), stokes_(stokes), reference_frequency_(0.0), : direction_(position), beam_id_(beam_id) {
polarizated_fraction_(0.0), polarization_angle_(0.0),
rotation_measure_(0.0), has_rotation_measure_(false),
has_logarithmic_si_(true), beam_id_(beam_id) {
spectrum_.SetReferenceFlux(stokes); spectrum_.SetReferenceFlux(stokes);
} }
PointSource::PointSource(const Direction &position, const Spectrum &spectrum,
const size_t beam_id)
: direction_(position), beam_id_(beam_id), spectrum_(spectrum) {}
void PointSource::SetDirection(const Direction &direction) { void PointSource::SetDirection(const Direction &direction) {
direction_ = direction; direction_ = direction;
} }
...@@ -36,31 +37,30 @@ void PointSource::ComputeSpectrum( ...@@ -36,31 +37,30 @@ void PointSource::ComputeSpectrum(
} }
void PointSource::SetRotationMeasure(double fraction, double angle, double rm) { void PointSource::SetRotationMeasure(double fraction, double angle, double rm) {
polarizated_fraction_ = fraction; spectrum_.SetPolarization(angle, fraction);
polarization_angle_ = angle; spectrum_.SetRotationMeasure(rm);
rotation_measure_ = rm;
has_rotation_measure_ = true;
} }
// FIXME: legacy code, remove it later // FIXME: legacy code, remove it later
Stokes PointSource::GetStokes(double freq) const { Stokes PointSource::GetStokes(double freq) const {
Stokes stokes(stokes_); Stokes stokes(spectrum_.GetReferenceFlux());
if (HasSpectralTerms()) { if (HasSpectralTerms()) {
if (has_logarithmic_si_) { if (spectrum_.HasLogarithmicSpectralIndex()) {
// Compute spectral index as: // Compute spectral index as:
// (v / v0) ^ (c0 + c1 * log10(v / v0) + c2 * log10(v / v0)^2 + ...) // (v / v0) ^ (c0 + c1 * log10(v / v0) + c2 * log10(v / v0)^2 + ...)
// Where v is the frequency and v0 is the reference frequency. // Where v is the frequency and v0 is the reference frequency.
// Compute log10(v / v0). // Compute log10(v / v0).
double base = log10(freq) - log10(reference_frequency_); double base = log10(freq) - log10(spectrum_.GetReferenceFrequency());
// Compute c0 + log10(v / v0) * c1 + log10(v / v0)^2 * c2 + ... // Compute c0 + log10(v / v0) * c1 + log10(v / v0)^2 * c2 + ...
// using Horner's rule. // using Horner's rule.
double exponent = 0.0; double exponent = 0.0;
typedef std::vector<double>::const_reverse_iterator iterator_type; typedef xt::xtensor<double, 1>::const_reverse_iterator iterator_type;
for (iterator_type it = spectral_terms_.rbegin(), auto spectral_terms = spectrum_.GetSpectralTerms();
end = spectral_terms_.rend(); for (iterator_type it = spectral_terms.rbegin(),
end = spectral_terms.rend();
it != end; ++it) { it != end; ++it) {
exponent = exponent * base + *it; exponent = exponent * base + *it;
} }
...@@ -70,9 +70,10 @@ Stokes PointSource::GetStokes(double freq) const { ...@@ -70,9 +70,10 @@ Stokes PointSource::GetStokes(double freq) const {
stokes.I *= pow(10., base * exponent); stokes.I *= pow(10., base * exponent);
stokes.V *= pow(10., base * exponent); stokes.V *= pow(10., base * exponent);
} else { } else {
double x = freq / reference_frequency_ - 1.0; double x = freq / spectrum_.GetReferenceFrequency() - 1.0;
typedef std::vector<double>::const_reverse_iterator iterator_type; typedef xt::xtensor<double, 1>::const_reverse_iterator iterator_type;
double val = 0.0; double val = 0.0;
auto spectral_terms_ = spectrum_.GetSpectralTerms();
for (iterator_type it = spectral_terms_.rbegin(), for (iterator_type it = spectral_terms_.rbegin(),
end = spectral_terms_.rend(); end = spectral_terms_.rend();
it != end; ++it) { it != end; ++it) {
...@@ -85,18 +86,22 @@ Stokes PointSource::GetStokes(double freq) const { ...@@ -85,18 +86,22 @@ Stokes PointSource::GetStokes(double freq) const {
if (HasRotationMeasure()) { if (HasRotationMeasure()) {
double lambda = casacore::C::c / freq; double lambda = casacore::C::c / freq;
double chi = double chi = 2.0 * (spectrum_.GetPolarizationAngle() +
2.0 * (polarization_angle_ + rotation_measure_ * lambda * lambda); spectrum_.GetRotationMeasure() * lambda * lambda);
double stokesQU = stokes.I * polarizated_fraction_; double stokesQU = stokes.I * spectrum_.GetPolarizationFactor();
stokes.Q = stokesQU * cos(chi); stokes.Q = stokesQU * cos(chi);
stokes.U = stokesQU * sin(chi); stokes.U = stokesQU * sin(chi);
} }
return stokes; return stokes;
} }
bool PointSource::HasSpectralTerms() const { return !spectral_terms_.empty(); } bool PointSource::HasSpectralTerms() const {
return spectrum_.HasSpectralTerms();
}
bool PointSource::HasRotationMeasure() const { return has_rotation_measure_; } bool PointSource::HasRotationMeasure() const {
return spectrum_.HasRotationMeasure();
}
} // namespace base } // namespace base
} // namespace dp3 } // namespace dp3
...@@ -34,5 +34,40 @@ void Predict::run(PredictPlanExec &plan, ...@@ -34,5 +34,40 @@ void Predict::run(PredictPlanExec &plan,
plan.Compute(sources, buffer); plan.Compute(sources, buffer);
} }
void Predict::run(PredictPlanExec &plan,
const GaussianSourceCollection &sources,
xt::xtensor<dcomplex, 4> &buffer) const {
plan.Precompute(sources);
xt::xtensor<dcomplex, 3>::shape_type tmp_buffer_shape = {
buffer.shape(1), buffer.shape(2), buffer.shape(3)};
for (auto &beam_id : sources.beam_ids) {
xt::xtensor<dcomplex, 3> direction_buffer(tmp_buffer_shape);
// TODO compute should be extended to accumulate per beam_id
plan.Compute(sources, direction_buffer);
xt::view(buffer, beam_id, xt::all(), xt::all(), xt::all()) =
direction_buffer;
}
}
void Predict::run(PredictPlanExec &plan, const PointSourceCollection &sources,
xt::xtensor<dcomplex, 4> &buffer) const {
// buffer dimensions are (nBean, nFreq, nBaselines, nSources)
plan.Precompute(sources);
xt::xtensor<dcomplex, 3>::shape_type tmp_buffer_shape = {
buffer.shape(1), buffer.shape(2), buffer.shape(3)};
for (auto &beam_id : sources.beam_ids) {
xt::xtensor<dcomplex, 3> direction_buffer(tmp_buffer_shape);
// TODO compute should be extended to accumulate per beam_id
plan.Compute(sources, direction_buffer);
xt::view(buffer, beam_id, xt::all(), xt::all(), xt::all()) =
direction_buffer;
}
}
// plan.Compute(sources, buffer);}
} // namespace base } // namespace base
} // namespace dp3 } // namespace dp3
...@@ -14,10 +14,10 @@ BOOST_AUTO_TEST_CASE(add_single) { ...@@ -14,10 +14,10 @@ BOOST_AUTO_TEST_CASE(add_single) {
collection.Add(source); collection.Add(source);
BOOST_CHECK_EQUAL(collection.Size(), 1); BOOST_CHECK_EQUAL(collection.Size(), 1);
BOOST_CHECK_EQUAL(collection.direction_vector.Size(), 1); BOOST_CHECK_EQUAL(collection.direction_vector.Size(), 1);
BOOST_CHECK_EQUAL(collection.stokes_vector.Size(), 1);
BOOST_CHECK_EQUAL(collection.direction_vector.ra[0], 0.1); BOOST_CHECK_EQUAL(collection.direction_vector.ra[0], 0.1);
BOOST_CHECK_EQUAL(collection.direction_vector.dec[0], 0.2); BOOST_CHECK_EQUAL(collection.direction_vector.dec[0], 0.2);
BOOST_CHECK_EQUAL(collection.stokes_vector.I[0], 1.0); BOOST_CHECK_EQUAL(collection.spectrums[0].GetReferenceFlux().I, 1.0);
} }
BOOST_AUTO_TEST_CASE(reserve) { BOOST_AUTO_TEST_CASE(reserve) {
...@@ -27,13 +27,13 @@ BOOST_AUTO_TEST_CASE(reserve) { ...@@ -27,13 +27,13 @@ BOOST_AUTO_TEST_CASE(reserve) {
PointSourceCollection collection; PointSourceCollection collection;
collection.Reserve(2); collection.Reserve(2);
auto ptr = collection.stokes_vector.I.data(); auto ptr = collection.direction_vector.ra.data();
collection.Add(sources[0]); collection.Add(sources[0]);
collection.Add(sources[1]); collection.Add(sources[1]);
BOOST_CHECK_EQUAL(collection.Size(), 2); BOOST_CHECK_EQUAL(collection.Size(), 2);
BOOST_CHECK_EQUAL(collection.stokes_vector.I.data(), ptr); BOOST_CHECK_EQUAL(collection.direction_vector.ra.data(), ptr);
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
...@@ -14,10 +14,10 @@ BOOST_AUTO_TEST_CASE(add_single) { ...@@ -14,10 +14,10 @@ BOOST_AUTO_TEST_CASE(add_single) {
collection.Add(source); collection.Add(source);
BOOST_CHECK_EQUAL(collection.Size(), 1); BOOST_CHECK_EQUAL(collection.Size(), 1);
BOOST_CHECK_EQUAL(collection.direction_vector.Size(), 1); BOOST_CHECK_EQUAL(collection.direction_vector.Size(), 1);
BOOST_CHECK_EQUAL(collection.stokes_vector.Size(), 1); BOOST_CHECK_EQUAL(collection.spectrums.size(), 1);
BOOST_CHECK_EQUAL(collection.direction_vector.ra[0], 0.1); BOOST_CHECK_EQUAL(collection.direction_vector.ra[0], 0.1);
BOOST_CHECK_EQUAL(collection.direction_vector.dec[0], 0.2); BOOST_CHECK_EQUAL(collection.direction_vector.dec[0], 0.2);
BOOST_CHECK_EQUAL(collection.stokes_vector.I[0], 1.0); BOOST_CHECK_EQUAL(collection.spectrums[0].GetReferenceFlux().I, 1.0);
} }
BOOST_AUTO_TEST_CASE(add_single_unspecified_beam_id) { BOOST_AUTO_TEST_CASE(add_single_unspecified_beam_id) {
...@@ -26,10 +26,10 @@ BOOST_AUTO_TEST_CASE(add_single_unspecified_beam_id) { ...@@ -26,10 +26,10 @@ BOOST_AUTO_TEST_CASE(add_single_unspecified_beam_id) {
collection.Add(source); collection.Add(source);
BOOST_CHECK_EQUAL(collection.Size(), 1); BOOST_CHECK_EQUAL(collection.Size(), 1);
BOOST_CHECK_EQUAL(collection.direction_vector.Size(), 1); BOOST_CHECK_EQUAL(collection.direction_vector.Size(), 1);
BOOST_CHECK_EQUAL(collection.stokes_vector.Size(), 1); BOOST_CHECK_EQUAL(collection.spectrums.size(), 1);
BOOST_CHECK_EQUAL(collection.direction_vector.ra[0], 0.1); BOOST_CHECK_EQUAL(collection.direction_vector.ra[0], 0.1);
BOOST_CHECK_EQUAL(collection.direction_vector.dec[0], 0.2); BOOST_CHECK_EQUAL(collection.direction_vector.dec[0], 0.2);
BOOST_CHECK_EQUAL(collection.stokes_vector.I[0], 1.0);
BOOST_CHECK_EQUAL(collection.beam_id[0], 0); BOOST_CHECK_EQUAL(collection.beam_id[0], 0);
} }
...@@ -39,10 +39,10 @@ BOOST_AUTO_TEST_CASE(add_single_with_beam_id) { ...@@ -39,10 +39,10 @@ BOOST_AUTO_TEST_CASE(add_single_with_beam_id) {
collection.Add(source); collection.Add(source);
BOOST_CHECK_EQUAL(collection.Size(), 1); BOOST_CHECK_EQUAL(collection.Size(), 1);
BOOST_CHECK_EQUAL(collection.direction_vector.Size(), 1); BOOST_CHECK_EQUAL(collection.direction_vector.Size(), 1);
BOOST_CHECK_EQUAL(collection.stokes_vector.Size(), 1); BOOST_CHECK_EQUAL(collection.spectrums.size(), 1);
BOOST_CHECK_EQUAL(collection.direction_vector.ra[0], 0.1); BOOST_CHECK_EQUAL(collection.direction_vector.ra[0], 0.1);
BOOST_CHECK_EQUAL(collection.direction_vector.dec[0], 0.2); BOOST_CHECK_EQUAL(collection.direction_vector.dec[0], 0.2);
BOOST_CHECK_EQUAL(collection.stokes_vector.I[0], 1.0); BOOST_CHECK_EQUAL(collection.spectrums[0].GetReferenceFlux().I, 1.0);
BOOST_CHECK_EQUAL(collection.beam_id[0], 15); BOOST_CHECK_EQUAL(collection.beam_id[0], 15);
BOOST_CHECK_EQUAL(collection.beam_ids.size(), 1); BOOST_CHECK_EQUAL(collection.beam_ids.size(), 1);
} }
...@@ -69,13 +69,13 @@ BOOST_AUTO_TEST_CASE(reserve) { ...@@ -69,13 +69,13 @@ BOOST_AUTO_TEST_CASE(reserve) {
PointSourceCollection collection; PointSourceCollection collection;
collection.Reserve(2); collection.Reserve(2);
auto ptr = collection.stokes_vector.I.data(); auto ptr = collection.direction_vector.ra.data();
collection.Add(sources[0]); collection.Add(sources[0]);
collection.Add(sources[1]); collection.Add(sources[1]);
BOOST_CHECK_EQUAL(collection.Size(), 2); BOOST_CHECK_EQUAL(collection.Size(), 2);
BOOST_CHECK_EQUAL(collection.stokes_vector.I.data(), ptr); BOOST_CHECK_EQUAL(collection.direction_vector.ra.data(), ptr);
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
...@@ -24,13 +24,11 @@ struct SpectrumFixture { ...@@ -24,13 +24,11 @@ struct SpectrumFixture {
}; };
BOOST_FIXTURE_TEST_CASE(normal_no_rotation, SpectrumFixture) { BOOST_FIXTURE_TEST_CASE(normal_no_rotation, SpectrumFixture) {
dp3::base::PointSource point_source(dp3::base::Direction(0.0, 0.0), dp3::base::PointSource point_source(dp3::base::Direction(0.0, 0.0), spectrum);
spectrum.GetReferenceFlux());
point_source.SetSpectralTerms( point_source.SetSpectralTerms(
spectrum.GetReferenceFrequency(), spectrum.HasLogarithmicSpectralIndex(), spectrum.GetReferenceFrequency(), spectrum.HasLogarithmicSpectralIndex(),
spectrum.GetSpectralTerms().begin(), spectrum.GetSpectralTerms().end()); spectrum.GetSpectralTerms().begin(), spectrum.GetSpectralTerms().end());
point_source.SetRotationMeasure(0.0, 0.0, 0.0);
Stokes stokes_nu0(0, 0, 0, 0); Stokes stokes_nu0(0, 0, 0, 0);
Stokes stokes_nu1(0, 0, 0, 0); Stokes stokes_nu1(0, 0, 0, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment