Commit 6db3283a authored by Martin Reinecke's avatar Martin Reinecke
Browse files

add RowChan type

parent 7faf4d5c
...@@ -245,6 +245,11 @@ size_t get_supp(double epsilon) ...@@ -245,6 +245,11 @@ size_t get_supp(double epsilon)
throw runtime_error("requested epsilon too small - minimum is 2e-13"); throw runtime_error("requested epsilon too small - minimum is 2e-13");
} }
struct RowChan
{
size_t row, chan;
};
template<typename T> class EC_Kernel template<typename T> class EC_Kernel
{ {
protected: protected:
...@@ -332,14 +337,17 @@ template<typename T> class Baselines ...@@ -332,14 +337,17 @@ template<typename T> class Baselines
coord[i] = UVW<T>(coord_(i,0), coord_(i,1), coord_(i,2)); coord[i] = UVW<T>(coord_(i,0), coord_(i,1), coord_(i,2));
} }
UVW<T> effectiveCoord(uint32_t index) const RowChan getRowChan(uint32_t index) const
{ {
size_t irow = index/nchan; size_t irow = index/nchan;
size_t ichan = index-nchan*irow; size_t ichan = index-nchan*irow;
return coord[irow]*f_over_c[ichan]; return RowChan{irow, ichan};
} }
UVW<T> effectiveCoord(size_t irow, size_t ichan) const
{ return coord[irow]*f_over_c[ichan]; } UVW<T> effectiveCoord(const RowChan &rc) const
{ return coord[rc.row]*f_over_c[rc.chan]; }
UVW<T> effectiveCoord(uint32_t index) const
{ return effectiveCoord(getRowChan(index)); }
size_t Nrows() const { return nrows; } size_t Nrows() const { return nrows; }
size_t Nchannels() const { return nchan; } size_t Nchannels() const { return nchan; }
...@@ -367,10 +375,8 @@ template<typename T> class Baselines ...@@ -367,10 +375,8 @@ template<typename T> class Baselines
#pragma omp parallel for num_threads(nthreads) #pragma omp parallel for num_threads(nthreads)
for (size_t i=0; i<nvis; ++i) for (size_t i=0; i<nvis; ++i)
{ {
auto t = idx(i); auto rc = getRowChan(idx(i));
auto row = t/nchan; vis[i] = ms(rc.row, rc.chan);
auto chan = t-row*nchan;
vis[i] = ms(row, chan);
} }
} }
...@@ -384,10 +390,8 @@ template<typename T> class Baselines ...@@ -384,10 +390,8 @@ template<typename T> class Baselines
#pragma omp parallel for num_threads(nthreads) #pragma omp parallel for num_threads(nthreads)
for (size_t i=0; i<nvis; ++i) for (size_t i=0; i<nvis; ++i)
{ {
auto t = idx(i); auto rc = getRowChan(idx(i));
auto row = t/nchan; ms(rc.row, rc.chan) += vis(i);
auto chan = t-row*nchan;
ms(row, chan) += vis(i);
} }
} }
}; };
...@@ -724,15 +728,13 @@ template<typename T> void ms2grid_c ...@@ -724,15 +728,13 @@ template<typename T> void ms2grid_c
#pragma omp for schedule(guided,100) #pragma omp for schedule(guided,100)
for (size_t ipart=0; ipart<nvis; ++ipart) for (size_t ipart=0; ipart<nvis; ++ipart)
{ {
auto tidx = idx(ipart); auto rc = baselines.getRowChan(idx(ipart));
auto row = tidx/nchan; UVW<T> coord = baselines.effectiveCoord(rc);
auto chan = tidx-row*nchan;
UVW<T> coord = baselines.effectiveCoord(tidx);
hlp.prep(coord.u, coord.v); hlp.prep(coord.u, coord.v);
auto * ptr = hlp.p0w; auto * ptr = hlp.p0w;
auto v(ms(row,chan)*emb); auto v(ms(rc.row,rc.chan)*emb);
if (have_wgt) if (have_wgt)
v*=wgt(row,chan); v*=wgt(rc.row,rc.chan);
for (size_t cu=0; cu<supp; ++cu) for (size_t cu=0; cu<supp; ++cu)
{ {
complex<T> tmp(v*ku[cu]); complex<T> tmp(v*ku[cu]);
...@@ -820,10 +822,8 @@ template<typename T> void grid2ms_c ...@@ -820,10 +822,8 @@ template<typename T> void grid2ms_c
#pragma omp for schedule(guided,100) #pragma omp for schedule(guided,100)
for (size_t ipart=0; ipart<nvis; ++ipart) for (size_t ipart=0; ipart<nvis; ++ipart)
{ {
auto tidx = idx(ipart); auto rc = baselines.getRowChan(idx(ipart));
auto row = tidx/nchan; UVW<T> coord = baselines.effectiveCoord(rc);
auto chan = tidx-row*nchan;
UVW<T> coord = baselines.effectiveCoord(tidx);
hlp.prep(coord.u, coord.v); hlp.prep(coord.u, coord.v);
complex<T> r = 0; complex<T> r = 0;
const auto * ptr = hlp.p0r; const auto * ptr = hlp.p0r;
...@@ -835,8 +835,8 @@ template<typename T> void grid2ms_c ...@@ -835,8 +835,8 @@ template<typename T> void grid2ms_c
r += tmp*ku[cu]; r += tmp*ku[cu];
ptr += jump; ptr += jump;
} }
if (have_wgt) r*=wgt(row,chan); if (have_wgt) r*=wgt(rc.row,rc.chan);
ms(row,chan) = r*emb; ms(rc.row,rc.chan) = r*emb;
} }
} }
} }
......
...@@ -649,7 +649,7 @@ template<typename T> pyarr<uint32_t> getIndices(const PyBaselines<T> &baselines, ...@@ -649,7 +649,7 @@ template<typename T> pyarr<uint32_t> getIndices(const PyBaselines<T> &baselines,
for (int ichan=chbegin; ichan<chend; ++ichan) for (int ichan=chbegin; ichan<chend; ++ichan)
if (!flags[irow*nchan+ichan]) if (!flags[irow*nchan+ichan])
{ {
auto uvw = baselines.effectiveCoord(irow, ichan); auto uvw = baselines.effectiveCoord(RowChan{irow,size_t(ichan)});
if ((uvw.w>=wmin) && (uvw.w<wmax)) if ((uvw.w>=wmin) && (uvw.w<wmax))
{ {
T u, v; T u, v;
...@@ -673,7 +673,7 @@ template<typename T> pyarr<uint32_t> getIndices(const PyBaselines<T> &baselines, ...@@ -673,7 +673,7 @@ template<typename T> pyarr<uint32_t> getIndices(const PyBaselines<T> &baselines,
for (int ichan=chbegin; ichan<chend; ++ichan) for (int ichan=chbegin; ichan<chend; ++ichan)
if (!flags[irow*nchan+ichan]) if (!flags[irow*nchan+ichan])
{ {
auto uvw = baselines.effectiveCoord(irow, ichan); auto uvw = baselines.effectiveCoord(RowChan{irow,size_t(ichan)});
if ((uvw.w>=wmin) && (uvw.w<wmax)) if ((uvw.w>=wmin) && (uvw.w<wmax))
iout[acc[tmp[idx++]]++] = irow*nchan+ichan; iout[acc[tmp[idx++]]++] = irow*nchan+ichan;
} }
......
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