Commit 0a38d894 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

first try at making the parameters more intuitive

parent f14b7c1d
......@@ -259,20 +259,20 @@ template<typename T> class Baselines
{
private:
vector<UVW<T>> coord;
vector<T> scaling;
vector<T> xlambda;
size_t nrows, nchan;
public:
Baselines(const pyarr_c<T> &coord_, const pyarr_c<T> &scaling_)
Baselines(const pyarr_c<T> &coord_, const pyarr_c<T> &lambda_)
{
myassert(coord_.ndim()==2, "coord array must be 2D");
myassert(coord_.shape(1)==3, "coord.shape[1] must be 3");
myassert(scaling_.ndim()==1, "scaling array must be 1D");
myassert(lambda_.ndim()==1, "lambda array must be 1D");
nrows = coord_.shape(0);
nchan = scaling_.shape(0);
scaling.resize(nchan);
nchan = lambda_.shape(0);
xlambda.resize(nchan);
for (size_t i=0; i<nchan; ++i)
scaling[i] = scaling_.data()[i];
xlambda[i] = T(1)/lambda_.data()[i];
coord.resize(nrows);
auto cood = coord_.data();
for (size_t i=0; i<coord.size(); ++i)
......@@ -284,10 +284,10 @@ template<typename T> class Baselines
{
size_t irow = index/nchan;
size_t ichan = index-nchan*irow;
return coord[irow]*scaling[ichan];
return coord[irow]*xlambda[ichan];
}
UVW<T> effectiveCoord(size_t irow, size_t ichan) const
{ return coord[irow]*scaling[ichan]; }
{ return coord[irow]*xlambda[ichan]; }
size_t Nrows() const { return nrows; }
size_t Nchannels() const { return nchan; }
......@@ -364,9 +364,9 @@ template<typename T> class GridderConfig
public:
GridderConfig(size_t nxdirty, size_t nydirty, double epsilon,
double urange, double vrange)
double incell_x, double incell_y)
: nx_dirty(nxdirty), ny_dirty(nydirty),
ucorr(1./urange), vcorr(1./vrange),
ucorr(1./(incell_x*nxdirty)), vcorr(1./(incell_y*nydirty)),
w(get_w(epsilon)), nsafe((w+1)/2),
nu(max(2*nsafe,2*nx_dirty)), nv(max(2*nsafe,2*ny_dirty)),
beta(2.3*w),
......@@ -375,8 +375,8 @@ template<typename T> class GridderConfig
myassert((nx_dirty&1)==0, "nx_dirty must be even");
myassert((ny_dirty&1)==0, "ny_dirty must be even");
myassert(epsilon>0, "epsilon must be positive");
myassert(urange>0, "urange must be positive");
myassert(vrange>0, "vrange must be positive");
myassert(incell_x>0, "incell_x must be positive");
myassert(incell_y>0, "incell_y must be positive");
auto tmp = correction_factors(nu, nx_dirty/2+1, w);
cfu[nx_dirty/2]=tmp[0];
......@@ -820,8 +820,8 @@ Parameters
==========
coord: np.array((nrows, 3), dtype=np.float)
u, v and w coordinates for each row
scaling: np.array((nchannels,), dtype=np.float)
scaling factor for u, v, w for each individual channel
lambda: np.array((nchannels,), dtype=np.float)
wave length for each individual channel
)""";
const char *BL_ms2vis_DS = R"""(
......@@ -886,8 +886,8 @@ nydirty: int
epsilon: float
required accuracy for the gridding/degridding step
Must be >= 2e-13.
urange: float
vrange: float
incell_x: float
incell_y: float
)""";
const char *grid2dirty_DS = R"""(
......@@ -997,7 +997,7 @@ PYBIND11_MODULE(nifty_gridder, m)
py::class_<Baselines<double>> (m, "Baselines", Baselines_DS)
.def(py::init<const pyarr_c<double> &, const pyarr_c<double> &>(),
"coord"_a, "scaling"_a)
"coord"_a, "lambda"_a)
.def ("Nrows",&Baselines<double>::Nrows)
.def ("Nchannels",&Baselines<double>::Nchannels)
.def ("ms2vis",&Baselines<double>::ms2vis<complex<double>>, BL_ms2vis_DS, "ms"_a, "idx"_a)
......@@ -1007,7 +1007,7 @@ PYBIND11_MODULE(nifty_gridder, m)
"vis"_a, "idx"_a, "ms"_a.noconvert());
py::class_<GridderConfig<double>> (m, "GridderConfig", GridderConfig_DS)
.def(py::init<size_t, size_t, double, double, double>(),"nxdirty"_a,
"nydirty"_a, "epsilon"_a, "urange"_a, "vrange"_a)
"nydirty"_a, "epsilon"_a, "incell_x"_a, "incell_y"_a)
.def("Nu", &GridderConfig<double>::Nu)
.def("Nv", &GridderConfig<double>::Nv)
.def("grid2dirty", &GridderConfig<double>::grid2dirty, grid2dirty_DS, "grid"_a)
......@@ -1024,7 +1024,7 @@ PYBIND11_MODULE(nifty_gridder, m)
#if 0
py::class_<Baselines<float>> (m, "Baselines_f", Baselines_DS)
.def(py::init<const pyarr_c<float> &, const pyarr_c<float> &>(),
"coord"_a, "scaling"_a)
"coord"_a, "lambda"_a)
.def ("Nrows",&Baselines<float>::Nrows)
.def ("Nchannels",&Baselines<float>::Nchannels)
.def ("ms2vis",&Baselines<float>::ms2vis<complex<float>>, BL_ms2vis_DS, "ms"_a, "idx"_a)
......@@ -1033,7 +1033,7 @@ PYBIND11_MODULE(nifty_gridder, m)
"vis"_a, "idx"_a, "ms"_a.noconvert());
py::class_<GridderConfig<float>> (m, "GridderConfig_f")
.def(py::init<size_t, size_t, float, float, float>(),"nxdirty"_a,
"nydirty"_a, "epsilon"_a, "urange"_a, "vrange"_a)
"nydirty"_a, "epsilon"_a, "incell_x"_a, "incell_y"_a)
.def("Nu", &GridderConfig<float>::Nu)
.def("Nv", &GridderConfig<float>::Nv)
.def("grid2dirty", &GridderConfig<float>::grid2dirty, "grid"_a)
......
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