casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ImageSummary.h
Go to the documentation of this file.
00001 //# ImageSummary.h: List descriptive information from an image 
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002
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 //#
00027 //# $Id: ImageSummary.h 20229 2008-01-29 15:19:06Z gervandiepen $
00028 
00029 #ifndef IMAGES_IMAGESUMMARY_H
00030 #define IMAGES_IMAGESUMMARY_H
00031 
00032 
00033 //# Includes
00034 #include <casa/aips.h>
00035 #include <measures/Measures/MFrequency.h>
00036 #include <measures/Measures/MDirection.h>
00037 #include <measures/Measures/MDoppler.h>
00038 #include <coordinates/Coordinates/CoordinateSystem.h>
00039 #include <coordinates/Coordinates/ObsInfo.h>
00040 #include <images/Images/ImageInfo.h>
00041 
00042 namespace casa { //# NAMESPACE CASA - BEGIN
00043 
00044 //# Forward Declarations
00045 template <class T> class ImageInterface;
00046 template <class T> class Vector;
00047 class IPosition;
00048 class Unit;
00049 class LogIO;
00050 class Coordinate;
00051 
00052 
00053 // <summary>
00054 // Provides and lists information about the header of an image.
00055 // </summary>
00056 
00057 // <use visibility=export>
00058 
00059 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00060 // </reviewed>
00061 
00062 // <prerequisite>
00063 //   <li> <linkto class=ImageInterface>ImageInterface</linkto>
00064 //   <li> <linkto module=Coordinates>Coordinates</linkto> 
00065 // </prerequisite>
00066 
00067 // <etymology>
00068 // This class lists the ancilliary descriptive information from an image
00069 // </etymology>
00070 
00071 // <synopsis>
00072 // Images consist of pixel values and descriptive information.
00073 // This information describes the coordinate system, the image 
00074 // units etc.  This class enables you to 
00075 // retrieve the descriptive information and/or list it.
00076 // <p>
00077 // The functions that retrieve specific coordinate information in vectors 
00078 // (e.g. <src>referenceValues</src>) return it in the order of the (pixel) axes of 
00079 // the image.  Note that this can be different from the order in which 
00080 // the <linkto class=CoordinateSystem>CoordinateSystem</linkto>
00081 // functions of similar name might return them.   This is because the
00082 // order of the coordinates in the CoordinateSystem is not necessarily 
00083 // the same order as the pixel axes in the associated image, although 
00084 // of course there is a known association.
00085 //
00086 // <note role=tip>
00087 // This class lists information about the coordinates in the image.
00088 // The Coordinates classes can maintain the information in a variety
00089 // of units.  For example, angular quantities are by default in radians,
00090 // but the manipulator of a <linkto class=CoordinateSystem>CoordinateSystem</linkto>
00091 // may have converted to some other unit such as arcseconds.  This
00092 // means that when this class fetches coordinate information and returns
00093 // it to you (such as the <src>referenceValues()</src> function, 
00094 // the information is returned to you in whatever units the coordinates
00095 // are currently in.  It does not convert it.
00096 // </note>
00097 // </synopsis>
00098 
00099 // <example>
00100 // <srcBlock>
00101 //     PagedImage<Float> inImage(fileName);
00102 //     ImageSummary<Float> summary(inImage);
00103 //     LogOrigin or("myClass", "myFunction(...)", WHERE);
00104 //     LogIO os(or);
00105 //     summary.list(os);
00106 // </srcBlock>
00107 // A <src>PagedImage</src> object is constructed and then logged to the 
00108 // supplied <src>LogIO</src> object.
00109 // </example>
00110 
00111 // <motivation>
00112 // The viewing of the descriptive image information is a basic capability.
00113 // </motivation>
00114 
00115 //# <todo asof="1998/08/31">
00116 //#  None that I know of.
00117 //# </todo>
00118  
00119 
00120 template <class T> class ImageSummary
00121 {
00122 public:
00123 // Constructor
00124    ImageSummary (const ImageInterface<T>&);
00125 
00126 // Copy constructor
00127    ImageSummary (const ImageSummary<T> &other);
00128 
00129 // Destructor
00130   ~ImageSummary();
00131 
00132 // Assignment operator
00133    ImageSummary<T> &operator=(const ImageSummary<T> &other);
00134 
00135 // Retrieve number of image dimension
00136    Int ndim () const;
00137  
00138 // Retrieve image shape
00139    IPosition shape () const;
00140 
00141 // Retrieve tile shape with which image is stored on disk
00142    IPosition tileShape () const;
00143 
00144 // Retrieve axis names in pixel or world axis order.
00145    Vector<String> axisNames (Bool pixelOrder=True) const;
00146 
00147 // Retrieve reference pixels (0 or 1 rel)
00148    Vector<Double> referencePixels (Bool oneRel=True) const;
00149 
00150 // Retrieve reference values in pixel or world axis order. 
00151    Vector<Double> referenceValues (Bool pixelOrder=True) const;
00152 
00153 // Retrieve axis increments in pixel or world axis order.  
00154    Vector<Double> axisIncrements (Bool pixelOrder=True) const;
00155 
00156 // Retrieve axis units in pixel or world axis order.
00157    Vector<String> axisUnits(Bool pixelOrder=True) const;
00158 
00159 // Retrieve image units
00160    Unit units () const;
00161  
00162 // Retrieve image name.  Any prepended path is stripped off.
00163    String name() const;
00164 
00165 // Retrieve observer name
00166    String observer() const;
00167 
00168 // Return epoch of observation as MEpoch or formatted string
00169    String obsDate(MEpoch& date) const;
00170 
00171 // Return telescope
00172    String telescope() const;
00173 
00174 // Return rest frequency.  Returns False if none.
00175    Bool restFrequency(String& restFreqString, Quantum<Double>& restFreq) const;
00176 
00177 // Return frequency system.  Returns False if none.
00178    Bool frequencySystem(String& freqTypeString, MFrequency::Types& freqType) const;
00179 
00180 // Return direction system.  Returns False if none.
00181    Bool directionSystem(String& dirTypeString, MDirection::Types& dirType) const;
00182 
00183 // Retrieve whether image has mask or not
00184    Bool hasAMask () const;
00185 
00186 // Retrieve mask names
00187    Vector<String> maskNames() const;
00188 
00189 // Retrieve region names
00190    Vector<String> regionNames() const;
00191 
00192 // Retrieve default mask name.  Empty if none
00193    String defaultMaskName() const;
00194 
00195 
00196 // Retrieve image type
00197    String imageType () const;
00198 
00199 // List all header information.  By default, the reference
00200 // values and pixel increments are converted to a "nice" unit before 
00201 // formatting (e.g. RA is  shown as HH:MM:SS.S).  
00202 // For spectral axes, both frequency and velocity information is listed. You
00203 // can specify what velocity definition you want with <src>velocityType</src>
00204 // If postLocally is True, the formatted strings are returned in the return value
00205    Vector<String> list(
00206                    LogIO& os, const MDoppler::Types velocityType=MDoppler::RADIO,
00207                    Bool postLocally=False, const Bool verbose=False
00208    );
00209 
00210 // Set a new image
00211    Bool setNewImage (const ImageInterface<T>& image);
00212 
00213 
00214 private:
00215    CoordinateSystem cSys_p;
00216    ObsInfo obsInfo_p;
00217    ImageInfo imageInfo_p;
00218    const ImageInterface<T>* pImage_p;
00219 //
00220     String makeMasksString() const;
00221     String makeRegionsString() const;
00222 
00223     void _listMultiBeam(LogIO& os, const Bool verbose) const;
00224 
00225     void _chanInfoToStream(
00226         ostream& os, const SpectralCoordinate *const &spCoord,
00227         const uInt chan, const uInt chanWidth, const uInt freqPrec,
00228         const uInt velWidth, const uInt velPrec
00229     ) const;
00230 
00231     void _beamToStream(
00232         ostream& os, const GaussianBeam& beam, const Unit& unit
00233     ) const;
00234 };
00235 
00236 
00237 } //# NAMESPACE CASA - END
00238 
00239 #ifndef CASACORE_NO_AUTO_TEMPLATES
00240 #include <images/Images/ImageSummary.tcc>
00241 #endif //# CASACORE_NO_AUTO_TEMPLATES
00242 #endif