casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MultiTermFTNew.h
Go to the documentation of this file.
1 //# NewMultiTermFT.h: Definition for NewMultiTermFT
2 //# Copyright (C) 1996,1997,1998,1999,2000,2002
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be adressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //#
27 //# $Id$
28 
29 #ifndef SYNTHESIS_TRANSFORM2_MULTITERMFTNEW_H
30 #define SYNTHESIS_TRANSFORM2_MULTITERMFTNEW_H
31 
33 #include <casa/Arrays/Matrix.h>
35 #include <msvis/MSVis/VisBuffer2.h>
38 #include <casa/Containers/Block.h>
39 #include <casa/Arrays/Array.h>
40 #include <casa/Arrays/Vector.h>
41 #include <casa/Arrays/Matrix.h>
45 //#include <synthesis/MeasurementComponents/SynthesisPeek.h>
46 #include <casa/OS/Timer.h>
47 
48 namespace casacore{
49 
50 class UVWMachine;
51 }
52 
53 namespace casa { //# NAMESPACE CASA - BEGIN
54 
55 namespace vi{
56  class VisibilityIterator2;
57  }
58 
59 namespace refim { //# namespace refactor imaginging
60 class MultiTermFTNew : public FTMachine {
61 public:
62 
63  // Construct using an existing FT-Machine
65 
66  // Construct from a casacore::Record containing the MultiTermFTNew state
68 
69  // Copy constructor.
70  // This first calls the default "=" operator, and then instantiates objects for member pointers.
71  MultiTermFTNew(const MultiTermFTNew &other);
72 
73  // Assignment operator --- leave it as the default
75 
76  // Destructor
78 
79  // Called at the start of de-gridding : subftm->initializeToVis()
80  // Note : Pre-de-gridding model-image divisions by PBs will go here.
81 
83  const vi::VisBuffer2& /*vb*/){throw(casacore::AipsError("not implemented"));};
84  // Vectorized InitializeToVis
85  // void initializeToVis(casacore::Block<casacore::CountedPtr<casacore::ImageInterface<casacore::Complex> > > & compImageVec,casacore::PtrBlock<casacore::SubImage<casacore::Float> *> & modelImageVec, casacore::PtrBlock<casacore::SubImage<casacore::Float> *>& weightImageVec, casacore::PtrBlock<casacore::SubImage<casacore::Float> *>& fluxScaleVec, casacore::Block<casacore::Matrix<casacore::Float> >& weightsVec, const VisBuffer& vb);
86 
87  virtual void initializeToVisNew(const vi::VisBuffer2& vb,
89 
90  // Called at the end of de-gridding : subftm->finalizeToVis()
91  void finalizeToVis();
92 
93  // Called at the start of gridding : subftm->initializeToSky()
95  casacore::Matrix<casacore::Float>& /*weight*/, const vi::VisBuffer2& /*vb*/){throw(casacore::AipsError("not implemented"));};
96  // void initializeToSky(casacore::Block<casacore::CountedPtr<casacore::ImageInterface<casacore::Complex> > > & compImageVec, casacore::Block<casacore::Matrix<casacore::Float> >& weightsVec, const VisBuffer& vb, const casacore::Bool dopsf);
97 
98  virtual void initializeToSkyNew(const casacore::Bool dopsf,
99  const vi::VisBuffer2& vb,
101 
103  // Called at the end of gridding : subftm->finalizeToSky()
104  void finalizeToSky(){throw(casacore::AipsError("MultiTermFTNew::finalizeToSky() called without arguments!"));};
105 
106  //void finalizeToSky(casacore::Block<casacore::CountedPtr<casacore::ImageInterface<casacore::Complex> > > & compImageVec, casacore::PtrBlock<casacore::SubImage<casacore::Float> *> & resImageVec, casacore::PtrBlock<casacore::SubImage<casacore::Float> *>& weightImageVec, casacore::PtrBlock<casacore::SubImage<casacore::Float> *>& fluxScaleVec, casacore::Bool dopsf, casacore::Block<casacore::Matrix<casacore::Float> >& weightsVec, const VisBuffer& vb);
107 
108  virtual void finalizeToSkyNew(casacore::Bool dopsf,
109  const vi::VisBuffer2& vb,
111 
112  // void normalizeToSky(casacore::ImageInterface<casacore::Complex>& compImage, casacore::ImageInterface<casacore::Float>& resImage, casacore::ImageInterface<casacore::Float>& weightImage, casacore::Bool dopsf, casacore::Matrix<casacore::Float>& weights)
113  // {throw(casacore::AipsError("MultiTermFTNew::normalizeToSky should not get called !"));};
114 
115 
116  // Do the degridding via subftm->get() and modify model-visibilities by Taylor-weights
117  void get(vi::VisBuffer2& vb, casacore::Int row=-1);
118  // Modify imaging weights with Taylor-weights and do gridding via subftm->put()
119  void put(vi::VisBuffer2& vb, casacore::Int row=-1, casacore::Bool dopsf=false,
121  // Have a const version for compatibility with other FTMs.. Throw an exception if called.
122  void put(const vi::VisBuffer2& /*vb*/, casacore::Int /*row=-1*/, casacore::Bool /*dopsf=false*/,
123  refim::FTMachine::Type /*type=FTMachine::OBSERVED*/)
124  {throw(casacore::AipsError("Internal error: called MultiTermFTNew::put(const VB2)"));};
125  // Calculate residual visibilities if possible.
126  // The purpose is to allow rGridFT to make this multi-threaded
127  virtual void ComputeResiduals(vi::VisBuffer2& vb, casacore::Bool useCorrected);
128 
129  // Make an image : subftm->makeImage()
140  // Get the final image: do the Fourier transform grid-correct, then
141  // optionally normalize by the summed weights
142  // Note : Post-gridding residual-image divisions by PBs will go here.
143  // For now, it just calls subftm->getImage()
144  // casacore::ImageInterface<casacore::Complex>& getImage(casacore::Matrix<casacore::Float>& weights, casacore::Bool normalize=true)
145  //{return getImage(weights,normalize,0);};
146  //casacore::ImageInterface<casacore::Complex>& getImage(casacore::Matrix<casacore::Float>& weights, casacore::Bool normalize=true,
147  // const casacore::Int taylorindex=0);
149  {throw(casacore::AipsError("MultiTermFTNew::getImage() should not be called"));}
150 
152  {AlwaysAssert(subftms_p.nelements()>0,casacore::AipsError); return subftms_p[0]->useWeightImage(); };
153 
155  {AlwaysAssert(subftms_p.nelements()>0,casacore::AipsError);
156  subftms_p[0]->getWeightImage(weightImage, weights);}
157  // {throw(casacore::AipsError("MultiTermFTNew::getWeightImage() should not be called"));}
158 
159  // Save and restore the MultiTermFTNew to and from a record
160  virtual casacore::Bool toRecord(casacore::String& error, casacore::RecordInterface& outRec, casacore::Bool withImage=false,
161  const casacore::String diskimage="");
163 
164  // Various small inline functions
165  virtual casacore::Bool isFourier() {return true;}
166  virtual void setNoPadding(casacore::Bool nopad){subftms_p[0]->setNoPadding(nopad);};
167  virtual casacore::String name()const {return machineName_p;};
168  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
169 
171  {
172  cout << "** Number of FTs : " << subftms_p.nelements() << " -- " ;
173  for(casacore::uInt tix=0; tix<(subftms_p).nelements(); tix++)
174  cout << tix << " : " << (subftms_p[tix])->name() << " " ;
175  cout << endl;
176  };
177 
178  FTMachine* cloneFTM();
179  virtual void setDryRun(casacore::Bool val)
180  {
181  isDryRun=val;
182  //cerr << "MTFTMN: " << isDryRun << endl;
183  for (casacore::uInt i=0;i<subftms_p.nelements();i++)
184  subftms_p[i]->setDryRun(val);
185  };
186  virtual casacore::Bool isUsingCFCache() {casacore::Bool v=false; if (subftms_p.nelements() > 0) v=subftms_p[0]->isUsingCFCache(); return v;};
188  virtual void setCFCache(casacore::CountedPtr<CFCache>& cfc, const casacore::Bool resetCFC=true);
189 
190 
192 
193  virtual casacore::Int nTerms(){ return nterms_p;};
194  virtual casacore::Int psfNTerms(){ return psfnterms_p;};
195 
196  // set a moving source aka planets or comets => adjust phase center
197  // on the fly for gridding
198  virtual void setMovingSource(const casacore::String& sourcename, const casacore::String& ephemtable="");
199  virtual void setMovingSource(const casacore::MDirection& mdir);
200  // set and get the location used for frame
201  virtual void setLocation(const casacore::MPosition& loc);
204 protected:
205  // have to call the initmaps of subftm
206  virtual void initMaps(const vi::VisBuffer2& vb);
207  // Instantiate a new sub FTM
209 
210  // Multiply Imaging weights by Taylor-function weights - during "put"
212  // Multiply model visibilities by Taylor-function weights - during "get"
214  // Restore vb.imagingweights to the original
216 
217  // Helper function to write ImageInterfaces to disk
219 
220 
222 
228 
229  // casacore::Bool donePSF_p;
230 
232 
233 };
234 
235 } //end namespace refim
236 } //# NAMESPACE CASA - END
237 
238 #endif
void finalizeToSky()
Called at the end of gridding : subftm-&gt;finalizeToSky()
A Measure: astronomical direction.
Definition: MDirection.h:174
A 1-D Specialization of the Array class.
A Measure: position on Earth.
Definition: MPosition.h:79
casacore::String machineName_p
int Int
Definition: aipstype.h:50
virtual void initBriggsWeightor(vi::VisibilityIterator2 &vi)
This function has to be called after initMaps to initialize Briggs Cube weighting scheme ...
virtual const casacore::CountedPtr< refim::FTMachine > & getFTM2(const casacore::Bool)
virtual casacore::Bool fromRecord(casacore::String &error, const casacore::RecordInterface &inRec)
virtual casacore::Long estimateRAM(const casacore::CountedPtr< SIImageStore > &imstore)
estimate of memory necessary in kB
defines interface for the Fourier Transform Machine
Definition: FTMachine.h:122
void put(const vi::VisBuffer2 &, casacore::Int, casacore::Bool, refim::FTMachine::Type)
Have a const version for compatibility with other FTMs.
VisibilityIterator2 iterates through one or more readonly MeasurementSets.
virtual void initMaps(const vi::VisBuffer2 &vb)
have to call the initmaps of subftm
virtual void initializeToVisNew(const vi::VisBuffer2 &vb, casacore::CountedPtr< SIImageStore > imstore)
Vectorized InitializeToVis void initializeToVis(casacore::Block&lt;casacore::CountedPtr&lt;casacore::ImageI...
virtual Type type()
Return the type enum.
casacore::Matrix< casacore::Float > imweights_p
virtual casacore::Bool isUsingCFCache()
void initializeToSky(casacore::ImageInterface< casacore::Complex > &, casacore::Matrix< casacore::Float > &, const vi::VisBuffer2 &)
Called at the start of gridding : subftm-&gt;initializeToSky()
virtual void finalizeToSkyNew(casacore::Bool dopsf, const vi::VisBuffer2 &vb, casacore::CountedPtr< SIImageStore > imstore)
void finalizeToSky(casacore::Block&lt;casacore::CountedPtr&lt;casacore::ImageInterface&lt;casacore::Complex&gt; &gt;...
virtual casacore::Bool useWeightImage()
All FTMachines that fill weightimage, need to set this.
virtual casacore::Bool isFourier()
Various small inline functions.
casacore::Bool modifyVisWeights(vi::VisBuffer2 &vb, casacore::uInt thisterm)
Multiply Imaging weights by Taylor-function weights - during &quot;put&quot;.
void put(vi::VisBuffer2 &vb, casacore::Int row=-1, casacore::Bool dopsf=false, refim::FTMachine::Type type=refim::FTMachine::OBSERVED)
Modify imaging weights with Taylor-weights and do gridding via subftm-&gt;put()
casacore::CountedPtr< FTMachine > getNewFTM(const casacore::CountedPtr< FTMachine > &ftm)
Instantiate a new sub FTM.
virtual void setMovingSource(const casacore::String &sourcename, const casacore::String &ephemtable="")
set a moving source aka planets or comets =&gt; adjust phase center on the fly for gridding ...
long Long
Definition: aipstype.h:52
void finalizeToVis()
Called at the end of de-gridding : subftm-&gt;finalizeToVis()
virtual casacore::Int nTerms()
return number of terms
void makeImage(refim::FTMachine::Type type, vi::VisibilityIterator2 &vs, casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight)
Make an image : subftm-&gt;makeImage()
MultiTermFTNew & operator=(const MultiTermFTNew &other)
Assignment operator — leave it as the default.
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
Make the multi term images void makeMTImages(refim::FTMachine::Type type, vi::VisibilityIterator2 &vi, casacore::Vector< casacore::CountedPtr< casacore::ImageInterface< casacore::Complex > > > &image, casacore::Vector< casacore::CountedPtr< casacore::Matrix< casacore::Float > > > &weight)
virtual casacore::Bool toRecord(casacore::String &error, casacore::RecordInterface &outRec, casacore::Bool withImage=false, const casacore::String diskimage="")
{throw(casacore::AipsError(&quot;MultiTermFTNew::getWeightImage() should not be called&quot;));} ...
void getWeightImage(casacore::ImageInterface< casacore::Float > &weightImage, casacore::Matrix< casacore::Float > &weights)
Get the final weights image.
double Double
Definition: aipstype.h:55
virtual void setMiscInfo(const casacore::Int qualifier)
set the order of the Taylor term for MFS this is to tell A-casacore::Projection to qualify the accumu...
New MTFT specific internal parameters and functions *casacore::uInt psfnterms_p
casacore::Bool modifyModelVis(vi::VisBuffer2 &vb, casacore::uInt thisterm)
Multiply model visibilities by Taylor-function weights - during &quot;get&quot;.
void initializeToVis(casacore::ImageInterface< casacore::Complex > &, const vi::VisBuffer2 &)
Called at the start of de-gridding : subftm-&gt;initializeToVis() Note : Pre-de-gridding model-image div...
LatticeExprNode nelements(const LatticeExprNode &expr)
1-argument function to get the number of elements in a lattice.
casacore::ImageInterface< casacore::Complex > & getImage(casacore::Matrix< casacore::Float > &, casacore::Bool=true)
Get the final image: do the Fourier transform grid-correct, then optionally normalize by the summed w...
Type
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:127
Converts UVW coordinates between coordinate systems.
Definition: UVWMachine.h:160
New MTFT specific internal parameters and functions *casacore::uInt nterms_p
#define AlwaysAssert(expr, exception)
These marcos are provided for use instead of simply using the constructors of assert_ to allow additi...
Definition: Assert.h:157
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
FTMachine * cloneFTM()
clone copy should make it pure virtual forcing every ftm to have a cloner
virtual void setCFCache(casacore::CountedPtr< CFCache > &cfc, const casacore::Bool resetCFC=true)
casacore::Cube< casacore::Complex > modviscube_p
simple 1-D array
MultiTermFTNew(casacore::CountedPtr< FTMachine > &subftm, casacore::Int nterms=1, casacore::Bool forward=false)
Construct using an existing FT-Machine.
virtual void setNoPadding(casacore::Bool nopad)
To make sure no padding is used in certain gridders.
virtual void setDryRun(casacore::Bool val)
virtual void setLocation(const casacore::MPosition &loc)
set and get the location used for frame
VisBuffer2s encapsulate one chunk of visibility data for processing.
Definition: VisBuffer2.h:141
void restoreImagingWeights(vi::VisBuffer2 &vb)
Restore vb.imagingweights to the original.
Base class for all Casacore library errors.
Definition: Error.h:134
virtual casacore::String name() const
Return the name of the machine.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Bool isDryRun
Definition: FTMachine.h:368
Abstract base class for Record classes.
virtual casacore::Int psfNTerms()
virtual void ComputeResiduals(vi::VisBuffer2 &vb, casacore::Bool useCorrected)
Calculate residual visibilities if possible.
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:395
casacore::Bool storeAsImg(casacore::String fileName, casacore::ImageInterface< casacore::Float > &theImg)
Helper function to write ImageInterfaces to disk.
unsigned int uInt
Definition: aipstype.h:51
casacore::Block< casacore::CountedPtr< FTMachine > > subftms_p
casacore::Bool donePSF_p;
virtual void initializeToSkyNew(const casacore::Bool dopsf, const vi::VisBuffer2 &vb, casacore::CountedPtr< SIImageStore > imstore)
void initializeToSky(casacore::Block&lt;casacore::CountedPtr&lt;casacore::ImageInterface&lt;casacore::Complex&gt;...
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42