Commit 33a8ede5 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

more syncing from minimal

parent d8d8c226
...@@ -72,17 +72,18 @@ nthreads = 4 ...@@ -72,17 +72,18 @@ nthreads = 4
epsilon = 6e-6 epsilon = 6e-6
t0 = time() t0 = time()
print('Start gridding...') print('Start gridding...')
do_wstacking=True
if epsilon > 5e-6: if epsilon > 5e-6:
ms = ms.astype("c8") ms = ms.astype("c8")
wgt = wgt.astype("f4") wgt = wgt.astype("f4")
dirty = ng.ms2dirty( dirty = ng.ms2dirty(
uvw, freq, ms, wgt, npixdirty, npixdirty, pixsize, pixsize, epsilon, uvw, freq, ms, wgt, npixdirty, npixdirty, pixsize, pixsize, epsilon,
do_wstacking=True, nthreads=nthreads, verbosity=2) do_wstacking=do_wstacking, nthreads=nthreads, verbosity=2)
print('Done') print('Done')
t = time() - t0 t = time() - t0
print("{} s".format(t)) print("{} s".format(t))
print("{} visibilities/thread/s".format(np.sum(wgt != 0)/nthreads/t)) print("{} visibilities/thread/s".format(np.sum(wgt != 0)/nthreads/t))
plt.imshow(dirty.real) plt.imshow(dirty)
plt.show() plt.show()
...@@ -103,26 +103,7 @@ template<typename T> pyarr<T> providePotentialArray(const py::object &in, ...@@ -103,26 +103,7 @@ template<typename T> pyarr<T> providePotentialArray(const py::object &in,
{ {
if (in.is_none()) if (in.is_none())
return makeArray<T>(vector<size_t>(shape.size(), 0)); return makeArray<T>(vector<size_t>(shape.size(), 0));
auto tmp_ = getPyarr<T>(in.cast<py::array>(), name); return getPyarr<T>(in.cast<py::array>(), name);
checkArray(tmp_, name, shape);
return tmp_;
}
template<typename T> pyarr<T> provideCArray(py::object &in,
const string &name, const vector<size_t> &shape)
{
if (in.is_none())
{
auto tmp_ = makeArray<T>(shape);
size_t sz = size_t(tmp_.size());
auto tmp = tmp_.mutable_data();
for (size_t i=0; i<sz; ++i)
tmp[i] = T(0);
return tmp_;
}
auto tmp_ = getPyarr<T>(in.cast<py::array>(), name);
checkArray(tmp_, name, shape);
return tmp_;
} }
template<size_t ndim, typename T> mav<T,ndim> make_mav(pyarr<T> &in) template<size_t ndim, typename T> mav<T,ndim> make_mav(pyarr<T> &in)
...@@ -437,7 +418,7 @@ template<typename T> pyarr<complex<T>> Pyvis2grid_c( ...@@ -437,7 +418,7 @@ template<typename T> pyarr<complex<T>> Pyvis2grid_c(
auto idx2 = make_const_mav<1>(idx_); auto idx2 = make_const_mav<1>(idx_);
pyarr<T> wgt = providePotentialArray<T>(wgt_, "wgt", {nvis}); pyarr<T> wgt = providePotentialArray<T>(wgt_, "wgt", {nvis});
auto wgt2 = make_const_mav<1>(wgt); auto wgt2 = make_const_mav<1>(wgt);
auto res = provideCArray<complex<T>>(grid_in, "grid_in", {gconf.Nu(), gconf.Nv()}); auto res = provideArray<complex<T>>(grid_in, "grid_in", {gconf.Nu(), gconf.Nv()});
auto grid = make_mav<2>(res); auto grid = make_mav<2>(res);
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
...@@ -475,7 +456,7 @@ template<typename T> pyarr<T> Pyvis2grid(const PyBaselines &baselines, ...@@ -475,7 +456,7 @@ template<typename T> pyarr<T> Pyvis2grid(const PyBaselines &baselines,
const pyarr<complex<T>> &vis_, py::object &grid_in, const py::object &wgt_) const pyarr<complex<T>> &vis_, py::object &grid_in, const py::object &wgt_)
{ {
auto tmp=Pyvis2grid_c(baselines, gconf, idx_, vis_, None, wgt_); auto tmp=Pyvis2grid_c(baselines, gconf, idx_, vis_, None, wgt_);
auto grd=provideCArray<T>(grid_in, "grid_in", {gconf.Nu(), gconf.Nv()}); auto grd=provideArray<T>(grid_in, "grid_in", {gconf.Nu(), gconf.Nv()});
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
gridder::detail::complex2hartley(make_const_mav<2>(tmp), make_mav<2>(grd), gconf.Nthreads()); gridder::detail::complex2hartley(make_const_mav<2>(tmp), make_mav<2>(grd), gconf.Nthreads());
...@@ -518,7 +499,7 @@ template<typename T> pyarr<complex<T>> Pyms2grid_c( ...@@ -518,7 +499,7 @@ template<typename T> pyarr<complex<T>> Pyms2grid_c(
auto idx2 = make_const_mav<1>(idx_); auto idx2 = make_const_mav<1>(idx_);
pyarr<T> wgt = providePotentialArray<T>(wgt_, "wgt", {nrows, nchan}); pyarr<T> wgt = providePotentialArray<T>(wgt_, "wgt", {nrows, nchan});
auto wgt2 = make_const_mav<2>(wgt); auto wgt2 = make_const_mav<2>(wgt);
auto res = provideCArray<complex<T>>(grid_in, "grid_in", {gconf.Nu(), gconf.Nv()}); auto res = provideArray<complex<T>>(grid_in, "grid_in", {gconf.Nu(), gconf.Nv()});
auto grid = make_mav<2>(res); auto grid = make_mav<2>(res);
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
...@@ -533,7 +514,7 @@ template<typename T> pyarr<T> Pyms2grid( ...@@ -533,7 +514,7 @@ template<typename T> pyarr<T> Pyms2grid(
py::object &grid_in, const py::object &wgt_) py::object &grid_in, const py::object &wgt_)
{ {
auto tmp = Pyms2grid_c(baselines, gconf, idx_, ms_, None, wgt_); auto tmp = Pyms2grid_c(baselines, gconf, idx_, ms_, None, wgt_);
auto res_ = provideCArray<T>(grid_in, "grid_in", {gconf.Nu(), gconf.Nv()}); auto res_ = provideArray<T>(grid_in, "grid_in", {gconf.Nu(), gconf.Nv()});
auto res = make_mav<2>(res_); auto res = make_mav<2>(res_);
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
...@@ -604,7 +585,7 @@ template<typename T> pyarr<complex<T>> Pygrid2ms_c( ...@@ -604,7 +585,7 @@ template<typename T> pyarr<complex<T>> Pygrid2ms_c(
auto idx2 = make_const_mav<1>(idx_); auto idx2 = make_const_mav<1>(idx_);
pyarr<T> wgt = providePotentialArray<T>(wgt_, "wgt", {nrows, nchan}); pyarr<T> wgt = providePotentialArray<T>(wgt_, "wgt", {nrows, nchan});
auto wgt2 = make_const_mav<2>(wgt); auto wgt2 = make_const_mav<2>(wgt);
auto res = provideCArray<complex<T>>(ms_in, "ms_in", {nrows, nchan}); auto res = provideArray<complex<T>>(ms_in, "ms_in", {nrows, nchan});
auto ms = make_mav<2>(res); auto ms = make_mav<2>(res);
{ {
py::gil_scoped_release release; py::gil_scoped_release release;
......
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