casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends
casa::CEMemModel Class Reference

Implements the Cornwell & Evans MEM Algorithm on Lattices. More...

#include <CEMemModel.h>

Inheritance diagram for casa::CEMemModel:
casa::LinearModel< Lattice< Float > >

List of all members.

Public Member Functions

 CEMemModel (Entropy &ent, Lattice< Float > &model, uInt nIntegrations=10, Float sigma=0.001, Float targetFlux=1.0, Bool useFluxConstraint=False, Bool initializeModel=True, Bool imagePlane=False)
 Construct the CEMemModel object and initialise the model.
 CEMemModel (Entropy &ent, Lattice< Float > &model, Lattice< Float > &prior, uInt nIntegrations=10, Float sigma=0.001, Float targetFlux=1.0, Bool useFluxConstraint=False, Bool initializeModel=True, Bool imagePlane=False)
 Construct the CEMemModel object, initialise the model and Prior images.
 CEMemModel (Entropy &ent, Lattice< Float > &model, Lattice< Float > &prior, Lattice< Float > &mask, uInt nIntegrations=10, Float sigma=0.001, Float targetFlux=1.0, Bool useFluxConstraint=False, Bool initializeModel=True, Bool imagePlane=False)
 Construct the CEMemModel object, initialise the model, Prior, and mask images.
virtual ~CEMemModel ()
 destructor
void state ()
 solve the convolution equation returns True if converged
Bool solve (ResidualEquation< Lattice< Float > > &eqn)
 This needs to be "ResidualEquation", using LatConvEquation as polymorphism is broken.
void setEntropy (Entropy &myEntropy)
 Set and get various state images and classes.
void getEntropy (Entropy &myEntropy)
Lattice< Float > & getModel () const
 set or get the Model image
void setModel (const Lattice< Float > &model)
 Set the current model.
Lattice< Float > & getPrior () const
 set or get the Prior image
void setPrior (Lattice< Float > &prior)
Lattice< Float > & getMask () const
 set or get the Mask image
void setMask (Lattice< Float > &mask)
Float getAlpha () const
 set and get alpha and beta
Float getBeta () const
void setAlpha (Float alpha)
void setBeta (Float beta)
Float getTolerance ()
 Set various controlling parameters (The most popular controlling parameters are set in the constructor)
void setTolerance (Float x)
Float getQ ()
void setQ (Float x)
Float getGain ()
void setGain (Float x)
Float getMaxNormGrad ()
void setMaxNormGrad (Float x)
Int getInitialNumberIterations ()
void setInitialNumberIterations (Int x)
void setThreshold (const Float x)
 The convergence can also be in terms of the maximum residual (ie, for use in stopping in a major cycle).
void setThresholdSpeedup (const Float iter)
 Thresh doubles in iter iterations.
Float getThreshold ()
virtual void setProgress (CEMemProgress &ccp)
 Set/get the progress display.
virtual CEMemProgressgetProgress ()
Int numberIterations ()
 return the number of iterations completed
void setCycleFlux (Float x)
 if this MEMModel is constructed in a MF loop, we may need to increment the flux by the last iterations flux
Float getCycleFlux ()

Protected Types

enum  GradientType {
  H,
  C,
  F,
  J
}
 Enumerate the different Gradient subscript types. More...

Protected Member Functions

void oneIteration ()
 Perform One Iteration.
Bool applyMask (Lattice< Float > &lat)
 apply mask to a lattice; returns True if mask is available, False if not
void formEntropy ()
 Helper functions that interface with Entropy routines Access to the entropy should be through this interface; the points at which the Entropy is mentioned is then limited to these lines right here, and to the constructors which set the Entropy.
void formGDG ()
void formGDGStep ()
void formGDS ()
void entropyType (String &str)
void relaxMin ()
Bool testConvergence ()
 CEMemModel ()
 protected generic constrcutor: DON'T USE IT!
void letEntropyDie ()
 Set entropy pointer to zero: called by Entropy's destructor.
Bool initStuff ()
 initialize itsStep and itsResidual and other stuff
void changeAlphaBeta ()
 controls how to change Alpha and Beta
void initializeAlphaBeta ()
 initialize Alpha-Beta (called by changeAlphaBeta)
void updateAlphaBeta ()
 update Alpha-Beta (called by changeAlphaBeta)
Bool checkImage (const Lattice< Float > *)
 Generic utility functions.
Bool checkImages (const Lattice< Float > *one, const Lattice< Float > *other)
 check that the lattices and the underlying tile sizes are consistent
Bool ok ()
 check that all is well in Denmark: ensure all images are the same size, ensure we have an entropy, ensure state variables have reasonable values
void calculateStep ()
 Helper functions for oneIteration:
void takeStep (Float wt1, Float wt2)
 take one step: clipped addition of wt1*itsModel + wt2*itsStep
Float formFlux ()
 Calculate the flux, itsModMin, and itsModMax.
Bool testConvergenceThreshold ()
 Determine if the peak residual is less than the getThreshold()

Protected Attributes

EntropyitsEntropy_ptr
 ------------Private Member Data--------------------- functional form of the entropy
ResidualEquation< Lattice
< Float > > * 
itsResidualEquation_ptr
 form of the Residual method
Lattice< Float > * itsModel_ptr
 Images:
Lattice< Float > * itsPrior_ptr
Lattice< Float > * itsMask_ptr
Lattice< Float > * itsStep_ptr
 Our OWN internal temp images; delete these upon destruction.
Lattice< Float > * itsResidual_ptr
Bool itsInitializeModel
 Controlling parameters.
uInt itsNumberIterations
Bool itsDoInit
Float itsSigma
Float itsTargetFlux
Float itsDefaultLevel
Float itsTargetChisq
Float itsTolerance
 tolerance for convergence
Float itsQ
 N points per beam.
Float itsGain
 gain for adding step image
Float itsMaxNormGrad
Bool itsUseFluxConstraint
 constrain flux or not?
Bool itsDoImagePlane
 is this an image plane problem (like Single Dish or Optical?)
Float itsThreshold0
Float itsThresholdSpeedup
Float itsCycleFlux
Float itsAlpha
 State variables.
Float itsBeta
Float itsNormGrad
Float itsFlux
Float itsTotalFlux
Float itsChisq
Float itsFit
 sqrt( chi^2/target_chi^2 )
Float itsAFit
 sqrt( chi^2/ Npixels )
Float itsEntropy
 numerical value of entropy
Float itsRequiredModelMin
 Model is constrained to be >= itsNewMin.
Float itsModelMax
 maximum pixel value in model
Float itsModelMin
 minimum pixel value n model
Float itsLength
Double itsGradDotStep0
Double itsGradDotStep1
uInt itsIteration
uInt itsFirstIteration
Matrix< DoubleitsGDG
 matrix of gradient dot products
Float itsCurrentPeakResidual
Float itsNumberPixels
Bool itsChoose
 Accesories.
LogIO itsLog
CEMemProgressitsProgressPtr

Friends

class Entropy
 Any new entropies derived from Entropy must sign the friend list:
class EntropyI
class EntropyEmptiness

Detailed Description

Implements the Cornwell & Evans MEM Algorithm on Lattices.

Intended use:

Public interface

 <h3>Review Status</h3><dl><dt>Date Reviewed:<dd>yyyy/mm/dd</dl> 

Prerequisite

Etymology

This class is called CEMemModel because it uses the Cornwell and Evans MEM algorithm to deconvolve the model.

Synopsis

This class is used to perform the Cornwell and Evans MEM Algorithm on an Array. Only the deconvolved model of the sky are directly stored by this class. The point spread function (psf) and convolved (dirty) image are stored in a companion class which is must be derived from ResidualEquation.

The deconvolution works like this. The user constructs a CEMemModel by specifying an initial model of the sky. This can by be one,two,three... dimensional depending on the dimension of the psf (see below). The user then constructs a class which implements the forward equation between the model and the dirty image. Typically this will be the ConvolutionEquation class, although any class which has a ResidualEquation interface will work (but perhaps very slowly, as the ConvolutionEquation class has member functions optimised for CLEAN and MEM)

The user then calls the solve() function (with the appropriate equation class as an arguement), and this class will perform the MEM deconvolution. The various MEM parameters are set (prior to calling solve) using the functions derived from the Iterate class, in particular setNumberIterations().

The solve() function does not return either the deconvolved model or the residuals. The solved model can be obtained using the getModel() function (derived from ArrayModel()) and the residual can be obtained using the residual() member function of the Convolution/Residual Equation Class.

The size and shape of the model used in this class MUST be the same as the convolved data (Dirty Image), stored in the companion ResidualEquation Class. However the model (and convolved data) can have more dimensions than the psf, as well as a different size (either larger or smaller). When the dimensionality is different the deconvolution is done independendtly in each "plane" of the model. (Note this has not been implemented yet but is relatively simple to do if necessary).

StokesVectors are not yet implemented.

A companion class to this one is MaskedCEMemModel. This provides the same functionality but is used with MaskedArrays which indicate which regions of the NewtonRaphson (residual) image to apply when forming the step image (MaskedCEMemModel is not yet implemented).

Example

    Matrix<Float> psf(12,12), dirty(10,10), initialModel(10,10);
    ...put appropriate values into psf, dirty, & initialModel...\.
    CEMemModel<Float> deconvolvedModel(initialModel); 
    ConvolutionEquation convEqn(psf, dirty);
    deconvolvedModel.setSigma(0.001); 
    deconvolvedModel.setTargetFlux(-2.500); 
    deconvolvedModel.setNumberIterations(30);
    Bool convWorked = deconvolvedModel.solve(convEqn);
    Array<Float> finalModel, residuals;
    if (convWorked){
      finalModel = deconvolvedModel.getModel();
      ConvEqn.residual(deconvolvedModel, finalResidual);
    }

Motivation

This class is needed to deconvolve extended images. In time, the MEM algorithm will be a principle player in the mosaicing stuff.

Template Type Argument Requirements (T)

testing: Float: lets try it first StokesVector: will require lots more work

To Do

Definition at line 146 of file CEMemModel.h.


Member Enumeration Documentation

Enumerate the different Gradient subscript types.

Enumerator:
H 

Entropy.

C 

Chi_sq.

F 

Flux.

J 

Objective function J.

Definition at line 445 of file CEMemModel.h.


Constructor & Destructor Documentation

casa::CEMemModel::CEMemModel ( Entropy ent,
Lattice< Float > &  model,
uInt  nIntegrations = 10,
Float  sigma = 0.001,
Float  targetFlux = 1.0,
Bool  useFluxConstraint = False,
Bool  initializeModel = True,
Bool  imagePlane = False 
)

Construct the CEMemModel object and initialise the model.

casa::CEMemModel::CEMemModel ( Entropy ent,
Lattice< Float > &  model,
Lattice< Float > &  prior,
uInt  nIntegrations = 10,
Float  sigma = 0.001,
Float  targetFlux = 1.0,
Bool  useFluxConstraint = False,
Bool  initializeModel = True,
Bool  imagePlane = False 
)

Construct the CEMemModel object, initialise the model and Prior images.

casa::CEMemModel::CEMemModel ( Entropy ent,
Lattice< Float > &  model,
Lattice< Float > &  prior,
Lattice< Float > &  mask,
uInt  nIntegrations = 10,
Float  sigma = 0.001,
Float  targetFlux = 1.0,
Bool  useFluxConstraint = False,
Bool  initializeModel = True,
Bool  imagePlane = False 
)

Construct the CEMemModel object, initialise the model, Prior, and mask images.

virtual casa::CEMemModel::~CEMemModel ( ) [virtual]

destructor

protected generic constrcutor: DON'T USE IT!


Member Function Documentation

Bool casa::CEMemModel::applyMask ( Lattice< Float > &  lat) [protected]

apply mask to a lattice; returns True if mask is available, False if not

void casa::CEMemModel::calculateStep ( ) [protected]

Helper functions for oneIteration:

calculate size of step

void casa::CEMemModel::changeAlphaBeta ( ) [protected]

controls how to change Alpha and Beta

Bool casa::CEMemModel::checkImage ( const Lattice< Float > *  ) [protected]

Generic utility functions.

check that a single image is onf plausible shape

Bool casa::CEMemModel::checkImages ( const Lattice< Float > *  one,
const Lattice< Float > *  other 
) [protected]

check that the lattices and the underlying tile sizes are consistent

void casa::CEMemModel::entropyType ( String str) [inline, protected]

Definition at line 302 of file CEMemModel.h.

References casa::Entropy::entropyType(), and itsEntropy_ptr.

void casa::CEMemModel::formEntropy ( ) [inline, protected]

Helper functions that interface with Entropy routines Access to the entropy should be through this interface; the points at which the Entropy is mentioned is then limited to these lines right here, and to the constructors which set the Entropy.

The entropy should not ever change the private

Definition at line 294 of file CEMemModel.h.

References casa::Entropy::formEntropy(), itsEntropy, and itsEntropy_ptr.

Calculate the flux, itsModMin, and itsModMax.

void casa::CEMemModel::formGDG ( ) [inline, protected]

Definition at line 296 of file CEMemModel.h.

References casa::Entropy::formGDG(), itsEntropy_ptr, and itsGDG.

void casa::CEMemModel::formGDGStep ( ) [inline, protected]

Definition at line 298 of file CEMemModel.h.

References casa::Entropy::formGDGStep(), itsEntropy_ptr, and itsGDG.

void casa::CEMemModel::formGDS ( ) [inline, protected]

Definition at line 300 of file CEMemModel.h.

References casa::Entropy::formGDS(), itsEntropy_ptr, and itsGradDotStep1.

Float casa::CEMemModel::getAlpha ( ) const [inline]

set and get alpha and beta

Definition at line 234 of file CEMemModel.h.

References itsAlpha.

Float casa::CEMemModel::getBeta ( ) const [inline]

Definition at line 235 of file CEMemModel.h.

References itsBeta.

Definition at line 275 of file CEMemModel.h.

References itsCycleFlux.

void casa::CEMemModel::getEntropy ( Entropy myEntropy) [inline]

Definition at line 212 of file CEMemModel.h.

References itsEntropy_ptr.

Definition at line 248 of file CEMemModel.h.

References itsGain.

Definition at line 252 of file CEMemModel.h.

References itsFirstIteration.

Lattice<Float>& casa::CEMemModel::getMask ( ) const [inline]

set or get the Mask image

Definition at line 226 of file CEMemModel.h.

References casa::Lattice< T >::clone(), and itsMask_ptr.

Definition at line 250 of file CEMemModel.h.

References itsMaxNormGrad.

Lattice<Float>& casa::CEMemModel::getModel ( ) const [inline, virtual]

set or get the Model image

Implements casa::LinearModel< Lattice< Float > >.

Definition at line 215 of file CEMemModel.h.

References casa::Lattice< T >::clone(), and itsModel_ptr.

set or get the Prior image

Definition at line 221 of file CEMemModel.h.

References casa::Lattice< T >::clone(), and itsPrior_ptr.

virtual CEMemProgress& casa::CEMemModel::getProgress ( ) [inline, virtual]

Definition at line 266 of file CEMemModel.h.

References itsProgressPtr.

Definition at line 246 of file CEMemModel.h.

References itsQ.

Set various controlling parameters (The most popular controlling parameters are set in the constructor)

Definition at line 244 of file CEMemModel.h.

References itsTolerance.

initialize Alpha-Beta (called by changeAlphaBeta)

initialize itsStep and itsResidual and other stuff

void casa::CEMemModel::letEntropyDie ( ) [inline, protected]

Set entropy pointer to zero: called by Entropy's destructor.

Definition at line 315 of file CEMemModel.h.

References itsEntropy_ptr.

return the number of iterations completed

Definition at line 270 of file CEMemModel.h.

References itsIteration.

Bool casa::CEMemModel::ok ( ) [protected]

check that all is well in Denmark: ensure all images are the same size, ensure we have an entropy, ensure state variables have reasonable values

void casa::CEMemModel::oneIteration ( ) [protected]

Perform One Iteration.

void casa::CEMemModel::relaxMin ( ) [inline, protected]

Definition at line 304 of file CEMemModel.h.

References itsEntropy_ptr, itsRequiredModelMin, and casa::Entropy::relaxMin().

void casa::CEMemModel::setAlpha ( Float  alpha) [inline]

Definition at line 236 of file CEMemModel.h.

References itsAlpha.

void casa::CEMemModel::setBeta ( Float  beta) [inline]

Definition at line 237 of file CEMemModel.h.

References itsBeta.

void casa::CEMemModel::setCycleFlux ( Float  x) [inline]

if this MEMModel is constructed in a MF loop, we may need to increment the flux by the last iterations flux

Definition at line 274 of file CEMemModel.h.

References itsCycleFlux.

void casa::CEMemModel::setEntropy ( Entropy myEntropy) [inline]

Set and get various state images and classes.

set or get the Entropy class

Definition at line 211 of file CEMemModel.h.

References itsEntropy_ptr.

void casa::CEMemModel::setGain ( Float  x) [inline]

Definition at line 249 of file CEMemModel.h.

References itsGain.

Definition at line 253 of file CEMemModel.h.

References itsFirstIteration.

Definition at line 251 of file CEMemModel.h.

References itsMaxNormGrad.

void casa::CEMemModel::setModel ( const Lattice< Float > &  model) [inline, virtual]

Set the current model.

Implements casa::LinearModel< Lattice< Float > >.

Definition at line 217 of file CEMemModel.h.

References casa::Lattice< T >::clone(), and itsModel_ptr.

virtual void casa::CEMemModel::setProgress ( CEMemProgress ccp) [inline, virtual]

Set/get the progress display.

Definition at line 265 of file CEMemModel.h.

References itsProgressPtr.

void casa::CEMemModel::setQ ( Float  x) [inline]

Definition at line 247 of file CEMemModel.h.

References itsQ.

void casa::CEMemModel::setThreshold ( const Float  x) [inline]

The convergence can also be in terms of the maximum residual (ie, for use in stopping in a major cycle).

Definition at line 258 of file CEMemModel.h.

References itsThreshold0.

void casa::CEMemModel::setThresholdSpeedup ( const Float  iter) [inline]

Thresh doubles in iter iterations.

Definition at line 260 of file CEMemModel.h.

References itsThresholdSpeedup.

void casa::CEMemModel::setTolerance ( Float  x) [inline]

Definition at line 245 of file CEMemModel.h.

References itsTolerance.

This needs to be "ResidualEquation", using LatConvEquation as polymorphism is broken.

solve the convolution equation returns True if converged

Gives information about the state of the CEMem (ie, using mask image, using prior image; more work here!)

void casa::CEMemModel::takeStep ( Float  wt1,
Float  wt2 
) [protected]

take one step: clipped addition of wt1*itsModel + wt2*itsStep

Bool casa::CEMemModel::testConvergence ( ) [inline, protected]

Definition at line 306 of file CEMemModel.h.

References itsEntropy_ptr, and casa::Entropy::testConvergence().

Determine if the peak residual is less than the getThreshold()

void casa::CEMemModel::updateAlphaBeta ( ) [protected]

update Alpha-Beta (called by changeAlphaBeta)


Friends And Related Function Documentation

friend class Entropy [friend]

Any new entropies derived from Entropy must sign the friend list:

Definition at line 150 of file CEMemModel.h.

friend class EntropyEmptiness [friend]

Definition at line 152 of file CEMemModel.h.

friend class EntropyI [friend]

Definition at line 151 of file CEMemModel.h.


Member Data Documentation

sqrt( chi^2/ Npixels )

Definition at line 417 of file CEMemModel.h.

State variables.

Definition at line 408 of file CEMemModel.h.

Referenced by getAlpha(), and setAlpha().

Definition at line 409 of file CEMemModel.h.

Referenced by getBeta(), and setBeta().

Definition at line 413 of file CEMemModel.h.

Accesories.

Definition at line 440 of file CEMemModel.h.

Definition at line 433 of file CEMemModel.h.

Definition at line 403 of file CEMemModel.h.

Referenced by getCycleFlux(), and setCycleFlux().

Definition at line 388 of file CEMemModel.h.

is this an image plane problem (like Single Dish or Optical?)

Definition at line 400 of file CEMemModel.h.

Definition at line 385 of file CEMemModel.h.

numerical value of entropy

Definition at line 419 of file CEMemModel.h.

Referenced by formEntropy().

------------Private Member Data--------------------- functional form of the entropy

Definition at line 367 of file CEMemModel.h.

Referenced by entropyType(), formEntropy(), formGDG(), formGDGStep(), formGDS(), getEntropy(), letEntropyDie(), relaxMin(), setEntropy(), and testConvergence().

Definition at line 430 of file CEMemModel.h.

Referenced by getInitialNumberIterations(), and setInitialNumberIterations().

sqrt( chi^2/target_chi^2 )

Definition at line 415 of file CEMemModel.h.

Definition at line 411 of file CEMemModel.h.

gain for adding step image

Definition at line 395 of file CEMemModel.h.

Referenced by getGain(), and setGain().

matrix of gradient dot products

Definition at line 432 of file CEMemModel.h.

Referenced by formGDG(), and formGDGStep().

Definition at line 427 of file CEMemModel.h.

Definition at line 428 of file CEMemModel.h.

Referenced by formGDS().

Controlling parameters.

Definition at line 383 of file CEMemModel.h.

Definition at line 429 of file CEMemModel.h.

Referenced by numberIterations().

Definition at line 426 of file CEMemModel.h.

Definition at line 441 of file CEMemModel.h.

Definition at line 375 of file CEMemModel.h.

Referenced by getMask().

Definition at line 396 of file CEMemModel.h.

Referenced by getMaxNormGrad(), and setMaxNormGrad().

Images:

Definition at line 373 of file CEMemModel.h.

Referenced by getModel(), and setModel().

maximum pixel value in model

Definition at line 423 of file CEMemModel.h.

minimum pixel value n model

Definition at line 425 of file CEMemModel.h.

Definition at line 410 of file CEMemModel.h.

Definition at line 384 of file CEMemModel.h.

Definition at line 435 of file CEMemModel.h.

Definition at line 374 of file CEMemModel.h.

Referenced by getPrior().

Definition at line 456 of file CEMemModel.h.

Referenced by getProgress(), and setProgress().

N points per beam.

Definition at line 393 of file CEMemModel.h.

Referenced by getQ(), and setQ().

Model is constrained to be >= itsNewMin.

Definition at line 421 of file CEMemModel.h.

Referenced by relaxMin().

Definition at line 378 of file CEMemModel.h.

form of the Residual method

Definition at line 370 of file CEMemModel.h.

Definition at line 386 of file CEMemModel.h.

Our OWN internal temp images; delete these upon destruction.

Definition at line 377 of file CEMemModel.h.

Definition at line 389 of file CEMemModel.h.

Definition at line 387 of file CEMemModel.h.

Definition at line 401 of file CEMemModel.h.

Referenced by setThreshold().

Definition at line 402 of file CEMemModel.h.

Referenced by setThresholdSpeedup().

tolerance for convergence

Definition at line 391 of file CEMemModel.h.

Referenced by getTolerance(), and setTolerance().

Definition at line 412 of file CEMemModel.h.

constrain flux or not?

Definition at line 398 of file CEMemModel.h.


The documentation for this class was generated from the following file: