#include <imageanalysis/ImageAnalysis/ImageRebinner.h>
template<class T> ImageRebinner<T>::ImageRebinner(
const casacore::Record *const region,
const casacore::String& maskInp,
const casacore::String& outname, casacore::Bool overwrite
image, "", region, "", "", "",
maskInp, outname, overwrite
_factors(), _crop(false) {
template<class T> void ImageRebinner<T>::setFactors(const casacore::Vector<casacore::Int>& f) {
"Rebinning factor vector cannot be empty"
"All factors must be positive"
"All rebinning factors are 1, which "
"means rebinning cannot occur"
casacore::uInt ndim = this->_getImage()->ndim();
"Factor vector length must be less than or "
"equal to the number of input image axes"
casacore::Vector<casacore::Int> fcopy = f.copy();
casacore::uInt mysize = f.size();
fcopy.resize(ndim, true);
for (casacore::uInt i=mysize; i<ndim; i++) {
*this->_getLog() << casacore::LogOrigin(getClass(), __func__)
<< casacore::LogIO::NORMAL << "Not all rebinning factors were specified, "
<< "filling in those not specified with factors of "
<< "1, so will rebin according to factor=" << fcopy
<< casacore::LogIO::POST;
const casacore::CoordinateSystem& csys = this->_getImage()->coordinates();
csys.hasPolarizationCoordinate() && fcopy[csys.polarizationAxisNumber()] > 1,
"A polarization axis cannot be rebinned"
template<class T> SPIIT ImageRebinner<T>::rebin() const {
ThrowIf(_factors.empty(), "Logic Error: factors have not been set");
SPCIIT image = this->_getImage();
casacore::uInt ndim = image->ndim();
"You have provided " + casacore::String::toString(_factors.size())
+ " factors. You must provide exactly " + casacore::String::toString(ndim)
? ". If you wish to drop degenerate axes, specify binning factors of 1 for them"
casacore::IPosition myFactors;
if (this->_getDropDegen()) {
casacore::IPosition shape = image->shape();
casacore::IPosition degenAxes;
for (casacore::uInt i=0; i<ndim; i++) {
degenAxes.append(casacore::IPosition(1, i));
myFactors = _factors.removeAxes(degenAxes);
SubImageFactory<T>::createImage(
*this->_getImage(), "", *this->_getRegion(),
this->_getMask(), this->_getDropDegen(),
false, false, this->_getStretch()