Commit ed1b72fa authored by Martin Reinecke's avatar Martin Reinecke
Browse files

add verbosity parameter

parent 4c437262
......@@ -992,7 +992,7 @@ template<typename T, typename T2> void apply_wcorr(const GridderConfig<T> &gconf
template<typename T, typename Serv> void wstack_common(
const GridderConfig<T> &gconf, const Serv &srv, T &wmin, vector<T> &wval,
double &dw, size_t &nplanes, vector<size_t> &nvis_plane, vector<int> &minplane)
double &dw, size_t &nplanes, vector<size_t> &nvis_plane, vector<int> &minplane, size_t verbosity)
{
auto nx_dirty=gconf.Nxdirty();
auto ny_dirty=gconf.Nydirty();
......@@ -1012,7 +1012,7 @@ template<typename T, typename Serv> void wstack_common(
wmin = min(wmin,wval[ipart]);
wmax = max(wmax,wval[ipart]);
}
if (verbosity>0) cout << "W range: " << wmin << " to " << wmax << endl;
double x0 = -0.5*nx_dirty*psx,
y0 = -0.5*ny_dirty*psy;
double nmin = sqrt(max(1.-x0*x0-y0*y0,0.))-1.;
......@@ -1024,6 +1024,8 @@ template<typename T, typename Serv> void wstack_common(
wmin -= (0.5*w_supp-1)*dw;
wmax += (0.5*w_supp-1)*dw;
nplanes += w_supp-2;
if (verbosity>0) cout << "Kernel support: " << w_supp << endl;
if (verbosity>0) cout << "nplanes: " << nplanes << endl;
nvis_plane.resize(nplanes,0);
minplane.resize(nvis);
#pragma omp parallel num_threads(nthreads)
......@@ -1044,7 +1046,7 @@ template<typename T, typename Serv> void wstack_common(
}
template<typename T, typename Serv> void x2dirty_wstack(const Baselines<T> &baselines,
const GridderConfig<T> &gconf, const Serv &srv, const mav<complex<T>,2> &dirty)
const GridderConfig<T> &gconf, const Serv &srv, const mav<complex<T>,2> &dirty, size_t verbosity=0)
{
auto nx_dirty=gconf.Nxdirty();
auto ny_dirty=gconf.Nydirty();
......@@ -1059,7 +1061,7 @@ template<typename T, typename Serv> void x2dirty_wstack(const Baselines<T> &base
size_t nplanes;
vector<size_t> nvis_plane;
vector<int> minplane;
wstack_common(gconf, srv, wmin, wval, dw, nplanes, nvis_plane, minplane);
wstack_common(gconf, srv, wmin, wval, dw, nplanes, nvis_plane, minplane, verbosity);
for (size_t i=0; i<nx_dirty; ++i)
for (size_t j=0; j<ny_dirty; ++j)
......@@ -1075,6 +1077,9 @@ template<typename T, typename Serv> void x2dirty_wstack(const Baselines<T> &base
for (size_t iw=0; iw<nplanes; ++iw)
{
if (nvis_plane[iw]==0) continue;
if (verbosity>1)
cout << "Working on plane " << iw << " containing " << nvis_plane[iw]
<< " visibilities" << endl;
T wcur = wmin+iw*dw;
size_t cnt=0;
vis_loc_.resize(nvis_plane[iw]);
......@@ -1117,7 +1122,7 @@ template<typename T> void vis2dirty_wstack(const Baselines<T> &baselines,
template<typename T, typename Serv> void dirty2x_wstack(const Baselines<T> &baselines,
const GridderConfig<T> &gconf, const const_mav<complex<T>,2> &dirty,
const Serv &srv)
const Serv &srv, size_t verbosity=0)
{
auto nx_dirty=gconf.Nxdirty();
auto ny_dirty=gconf.Nydirty();
......@@ -1132,7 +1137,7 @@ template<typename T, typename Serv> void dirty2x_wstack(const Baselines<T> &base
size_t nplanes;
vector<size_t> nvis_plane;
vector<int> minplane;
wstack_common(gconf, srv, wmin, wval, dw, nplanes, nvis_plane, minplane);
wstack_common(gconf, srv, wmin, wval, dw, nplanes, nvis_plane, minplane, verbosity);
for (size_t i=0; i<nvis; ++i)
srv.setVis(i, 0.);
......@@ -1155,6 +1160,9 @@ template<typename T, typename Serv> void dirty2x_wstack(const Baselines<T> &base
for (size_t iw=0; iw<nplanes; ++iw)
{
if (nvis_plane[iw]==0) continue;
if (verbosity>1)
cout << "Working on plane " << iw << " containing " << nvis_plane[iw]
<< " visibilities" << endl;
T wcur = wmin+iw*dw;
size_t cnt=0;
vis_loc_.resize(nvis_plane[iw]);
......@@ -1232,7 +1240,7 @@ template<typename T> vector<uint32_t> getWgtIndices(const Baselines<T> &baseline
template<typename T> void full_gridding(const const_mav<T,2> &uvw,
const const_mav<T,1> &freq, const const_mav<complex<T>,2> &ms,
const const_mav<T,2> &wgt, T pixsize_x, T pixsize_y, double epsilon,
size_t nthreads, const mav<complex<T>,2> &dirty)
size_t nthreads, const mav<complex<T>,2> &dirty, size_t verbosity)
{
set_nthreads(nthreads);
Baselines<T> baselines(uvw, freq);
......@@ -1240,13 +1248,13 @@ template<typename T> void full_gridding(const const_mav<T,2> &uvw,
auto idx = getWgtIndices(baselines, gconf, wgt);
auto idx2 = const_mav<uint32_t,1>(idx.data(),{idx.size()});
auto srv = MsServ<T,const_mav<complex<T>,2>,const_mav<T,2>>(baselines,idx2,ms,wgt);
x2dirty_wstack(baselines, gconf, srv, dirty);
x2dirty_wstack(baselines, gconf, srv, dirty, verbosity);
}
template<typename T> void full_degridding(const const_mav<T,2> &uvw,
const const_mav<T,1> &freq, const const_mav<complex<T>,2> &dirty,
const const_mav<T,2> &wgt, T pixsize_x, T pixsize_y, double epsilon,
size_t nthreads, const mav<complex<T>,2> &ms)
size_t nthreads, const mav<complex<T>,2> &ms, size_t verbosity)
{
set_nthreads(nthreads);
Baselines<T> baselines(uvw, freq);
......@@ -1257,7 +1265,7 @@ template<typename T> void full_degridding(const const_mav<T,2> &uvw,
for (size_t j=0; j<ms.shape(1); ++j)
ms(i,j) = 0;
auto srv = MsServ<T,mav<complex<T>,2>,const_mav<T,2>>(baselines,idx2,ms,wgt);
dirty2x_wstack(baselines, gconf, dirty, srv);
dirty2x_wstack(baselines, gconf, dirty, srv, verbosity);
}
} // namespace gridder
......
......@@ -706,7 +706,8 @@ template<typename T> pyarr<complex<T>> Pydirty2vis_wstack(const PyBaselines<T> &
template<typename T> pyarr<complex<T>> Pyfull_gridding(const pyarr<T> &uvw,
const pyarr<T> &freq, const pyarr<complex<T>> &ms, const py::object &wgt_,
size_t npix_x, size_t npix_y, T pixsize_x, T pixsize_y, double epsilon, size_t nthreads)
size_t npix_x, size_t npix_y, T pixsize_x, T pixsize_y, double epsilon,
size_t nthreads, size_t verbosity)
{
auto uvw2 = make_const_mav<2>(uvw);
auto freq2 = make_const_mav<1>(freq);
......@@ -715,13 +716,13 @@ template<typename T> pyarr<complex<T>> Pyfull_gridding(const pyarr<T> &uvw,
auto wgt2 = make_const_mav<2>(wgt);
auto dirty=makeArray<complex<T>>({npix_x,npix_y});
auto dirty2 =make_mav<2>(dirty);
full_gridding(uvw2,freq2,ms2,wgt2,pixsize_x,pixsize_y,epsilon,nthreads,dirty2);
full_gridding(uvw2,freq2,ms2,wgt2,pixsize_x,pixsize_y,epsilon,nthreads,dirty2,verbosity);
return dirty;
}
template<typename T> pyarr<complex<T>> Pyfull_degridding(const pyarr<T> &uvw,
const pyarr<T> &freq, const pyarr<complex<T>> &dirty, const py::object &wgt_,
T pixsize_x, T pixsize_y, double epsilon, size_t nthreads)
T pixsize_x, T pixsize_y, double epsilon, size_t nthreads, size_t verbosity)
{
auto uvw2 = make_const_mav<2>(uvw);
auto freq2 = make_const_mav<1>(freq);
......@@ -730,7 +731,7 @@ template<typename T> pyarr<complex<T>> Pyfull_degridding(const pyarr<T> &uvw,
auto wgt2 = make_const_mav<2>(wgt);
auto ms=makeArray<complex<T>>({uvw2.shape(0),freq2.shape(0)});
auto ms2 =make_mav<2>(ms);
full_degridding(uvw2,freq2,dirty2,wgt2,pixsize_x,pixsize_y,epsilon,nthreads,ms2);
full_degridding(uvw2,freq2,dirty2,wgt2,pixsize_x,pixsize_y,epsilon,nthreads,ms2,verbosity);
return ms;
}
......@@ -809,11 +810,15 @@ PYBIND11_MODULE(nifty_gridder, m)
"idx"_a, "dirty"_a);
m.def("full_gridding",&Pyfull_gridding<double>,"uvw"_a,"freq"_a,"vis"_a,
"wgt"_a,"npix_x"_a,"npix_y"_a,"pixsize_x"_a,"pixsize_y"_a,"epsilon"_a,"nthreads"_a=1);
"wgt"_a,"npix_x"_a,"npix_y"_a,"pixsize_x"_a,"pixsize_y"_a,"epsilon"_a,
"nthreads"_a=1, "verbosity"_a=0);
m.def("full_gridding_f",&Pyfull_gridding<float>,"uvw"_a,"freq"_a,"vis"_a,
"wgt"_a,"npix_x"_a,"npix_y"_a,"pixsize_x"_a,"pixsize_y"_a,"epsilon"_a,"nthreads"_a=1);
"wgt"_a,"npix_x"_a,"npix_y"_a,"pixsize_x"_a,"pixsize_y"_a,"epsilon"_a,
"nthreads"_a=1, "verbosity"_a=0);
m.def("full_degridding",&Pyfull_degridding<double>,"uvw"_a,"freq"_a,"dirty"_a,
"wgt"_a,"pixsize_x"_a,"pixsize_y"_a, "epsilon"_a,"nthreads"_a=1);
"wgt"_a,"pixsize_x"_a,"pixsize_y"_a, "epsilon"_a,"nthreads"_a=1,
"verbosity"_a=0);
m.def("full_degridding_f",&Pyfull_degridding<float>,"uvw"_a,"freq"_a,"dirty"_a,
"wgt"_a,"pixsize_x"_a,"pixsize_y"_a, "epsilon"_a, "nthreads"_a=1);
"wgt"_a,"pixsize_x"_a,"pixsize_y"_a, "epsilon"_a, "nthreads"_a=1,
"verbosity"_a=0);
}
Markdown is supported
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