1 #ifndef PURIFY_UVW_UTILITIES_H
2 #define PURIFY_UVW_UTILITIES_H
4 #include "purify/config.h"
22 Vector<t_complex>
vis;
32 return vis_params(this->u.segment(pos, length), this->v.segment(pos, length),
33 this->w.segment(pos, length), this->vis.segment(pos, length),
34 this->weights.segment(pos, length), this->units, this->ra, this->dec,
35 this->average_frequency);
40 vis_params(
const Vector<t_real> &u_,
const Vector<t_real> &v_,
const Vector<t_real> &w_,
41 const Vector<t_complex> &vis_,
const Vector<t_complex> &weights_,
43 const t_real &dec_ = 0,
const t_real &average_frequency_ = 0)
54 t_uint
size()
const {
return this->vis.size(); };
61 return u * (std::cos(alpha) * std::cos(beta) * std::cos(gamma) -
62 std::sin(alpha) * std::sin(gamma)) +
63 v * (-std::cos(alpha) * std::cos(beta) * std::sin(gamma) -
64 std::sin(alpha) * std::cos(gamma)) +
65 w * std::cos(alpha) * std::sin(beta);
71 return u * (std::sin(alpha) * std::cos(beta) * std::cos(gamma) +
72 std::cos(alpha) * std::sin(gamma)) +
73 v * (-std::sin(alpha) * std::cos(beta) * std::sin(gamma) +
74 std::cos(alpha) * std::cos(gamma)) +
75 w * std::sin(alpha) * std::sin(beta);
81 return u * (-std::sin(beta) * std::cos(gamma)) +
v * (std::sin(beta) * std::sin(gamma)) +
88 const t_real rms_w = 0);
99 const std::vector<t_real> ×,
const t_real theta_ra,
100 const t_real phi_dec,
const t_real latitude);
103 const t_real times,
const t_real theta_ra,
104 const t_real phi_dec,
const t_real latitude);
107 const std::vector<t_real> &frequencies,
108 const t_real times,
const t_real theta_ra,
109 const t_real phi_dec,
const t_real latitude);
113 const std::vector<t_real> &frequencies,
114 const std::vector<t_real> times,
const t_real theta_ra,
115 const t_real phi_dec,
const t_real latitude);
120 const std::vector<t_real> &frequencies,
121 const std::vector<t_real> ×,
122 const F &position_angle_RA_function,
123 const F &position_angle_DEC_function,
124 const t_real latitude) {
125 if (B.cols() != 3)
throw std::runtime_error(
"Antennae coordinates are not 3D vectors.");
126 const t_uint M = B.rows() * (B.rows() - 1) / 2;
127 const t_uint chans = frequencies.size();
128 const t_uint time_samples = times.size();
129 Vector<t_real>
u = Vector<t_real>::Zero(M * chans * time_samples);
130 Vector<t_real>
v = Vector<t_real>::Zero(M * chans * time_samples);
131 Vector<t_real> w = Vector<t_real>::Zero(M * chans * time_samples);
132 Vector<t_complex> weights = Vector<t_complex>::Ones(M * chans * time_samples);
133 Vector<t_complex> vis = Vector<t_complex>::Ones(M * chans * time_samples);
135 for (t_uint i = 0; i < B.rows(); i++) {
136 for (t_uint j = i + 1; j < B.rows(); j++) {
137 const Vector<t_real> r = (B.row(i) - B.row(j));
138 for (t_int k = 0; k < chans; k++) {
139 for (t_int t = 0; t < time_samples; t++) {
140 const t_int index = m + M * (k + chans * t);
142 r(0), r(1), r(2), position_angle_RA_function(times.at(t)),
143 position_angle_DEC_function(times.at(t)) - latitude, 0.) *
146 r(0), r(1), r(2), position_angle_RA_function(times.at(t)),
147 position_angle_DEC_function(times.at(t)) - latitude, 0.) *
150 r(0), r(1), r(2), position_angle_RA_function(times.at(t)),
151 position_angle_DEC_function(times.at(t)) - latitude, 0.) *
159 throw std::runtime_error(
160 "Number of created baselines does not match expected baseline number N * (N - 1) / 2.");
165 template <
class T,
class K>
167 const Vector<t_real> &z,
const T &frequencies,
168 const K ×,
const t_real theta_ra,
169 const t_real phi_dec,
const t_real latitude) {
170 if (x.size() != y.size())
throw std::runtime_error(
"x and y positions are not the same amount.");
171 if (x.size() != z.size())
throw std::runtime_error(
"x and z positions are not the same amount.");
172 Matrix<t_real> B(x.size(), 3);
182 template <
class T,
class K>
184 const T &frequencies,
const K ×,
185 const t_real theta_ra,
const t_real phi_dec,
186 const t_real latitude) {
198 const bool w_term =
false);
204 const bool w_term =
false);
207 const t_real &cell_size_u = 0,
const t_real &cell_size_v = 0);
209 const t_real &max_v,
const t_real &cell_size_u,
210 const t_real &cell_size_v);
213 const t_real cell_y,
const t_real imsizex,
214 const t_real imsizey,
const t_real oversample_ratio);
217 const t_int &ftsizev);
const std::vector< t_real > u
data for u coordinate
const std::vector< t_real > v
data for v coordinate
const t_real c
speed of light in vacuum
void write_visibility(const utilities::vis_params &uv_vis, const std::string &file_name, const bool w_term)
Writes visibilities to txt.
utilities::vis_params antenna_to_coverage(const Matrix< t_real > &B, const t_real frequency, const t_real times, const t_real theta_ra, const t_real phi_dec, const t_real latitude)
Provided antenna positions generate a coverage for a fixed frequency a fixed time.
Matrix< t_real > generate_antennas(const t_uint N, const t_real scale)
Generate guassianly distributed (sigma = scale) antenna positions.
T calculate_rotated_v(const T &u, const T &v, const T &w, const t_real alpha, const t_real beta, const t_real gamma)
calculate the rotated v from euler angles in zyz and starting coordinates (u, v, w)
utilities::vis_params antenna_to_coverage_general(const Matrix< t_real > &B, const std::vector< t_real > &frequencies, const std::vector< t_real > ×, const F &position_angle_RA_function, const F &position_angle_DEC_function, const t_real latitude)
utilities::vis_params convert_to_pixels(const utilities::vis_params &uv_vis, const t_real cell_x, const t_real cell_y, const t_real imsizex, const t_real imsizey, const t_real oversample_ratio)
Converts u and v coordaintes to units of pixels.
utilities::vis_params uv_scale(const utilities::vis_params &uv_vis, const t_int &sizex, const t_int &sizey)
scales the visibilities to units of pixels
K::Scalar mean(const K x)
Calculate mean of vector.
t_real streamtoreal(std::ifstream &stream)
Reading reals from visibility file (including nan's and inf's)
Matrix< t_real > read_ant_positions(const std::string &pos_name)
Read in a text file of antenna positions into a matrix [x, y ,z].
utilities::vis_params read_ant_positions_to_coverage(const std::string &pos_name, const T &frequencies, const K ×, const t_real theta_ra, const t_real phi_dec, const t_real latitude)
T calculate_rotated_u(const T &u, const T &v, const T &w, const t_real alpha, const t_real beta, const t_real gamma)
calculate the rotated u from euler angles in zyz and starting coordinates (u, v, w)
utilities::vis_params conjugate_w(const utilities::vis_params &uv_vis)
reflects visibilities into the w >= 0 domain
utilities::vis_params read_visibility(const std::vector< std::string > &names, const bool w_term)
Read visibility files from name of vector.
T calculate_rotated_w(const T &u, const T &v, const T &w, const t_real alpha, const t_real beta, const t_real gamma)
calculate the rotated w from euler angles in zyz and starting coordinates (u, v, w)
utilities::vis_params set_cell_size(const sopt::mpi::Communicator &comm, utilities::vis_params const &uv_vis, const t_real &cell_x, const t_real &cell_y)
utilities::vis_params random_sample_density(const t_int vis_num, const t_real mean, const t_real standard_deviation, const t_real rms_w)
Generates a random visibility coverage.
t_real standard_deviation(const K x)
Calculates the standard deviation of a vector.
utilities::vis_params read_visibility_csv(const std::string &vis_name, const bool w_term)
Reads in visibility csv file.
vis_params()
default constructor
Vector< t_uint > baseline
vis_params segment(const t_uint pos, const t_uint length) const
return subset of measurements
t_uint size() const
return number of measurements
Vector< t_complex > weights
Vector< t_real > frequencies
vis_params(const Vector< t_real > &u_, const Vector< t_real > &v_, const Vector< t_real > &w_, const Vector< t_complex > &vis_, const Vector< t_complex > &weights_, const vis_units units_=vis_units::lambda, const t_real &ra_=0, const t_real &dec_=0, const t_real &average_frequency_=0)
constructor