Source
xxxxxxxxxx
// If we resize the psf and itsVirgin == true, we need to create a new psf and
//# LatConvEquation.cc: this defines LatConvEquation
//# Copyright (C) 1996,1997,1998,1999,2000,2001,2003
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library 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 Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; 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
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# $Id$
using namespace casacore;
namespace casa { //# NAMESPACE CASA - BEGIN
LatConvEquation::LatConvEquation(Lattice<Float> & psf,
Lattice<Float> & dirtyImage)
:itsMeas(&dirtyImage),
itsPsf(&psf),
itsConv(psf, dirtyImage.shape(), true)
{
itsVirgin = true;
itsRealPsfSize = psf.shape();
itsPsfOrigin = itsPsf->shape()/2;
}
LatConvEquation::~LatConvEquation() {
if (!itsVirgin) {
// cout << "Deleting nonVirgin PSF" << endl;
delete itsPsf;
}
}
Bool LatConvEquation::evaluate(Lattice<Float> & result,
const LinearModel<Lattice<Float> > & model){
const Lattice<Float> & modelLattice = model.getModel();
// DebugAssert(modelLattice.shape().isEqual(result.shape()), AipsError);
itsConv.linear(result, modelLattice);
return true;
}
Lattice<Float> *
LatConvEquation::evaluate(const IPosition & position,
const Float amplitude,
const IPosition & modelSize){
if (itsPsf->nelements() == 0){
itsConv.getPsf(*itsPsf);
itsPsfOrigin = itsPsf->shape()/2;
itsRealPsfSize = itsPsf->shape();
}
IPosition psfSize = itsPsf->shape();
IPosition blc = itsPsfOrigin - position;
IPosition trc = blc + modelSize - 1;
// Check if the required bounds are outside the psf. If they are then
// resize the psf (with zero padding) to encompass the requested
// convolution. Another way to do this is to just return the required
// portion of the psf (of size modelSize) suitably padded. This will be
// quicker and more memory efficient for just one evaluation, but if the
// user is cleaning near the edges of their image, then it will have to be
// done for each iteration that is near the edge. By resizing the whole
// psf when necessary it will after a few resizes be at the required size
// for all the iterations.