7 t_int
w_support(
const t_real w,
const t_real du,
const t_int min,
const t_int max) {
8 return std::min<int>(std::max<int>(
static_cast<int>(2 * std::floor(std::abs(w / du))), min), max);
11 t_real
pixel_to_lambda(
const t_real cell,
const t_uint imsize,
const t_real oversample_ratio) {
12 return 1. / (oversample_ratio *
fov_cosine(cell, imsize));
15 t_real
estimate_cell_size(
const t_real max_u,
const t_uint imsize,
const t_real oversample_ratio) {
16 return (2. /
static_cast<t_real
>(imsize)) *
17 std::asin(
static_cast<t_real
>(imsize) / (4 * oversample_ratio * max_u)) * 60. * 60. *
21 t_real
fov_cosine(t_real
const cell, t_uint
const imsize) {
22 const t_real theta_FoV_L = imsize * cell;
23 const t_real extra_theta = (theta_FoV_L > 180. * 60. * 60.) ? theta_FoV_L - 180. * 60. * 60. : 0.;
24 return 2 * std::sin(
constant::pi / 180. * (theta_FoV_L - extra_theta) / (60. * 60.) * 0.5) +
25 2 * std::sin(
constant::pi / 180. * extra_theta / (60. * 60.) * 0.5);
29 const t_real oversample_ratio) {
31 return 60. * 60. * 180. / (
static_cast<t_real
>(imsize) * oversample_ratio * du *
constant::pi);
34 Matrix<t_complex>
generate_chirp(
const t_real w_rate,
const t_real cell_x,
const t_real cell_y,
35 const t_uint x_size,
const t_uint y_size) {
36 return generate_chirp([](t_real, t_real) {
return 1.; }, w_rate, cell_x, cell_y, x_size, y_size);
40 const t_real cellx,
const t_real celly,
41 const t_uint imsizex,
const t_uint imsizey,
42 const t_real oversample_ratio,
const t_real scale) {
43 const t_int ftsizeu = std::floor(oversample_ratio * imsizex);
44 const t_int ftsizev = std::floor(oversample_ratio * imsizex);
45 Matrix<t_complex> sample_density = Matrix<t_complex>::Zero(ftsizev, ftsizeu);
46 const t_real du =
pixel_to_lambda(cellx, imsizex, oversample_ratio) * scale;
47 const t_real dv =
pixel_to_lambda(celly, imsizey, oversample_ratio) * scale;
48 for (t_int i = 0; i <
u.size(); ++i) {
51 sample_density(p, q) += 1.;
53 return sample_density;
57 const t_real cellx,
const t_real celly,
58 const t_uint imsizex,
const t_uint imsizey,
59 const t_real oversample_ratio,
const t_real scale) {
60 Vector<t_complex> weights = Vector<t_complex>::Zero(
u.size());
61 const t_int ftsizeu = std::floor(oversample_ratio * imsizex);
62 const t_int ftsizev = std::floor(oversample_ratio * imsizex);
63 const Matrix<t_complex> sample_density =
65 const t_real du =
pixel_to_lambda(cellx, imsizex, oversample_ratio) * scale;
66 const t_real dv =
pixel_to_lambda(celly, imsizey, oversample_ratio) * scale;
67 for (t_int i = 0; i <
u.size(); ++i) {
70 weights(i) = 1. / sample_density(p, q);
72 const t_real max_weight = weights.array().cwiseAbs().maxCoeff();
73 weights /= max_weight;
78 const t_real cellx,
const t_real celly,
79 const t_uint imsizex,
const t_uint imsizey,
80 const t_real oversample_ratio,
const t_real scale,
81 const sopt::mpi::Communicator &comm) {
82 Vector<t_complex> weights = Vector<t_complex>::Zero(
u.size());
83 const t_int ftsizeu = std::floor(oversample_ratio * imsizex);
84 const t_int ftsizev = std::floor(oversample_ratio * imsizex);
85 const Matrix<t_complex> sample_density = comm.all_sum_all(
87 const t_real du =
pixel_to_lambda(cellx, imsizex, oversample_ratio) * scale;
88 const t_real dv =
pixel_to_lambda(celly, imsizey, oversample_ratio) * scale;
89 for (t_int i = 0; i <
u.size(); ++i) {
92 weights(i) = 1. / sample_density(p, q);
94 const t_real max_weight = comm.all_reduce<t_real>(weights.array().cwiseAbs().maxCoeff(), MPI_MAX);
95 weights /= max_weight;
const std::vector< t_real > u
data for u coordinate
const std::vector< t_real > v
data for v coordinate
const t_real pi
mathematical constant
t_real mod(const t_real &x, const t_real &y)
Mod function modified to wrap circularly for negative numbers.
t_real fov_cosine(t_real const cell, t_uint const imsize)
Work out max L and M directional cosines from image parameters.
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 equivalent_miriad_cell_size(const t_real cell, const t_uint imsize, const t_real oversample_ratio)
for a given purify cell size in arcsec provide the equivalent miriad cell size in arcsec
Vector< t_complex > sample_density_weights(const Vector< t_real > &u, const Vector< t_real > &v, const t_real cellx, const t_real celly, const t_uint imsizex, const t_uint imsizey, const t_real oversample_ratio, const t_real scale)
create sample density weights for a given field of view, uniform weighting
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
Matrix< t_complex > estimate_sample_density(const Vector< t_real > &u, const Vector< t_real > &v, const t_real cellx, const t_real celly, const t_uint imsizex, const t_uint imsizey, const t_real oversample_ratio, const t_real scale)
estimate sample desity grid for a given field of view
Matrix< t_complex > generate_chirp(const t_real w_rate, const t_real cell_x, const t_real cell_y, const t_uint x_size, const t_uint y_size)
Generates image of chirp.
t_real estimate_cell_size(const t_real max_u, const t_uint imsize, const t_real oversample_ratio)
return cell size from the bandwidth