casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ImagePolProxy.h
Go to the documentation of this file.
00001 //# ImagePolProxy.h: a casa namespace class for imagepol tool
00002 //# Copyright (C) 2007
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 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: ImagePolProxy.h 20299 2008-04-03 05:56:44Z gervandiepen $
00027 
00028 #ifndef IMAGES_IMAGEPOL_H
00029 #define IMAGES_IMAGEPOL_H
00030 
00031 #include <imageanalysis/ImageAnalysis/ImagePolarimetry.h>
00032 
00033 namespace casa {
00034 
00035 //# Forward declarations
00036 class LogIO;
00037 class String;
00038 class Record;
00039 class Normal;
00040 template<class T> class ImageInterface;
00041 
00042 // Implementation of the image polarimetry functionality
00043 // available from casapy.
00044 
00045 class ImagePol
00046 {
00047 
00048  public:
00049   // "imagepol" constructors 
00050   ImagePol();
00051   ImagePol(ImageInterface<Float>& im);
00052   virtual ~ImagePol();
00053 
00054   // Make test image
00055   Bool imagepoltestimage(const String& outFile = "imagepol.iquv",
00056                          const Vector<Double>& rm = Vector<Double>(1, 0.0),
00057                          Bool rmDefault = True,
00058                          Double pa0 = 0.0, Double sigma = 0.01,
00059                          Int nx = 32, Int ny = 32, Int nf = 32,
00060                          Double f0 = 1.4e9, Double df = 128.0e6);
00061 
00062   Bool open(ImageInterface<Float>& im);
00063   Bool open(const String& infile);
00064 
00065   // Depolarization ratio
00066   // The image containing the delpolratio is in the returnrec 
00067   // Can be recovered using ImageInterface::fromRecord
00068   Bool depolratio(ImageInterface<Float>*& rtnim, const String& infile, 
00069                   Bool debias = False,
00070                   Double clip = 10.0, Double sigma = -1, 
00071                   const String& oufile="");  
00072 
00073   //Complex linear polarization image is stored in outfile
00074   Bool complexlinpol(const String& outfile);
00075 
00076 
00077   // Summary
00078   void summary() const;
00079 
00080   // sigma
00081   Float sigma(Float clip = 10.0) const;
00082 
00083   // Stokes I
00084   Bool stokesI(ImageInterface<Float>*& rtnim, const String& outfile="");
00085   Float sigmaStokesI(Float clip = 10.0) const;
00086 
00087   // Stokes Q
00088   Bool stokesQ(ImageInterface<Float>*& rtnim, const String& outfile="");
00089   Float sigmaStokesQ(Float clip = 10.0) const;
00090 
00091   // Stokes U
00092   Bool stokesU(ImageInterface<Float>*& rtnim, const String& outfile="");
00093   Float sigmaStokesU(Float clip = 10.0) const;
00094 
00095   // Stokes V
00096   Bool stokesV(ImageInterface<Float>*& rtnim, const String& outfile="");
00097   Float sigmaStokesV(Float clip = 10.0) const;
00098 
00099   // Linearly polarized intensity
00100   Bool linPolInt(ImageInterface<Float>*& rtnim, Bool debias = False,
00101                  Float clip = 10.0,
00102                  Float sigma = -1, const String& outfile = "");
00103   Float sigmaLinPolInt(Float clip = 10.0, Float sigma = -1) const;
00104 
00105   // Total polarized intensity.
00106   Bool totPolInt(ImageInterface<Float>*& rtnim, Bool debias = False,
00107                  Float clip = 10.0,
00108                  Float sigma = -1, const String& outfile = "");
00109   Float sigmaTotPolInt(Float clip = 10.0, Float sigma = -1) const;
00110 
00111   // Complex linear polarization
00112   void complexLinearPolarization (const String& outfile);
00113 
00114   // Complex linear polarization
00115   void complexFractionalLinearPolarization (const String& outfile);
00116 
00117   // Linearly polarized position angle
00118   Bool linPolPosAng(ImageInterface<Float>*& rtnim,
00119                     const String& outfile = "");
00120   Bool sigmaLinPolPosAng(ImageInterface<Float>*& rtnim, Float clip = 10.0,
00121                          Float sigma = -1, const String& outfile = "");
00122 
00123   // Fractional linearly polarized intensity
00124   Bool fracLinPol(ImageInterface<Float>*& rtnim, Bool debias = False,
00125                   Float clip = 10.0,
00126                   Float sigma = -1, const String& outfile = "");
00127   Bool sigmaFracLinPol(ImageInterface<Float>*& rtnim, Float clip = 10.0,
00128                        Float sigma = -1, const String& outfile = "");
00129 
00130   // Fractional total polarized intensity
00131   Bool fracTotPol(ImageInterface<Float>*& rtnim, Bool debias = False,
00132                   Float clip = 10.0,
00133                   Float sigma = -1, const String& outfile = "");
00134   Bool sigmaFracTotPol(ImageInterface<Float>*& rtnim, Float clip = 10.0,
00135                        Float sigma = -1, const String& outfile = "");
00136 
00137   // Depolarization ratio
00138   Bool depolarizationRatio (ImageInterface<Float>*& rtnim, 
00139                             const String& infile,
00140                             Bool debias = False, Float clip = 10.0,
00141                             Float sigma = -1, const String& outfile = "");
00142   Bool sigmaDepolarizationRatio (ImageInterface<Float>*& rtnim,
00143                                  const String& infile,
00144                                  Bool debias = False, Float clip = 10.0,
00145                                  Float sigma = -1, const String& outfile = "");
00146 
00147   // Find Rotation Measure from Fourier method
00148   void fourierRotationMeasure(const String& outfile = "",
00149                               const String& outfileAmp = "",
00150                               const String& outfilePA = "",
00151                               const String& outfileReal = "",
00152                               const String& outfileImag = "",
00153                               Bool zeroZeroLag = False);
00154 
00155   // Find Rotation Measure from traditional method
00156   void rotationMeasure(const String& outRM = "", const String& outRMErr = "",
00157                        const String& outPA0 = "", const String& outPA0Err = "",
00158                        const String& outNTurns = "",
00159                        const String& outChiSq = "",
00160                        Int axis = -1, Float varQU = -1, Float rmFg = 0.0,
00161                        Float rmMax = 0.0, Float maxPaErr = 1e30,
00162                        const String& plotter = "",
00163                        Int nx = 5, Int ny = 5);
00164 
00165   // Make a complex image
00166   void makeComplex (const String& complex, const String& real = "",
00167                     const String& imag = "", const String& amp = "",
00168                     const String& phase = "");
00169 
00170  private:
00171   LogIO *itsLog;
00172   ImagePolarimetry *itsImPol;
00173   
00174   Bool copyImage(ImageInterface<Float>*& out, const ImageInterface<Float>&in, 
00175             const String& outfile="", Bool overwrite=true);
00176   // Copy miscellaneous (MiscInfo, ImageInfo, history, units)
00177   void copyMiscellaneous (ImageInterface<Complex>& out,
00178                           const ImageInterface<Float>& in);
00179   void copyMiscellaneous (ImageInterface<Float>& out,
00180                          const ImageInterface<Float>& in);
00181   void fiddleStokesCoordinate(ImageInterface<Float>& ie,
00182                               Stokes::StokesTypes type);
00183   void fiddleStokesCoordinate(ImageInterface<Complex>& ie,
00184                               Stokes::StokesTypes type);
00185   // Make a PagedImage or TempImage output
00186   Bool makeImage (ImageInterface<Complex>*& out, 
00187                   const String& outfile, const CoordinateSystem& cSys,
00188                   const IPosition& shape, Bool isMasked=False,
00189                   Bool tempAllowed=True);
00190   Bool makeImage (ImageInterface<Float>*& out, 
00191                   const String& outfile, const CoordinateSystem& cSys,
00192                   const IPosition& shape, Bool isMasked=False,
00193                   Bool tempAllowed=True);
00194   // Make an IQUV image with some dummy RM data
00195   Bool  makeIQUVImage (ImageInterface<Float>*& pImOut, const String& outfile, 
00196                        Double sigma, 
00197                        Double pa0, const Vector<Float>& rm, 
00198                        const IPosition& shape,
00199                        Double f0, Double dF);
00200   // Fill IQUV image with Stokes values from RM data
00201   Bool fillIQUV (ImageInterface<Float>& im, uInt stokesAxis,
00202                  uInt spectralAxis, const Vector<Float>& rm, 
00203                  Float pa0);
00204   // Add noise to Array
00205   void addNoise (Array<Float>& slice, Normal& noiseGen);
00206   // Centre reference pixelin image
00207   void centreRefPix (CoordinateSystem& cSys, const IPosition& shape);
00208   // Make and define a mask
00209   Bool makeMask(ImageInterface<Float>& out, Bool init=False);
00210   Bool makeMask(ImageInterface<Complex>& out, Bool init=False);
00211   // What Stokes type?  Exception if more than one.
00212   Stokes::StokesTypes stokesType(const CoordinateSystem& cSys);
00213 
00214 
00215 };
00216 
00217 } // casa namespace
00218 
00219 #endif