File: rm_gridding_example.cc

package info (click to toggle)
purify 2.0.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 58,688 kB
  • sloc: cpp: 8,410; python: 375; makefile: 7
file content (40 lines) | stat: -rw-r--r-- 1,213 bytes parent folder | download | duplicates (3)
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

#include "purify/RMOperator.h"
#include "purify/pfitsio.h"
#include "purify/types.h"
#include "purify/utilities.h"
using namespace purify;

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

  utilities::rm_params rm_vis;
  t_real over_sample;
  t_real cellsize;
  std::string kernel;

  // Gridding example
  cellsize = 0.1; // in rad/m^2
  over_sample = 2;
  t_int J = 4;
  t_int width = 2048;
  kernel = "kb";
  t_int number_of_samples = 100;
  t_real RM1 = -70;
  t_real RM2 = 50;

  rm_vis.frequency.setLinSpaced(number_of_samples, 100, 110);
  Array<t_real> wavelength_squared
      = constant::c * constant::c / (rm_vis.frequency.array() * rm_vis.frequency.array()) * 1e-12;
  t_complex I(0, 1);
  rm_vis.linear_polarisation
      = exp(-2. * I * RM1 * wavelength_squared)
        + exp(-2. * I * RM2 * wavelength_squared); // rotation measure component
  rm_vis.weights = rm_vis.linear_polarisation.array() * 0. + 1.;
  RMOperator op(rm_vis, J, kernel, width, over_sample, cellsize, "none",
                0); // Generating gridding matrix

  auto faraday_dispersion = op.grid(rm_vis.linear_polarisation);

  Image<t_real> output = faraday_dispersion.array().abs();
  pfitsio::write2d(output, "rm_kb_4.fits");
}