C++ Proxy
The various implementations of IDG are all subclasses of the Proxy class.
See the list of proxy subclasses for specific implementations.
See below for the description of the Proxy class itself.
-
class Proxy
Subclassed by idg::proxy::cpu::CPU, idg::proxy::cuda::CUDA
Public Functions
-
void gridding(const Plan &plan, const aocommon::xt::Span<float, 1> &frequencies, const aocommon::xt::Span<std::complex<float>, 4> &visibilities, const aocommon::xt::Span<UVW<float>, 2> &uvw, const aocommon::xt::Span<std::pair<unsigned int, unsigned int>, 1> &baselines, const aocommon::xt::Span<Matrix2x2<std::complex<float>>, 4> &aterms, const aocommon::xt::Span<unsigned int, 1> &aterm_offsets, const aocommon::xt::Span<float, 2> &taper)
Add visibilities to a grid, applying A-terms.
Before calling this function, the grid needs to have been set by a call to the set_grid function and the cache needs to be initialized by a call to the init_cache function. On return the results might still be in a cache, and to obtain the final grid a call to get_final_grid() is needed.
- Parameters:
plan – [in] A Plan object, previously created by a call to the make_plan() member function. The Plan contains the partitioning of the visibilities in subgrids.
frequencies – [in] A one dimensional array of floats, containing the frequency per channel
visibilities – [in] A four dimensional array of complex floats. The axes are baseline, time, channel, and correlation (XX,XY,YX,XX). Note that the baseline and time axis are transposed compared to the ordering in a Measurement Set.
uvw – [in] A two dimensional array of UVW coordinates (triplet of floats). The axes are baseline and time.
baselines – [in] A one dimensional array of pairs station indices (integers) comprising a baseline.
aterms – [in] Four dimensional array of 2x2 (Jones) matrices of complex floats. The axes are time slot, station, subgrid x, subgrid y. A time slot is a range of time samples over which the aterms are constant The time slots are defined by the aterm_offsets parameters.
aterm_offsets – [in] A one dimensional array of time indices (ints) that represent the time ranges of time slots. The array is one longer than the number of time slots. Time slot k is valid from aterm_offsets[k] until aterm_offsets[k+1].
taper – [in] A two dimensional array of floats of the size of a subgrid.
-
void degridding(const Plan &plan, const aocommon::xt::Span<float, 1> &frequencies, aocommon::xt::Span<std::complex<float>, 4> &visibilities, const aocommon::xt::Span<UVW<float>, 2> &uvw, const aocommon::xt::Span<std::pair<unsigned int, unsigned int>, 1> &baselines, const aocommon::xt::Span<Matrix2x2<std::complex<float>>, 4> &aterms, const aocommon::xt::Span<unsigned int, 1> &aterm_offsets, const aocommon::xt::Span<float, 2> &taper)
Degrid (predict) visibilities, applying A-terms.
Before calling this function, the grid needs to have been set by a call to the set_grid function, and the cache needs to be initialized by a call to the init_cache function.
- Parameters:
plan – [in] A Plan object, previously created by a call to the make_plan() member function. The Plan contains the partitioning of the visibilities in subgrids.
frequencies – [in] A one dimensional array of floats, containing the frequency per channel
visibilities – [out] A four dimensional array of complex floats. The axes are baseline, time, channel, and correlation (XX,XY,YX,XX). Note that the baseline and time axis are transposed compared to the ordering in a Measurement Set.
uvw – [in] A two dimensional array of UVW coordinates (triplet of floats). The axes are baseline and time.
baselines – [in] A one dimensional array of pairs station indices (integers) comprising a baseline.
aterms – [in] Four dimensional array of 2x2 (Jones) matrices of complex floats. The axes are time slot, station, subgrid x, subgrid y. A time slot is a range of time samples over which the aterms are constant The time slots are defined by the aterm_offsets parameters.
aterm_offsets – [in] A one dimensional array of time indices (ints) that represent the time ranges of time slots. The array is one longer than the number of time slots. Time slot k is valid from aterm_offsets[k] until aterm_offsets[k+1].
taper – [in] A two dimensional array of floats of the size of a subgrid.
-
void calibrate_init(const unsigned int kernel_size, const aocommon::xt::Span<float, 2> &frequencies, aocommon::xt::Span<std::complex<float>, 4> &visibilities, aocommon::xt::Span<float, 4> &weights, const aocommon::xt::Span<UVW<float>, 2> &uvw, const aocommon::xt::Span<std::pair<unsigned int, unsigned int>, 1> &baselines, const aocommon::xt::Span<unsigned int, 1> &aterm_offsets, const aocommon::xt::Span<float, 2> &taper)
Prepare a calibration cycle.
- Parameters:
kernel_size – Size of the kernel, see
frequencies – [in] A nr_channel_blocks x nr_channels_per_block array of floats, containing the frequency per channel.
visibilities – [in] A four dimensional array of complex floats. The axes are baseline, time, channel, and correlation (XX,XY,YX,XX). Note that the baseline and time axis are transposed compared to the ordering in a Measurement Set.
weights – Visibility weights, should have same dimension as
visibilities.uvw – [in] A two dimensional array of UVW coordinates (triplet of floats). The axes are baseline and time.
baselines – [in] A one dimensional array of pairs station indices (integers) comprising a baseline.
aterm_offsets – [in] A one dimensional array of time indices (ints) that represent the time ranges of time slots. The array is one longer than the number of time slots. Time slot k is valid from aterm_offsets[k] until aterm_offsets[k+1].
taper – [in] A two dimensional array of floats of the size of a subgrid.
-
void calibrate_update(const int antenna_nr, const aocommon::xt::Span<Matrix2x2<std::complex<float>>, 5> &aterms, const aocommon::xt::Span<Matrix2x2<std::complex<float>>, 5> &aterm_derivatives, aocommon::xt::Span<double, 4> &hessian, aocommon::xt::Span<double, 3> &gradient, aocommon::xt::Span<double, 1> &residual)
Compute a hessian, gradient and residual per time slot for station antenna_nr, given the current aterms and derivative aterms.
The calibration functions provided by the Proxy do not implement a full solving strategy. They are intended to be called by an iterative solver to compute the Hessian, derivative and residual in some working point.
It is assumed that the solver updates the aterm of a single station at a time, and iterates over the stations. The aterm is assumed to be described by a model with a number of unknown parameters.
The aterm_derivatives are the derivatives of the aterm of station antenna_nr with respect to the unknowns.
The values returned are 1) the residual, the root mean square (TODO check, maybe it is the sum of squares) of the difference between the predicted (degridded) visibilities and the visibilities provided in the calibrate_init() call. 2) the gradient, the derivative of the residual with respect to the unknowns 3) the derivative of the gradient with respect to the unknowns
- Parameters:
antenna_nr – [in]
aterms – [in] Five dimensional array of 2x2 (Jones) matrices of complex floats. The axes are channel block, time slot, station, subgrid x, subgrid y. A time slot is a range of time samples over which the aterms are constant The time slots are defined by the aterm_offsets parameters.
aterm_derivatives – [in] Five dimensional array of 2x2 (Jones) matrices of complex floats. The axes are channel block, time slot, terms, subgrid x, subgrid y.
hessian – [out]
gradient – [out]
residual – [out]
-
void calibrate_finish()
Clean up after calibration cycle.
-
void transform(DomainAtoDomainB direction)
Applies (inverse) Fourier transform to grid.
-
virtual void compute_avg_beam(const unsigned int nr_antennas, const unsigned int nr_channels, const aocommon::xt::Span<UVW<float>, 2> &uvw, const aocommon::xt::Span<std::pair<unsigned int, unsigned int>, 1> &baselines, const aocommon::xt::Span<Matrix2x2<std::complex<float>>, 4> &aterms, const aocommon::xt::Span<unsigned int, 1> &aterm_offsets, const aocommon::xt::Span<float, 4> &weights, aocommon::xt::Span<std::complex<float>, 4> &average_beam)
Computes the average beam term.
- Parameters:
nr_antennas – [in]
nr_channels – [in]
uvw – [in]
baselines – [in]
aterms – [in]
aterm_offsets – [in]
weights – [in]
average_beam – [out] Four dimensional array of complex floats. The axes are subgrid x, subgrid y, mueller matrix row, mueller matrix col
-
virtual std::unique_ptr<auxiliary::Memory> allocate_memory(size_t bytes)
Methods for memory management.
-
virtual void set_grid(aocommon::xt::Span<std::complex<float>, 4> &grid)
Set grid to be used for gridding, degridding or calibration.
-
virtual aocommon::xt::Span<std::complex<float>, 4> &get_final_grid()
Flush all pending operations and return the final grid.
- Returns:
aocommon::xt::Span<std::complex<float>
-
inline aocommon::xt::Span<std::complex<float>, 4> &get_grid()
Get the current grid without flushing pending operations.
- Returns:
aocommon::xt::Span<std::complex<float>
-
inline virtual void init_cache(int subgrid_size, float cell_size, float w_step, const std::array<float, 2> &shift)
Methods for cache management.
Initialize cache
Sets the configuration for subsequent gridding, degridding or calibrate calls This allows the Proxy to set up a caching strategy
- Parameters:
subgrid_size – Size of the subgrid, see
cell_size –
w_step –
shift –
-
inline virtual std::unique_ptr<Plan> make_plan(const int kernel_size, const aocommon::xt::Span<float, 1> &frequencies, const aocommon::xt::Span<UVW<float>, 2> &uvw, const aocommon::xt::Span<std::pair<unsigned int, unsigned int>, 1> &baselines, const aocommon::xt::Span<unsigned int, 1> &aterm_offsets, Plan::Options options = Plan::Options())
Create a plan that can be used for calls to the gridding or degridding functions.
- Parameters:
kernel_size – Size of the kernel, see
frequencies – [in] A one dimensional array of floats, containing the frequency per channel
uvw – [in] A two dimensional array of UVW coordinates (triplet of floats). The axes are baseline and time.
baselines – [in] A one dimensional array of pairs station indices (integers) comprising a baseline.
aterm_offsets – [in] A one dimensional array of time indices (ints) that represent the time ranges of time slots. The array is one longer than the number of time slots. Time slot k is valid from aterm_offsets[k] until aterm_offsets[k+1].
options –
- Returns:
std::unique_ptr<Plan>
-
void gridding(const Plan &plan, const aocommon::xt::Span<float, 1> &frequencies, const aocommon::xt::Span<std::complex<float>, 4> &visibilities, const aocommon::xt::Span<UVW<float>, 2> &uvw, const aocommon::xt::Span<std::pair<unsigned int, unsigned int>, 1> &baselines, const aocommon::xt::Span<Matrix2x2<std::complex<float>>, 4> &aterms, const aocommon::xt::Span<unsigned int, 1> &aterm_offsets, const aocommon::xt::Span<float, 2> &taper)