PURIFY
Next-generation radio interferometric imaging
Macros | Functions
plot_wkernel.cc File Reference
#include "purify/config.h"
#include <iostream>
#include "purify/directories.h"
#include "purify/types.h"
#include "purify/logging.h"
#include "purify/kernels.h"
#include "purify/pfitsio.h"
#include "purify/wide_field_utilities.h"
#include "purify/wkernel_integration.h"
+ Include dependency graph for plot_wkernel.cc:

Go to the source code of this file.

Macros

#define ARGS_MACRO(NAME, ARGN, VALUE, TYPE)
 

Functions

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

Macro Definition Documentation

◆ ARGS_MACRO

#define ARGS_MACRO (   NAME,
  ARGN,
  VALUE,
  TYPE 
)
Value:
auto const NAME = \
static_cast<TYPE>((nargs > ARGN) ? std::stod(static_cast<std::string>(args[ARGN])) : VALUE);

Function Documentation

◆ main()

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

Definition at line 21 of file plot_wkernel.cc.

21  {
22  auto const output_name = (nargs > 2) ? static_cast<std::string>(args[1]) : "kernel";
23 #define ARGS_MACRO(NAME, ARGN, VALUE, TYPE) \
24  auto const NAME = \
25  static_cast<TYPE>((nargs > ARGN) ? std::stod(static_cast<std::string>(args[ARGN])) : VALUE);
26 
27  ARGS_MACRO(w, 2, 10, t_real)
28  ARGS_MACRO(absolute_error, 3, 1e-2, t_real)
29  ARGS_MACRO(imsize, 4, 1024, t_uint)
30  ARGS_MACRO(cell, 5, 20, t_real)
31  ARGS_MACRO(radial, 6, false, bool)
32 
33 #undef ARGS_MACRO
35  t_uint const J = 4;
36  t_int const Jw = 30;
37  const t_real oversample_ratio = 2;
38  PURIFY_LOW_LOG("image size: {}", imsize);
39  PURIFY_LOW_LOG("cell size: {}", cell);
40  const t_real du = widefield::pixel_to_lambda(cell, imsize, oversample_ratio);
41  PURIFY_LOW_LOG("1/du: {}", 1. / du);
42  auto const normu = [=](const t_real l) -> t_real { return kernels::ft_kaiser_bessel(l, J); };
43 
44  const t_uint max_evaluations = 1e8;
45  const t_real relative_error = 0;
46  t_uint e;
47  const t_real norm =
48  (not radial)
50  0, 0, 0, du, du, oversample_ratio, normu, normu, 1e9, 0, 1e-8,
51  integration::method::h, e))
53  0, 0, 0, du, oversample_ratio, normu, 1e9, 0, 1e-7, integration::method::h, e));
54  auto const ftkernelu = [=](const t_real l) -> t_real {
55  return kernels::ft_kaiser_bessel(l, J) / norm;
56  };
57  auto const ftkernelv = [=](const t_real l) -> t_real { return kernels::ft_kaiser_bessel(l, J); };
58  t_uint total = 0;
59  t_uint rtotal = 0;
60  t_int const Ju = 20;
61  t_real const upsample = 5;
62  t_int const Ju_max = std::floor(Ju * upsample);
63  const t_int Jw_max =
64  100; // std::min<int>(std::max<int>(std::floor(std::abs(w * 1./du)), J), Jw);
65  Vector<t_complex> kernel = Vector<t_complex>::Zero(Ju_max * Jw_max);
66  Vector<t_real> evals = Vector<t_real>::Zero(Ju_max * Jw_max);
67  Vector<t_real> support = Vector<t_real>::Zero(Jw_max);
68  PURIFY_LOW_LOG("w: {}", w);
69  PURIFY_LOW_LOG("Kernel size: {} x {}", Ju_max, Jw_max);
70  PURIFY_LOW_LOG("FoV (deg): {}", imsize * cell / 60 / 60);
71  PURIFY_LOW_LOG("du: {}", du);
72 #pragma omp parallel for collapse(2)
73  for (int i = 0; i < Jw_max; i++) {
74  for (int j = 0; j < Ju_max; j++) {
75  t_uint evaluations = 0;
76  t_uint revaluations = 0;
77  t_uint e;
78  kernel(j * Jw_max + i) =
79  (not radial)
81  j / upsample, 0, w * i / Jw_max, du, du, oversample_ratio, ftkernelu, ftkernelv,
82  max_evaluations, absolute_error, 0, integration::method::h, evaluations)
84  j / upsample, 0, w * i / Jw_max, du, oversample_ratio, ftkernelu,
85  max_evaluations, absolute_error, 0, integration::method::p, evaluations);
86  evals(j * Jw_max + i) = evaluations;
87 #pragma omp critical(print)
88  {
89  PURIFY_LOW_LOG("u : {}, w : {}", j / upsample, w * i / Jw_max);
90  PURIFY_LOW_LOG("Kernel value: {}", kernel(j * Jw_max + i));
91  PURIFY_LOW_LOG("Evaluations: {}", evaluations);
92  }
93  if (kernel(j * Jw_max + i) != kernel(j * Jw_max + i))
94  throw std::runtime_error("Kernel value is a nan.");
95  total += evaluations;
96  }
97  }
98  PURIFY_LOW_LOG("Total Evaluations: {}", total);
99  PURIFY_LOW_LOG("FoV (deg): {}", imsize * cell / 60 / 60);
100  PURIFY_LOW_LOG("du: {}", du);
101  pfitsio::write2d(kernel.real(), Jw_max, Ju_max, output_name + "_real.fits");
102  pfitsio::write2d(kernel.imag(), Jw_max, Ju_max, output_name + "_imag.fits");
103  pfitsio::write2d(kernel.cwiseAbs(), Jw_max, Ju_max, output_name + ".fits");
104  pfitsio::write2d(evals, Jw_max, Ju_max, output_name + "_evals.fits");
105 }
#define PURIFY_LOW_LOG(...)
Low priority message.
Definition: logging.h:207
t_real ft_kaiser_bessel(const t_real x, const t_real J)
Fourier transform of kaiser bessel kernel.
Definition: kernels.cc:40
void set_level(const std::string &level)
Method to set the logging level of the default Log object.
Definition: logging.h:137
void write2d(const Image< t_real > &eigen_image, const pfitsio::header_params &header, const bool &overwrite)
Write image to fits file.
Definition: pfitsio.cc:30
t_complex exact_w_projection_integration_1d(const t_real u, const t_real v, const t_real w, const t_real du, const t_real oversample_ratio, const std::function< t_complex(t_real)> &ftkerneluv, const t_uint &max_evaluations, const t_real &absolute_error, const t_real &relative_error, const integration::method method, t_uint &evaluations)
t_complex exact_w_projection_integration(const t_real u, const t_real v, const t_real w, const t_real du, const t_real dv, const t_real oversample_ratio, const std::function< t_complex(t_real)> &ftkernelu, const std::function< t_complex(t_real)> &ftkernelv, const t_uint &max_evaluations, const t_real &absolute_error, const t_real &relative_error, const integration::method method, t_uint &evaluations)
numerical integration of chirp and kernel in image domain
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
#define ARGS_MACRO(NAME, ARGN, VALUE, TYPE)

References ARGS_MACRO, purify::projection_kernels::exact_w_projection_integration(), purify::projection_kernels::exact_w_projection_integration_1d(), purify::kernels::ft_kaiser_bessel(), purify::integration::h, purify::integration::p, purify::widefield::pixel_to_lambda(), PURIFY_LOW_LOG, purify::logging::set_level(), and purify::pfitsio::write2d().