casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
VisModelData.h
Go to the documentation of this file.
00001 //# VisModelData.h: Calculate Model Visibilities for a buffer from model images / complist
00002 //# Copyright (C) 2011
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library 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 Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be adressed 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 //#
00027 //# $Id$
00028 #ifndef VISMODELDATA_H
00029 #define VISMODELDATA_H
00030 #include <casa/aips.h>
00031 #include <casa/Containers/Record.h>
00032 #include <casa/Containers/Block.h>
00033 #include <casa/Arrays/Cube.h>
00034 #include <synthesis/TransformMachines/ComponentFTMachine.h>
00035 namespace casa { //# NAMESPACE CASA - BEGIN
00036 //#forward
00037   class VisBuffer;
00038   class ComponentList;  
00039   class FTMachine;
00040   class MeasurementSet;
00041   template <class T> class Vector;
00042   template <class T> class CountedPtr;
00043 // <summary>
00044 // Object to provide MODEL_DATA visibilities on demand
00045 // 
00046 // </summary>
00047 
00048 // <reviewed reviewer="" date="" tests="" demos="">
00049 
00050 // <prerequisite>
00051 //  FTMachine and ComponentFTMachine
00052 //
00053 // </prerequisite>
00054 //
00055 // <etymology>
00056 
00057 
00058 // </etymology>
00059 //
00060 // <synopsis>
00061 // </synopsis>
00062 //
00063 // <example>
00064 // <srcblock>
00065 // </srcblock>
00066 // </example>
00067 //
00068 // <motivation>
00069 // </motivation>
00070 //
00071 // <todo asof="">
00072 // </todo>
00073 
00074 class VisModelData {
00075  public:
00076   //empty constructor
00077   VisModelData();
00078   //From a FTMachine Record
00079   //VisModelData(const Record& ftmachinerec, const Vector<Int>& validfieldids, const Vector<Int>& msIds);
00080   virtual ~VisModelData();
00081   //Add Image/FTMachine to generate visibilities for
00082   //void addFTMachine(const Record& recordFTMachine, const Vector<Int>& validfieldids, const Vector<Int>& msIds);
00083   //Add componentlist to generate visibilities for
00084   //void addCompFTMachine(const ComponentList& cl, const Vector<Int>& validfieldids, 
00085   //                    const Vector<Int>& msIds);
00086   //For simple model a special case for speed 
00087   
00088   void addFlatModel(const Vector<Double>& value, const Vector<Int>& validfieldids, 
00089                     const Vector<Int>& msIds);
00090 
00091   //add componentlists or ftmachines 
00092   void addModel(const Record& rec,  const Vector<Int>& msids, const VisBuffer& vb);
00093 
00094   //put the model data for this VisBuffer in the modelVisCube
00095   Bool getModelVis(VisBuffer& vb);
00096 
00097   //this is a helper function that writes the model record to the ms 
00098   static void putModel(const MeasurementSet& thems, const RecordInterface& rec, const Vector<Int>& validfields, const Vector<Int>& spws, const Vector<Int>& starts, const Vector<Int>& nchan,  const Vector<Int>& incr, Bool iscomponentlist=True, Bool incremental=False);
00099 
00100   //helper function to clear the keywordSet of the ms of the model  for the fields 
00101   //in that ms
00102   static void clearModel(const MeasurementSet& thems);
00103   // ...with field selection and optionally spw
00104   static void clearModel(const MeasurementSet& thems, const String field, const String spws=String(""));
00105 
00106   // List the fields
00107   static void listModel(const MeasurementSet& thems);
00108 
00109   static FTMachine* NEW_FT(const Record& ftrec);
00110   //check if an addFT or addCompFT is necessary
00111   //Bool hasFT(Int msid, Int fieldid);
00112   //Bool hasCL(Int msid, Int fieldid);
00113   //returns a -1 if there is no model for this combination of ms,field,spw...but has not been  // checked yet if there is one
00114   //returns a -2 if it has been tested before but does have it.
00115   //returns a 1 if it has a model stored 
00116   Int hasModel(Int msid, Int field, Int spw); 
00117  private:
00118   void initializeToVis();
00119   Vector<CountedPtr<ComponentList> >getCL(const Int msId, const Int fieldId, Int spw);
00120   Vector<CountedPtr<FTMachine> >getFT(const Int msId, const Int fieldId, Int spw);
00121   static Bool addToRec(Record& therec, const Vector<Int>& spws);
00122   static Bool removeSpwFromMachineRec(RecordInterface& ftclrec, const Vector<Int>& spws);
00123   static Bool removeFTFromRec(Record& therec, const String& keyval);
00124   static Bool removeSpw(Record& therec, const Vector<Int>& spws);
00125 
00126   Block<Vector<CountedPtr<ComponentList> > > clholder_p;
00127   Block<Vector<CountedPtr<FTMachine> > > ftholder_p;
00128   Block<Vector<Double> > flatholder_p;
00129   CountedPtr<ComponentFTMachine> cft_p;
00130   Cube<Int> ftindex_p;
00131   Cube<Int> clindex_p;
00132 
00133 };
00134 
00135 }//end namespace
00136 #endif // VISMODELDATA_H