PURIFY
Next-generation radio interferometric imaging
Functions
mem_w_algos.cc File Reference
#include "purify/config.h"
#include "purify/types.h"
#include <ctime>
#include "purify/directories.h"
#include "purify/logging.h"
#include "purify/measurement_operator_factory.h"
#include "purify/utilities.h"
+ Include dependency graph for mem_w_algos.cc:

Go to the source code of this file.

Functions

int main (int nargs, char const **args)
 

Function Documentation

◆ main()

int main ( int  nargs,
char const **  args 
)

Definition at line 11 of file mem_w_algos.cc.

11  {
12  auto const session = sopt::mpi::init(nargs, args);
13  auto const world = sopt::mpi::Communicator::World();
15  // Gridding example
16  auto const oversample_ratio = 2;
17  auto const Ju = 4;
18  auto const Jw = 100;
19  const t_real FoV = 30 * 60 * 60;
20  const t_real k_means_rel_diff = 1e-5;
21  std::string const results = output_filename("mems_" + std::to_string(world.size()) + ".txt");
22  std::ofstream out(world.is_root() ? results : output_filename("empty.txt"));
23  if (world.is_root()) {
24  out.precision(13);
25  }
26  t_int const number_of_vis = std::pow(10, 6);
27  const t_real rms_w = 200; // lambda
28  t_int const imsizex = 1024;
29  t_int const imsizey = imsizex;
30  const t_real cell = FoV / static_cast<t_real>(imsizex);
31  auto const kernel = "kb";
32  const t_int channels = 80;
33 
34  const std::string pos_filename = mwa_filename("Phase1_config.txt");
35  t_uint const number_of_pixels = imsizex * imsizey;
36  // Generating random uv(w) coverage
37  t_real const sigma_m = constant::pi / 3;
38  Vector<t_real> mem_stack = Vector<t_real>::Zero(world.size());
39  Vector<t_real> mem_node = Vector<t_real>::Zero(world.size());
40  std::vector<t_real> frequencies;
41  for (t_int k = 0; k < channels; k++)
42  frequencies.push_back(87.68e6 +
43  (world.rank() * channels + k - world.size() * channels * 0.5) * 40e3);
44 
45  const std::vector<t_real> times = {0., 8., 16., 24., 32., 40., 48., 56.,
46  64., 72., 80., 88., 96., 104., 112.};
47  const t_real theta_ra = 0. * 180. / constant::pi;
48  const t_real phi_dec = 18.3 * 180. / constant::pi;
49  const t_real latitude = -26.7 * 180. / constant::pi;
50  auto uv_data = utilities::read_ant_positions_to_coverage(pos_filename, frequencies, times,
51  theta_ra, phi_dec, latitude);
52  const t_real number_of_baselines = uv_data.size() / times.size() / channels;
53  uv_data = utilities::conjugate_w(uv_data);
54  const auto cost = [](t_real x) -> t_real { return std::abs(x * x); };
55  const t_real du = widefield::pixel_to_lambda(cell, imsizex, oversample_ratio);
56  std::vector<t_real> w_stacks;
57  std::vector<t_int> image_index;
58  std::tie(uv_data, image_index, w_stacks) = utilities::w_stacking_with_all_to_all(
59  uv_data, du, Ju, Jw, world, 100, 0., cost, k_means_rel_diff);
60  for (t_int k = 0; k < uv_data.size(); k++) {
61  const t_int Ju_max = widefield::w_support(uv_data.w(k) - w_stacks.at(image_index.at(k)), du,
62  static_cast<t_int>(Ju), static_cast<t_int>(Jw));
63  const t_real mem = (Ju_max * Ju_max) * 16.;
64  mem_stack(image_index.at(k)) += mem;
65  mem_node(world.rank()) += mem;
66  }
67  world.all_sum_all<Vector<t_real>>(mem_stack);
68  world.all_sum_all<Vector<t_real>>(mem_node);
69  if (world.is_root()) {
70  out << number_of_vis << " " << rms_w << std::endl; // in seconds
71  out << "stacks" << std::endl; // in seconds
72  out << mem_stack.transpose() / mem_stack.sum() << std::endl;
73  out << "nodes" << std::endl; // in seconds
74  out << mem_node.transpose() / mem_node.sum() << std::endl;
75  }
76  out.close();
77 }
const t_real pi
mathematical constant
Definition: types.h:70
void set_level(const std::string &level)
Method to set the logging level of the default Log object.
Definition: logging.h:137
utilities::vis_params read_ant_positions_to_coverage(const std::string &pos_name, const T &frequencies, const K &times, const t_real theta_ra, const t_real phi_dec, const t_real latitude)
utilities::vis_params conjugate_w(const utilities::vis_params &uv_vis)
reflects visibilities into the w >= 0 domain
std::tuple< utilities::vis_params, std::vector< t_int >, std::vector< t_real > > w_stacking_with_all_to_all(utilities::vis_params const &params, const t_real du, const t_int min_support, const t_int max_support, sopt::mpi::Communicator const &comm, const t_int iters, const t_real fill_relaxation, const std::function< t_real(t_real)> &cost, const t_real k_means_rel_diff)
t_int w_support(const t_real w, const t_real du, const t_int min, const t_int max)
estimate support size of w given u resolution du
t_real pixel_to_lambda(const t_real cell, const t_uint imsize, const t_real oversample_ratio)
return factors to convert between arcsecond pixel size image space and lambda for uv space
std::string output_filename(std::string const &filename)
Test output file.
std::string mwa_filename(std::string const &filename)
Specific mwa data.

References purify::utilities::conjugate_w(), purify::mwa_filename(), purify::output_filename(), purify::constant::pi, purify::widefield::pixel_to_lambda(), purify::utilities::read_ant_positions_to_coverage(), purify::logging::set_level(), purify::utilities::w_stacking_with_all_to_all(), and purify::widefield::w_support().