Skip to content
Snippets Groups Projects
Commit b3805bea authored by Jakob Maljaars's avatar Jakob Maljaars
Browse files

Minor clean up

parent cd72db38
No related branches found
No related tags found
No related merge requests found
......@@ -22,56 +22,51 @@ std::array<double, 5> VLABeam::GetCoefficients(const std::string& bandName,
const std::array<double, 5>* coeff;
double freqMHz = freq * 1e-6;
double freqUsed = freq * 1e-6;
std::map<int, std::array<double, 5>>::iterator low, prev;
low = coeffmap.lower_bound(freqMHz);
if (low == coeffmap.end()) {
--low;
coeff = &low->second;
freqUsed = low->first;
} else if (low == coeffmap.begin()) {
coeff = &low->second;
freqUsed = low->first;
} else {
prev = low;
--prev;
if (std::fabs(freqMHz - prev->first) < std::fabs(low->first - freqMHz)) {
coeff = &prev->second;
freqUsed = prev->first;
} else {
coeff = &low->second;
freqUsed = low->first;
}
}
return *coeff;
}
char VLABeam::DetermineFeed(double freq, double freqCenter) {
if ((freqCenter > 224e6 && freqCenter < 480e6) ||
char VLABeam::DetermineFeed(double freq, double freq_center) {
if ((freq_center > 224e6 && freq_center < 480e6) ||
(freq > 224e6 && freq < 480e6))
return 'P';
if ((freqCenter > 900e6 && freqCenter < 2003.0e6) ||
if ((freq_center > 900e6 && freq_center < 2003.0e6) ||
(freq > 900e6 && freq < 2003e6))
return 'L';
if ((freqCenter > 1990e6 && freqCenter < 4001.0e6) ||
if ((freq_center > 1990e6 && freq_center < 4001.0e6) ||
(freq > 1990e6 && freq < 4001e6))
return 'S';
if ((freqCenter > 3990e6 && freqCenter < 8001.0e6) ||
if ((freq_center > 3990e6 && freq_center < 8001.0e6) ||
(freq > 3990e6 && freq < 8001e6))
return 'C';
if ((freqCenter > 7990e6 && freqCenter < 12001.0e6) ||
if ((freq_center > 7990e6 && freq_center < 12001.0e6) ||
(freq > 7990e6 && freq < 12001e6))
return 'X';
if ((freqCenter > 12000e6 && freqCenter < 18000.0e6) ||
if ((freq_center > 12000e6 && freq_center < 18000.0e6) ||
(freq > 12000e6 && freq < 18000e6))
return 'U';
if ((freqCenter > 19000e6 && freqCenter < 26000.0e6) ||
if ((freq_center > 19000e6 && freq_center < 26000.0e6) ||
(freq > 19000e6 && freq < 26000e6))
return 'K';
if ((freqCenter > 28000e6 && freqCenter < 38000.0e6) ||
if ((freq_center > 28000e6 && freq_center < 38000.0e6) ||
(freq > 28000e6 && freq < 38000e6))
return 'A';
if ((freqCenter > 41000e6 && freqCenter < 50000.0e6) ||
if ((freq_center > 41000e6 && freq_center < 50000.0e6) ||
(freq > 41000e6 && freq < 50000e6))
return 'Q';
......
......@@ -15,7 +15,7 @@ class VLABeam {
private:
static std::map<int, std::array<double, 5>> GetCoefficients();
static std::map<char, double> GetFeedConf();
static char DetermineFeed(double freq, double freqCenter = 0.0);
static char DetermineFeed(double freq, double freq_center = 0.0);
static void LimitFreqForBand(char band, double& freq);
};
} // namespace circularsymmetric
......
......@@ -89,61 +89,6 @@ double VoltagePattern::LmMaxSquared(double frequency_hz) const {
return rmax * rmax;
}
// void VoltagePattern::Render(PrimaryBeamImageSet& beamImages, double
// pixel_scale_x,
// double pixel_scale_y, double phase_centre_ra,
// double phase_centre_dec, double pointing_ra,
// double pointing_dec, double phase_centre_dl,
// double phase_centre_dm, double frequency_hz)
// const {
// size_t width = beamImages.Width(), height = beamImages.Height();
// double lmMaxSq = LmMaxSquared(frequency_hz);
// UVector<double> interpolated_values;
// const double* vp = InterpolateValues(frequency_hz, interpolated_values);
// double factor =
// (180.0 / M_PI) * 60.0 * frequency_hz * 1.0e-9; // arcminutes * GHz
// double l0, m0;
// ImageCoordinates::RaDecToLM(pointing_ra, pointing_dec, phase_centre_ra,
// phase_centre_dec, l0, m0);
// l0 += phase_centre_dl;
// m0 += phase_centre_dm;
// size_t imgIndex = 0;
// // Logger::Debug << "Interpolating 1D voltage pattern to output
// image...\n";
// for (size_t iy = 0; iy != height; ++iy) {
// for (size_t ix = 0; ix != width; ++ix) {
// double l, m, ra, dec;
// ImageCoordinates::XYToLM(ix, iy, pixel_scale_x, pixel_scale_y, width,
// height,
// l, m);
// l += phase_centre_dl;
// m += m0;
// ImageCoordinates::LMToRaDec(l, m, phase_centre_ra, phase_centre_dec,
// ra, dec); ImageCoordinates::RaDecToLM(ra, dec, pointing_ra,
// pointing_dec, l, m); l -= l0; m -= m0; double r2 = l * l + m * m;
// double out; if (r2 > lmMaxSq) {
// out = 0.0;
// } else {
// double r = std::sqrt(r2) * factor;
// int indx = int(r * inverse_increment_radius_);
// out = vp[indx];
// }
// beamImages[0][imgIndex] = out;
// beamImages[1][imgIndex] = 0.0;
// beamImages[2][imgIndex] = 0.0;
// beamImages[3][imgIndex] = 0.0;
// beamImages[4][imgIndex] = 0.0;
// beamImages[5][imgIndex] = 0.0;
// beamImages[6][imgIndex] = out;
// beamImages[7][imgIndex] = 0.0;
// ++imgIndex;
// }
// }
// }
void VoltagePattern::Render(std::complex<float>* aterm, size_t width,
size_t height, double pixel_scale_x,
double pixel_scale_y, double phase_centre_ra,
......
......@@ -24,12 +24,6 @@ class VoltagePattern {
void EvaluatePolynomial(const aocommon::UVector<double>& coefficients,
bool invert);
// void Render(class PrimaryBeamImageSet& beamImages, double pixel_scale_x,
// double pixel_scale_y, double phase_centre_ra, double
// phase_centre_dec, double pointing_ra, double pointing_dec,
// double phase_centre_dl, double phase_centre_dm, double
// frequency_hz) const;
void Render(std::complex<float>* aterm, size_t width, size_t height,
double pixel_scale_x, double pixel_scale_y,
double phase_centre_ra, double phase_centre_dec,
......
......@@ -60,7 +60,7 @@ class GriddedResponse {
*/
virtual void CalculateStation(std::complex<float>* buffer, double time,
double freq, const size_t station_idx,
const size_t field_id = 0) = 0;
const size_t field_id) = 0;
/**
* @brief Compute the Beam response for all stations in a Telescope
......@@ -72,7 +72,7 @@ class GriddedResponse {
*/
virtual void CalculateAllStations(std::complex<float>* buffer, double time,
double frequency,
const size_t field_id = 0) = 0;
const size_t field_id) = 0;
std::size_t GetBufferSize(std::size_t nstations) {
return std::size_t(nstations * width_ * height_ * 2 * 2);
......
......@@ -62,7 +62,7 @@ class LOFARGrid final : public GriddedResponse {
*/
void CalculateStation(std::complex<float>* buffer, double time,
double frequency, const size_t station_idx,
const size_t) override;
const size_t field_id) override;
/**
* @brief Compute the Beam response for all stations in a Telescope
......@@ -73,7 +73,7 @@ class LOFARGrid final : public GriddedResponse {
* @param freq Frequency (Hz)
*/
void CalculateAllStations(std::complex<float>* buffer, double time,
double frequency, const size_t) override;
double frequency, const size_t field_id) override;
private:
casacore::MDirection delay_dir_, tile_beam_dir_, preapplied_beam_dir_;
......
......@@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(load_lofar) {
std::vector<std::complex<float>> antenna_buffer_single(
grid_response->GetBufferSize(1));
grid_response->CalculateStation(antenna_buffer_single.data(), time, frequency,
23);
23, 0);
BOOST_CHECK_EQUAL(antenna_buffer_single.size(),
std::size_t(width * height * 2 * 2));
......@@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(load_lofar) {
std::vector<std::complex<float>> antenna_buffer_all(
grid_response->GetBufferSize(telescope->GetNrStations()));
grid_response->CalculateAllStations(antenna_buffer_all.data(), time,
frequency);
frequency, 0);
BOOST_CHECK_EQUAL(
antenna_buffer_all.size(),
std::size_t(telescope->GetNrStations() * width * height * 2 * 2));
......@@ -110,7 +110,7 @@ BOOST_AUTO_TEST_CASE(load_lofar) {
std::vector<std::complex<float>> antenna_buffer_diff_beam(
grid_response_diff_beam->GetBufferSize(1));
grid_response_diff_beam->CalculateStation(antenna_buffer_diff_beam.data(),
time, frequency, 15);
time, frequency, 15, 0);
double norm_jones_mat = 0.;
for (std::size_t i = 0; i < 4; ++i) {
......
......@@ -45,7 +45,8 @@ BOOST_AUTO_TEST_CASE(load_vla) {
std::vector<std::complex<float>> antenna_buffer(
grid_response->GetBufferSize(telescope->GetNrStations()));
grid_response->CalculateAllStations(antenna_buffer.data(), time, frequency);
grid_response->CalculateAllStations(antenna_buffer.data(), time, frequency,
0);
// Check that XX/YY are equal
// Loop over pixels to check that off-diagonals are 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment