GaussianConvert.h

Go to the documentation of this file.
00001 //# GaussianConvert.h: Class to convert units of Gaussians from pixel to world 
00002 //# Copyright (C) 1997,1998,1999,2000
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$
00027 
00028 #ifndef COORDINATES_GAUSSIANCONVERT_H
00029 #define COORDINATES_GAUSSIANCONVERT_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/Arrays/Vector.h>
00034 #include <casacore/coordinates/Coordinates/CoordinateSystem.h>
00035 
00036 
00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00038 
00039 template<class T> class Quantum;
00040 
00041 
00042 // <summary>
00043 // Converts Gaussian parameters between pixel and world
00044 // </summary>
00045 
00046 // <use visibility=export>
00047 
00048 // <reviewed reviewer="" date="" tests="">
00049 // </reviewed>
00050 
00051 // <prerequisite>
00052 //   <li> <linkto class=CoordinateSystem>CoordinateSystem</linkto>
00053 // </prerequisite>
00054 
00055 // <synopsis> 
00056 // Converts Gaussian parameters between world and pixel. 
00057 // In the pixel coordinate system ([0,0] in center of image)
00058 // the position angle is positive +y to -x. This is consistent
00059 // with Gaussian2D.  In the world coordinate system the pa
00060 // is positive N through E
00061 // </synopsis> 
00062 
00063 // <example>
00064 // <srcblock>
00065 // </srcblock>
00066 // </example>
00067 
00068 // <todo asof="1998/12/11">
00069 //  <li> Position angle signs require more thinking in Casacore
00070 // </todo>
00071 
00072 class GaussianConvert
00073 {
00074 public:
00075 
00076     // Default constructor
00077     GaussianConvert ();
00078 
00079     // Constructor.  You specify which world axes (must be length 2)
00080     // of the coordinate system are the relevant ones for
00081     // your gaussian (x then y)
00082     GaussianConvert (const CoordinateSystem& cSys, 
00083                      const Vector<uInt>& worldAxes);
00084 
00085     // Destructor
00086    ~GaussianConvert ();
00087 
00088     // Copy constructor.  Uses copy semantics.
00089     GaussianConvert(const GaussianConvert& other);
00090  
00091     // Assignment operator. Uses copy semantics.
00092     GaussianConvert& operator=(const GaussianConvert& other);
00093 
00094     // (Re)set the coordinate system 
00095     void setCoordinateSystem (const CoordinateSystem& cSys);
00096 
00097     // Re(set) the world axes 
00098     void setWorldAxes (const Vector<uInt>& worldAxes);
00099 
00100     // Convert Gaussian parameters from pixels to world.  Returns
00101     // False if it fails with an error message recoverable with
00102     // function errorMessage.  If you set the units of the output
00103     // axis quanta they will be honoured, otherwise they will come out
00104     // in the axis units of the coordinate system.  For the output position angle,
00105     // if the output units are not set, the units of the input position angle
00106     // will be used.
00107     Bool toWorld(Quantum<Double>& majorAxisOut, Quantum<Double>& minorAxisOut,
00108                  Quantum<Double>& positionAngleOut, Double majorAxisIn,
00109                  Double minorAxisIn, const Quantum<Double>& positionAngleIn);
00110 
00111     // Convert Gaussian parameters from world to pixel.  Returns
00112     // False if it fails with an error message recoverable with
00113     // function errorMessage. For the output position angle,
00114     // if the output units are not set, the units of the input position angle
00115     // will be used.
00116     Bool toPixel(Double& majorAxisOut, Double& minorAxisOut,
00117                  Quantum<Double>& positionAngleOut, const Quantum<Double>& majorAxisIn,
00118                  const Quantum<Double>& minorAxisIn, const Quantum<Double>& positionAngleIn);
00119 
00120     // Convert location
00121     // <group>
00122     Bool toPixel(Vector<Double>& pixel,
00123                  const Vector<Quantum<Double> >& world);
00124     Bool toWorld(Vector<Quantum<Double> >& world,
00125                  const Vector<Double>& pixel);
00126     // </group>
00127 
00128     // Recover error messages from the conversion functions
00129     String errorMessage() const {return itsErrorMessage;}
00130 
00131 
00132 private:
00133 
00134    CoordinateSystem itsCSys;
00135    Vector<uInt> itsWorldAxes;
00136    String itsErrorMessage;
00137    Bool itsValid;
00138 
00139    void convertAxes (Double& minorAxisOut, Double& majorAxisOut,
00140                      Quantum<Double>& positionAngleOut,
00141                      Double minorAxisIn, Double majorAxisIn,
00142                      const Quantum<Double>& positionAngleIn,
00143                      const CoordinateSystem& cSys,
00144                      String dir);
00145 
00146    void checkCoordinateSystem();
00147 
00148    void checkWorldAxes();
00149 
00150    Double positionAngleRange(Double pa);
00151 
00152 };
00153 
00154 
00155 } //# NAMESPACE CASACORE - END
00156 
00157 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1