Commit 92535d78 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

merge some improvements from minimal branch

parent 1f7224ef
...@@ -837,9 +837,9 @@ template<class T, class T2> class VisServ ...@@ -837,9 +837,9 @@ template<class T, class T2> class VisServ
{ {
private: private:
const Baselines &baselines; const Baselines &baselines;
const const_mav<uint32_t,1> &idx; const_mav<uint32_t,1> idx;
T2 vis; T2 vis;
const const_mav<T,1> &wgt; const_mav<T,1> wgt;
size_t nvis; size_t nvis;
bool have_wgt; bool have_wgt;
...@@ -877,9 +877,9 @@ template<class T, class T2> class MsServ ...@@ -877,9 +877,9 @@ template<class T, class T2> class MsServ
{ {
private: private:
const Baselines &baselines; const Baselines &baselines;
const const_mav<uint32_t,1> &idx; const_mav<uint32_t,1> idx;
T2 ms; T2 ms;
const const_mav<T,2> &wgt; const_mav<T,2> wgt;
size_t nvis; size_t nvis;
bool have_wgt; bool have_wgt;
...@@ -1025,7 +1025,7 @@ template<typename T, typename Serv> void grid2x_c ...@@ -1025,7 +1025,7 @@ template<typename T, typename Serv> void grid2x_c
} }
if (flip) r=conj(r); if (flip) r=conj(r);
if (do_w_gridding) r*=hlp.Wfac(); if (do_w_gridding) r*=hlp.Wfac();
srv.setVis(ipart, r); srv.addVis(ipart, r);
} }
} }
} }
...@@ -1329,7 +1329,7 @@ template<typename T, typename Serv> void x2dirty( ...@@ -1329,7 +1329,7 @@ template<typename T, typename Serv> void x2dirty(
} }
gconf.grid2dirty_c(cmav(grid), tdirty); gconf.grid2dirty_c(cmav(grid), tdirty);
gconf.apply_wscreen(cmav(tdirty), tdirty, wcur, true); gconf.apply_wscreen(cmav(tdirty), tdirty, wcur, true);
#pragma omp parallel for num_threads(nthreads) #pragma omp parallel for num_threads(nthreads)
for (size_t i=0; i<nx_dirty; ++i) for (size_t i=0; i<nx_dirty; ++i)
for (size_t j=0; j<ny_dirty; ++j) for (size_t j=0; j<ny_dirty; ++j)
dirty(i,j) += tdirty(i,j).real(); dirty(i,j) += tdirty(i,j).real();
...@@ -1389,7 +1389,7 @@ template<typename T, typename Serv> void dirty2x( ...@@ -1389,7 +1389,7 @@ template<typename T, typename Serv> void dirty2x(
apply_wcorr(gconf, tdirty, ES_Kernel_with_correction(supp, nthreads), dw); apply_wcorr(gconf, tdirty, ES_Kernel_with_correction(supp, nthreads), dw);
vector<complex<T>> vis_loc_; vector<complex<T>> vis_loc_;
vector<uint32_t> idx_loc_, mapper; vector<uint32_t> idx_loc_, newidx;
tmpStorage<complex<T>,2> grid_({gconf.Nu(),gconf.Nv()}); tmpStorage<complex<T>,2> grid_({gconf.Nu(),gconf.Nv()});
auto grid=grid_.getMav(); auto grid=grid_.getMav();
tmpStorage<complex<T>,2> tdirty2_({nx_dirty,ny_dirty}); tmpStorage<complex<T>,2> tdirty2_({nx_dirty,ny_dirty});
...@@ -1401,31 +1401,44 @@ template<typename T, typename Serv> void dirty2x( ...@@ -1401,31 +1401,44 @@ template<typename T, typename Serv> void dirty2x(
cout << "Working on plane " << iw << " containing " << nvis_plane[iw] cout << "Working on plane " << iw << " containing " << nvis_plane[iw]
<< " visibilities" << endl; << " visibilities" << endl;
double wcur = wmin+iw*dw; double wcur = wmin+iw*dw;
size_t cnt=0;
vis_loc_.resize(nvis_plane[iw]);
auto vis_loc = mav<complex<T>,1>(vis_loc_.data(), {nvis_plane[iw]});
idx_loc_.resize(nvis_plane[iw]);
auto idx_loc = mav<uint32_t,1>(idx_loc_.data(), {nvis_plane[iw]});
mapper.resize(nvis_plane[iw]);
for (size_t ipart=0; ipart<nvis; ++ipart)
if ((int(iw)>=minplane[ipart]) && (iw<minplane[ipart]+supp))
mapper[cnt++] = ipart;
#pragma omp parallel for num_threads(nthreads)
for (size_t i=0; i<nvis_plane[iw]; ++i)
idx_loc[i] = srv.getIdx(mapper[i]);
#pragma omp parallel for num_threads(nthreads) #pragma omp parallel for num_threads(nthreads)
for (size_t i=0; i<nx_dirty; ++i) for (size_t i=0; i<nx_dirty; ++i)
for (size_t j=0; j<ny_dirty; ++j) for (size_t j=0; j<ny_dirty; ++j)
tdirty2(i,j) = tdirty(i,j); tdirty2(i,j) = tdirty(i,j);
gconf.apply_wscreen(cmav(tdirty2), tdirty2, wcur, false); gconf.apply_wscreen(cmav(tdirty2), tdirty2, wcur, false);
gconf.dirty2grid_c(cmav(tdirty2), grid); gconf.dirty2grid_c(cmav(tdirty2), grid);
newidx.resize(nvis_plane[iw]);
size_t cnt=0;
if (srv.isMsServ())
{
for (size_t ipart=0; ipart<nvis; ++ipart)
if ((int(iw)>=minplane[ipart]) && (iw<minplane[ipart]+supp))
newidx[cnt++] = srv.getIdx(ipart);
auto newidx2 = const_mav<uint32_t, 1>(newidx.data(), {newidx.size()});
Serv newsrv(srv, newidx2);
grid2x_c(gconf, cmav(grid), newsrv, wcur, dw);
}
else
{
for (size_t ipart=0; ipart<nvis; ++ipart)
if ((int(iw)>=minplane[ipart]) && (iw<minplane[ipart]+supp))
newidx[cnt++] = ipart;
vis_loc_.resize(nvis_plane[iw]);
auto vis_loc = mav<complex<T>,1>(vis_loc_.data(), {nvis_plane[iw]});
vis_loc.fill(0);
idx_loc_.resize(nvis_plane[iw]);
auto idx_loc = mav<uint32_t,1>(idx_loc_.data(), {nvis_plane[iw]});
#pragma omp parallel for num_threads(nthreads)
for (size_t i=0; i<nvis_plane[iw]; ++i)
idx_loc[i] = srv.getIdx(newidx[i]);
grid2vis_c(srv.getBaselines(), gconf, cmav(idx_loc), cmav(grid), vis_loc, grid2vis_c(srv.getBaselines(), gconf, cmav(idx_loc), cmav(grid), vis_loc,
nullmav<T,1>(), wcur, dw); nullmav<T,1>(), wcur, dw);
#pragma omp parallel for num_threads(nthreads)
#pragma omp parallel for num_threads(nthreads)
for (size_t i=0; i<nvis_plane[iw]; ++i) for (size_t i=0; i<nvis_plane[iw]; ++i)
srv.addVis(mapper[i], vis_loc[i]); srv.addVis(newidx[i], vis_loc[i]);
}
} }
} }
else else
......
...@@ -554,6 +554,7 @@ template<typename T> pyarr<complex<T>> Pygrid2vis_c( ...@@ -554,6 +554,7 @@ template<typename T> pyarr<complex<T>> Pygrid2vis_c(
auto wgt2 = make_const_mav<1>(wgt); auto wgt2 = make_const_mav<1>(wgt);
auto res = makeArray<complex<T>>({nvis}); auto res = makeArray<complex<T>>({nvis});
auto vis = make_mav<1>(res); auto vis = make_mav<1>(res);
vis.fill(0);
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
grid2vis_c<T>(baselines, gconf, idx2, grid2, vis, wgt2); grid2vis_c<T>(baselines, gconf, idx2, grid2, vis, wgt2);
...@@ -751,6 +752,7 @@ template<typename T> pyarr<complex<T>> dirty2vis2(const PyBaselines &baselines, ...@@ -751,6 +752,7 @@ template<typename T> pyarr<complex<T>> dirty2vis2(const PyBaselines &baselines,
auto dirty2 = make_const_mav<2>(dirty_); auto dirty2 = make_const_mav<2>(dirty_);
auto vis = makeArray<complex<T>>({idx2.shape(0)}); auto vis = makeArray<complex<T>>({idx2.shape(0)});
auto vis2 = make_mav<1>(vis); auto vis2 = make_mav<1>(vis);
vis2.fill(0);
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
vis2.fill(0); vis2.fill(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