casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ComponentUpdate.h
Go to the documentation of this file.
00001 //# ComponentUpdate.h: This class updates components in UV plane
00002 //# Copyright (C) 2000,2004
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This program is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU General Public License as published by the Free
00007 //# Software Foundation; either version 2 of the License, or (at your option)
00008 //# any later version.
00009 //#
00010 //# This program is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00013 //# more details.
00014 //#
00015 //# You should have received a copy of the GNU General Public License along
00016 //# with this program; if not, write to the Free Software Foundation, Inc.,
00017 //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: ComponentUpdate.h 18093 2004-11-30 17:51:10Z ddebonis $
00027 
00028 #ifndef IMAGES_COMPONENTUPDATE_H
00029 #define IMAGES_COMPONENTUPDATE_H
00030 
00031 //# Includes
00032 
00033 #include <casa/aips.h>
00034 #include <scimath/Fitting/LSQaips.h>
00035 #include <casa/Containers/Block.h>
00036 #include <components/ComponentModels/ComponentList.h>
00037 #include <casa/BasicSL/Complexfwd.h>
00038 
00039 namespace casa { //# NAMESPACE CASA - BEGIN
00040 
00041 //# Forward declarations
00042 template <class T> class Array;
00043 template <class T> class Vector;
00044 template <class T> class Matrix;
00045 
00046 // <summary> This class updates components in UV plane </summary>
00047 
00048 // <use visibility=export>
00049 
00050 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00051 // </reviewed>
00052 
00053 // <prerequisite>
00054 //   <li> <linkto module=ComponentModels>ComponentModels</linkto> module
00055 // </prerequisite>
00056 
00057 // <etymology>
00058 // Component and Update
00059 // </etymology>
00060 
00061 // <synopsis>
00062 // This class is an update machine for model components. The updating is
00063 // done using UV-plane information (and, of course, already available 
00064 // calibration information). In principle all the elements of a
00065 // component can be updated (like polarisation flux, position, etc),
00066 // but certain combinations are more useful (and orthogonal enough) to
00067 // be of practical use.
00068 //
00069 // The update process works by comparing the theoretical UV-plane
00070 // expectations of a model component, with the actual UV-plane data,
00071 // and solve, in the least-squares sense) for the component data
00072 // elements. In practice the full nodel sky, as known, is subtracted
00073 // from the observed data, after which the solution for for differnces
00074 // is done. This solution can proceed in a variety of ways:
00075 // <ul>
00076 // <li> for all model components to be solved for in one solution. In
00077 // this case the dependences between the different source components
00078 // are taken properly into account, but the number of simultaneously
00079 // to be solved unknowns can be very large.
00080 // <li> solve for all model components separately, as if they were the
00081 // only one producing UV-plane output. In practice this would cause
00082 // dependencies between sources (e.g. if two components have (almost)
00083 // the same position, they will both be adjusted e.g, in flux as if
00084 // they were the only one, resulting in a twice too high
00085 // adjustment. By using an (estimate of the) synthesised beam, this
00086 // can be adjusted
00087 // <li> a combination of the above two. If components are close
00088 // together, they will be combined as one source to be solved for,
00089 // otherwise they will be treated separately.
00090 // </ul>
00091 // Non-component sky models (like images) could be adjusted for their
00092 // overall parameters (integrated flux, position) as well. This could
00093 // be added at a later stage.
00094 //
00095 // Not all of the different possibilities and adjustable parameters
00096 // will be implemented initially.
00097 // </synopsis>
00098 
00099 
00100 // <motivation>
00101 // To provide an accurate way to adjust model component parameters
00102 // from the observed data, using all the available data. 
00103 // </motivation>
00104 
00105 // <todo asof="2000/07/13">
00106 //  <li>
00107 // </todo>
00108 
00109 class ComponentUpdate {
00110   // The different solution types
00111   enum Type {
00112     // Sove each source individually
00113     SEPARATE=0,
00114     // Slove in one solution
00115     COMBINED,
00116     // Solve in clusters of sources
00117     CLUSTER,
00118     // Number of options
00119     N_Type
00120   };
00121   // The different solvable parameters
00122   enum Solve {
00123     // Solve for I and l,m
00124     ILM=0,
00125     // Number of solvable parameters
00126     N_Solve
00127   };
00128     
00129 public:
00130   //# Standard constructors/destructors
00131   // Default constructor --  update not possible without one or more
00132   // set() methods.
00133   ComponentUpdate();
00134   // Construct an update machine for the sources in the given
00135   // ComponentList, using the 'separate' type of solution, and ILM
00136   // solve. Note that the component list must be a writable one to
00137   // receive the updates.
00138   explicit ComponentUpdate(const ComponentList &model);
00139   // Construct an update machine for the sources in the given
00140   // ComponentList, using the specified sovables and the separate type.
00141   ComponentUpdate(const ComponentList &model,
00142                   const ComponentUpdate::Solve solve);
00143   // Construct an update machine for the sources in the given
00144   // ComponentList, using the specified type of solution and solvables
00145   ComponentUpdate(const ComponentList &model,
00146                   const ComponentUpdate::Solve solve,
00147                   const ComponentUpdate::Type tp);
00148   // Destructor
00149   ~ComponentUpdate();
00150   // Create the solution equations. For each series of UV points,
00151   // provide the following information to the engine (we can speed it
00152   // up later by having raw rather than Array type interface). Needed:
00153   // <ul> <li> data: a vector(=data) of length equal to the number of
00154   // UV points provided in one go (nuv) representing the observed
00155   // residual data
00156   // <li> A Cube with dimensions (3, nsource, nuv) (the 3 for the ILM
00157   // case, but different for other solutions). nsource is the number
00158   // of sources, and the 3 are the coefficients of the derivatives (in
00159   // the default case the values provided should be X, 2pi.U.i.X and
00160   // 2pi.V.i.X (i == sqrt(-1); X == the calculated UV plane value for
00161   // the source model component). In this we solve dI/I, dl and dm. 
00162   // Order of indices is determined by VectorIterator...
00163   // </ul>
00164   // Extra arguments possible: data weight.<br>
00165   // Extra calls: Just provide list of data (and weight) and UVW
00166   // coordinates. Calls to some Skymodel.visibility() and/or
00167   // .derivative() would then suffice. <br>
00168   // Improvements, by providing telescope rather than baseline based
00169   // data; proper care taken analytically of integration over time and
00170   // frequency.
00171   // <group>
00172   void makeEquations(const Array<DComplex> &deriv,
00173                      const Vector<DComplex> &data);
00174   // </group>
00175   // Provide the solution (i.e. dI/I and dl, dm) with errors (standard
00176   // deviation of solution). The Matrices filled (and resized) are of
00177   // sizes 3,nsource.
00178   Bool solve(Matrix<Double> &sol, Matrix<Double> &err);
00179 private:
00180   //# Data
00181   // List of number of unknowns for solvables
00182   static const Int N_unknown[N_Solve];
00183   // Type of solution
00184   ComponentUpdate::Type soltp_p;
00185   // Solvable parameters
00186   ComponentUpdate::Solve solve_p;
00187   // Number of sources to fit
00188   Int nmodel_p;
00189   // Work area for expression data
00190   Double *dt_p;
00191   // Component list to solve (note: a pointer to it)
00192   ComponentList complist_p;
00193   // List of solution fitting areas
00194   PtrBlock<LSQaips *> fit_p;
00195   //# Standard constructors/destructors
00196   // Copy constructor (not implemented)
00197   ComponentUpdate(const ComponentUpdate &other);
00198   // Assignment (not implemented)
00199   ComponentUpdate &operator=(const ComponentUpdate &other);
00200   //# Member functions
00201   // Initialise the list of fitting areas
00202   void init();
00203   // Empty the list of fitting areas
00204   void clean();
00205 };
00206 
00207 
00208 } //# NAMESPACE CASA - END
00209 
00210 #endif