casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GaussianBeam.h
Go to the documentation of this file.
00001 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2003
00002 //# Associated Universities, Inc. Washington DC, USA.
00003 //#
00004 //# This library is free software; you can redistribute it and/or modify it
00005 //# under the terms of the GNU Library General Public License as published by
00006 //# the Free Software Foundation; either version 2 of the License, or (at your
00007 //# option) any later version.
00008 //#
00009 //# This library is distributed in the hope that it will be useful, but WITHOUT
00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012 //# License for more details.
00013 //#
00014 //# You should have received a copy of the GNU Library General Public License
00015 //# along with this library; if not, write to the Free Software Foundation,
00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00017 //#
00018 //# Correspondence concerning AIPS++ should be addressed as follows:
00019 //#        Internet email: aips2-request@nrao.edu.
00020 //#        Postal address: AIPS++ Project Office
00021 //#                        National Radio Astronomy Observatory
00022 //#                        520 Edgemont Road
00023 //#                        Charlottesville, VA 22903-2475 USA
00024 //#
00025 
00026 #ifndef COMPONENTS_GAUSSIANBEAM_H
00027 #define COMPONENTS_GAUSSIANBEAM_H
00028 
00029 #include <casa/aips.h>
00030 #include <casa/Quanta/Quantum.h>
00031 
00032 namespace casa {
00033         // so the typedef that comes next works
00034         class GaussianBeam;
00035 
00036         // for when we want the same thing, but it really doesn't represent a beam
00037         // but eg. a source
00038         typedef GaussianBeam Angular2DGaussian;
00039 
00040 // <summary>
00041 // Represents a Gaussian restoring beam associated with an image.
00042 // </summary>
00043 
00044 // <use visibility=export>
00045 
00046 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 // </prerequisite>
00051 
00052 // <etymology>
00053 // A Gaussian Beam.
00054 // </etymology>
00055 
00056 // <synopsis>
00057 // This class represents a Gaussian restoring beam associated with
00058 // a deconvolved image.
00059 // </synopsis>
00060 //
00061 // <example>
00062 
00063 // </example>
00064 
00065 
00066 // <motivation>
00067 // Restoring beams are used many places in image analysis tasks.
00068 // </motivation>
00069 
00070 // <todo>
00071 // </todo>
00072 
00073 class GaussianBeam {
00074 public:
00075 
00076         static const GaussianBeam NULL_BEAM;
00077 
00078         // create a beam with all quantities zero (a null beam).
00079         GaussianBeam();
00080 
00081 
00082         // Construct a beam from a set of Quantities. If minor > major
00083         // an exception is thrown. If any units are not angular, an
00084         // exception is thrown
00085         GaussianBeam(
00086                 const Quantity& major, const Quantity& minor,
00087                 const Quantity& pa
00088         );
00089 
00090         // Construct a beam from a 3-Vector of Quantities representing
00091         // the major axis, the minor axis and the position angle (in that order).
00092         // If parms[1] > parms[0] (minor axis > major axis),
00093         // an exception is thrown. If any units are not angular, an
00094         // exception is thrown
00095         GaussianBeam(
00096                 const Vector<Quantity>& parms
00097         );
00098 
00099         GaussianBeam(const GaussianBeam& other);
00100 
00101         ~GaussianBeam();
00102 
00103         GaussianBeam& operator=(const GaussianBeam& other);
00104 
00105         Bool operator==(const GaussianBeam& other) const;
00106 
00107         Bool operator!=(const GaussianBeam& other) const;
00108 
00109         // returns the major axis in the same units as it had at construction
00110         const Quantity& getMajor() const;
00111 
00112         // returns the value portion of the major axis in the specified units
00113         Double getMajor(const Unit& u) const;
00114 
00115         // returns the minor axis in the same units as it had at construction
00116         const Quantity& getMinor() const;
00117 
00118         // returns the value portion of the minor axis in the specified units
00119         Double getMinor(const Unit& u) const;
00120 
00121         // returns the position angle's value as it was at construction,
00122         // unless <src>unwrap</src> is True, in which case the value of the angle
00123         // returned will be between -90 and 90 degrees (but with unit the same
00124         // as it had when this object was constructed).
00125         Quantity getPA(const Bool unwrap=True) const;
00126 
00127         // returns the value portion of the position angle in the specified units
00128         Double getPA(const Unit& u, const Bool unwrap=True) const;
00129 
00130         // returns the beam area in the specified <src>unit</src>, which much conform to
00131         // solid angle units.
00132         Double getArea(const Unit& unit) const;
00133 
00134         // is this object a null beam (ie is either its major and/or minor axis zero)?
00135         Bool isNull() const;
00136 
00137         // returns GassianBeam.
00138         static const String& className();
00139 
00140         Record toRecord() const;
00141 
00142         void setMajorMinor(const Quantity& majAx, const Quantity& minAx);
00143 
00144         void setPA(const Quantity& pa);
00145 
00146         static GaussianBeam fromRecord(const Record& rec);
00147 
00148         // convert this object to a three-Vector of (major FWHM, minor FWHM, and pa).
00149         // If <src>unwrap</src> is True, the returned pa will fall between -90 and +90
00150         // degrees.
00151         Vector<Quantity> toVector(const Bool unwrap=True) const;
00152 
00153         // convert stored Quantities to the specified units
00154         void convert(
00155                 const String& majUnit, const String& minUnit,
00156                 const String& paUnit
00157         );
00158 
00159         // Deconvolve the parameters of a source Gaussian from a this GaussianBeam
00160         // to give the deconvolved Gaussian source.  The return is True if the model appears
00161         // to be a point source and the output model will be set to
00162         // the parameters of the beam.
00163         Bool deconvolve(
00164                 Angular2DGaussian& deconvolvedSize,
00165                 const Angular2DGaussian& convolvedSize
00166         ) const;
00167 
00168 private:
00169         Quantity _major, _minor, _pa;
00170 
00171 };
00172 
00173 
00174 
00175 ostream &operator<<(ostream &os, const GaussianBeam& beam);
00176 
00177 LogIO &operator<<(LogIO &os, const GaussianBeam& beam);
00178 
00179 Bool near(
00180         const GaussianBeam& left, const GaussianBeam& other,
00181         const Double relWidthTol, const Quantity& absPaTol
00182 );
00183 
00184 }
00185 
00186 #endif
00187