casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ALMAAperture.h
Go to the documentation of this file.
00001 //# ALMAAperture.h: Definition of the ALMAAperture class
00002 //# Copyright (C) 1997,1998,1999,2000,2001,2002,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //# Copyright (C) 2011 by ESO (in the framework of the ALMA collaboration)
00005 //#
00006 //# This library is free software; you can redistribute it and/or modify it
00007 //# under the terms of the GNU Library General Public License as published by
00008 //# the Free Software Foundation; either version 2 of the License, or (at your
00009 //# option) any later version.
00010 //#
00011 //# This library is distributed in the hope that it will be useful, but WITHOUT
00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 //# License for more details.
00015 //#
00016 //# You should have received a copy of the GNU Library General Public License
00017 //# along with this library; if not, write to the Free Software Foundation,
00018 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00019 //#
00020 //# Correspondence concerning AIPS++ should be addressed as follows:
00021 //#        Internet email: aips2-request@nrao.edu.
00022 //#        Postal address: AIPS++ Project Office
00023 //#                        National Radio Astronomy Observatory
00024 //#                        520 Edgemont Road
00025 //#                        Charlottesville, VA 22903-2475 USA
00026 //#
00027 //# $Id$
00028 //
00029 #ifndef SYNTHESIS_ALMAAPERTURE_H
00030 #define SYNTHESIS_ALMAAPERTURE_H
00031 
00032 #include <images/Images/PagedImage.h>
00033 #include <synthesis/TransformMachines/AzElAperture.h>
00034 #include <coordinates/Coordinates/CoordinateSystem.h>
00035 #include <imageanalysis/ImageAnalysis/AntennaResponses.h>
00036 #include <imageanalysis/ImageAnalysis/ImageConvolver.h>
00037 #include <imageanalysis/ImageAnalysis/ImageFFT.h>
00038 #include <images/Images/ImageRegrid.h>
00039 #include <images/Images/ImageRegrid.h>
00040 
00041 //
00042 //---------------------------------------------------------------------
00043 //---------------------------------------------------------------------
00044 // TEMPS The following #defines should REALLY GO!
00045 //---------------------------------------------------------------------
00046 //---------------------------------------------------------------------
00047 //
00048 #define CONVSIZE (1024*2)
00049 #define CONVWTSIZEFACTOR sqrt(2.0)
00050 #define OVERSAMPLING 10
00051 #define THRESHOLD 1E-3
00052 
00053 namespace casa { //# NAMESPACE CASA - BEGIN
00054   template<class T> class ImageInterface;
00055   template<class T> class Matrix;
00056   class VisBuffer;
00057 
00058   enum ALMAAntennaType {
00059     ALMA_INVALID = 0,
00060     ALMA_DA = 1,
00061     ALMA_DV,
00062     ALMA_CM,
00063     ALMA_PM,
00064     ALMA_numAntTypes
00065   };
00066 
00067   //  class ALMAAperture : public ATerm
00068   class ALMAAperture : public AzElAperture
00069   {
00070   public:
00071     ALMAAperture();
00072 
00073     ~ALMAAperture();
00074 
00075     ALMAAperture& operator=(const ALMAAperture& other);
00076     //
00077     // Overload these functions.  They are pure virtual in the base class (ATerm).
00078     //
00079     virtual String name() {return String("ALMA Aperture");};
00080 
00081     virtual void applySky(ImageInterface<Float>& outputImage,
00082                           const VisBuffer& vb, 
00083                           const Bool doSquint=True,
00084                           const Int& cfKey=0){
00085       applySky(outputImage, vb, doSquint, cfKey, False);};
00086     virtual void applySky(ImageInterface<Complex>& outputImage,
00087                           const VisBuffer& vb, 
00088                           const Bool doSquint=True,
00089                           const Int& cfKey=0){
00090       applySky(outputImage, vb, doSquint, cfKey, False);};
00091 
00092     void applySky(ImageInterface<Float>& outputImage,
00093                   const VisBuffer& vb, 
00094                   const Bool doSquint,
00095                   const Int& cfKey,
00096                   const Bool raytrace); // if True, use raytracing even if canned responses exist
00097     void applySky(ImageInterface<Complex>& outputImage,
00098                   const VisBuffer& vb, 
00099                   const Bool doSquint,
00100                   const Int& cfKey,
00101                   const Bool raytrace); // if True, use raytracing even if canned responses exist
00102 
00103     virtual Vector<Int> vbRow2CFKeyMap(const VisBuffer& vb, Int& nUnique);
00104 
00105     virtual void setPolMap(const Vector<Int>& polMap) {polMap_p.resize(0);polMap_p=polMap;};
00106     virtual void getPolMap(Vector<Int>& polMap) {polMap.resize(0);polMap=polMap_p;};
00107     virtual Int getConvSize() {return CONVSIZE;};
00108     virtual Int getOversampling() {return OVERSAMPLING;}
00109     virtual Float getConvWeightSizeFactor() {return CONVWTSIZEFACTOR;};
00110     virtual Float getSupportThreshold() {return THRESHOLD;};
00111 
00112     // tell the antenna type number for each antenna in the antenna table
00113     Vector<ALMAAntennaType> antTypeMap(const VisBuffer& vb);
00114 
00115     // call this before reusing the same ALMAAperture object on a different MS
00116     void resetAntTypeMap(){antTypeMap_p.resize(0);};
00117 
00118     // derive type number from first two characters in antenna name, 
00119     // return -1 if not recognised 
00120     static ALMAAntennaType antTypeFromName(const String& name);
00121     static String antTypeStrFromType(const ALMAAntennaType& aType);
00122 
00123     static Int cFKeyFromAntennaTypes(const ALMAAntennaType aT1, const ALMAAntennaType aT2);
00124     static Vector<ALMAAntennaType> antennaTypesFromCFKey(const Int& cFKey);
00125 
00126     // generate the lists of antenna types for the whole vb
00127     Vector<ALMAAntennaType> antTypeList(const VisBuffer& vb);
00128 
00129     Int getVisParams(const VisBuffer& vb, const CoordinateSystem& skyCoord=CoordinateSystem());
00130     Int makePBPolnCoords(const VisBuffer&vb,
00131                          const Int& convSize,
00132                          const Int& convSampling,
00133                          const CoordinateSystem& skyCoord,
00134                          const Int& skyNx, const Int& skyNy,
00135                          CoordinateSystem& feedCoord);
00136 
00137     void destroyAntResp(){ delete aR_p; aR_p=0;};
00138 
00139 
00140   private:
00141     static AntennaResponses* aR_p; // shared between all instances of this class
00142     static Bool orderMattersInCFKey;
00143     Vector<Int> polMap_p;
00144     Bool haveCannedResponses_p; // true if there are precalculated response images available
00145     Vector<ALMAAntennaType> antTypeMap_p; // maps antenna id to antenna type
00146     Vector<PagedImage<Complex>* > respImage_p;
00147   };
00148 };
00149 #endif