File: facetutil.cpp

package info (click to toggle)
wsclean 3.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,296 kB
  • sloc: cpp: 129,246; python: 22,066; sh: 360; ansic: 230; makefile: 185
file content (54 lines) | stat: -rw-r--r-- 1,915 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "facetutil.h"

#include <aocommon/imagecoordinates.h>

using schaapcommon::facets::Facet;

namespace wsclean {

Facet::InitializationData CreateFacetInitializationData(
    double width, double height, double pixelScaleX, double pixelScaleY,
    double phaseCentreRA, double phaseCentreDec, double l_shift, double m_shift,
    double imagePadding, bool make_square, size_t feather_size) {
  Facet::InitializationData data(pixelScaleX, pixelScaleY, width, height);
  data.phase_centre.ra = phaseCentreRA;
  data.phase_centre.dec = phaseCentreDec;
  data.l_shift = l_shift;
  data.m_shift = m_shift;
  data.padding = imagePadding;
  data.align = 2;
  data.make_square = make_square;
  data.feather_size = feather_size;
  return data;
}

std::vector<std::shared_ptr<Facet>> CreateFacetGrid(
    const Facet::InitializationData& facet_data, size_t grid_width,
    size_t grid_height) {
  std::vector<std::shared_ptr<Facet>> facets;
  facets.reserve(grid_height * grid_width);

  for (int grid_y = 0; grid_y < static_cast<int>(grid_height); ++grid_y) {
    const int facet_start_y = grid_y * facet_data.image_height / grid_height;
    const int facet_end_y =
        (grid_y + 1) * facet_data.image_height / grid_height;

    for (int grid_x = 0; grid_x < static_cast<int>(grid_width); ++grid_x) {
      const int facet_start_x = grid_x * facet_data.image_width / grid_width;
      const int facet_end_x =
          (grid_x + 1) * facet_data.image_width / grid_width;
      const schaapcommon::facets::BoundingBox box(
          {{facet_start_x, facet_start_y}, {facet_end_x, facet_end_y}}, 1,
          false);

      facets.emplace_back(std::make_shared<Facet>(facet_data, box));
      // add a name label for this box
      facets.back()->SetDirectionLabel(std::to_string(grid_x) + ", " +
                                       std::to_string(grid_y));
    }
  }

  return facets;
}

}  // namespace wsclean