//# Copyright (C) 1998,1999,2000,2001,2003
//# Associated Universities, Inc. Washington DC, USA.
//# This program is free software; you can redistribute it and/or modify it
//# under the terms of the GNU General Public License as published by the Free
//# Software Foundation; either version 2 of the License, or (at your option)
//# This program is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
//# You should have received a copy of the GNU General Public License along
//# with this program; if not, write to the Free Software Foundation, Inc.,
//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# Charlottesville, VA 22903-2475 USA
#include <imageanalysis/ImageAnalysis/ImageRegridder.h>
#include <imageanalysis/ImageAnalysis/ImageFactory.h>
#include <imageanalysis/ImageAnalysis/ImageMetaData.h>
#include <imageanalysis/ImageAnalysis/SubImageFactory.h>
#include <casacore/images/Images/ImageConcat.h>
#include <casacore/images/Images/ImageRegrid.h>
#include <casacore/scimath/Mathematics/Geometry.h>
#include <casacore/casa/BasicSL/STLIO.h>
template<class T> const String ImageRegridder<T>::_class = "ImageRegridder";
template<class T> ImageRegridder<T>::ImageRegridder(
const SPCIIT image, const casacore::Record *const regionRec,
const casacore::String& maskInp, const casacore::String& outname,
casacore::Bool overwrite, const casacore::CoordinateSystem& csysTo,
const casacore::IPosition& axes, const casacore::IPosition& shape
) : ImageRegridderBase<T>(
image, regionRec, maskInp, outname,
overwrite, csysTo, axes, shape
template<class T> ImageRegridder<T>::ImageRegridder(
const SPCIIT image, const casacore::String& outname,
const SPCIIT templateIm, const casacore::IPosition& axes,
const casacore::Record *const regionRec, const casacore::String& maskInp,
casacore::Bool overwrite, const casacore::IPosition& shape
) : ImageRegridderBase<T>(
image, regionRec, maskInp, outname, overwrite,
templateIm->coordinates(), axes, shape
template<class T> ImageRegridder<T>::~ImageRegridder() {}
template<class T> SPIIT ImageRegridder<T>::regrid() const {
_subimage = SubImageFactory<T>::createImage(
*this->_getImage(), "", *this->_getRegion(), this->_getMask(),
this->_getDropDegen(), false, false, this->_getStretch()
auto regridByVel = false;
const auto axes = this->_getAxes();
auto hasMultipleBeams = this->_getImage()->imageInfo().hasMultipleBeams();
const auto& csys = this->_getImage()->coordinates();
(this->_getSpecAsVelocity() || hasMultipleBeams)
&& csys.hasSpectralAxis()
&& this->_getTemplateCoords().hasSpectralAxis()
auto inputSpecAxis = csys.spectralAxisNumber(false);
auto isInputSpecDegen = _subimage->shape()[inputSpecAxis] == 1;
"An image with multiple beams cannot be regridded along the "
"spectral axis. You may wish to convolve all channels to a "
"common resolution and retry"
if (! isInputSpecDegen && this->_getSpecAsVelocity()) {