Commit 7f820d1e authored by Martin Reinecke's avatar Martin Reinecke
Browse files

add helper functions

parent 7dd39675
......@@ -384,6 +384,30 @@ a_c_c to_grid (const a_d_c &uv_, const a_c_c &vis_,
return res;
}
a_d_c to_grid_post (const a_c_c &grid_)
{
myassert(grid_.ndim()==2, "grid array must be 2D");
int nu = grid_.shape(0), nv = grid_.shape(1);
auto grid = grid_.data();
int odim[] = {nu,nv};
a_d_c res(odim);
auto grid2 = res.mutable_data();
for (int u=0; u<nu; ++u)
{
int xu = (u==0) ? 0 : nu-u;
for (int v=0; v<nv; ++v)
{
int xv = (v==0) ? 0 : nv-v;
int i1 = u*nv+v;
int i2 = xu*nv+xv;
grid2[i1] = 0.5*(grid[i1].real()+grid[i1].imag()+
grid[i2].real()-grid[i2].imag());
}
}
return res;
}
a_c_c from_grid (const a_d_c &uv_, const a_c_c &grid_,
int nu, int nv, int nspread, double r2lamb)
{
......@@ -425,6 +449,31 @@ a_c_c from_grid (const a_d_c &uv_, const a_c_c &grid_,
return res;
}
a_c_c from_grid_pre (const a_d_c &grid_)
{
myassert(grid_.ndim()==2, "grid array must be 2D");
int nu = grid_.shape(0), nv = grid_.shape(1);
auto grid = grid_.data();
int odim[] = {nu,nv};
a_c_c res(odim);
auto grid2 = res.mutable_data();
for (int u=0; u<nu; ++u)
{
int xu = (u==0) ? 0 : nu-u;
for (int v=0; v<nv; ++v)
{
int xv = (v==0) ? 0 : nv-v;
int i1 = u*nv+v;
int i2 = xu*nv+xv;
double v1 = 0.5*grid[i1];
double v2 = 0.5*grid[i2];
grid2[i1] = complex<double>(v1+v2, v1-v2);
}
}
return res;
}
} // unnamed namespace
PYBIND11_MODULE(nifty_gridder, m)
......@@ -433,5 +482,7 @@ PYBIND11_MODULE(nifty_gridder, m)
m.def("peanoindex",&peanoindex);
m.def("to_grid",&to_grid);
m.def("to_grid_post",&to_grid_post);
m.def("from_grid",&from_grid);
m.def("from_grid_pre",&from_grid_pre);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment