Commit 37fb8111 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

move docstrings to their functions

parent cc89e037
......@@ -319,6 +319,16 @@ template<typename T> struct UVW
{ return UVW(u*fct, v*fct, w*fct); }
};
constexpr auto Baselines_DS = R"""(
Class storing UVW coordinates and channel information.
Parameters
==========
coord: np.array((nrows, 3), dtype=np.float)
u, v and w coordinates for each row
freq: np.array((nchannels,), dtype=np.float)
frequency for each individual channel (in Hz)
)""";
template<typename T> class Baselines
{
private:
......@@ -359,6 +369,21 @@ template<typename T> class Baselines
size_t Nrows() const { return nrows; }
size_t Nchannels() const { return nchan; }
static constexpr auto ms2vis_DS = R"""(
Extracts visibility data from a measurement for the provided indices.
Parameters
==========
ms: np.array((nrows, nchannels), dtype=np.complex)
the measurement set's visibility data
idx: np.array((nvis,), dtype=np.uint32)
the indices to be extracted
Returns
=======
np.array((nvis,), dtype=np.complex)
The visibility data for the index array
)""";
template<typename T2> pyarr_c<T2> ms2vis(const pyarr<T2> &ms_,
const pyarr_c<uint32_t> &idx_) const
{
......@@ -384,6 +409,23 @@ template<typename T> class Baselines
return res;
}
static constexpr auto vis2ms_DS = R"""(
Produces a new MS with the provided visibilities set.
Parameters
==========
vis: np.array((nvis,), dtype=np.complex)
The visibility data for the index array
idx: np.array((nvis,), dtype=np.uint32)
the indices to be inserted
ms_in: np.array((nrows, nchannels), dtype=np.complex), optional
input measurement set to which the visibilities are added.
Returns
=======
np.array((nrows, nchannels), dtype=np.complex)
the measurement set's visibility data (0 where not covered by idx)
)""";
template<typename T2> pyarr_c<T2> vis2ms(const pyarr<T2> &vis_,
const pyarr<uint32_t> &idx_, py::object &ms_in) const
{
......@@ -412,6 +454,23 @@ template<typename T> class Baselines
constexpr int logsquare=4;
constexpr auto GridderConfig_DS = R"""(
Class storing information related to the gridding/degridding process.
Parameters
==========
nxdirty: int
x resolution of the dirty image; must be even
nydirty: int
y resolution of the dirty image; must be even
epsilon: float
required accuracy for the gridding/degridding step
Must be >= 2e-13.
pixsize_x: float
Pixel size in x direction (radians)
pixsize_y: float
Pixel size in y direction (radians)
)""";
template<typename T> class GridderConfig
{
private:
......@@ -461,6 +520,20 @@ template<typename T> class GridderConfig
size_t W() const { return w; }
size_t Nsafe() const { return nsafe; }
T Beta() const { return beta; }
static constexpr auto grid2dirty_DS = R"""(
Converts from UV grid to dirty image (FFT, cropping, correction)
Parameters
==========
grid: np.array((nu, nv), dtype=np.float64)
gridded UV data
Returns
=======
nd.array((nxdirty, nydirty), dtype=np.float64)
the dirty image
)""";
pyarr_c<T> grid2dirty(const pyarr_c<T> &grid) const
{
checkArray(grid, "grid", {nu, nv});
......@@ -507,6 +580,20 @@ template<typename T> class GridderConfig
}
return res;
}
static constexpr auto dirty2grid_DS = R"""(
Converts from a dirty image to a UV grid (correction, padding, FFT)
Parameters
==========
dirty: nd.array((nxdirty, nydirty), dtype=np.float64)
the dirty image
Returns
=======
np.array((nu, nv), dtype=np.float64)
gridded UV data
)""";
pyarr_c<T> dirty2grid(const pyarr_c<T> &dirty) const
{
checkArray(dirty, "dirty", {nx_dirty, ny_dirty});
......@@ -665,6 +752,28 @@ template<typename T> class Helper
}
};
constexpr auto vis2grid_c_DS = R"""(
Grids visibilities onto a UV grid
Parameters
==========
baselines: Baselines
the Baselines object
gconf: GridderConf
the GridderConf object to be used
(used to optimize the ordering of the indices)
idx: np.array((nvis,), dtype=np.uint32)
the indices for the entries to be gridded
vis: np.array((nvis,), dtype=np.complex)
The visibility data for the index array
grid_in: np.array((nu,nv), dtype=np.complex128), optional
If present, the result is added to this array.
Returns
=======
np.array((nu,nv), dtype=np.complex128):
the gridded visibilities
)""";
template<typename T> pyarr_c<complex<T>> vis2grid_c(
const Baselines<T> &baselines, const GridderConfig<T> &gconf,
const pyarr<uint32_t> &idx_, const pyarr<complex<T>> &vis_,
......@@ -713,11 +822,53 @@ template<typename T> pyarr_c<complex<T>> vis2grid_c(
return res;
}
constexpr auto vis2grid_DS = R"""(
Grids visibilities onto a UV grid
Parameters
==========
baselines: Baselines
the Baselines object
gconf: GridderConf
the GridderConf object to be used
(used to optimize the ordering of the indices)
idx: np.array((nvis,), dtype=np.uint32)
the indices for the entries to be gridded
vis: np.array((nvis,), dtype=np.complex)
The visibility data for the index array
Returns
=======
np.array((nu,nv), dtype=np.float64):
the gridded visibilities (made real by making use of Hermitian symmetry)
)""";
template<typename T> pyarr_c<T> vis2grid(const Baselines<T> &baselines,
const GridderConfig<T> &gconf, const pyarr<uint32_t> &idx_,
const pyarr<complex<T>> &vis_)
{ return complex2hartley(vis2grid_c(baselines, gconf, idx_, vis_, None)); }
constexpr auto ms2grid_c_DS = R"""(
Grids measurement set data onto a UV grid
Parameters
==========
baselines: Baselines
the Baselines object
gconf: GridderConf
the GridderConf object to be used
(used to optimize the ordering of the indices)
idx: np.array((nvis,), dtype=np.uint32)
the indices for the entries to be gridded
ms: np.array((nrows, nchannels), dtype=np.complex128)
the measurement set.
grid_in: np.array((nu,nv), dtype=np.complex128), optional
If present, the result is added to this array.
Returns
=======
np.array((nu,nv), dtype=np.complex128):
the gridded visibilities
)""";
template<typename T> pyarr_c<complex<T>> ms2grid_c(
const Baselines<T> &baselines, const GridderConfig<T> &gconf,
const pyarr<uint32_t> &idx_, const pyarr<complex<T>> &ms_,
......@@ -885,6 +1036,28 @@ template<typename T> pyarr_c<complex<T>> grid2vis_c(
return res;
}
constexpr auto grid2vis_DS = R"""(
Degrids visibilities from a UV grid
Parameters
==========
baselines: Baselines
the Baselines object
gconf: GridderConf
the GridderConf object to be used
(used to optimize the ordering of the indices)
idx: np.array((nvis,), dtype=np.uint32)
the indices for the entries to be degridded
grid: np.array((nu,nv), dtype=np.float64):
the gridded visibilities (made real by making use of Hermitian symmetry)
vis: np.array((nvis,), dtype=np.complex)
The visibility data for the index array
Returns
=======
np.array((nvis,), dtype=np.complex)
The degridded visibility data
)""";
template<typename T> pyarr_c<complex<T>> grid2vis(const Baselines<T> &baselines,
const GridderConfig<T> &gconf, const pyarr<uint32_t> &idx_,
const pyarr_c<T> &grid_)
......@@ -1071,6 +1244,34 @@ template<typename T> pyarr_c<complex<T>> apply_holo(
}
return res;
}
constexpr auto getIndices_DS = R"""(
Selects a subset of entries from a `Baselines` object.
Parameters
==========
baselines: Baselines
the Baselines object
gconf: GridderConf
the GridderConf object to be used with the returned indices.
(used to optimize the ordering of the indices)
flags: np.array((nrows, nchannels), dtype=np.bool)
"True" indicates that the value should not be used
chbegin: int
first channel to use (-1: start with the first available channel)
chend: int
one-past last channel to use (-1: one past the last available channel)
wmin: float
only select entries with w>=wmin
wmax: float
only select entries with w<wmax
Returns
=======
np.array((nvis,), dtype=np.uint32)
the compressed indices for all entries which match the selected criteria
and are not flagged.
)""";
template<typename T> pyarr_c<uint32_t> getIndices(const Baselines<T> &baselines,
const GridderConfig<T> &gconf, const pyarr_c<bool> &flags_, int chbegin,
int chend, T wmin, T wmax)
......@@ -1128,191 +1329,6 @@ template<typename T> pyarr_c<uint32_t> getIndices(const Baselines<T> &baselines,
return res;
}
const char *Baselines_DS = R"""(
Class storing UVW coordinates and channel information.
Parameters
==========
coord: np.array((nrows, 3), dtype=np.float)
u, v and w coordinates for each row
freq: np.array((nchannels,), dtype=np.float)
frequency for each individual channel (in Hz)
)""";
const char *BL_ms2vis_DS = R"""(
Extracts visibility data from a measurement for the provided indices.
Parameters
==========
ms: np.array((nrows, nchannels), dtype=np.complex)
the measurement set's visibility data
idx: np.array((nvis,), dtype=np.uint32)
the indices to be extracted
Returns
=======
np.array((nvis,), dtype=np.complex)
The visibility data for the index array
)""";
const char *BL_vis2ms_DS = R"""(
Produces a new MS with the provided visibilities set.
Parameters
==========
vis: np.array((nvis,), dtype=np.complex)
The visibility data for the index array
idx: np.array((nvis,), dtype=np.uint32)
the indices to be inserted
ms_in: np.array((nrows, nchannels), dtype=np.complex), optional
input measurement set to which the visibilities are added.
Returns
=======
np.array((nrows, nchannels), dtype=np.complex)
the measurement set's visibility data (0 where not covered by idx)
)""";
const char *GridderConfig_DS = R"""(
Class storing information related to the gridding/degridding process.
Parameters
==========
nxdirty: int
x resolution of the dirty image; must be even
nydirty: int
y resolution of the dirty image; must be even
epsilon: float
required accuracy for the gridding/degridding step
Must be >= 2e-13.
pixsize_x: float
Pixel size in x direction (radians)
pixsize_y: float
Pixel size in y direction (radians)
)""";
const char *grid2dirty_DS = R"""(
Converts from UV grid to dirty image (FFT, cropping, correction)
Parameters
==========
grid: np.array((nu, nv), dtype=np.float64)
gridded UV data
Returns
=======
nd.array((nxdirty, nydirty), dtype=np.float64)
the dirty image
)""";
const char *dirty2grid_DS = R"""(
Converts from a dirty image to a UV grid (correction, padding, FFT)
Parameters
==========
dirty: nd.array((nxdirty, nydirty), dtype=np.float64)
the dirty image
Returns
=======
np.array((nu, nv), dtype=np.float64)
gridded UV data
)""";
const char *getIndices_DS = R"""(
Selects a subset of entries from a `Baselines` object.
Parameters
==========
baselines: Baselines
the Baselines object
gconf: GridderConf
the GridderConf object to be used with the returned indices.
(used to optimize the ordering of the indices)
flags: np.array((nrows, nchannels), dtype=np.bool)
"True" indicates that the value should not be used
chbegin: int
first channel to use (-1: start with the first available channel)
chend: int
one-past last channel to use (-1: one past the last available channel)
wmin: float
only select entries with w>=wmin
wmax: float
only select entries with w<wmax
Returns
=======
np.array((nvis,), dtype=np.uint32)
the compressed indices for all entries which match the selected criteria
and are not flagged.
)""";
const char *vis2grid_DS = R"""(
Grids visibilities onto a UV grid
Parameters
==========
baselines: Baselines
the Baselines object
gconf: GridderConf
the GridderConf object to be used
(used to optimize the ordering of the indices)
idx: np.array((nvis,), dtype=np.uint32)
the indices for the entries to be gridded
vis: np.array((nvis,), dtype=np.complex)
The visibility data for the index array
Returns
=======
np.array((nu,nv), dtype=np.float64):
the gridded visibilities (made real by making use of Hermitian symmetry)
)""";
const char *vis2grid_c_DS = R"""(
Grids visibilities onto a UV grid
Parameters
==========
baselines: Baselines
the Baselines object
gconf: GridderConf
the GridderConf object to be used
(used to optimize the ordering of the indices)
idx: np.array((nvis,), dtype=np.uint32)
the indices for the entries to be gridded
vis: np.array((nvis,), dtype=np.complex)
The visibility data for the index array
grid_in: np.array((nu,nv), dtype=np.complex128), optional
If present, the result is added to this array.
Returns
=======
np.array((nu,nv), dtype=np.complex128):
the gridded visibilities
)""";
const char *grid2vis_DS = R"""(
Degrids visibilities from a UV grid
Parameters
==========
baselines: Baselines
the Baselines object
gconf: GridderConf
the GridderConf object to be used
(used to optimize the ordering of the indices)
idx: np.array((nvis,), dtype=np.uint32)
the indices for the entries to be degridded
grid: np.array((nu,nv), dtype=np.float64):
the gridded visibilities (made real by making use of Hermitian symmetry)
vis: np.array((nvis,), dtype=np.complex)
The visibility data for the index array
Returns
=======
np.array((nvis,), dtype=np.complex)
The degridded visibility data
)""";
} // unnamed namespace
PYBIND11_MODULE(nifty_gridder, m)
......@@ -1324,10 +1340,10 @@ PYBIND11_MODULE(nifty_gridder, m)
"coord"_a, "freq"_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)
.def ("vis2ms",&Baselines<double>::vis2ms<complex<double>>, BL_vis2ms_DS,
"vis"_a, "idx"_a, "ms_in"_a=None);
.def ("ms2vis",&Baselines<double>::ms2vis<complex<double>>,
Baselines<double>::ms2vis_DS, "ms"_a, "idx"_a)
.def ("vis2ms",&Baselines<double>::vis2ms<complex<double>>,
Baselines<double>::vis2ms_DS, "vis"_a, "idx"_a, "ms_in"_a=None);
py::class_<GridderConfig<double>> (m, "GridderConfig", GridderConfig_DS)
.def(py::init<size_t, size_t, double, double, double>(),"nxdirty"_a,
"nydirty"_a, "epsilon"_a, "pixsize_x"_a, "pixsize_y"_a)
......@@ -1338,11 +1354,11 @@ PYBIND11_MODULE(nifty_gridder, m)
.def("Pixsize_y", &GridderConfig<double>::Pixsize_y)
.def("Nu", &GridderConfig<double>::Nu)
.def("Nv", &GridderConfig<double>::Nv)
.def("grid2dirty", &GridderConfig<double>::grid2dirty, grid2dirty_DS,
"grid"_a)
.def("grid2dirty", &GridderConfig<double>::grid2dirty,
/*GridderConfig<double>::grid2dirty_DS,*/ "grid"_a)
.def("grid2dirty_c", &GridderConfig<double>::grid2dirty_c, "grid"_a)
.def("dirty2grid", &GridderConfig<double>::dirty2grid, dirty2grid_DS,
"dirty"_a)
.def("dirty2grid", &GridderConfig<double>::dirty2grid,
GridderConfig<double>::dirty2grid_DS, "dirty"_a)
.def("dirty2grid_c", &GridderConfig<double>::dirty2grid_c, "dirty"_a)
// pickle support
......@@ -1380,8 +1396,8 @@ PYBIND11_MODULE(nifty_gridder, m)
"grid"_a, "wgt"_a, "ms_in"_a=None);
m.def("vis2grid_c",&vis2grid_c<double>, vis2grid_c_DS, "baselines"_a,
"gconf"_a, "idx"_a, "vis"_a, "grid_in"_a);
m.def("ms2grid_c",&ms2grid_c<double>, "baselines"_a, "gconf"_a, "idx"_a,
"ms"_a, "grid_in"_a=None);
m.def("ms2grid_c",&ms2grid_c<double>, ms2grid_c_DS, "baselines"_a, "gconf"_a,
"idx"_a, "ms"_a, "grid_in"_a=None);
m.def("ms2grid_c_wgt",&ms2grid_c_wgt<double>, "baselines"_a, "gconf"_a,
"idx"_a, "ms"_a, "wgt"_a, "grid_in"_a=None);
m.def("grid2vis_c",&grid2vis_c<double>, "baselines"_a, "gconf"_a, "idx"_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