ImageInfo.h

Go to the documentation of this file.
00001 //# ImageInfo.h: Miscellaneous information related to an image
00002 //# Copyright (C) 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$
00028 
00029 #ifndef IMAGES_IMAGEINFO_H
00030 #define IMAGES_IMAGEINFO_H
00031 
00032 #include <casa/aips.h>
00033 #include <casa/Utilities/RecordTransformable.h>
00034 
00035 #include <casa/Arrays/Vector.h>
00036 #include <casa/Quanta/Quantum.h>
00037 #include <casa/BasicSL/String.h>
00038 
00039 //# Forward declarations
00040 #include <casa/iosfwd.h>
00041 namespace casa { //# NAMESPACE CASA - BEGIN
00042 
00043 class LoggerHolder;
00044 
00045 // <summary>
00046 // Miscellaneous information related to an image.
00047 // </summary>
00048 
00049 // <use visibility=export>
00050 
00051 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00052 // </reviewed>
00053 
00054 // <prerequisite>
00055 //   <li> <linkto class=RecordTransformable>RecordTransformable</linkto>
00056 // </prerequisite>
00057 //
00058 // <synopsis>
00059 // This class is used to record information about an image.
00060 // At present it contains the following:
00061 // <ol>
00062 //    <li> The restoring beam
00063 //    <li> A parameter describing what quantity the image holds.
00064 //    <li> The image object name.
00065 // </ol>
00066 // This list can easily be extended if necessary.
00067 //
00068 // </synopsis>
00069 //
00070 // <example>
00071 // The interface is a simple get/set interface. Note that the "set" methods
00072 // can be chained together since each set method returns a reference to its
00073 // object (rather like cout).
00074 // <srcblock>
00075 //    ImageInfo ii;
00076 //    ii.setRestoringBeam(Quantity(30,"arcsec"), Quantity(10,"arcsec"),
00077 //                        Quantity(-18,"deg"));
00078 //    ...
00079 //    cout << "The restoring beam is : " << oi.restoringBeam() << endl;
00080 // </srcblock>
00081 // </example>
00082 //
00083 // <motivation>
00084 // This sort of information needed a standard place to go with a
00085 // standard interface so it could be moved out of MiscInfo.
00086 // </motivation>
00087 //
00088 // <todo asof="2002/02/05">
00089 //   <li> Probably add the image min and max
00090 // </todo>
00091 
00092 class ImageInfo : public RecordTransformable
00093 {
00094 public:
00095 
00096     // This enum defines the actual quantity being held in an image
00097     // It's really only used for descriptive information.
00098     enum ImageTypes {
00099        Undefined=0,
00100        Intensity,
00101        Beam,
00102        ColumnDensity,
00103        DepolarizationRatio,
00104        KineticTemperature,
00105        MagneticField,
00106        OpticalDepth,
00107        RotationMeasure,
00108        RotationalTemperature,
00109        SpectralIndex,
00110        Velocity,
00111        VelocityDispersion,
00112        nTypes
00113     };
00114 
00115 // Default constructor
00116 
00117     ImageInfo();
00118 
00119 // Destructor
00120     ~ImageInfo();
00121 
00122 // Copy constructor (copy semantics)
00123     ImageInfo(const ImageInfo &other);
00124 
00125 // Assignment (copy semantics)
00126     ImageInfo &operator=(const ImageInfo &other);
00127 
00128 // Set and get the restoring beam.  Vector beam in order
00129 // major axis, minor axis, position angle.
00130 // <group>
00131     Vector<Quantum<Double> > restoringBeam() const;
00132     ImageInfo& setRestoringBeam(const Vector<Quantum<Double> >& beam);
00133     ImageInfo& setRestoringBeam(const Quantum<Double>& major,
00134                                 const Quantum<Double>& minor,
00135                                 const Quantum<Double>& pa);
00136     ImageInfo& removeRestoringBeam();
00137 // </group>
00138 
00139 // Get the restoring beam from a LoggerHolder (where the history is stored)
00140 // as AIPS writes the beam in the FITS history rather than the header keywords.  
00141 // If there is no beam,  False is returned, and the internal state of the object
00142 // is unchanged.
00143    Bool getRestoringBeam (LoggerHolder& logger);
00144 
00145 // Set and get the Image Type.  
00146 // <group>
00147     ImageInfo::ImageTypes imageType () const;
00148     ImageInfo& setImageType(ImageTypes type);
00149     static String imageType(ImageInfo::ImageTypes type);
00150     static ImageInfo::ImageTypes imageType(String type);
00151 // </group>
00152 
00153 // Set and get the Image object name
00154 // <group>
00155     String objectName () const;
00156     ImageInfo& setObjectName (const String& object);
00157 // </group>
00158 
00159 // Functions to interconvert between an ImageInfo and a record. These 
00160 // functions are inherited from class
00161 // <linkto class=RecordTransformable>RecordTransformable</linkto>. As new
00162 // fields get added to ImageInfo these functions should be augmented. Missing
00163 // fields should not generate an error to in fromRecord to allow for 
00164 // backwards compatibility - null values should be supplied instead.
00165 // The record field names are: "restoringbeam, imagetype, objectname".
00166 // <group>
00167     virtual Bool toRecord(String & error, RecordInterface & outRecord) const;
00168     virtual Bool fromRecord(String & error, const RecordInterface & inRecord);
00169 // </group>
00170 
00171 // In some circumstances it might be useful to know what the defaults for
00172 // the various values are so you can check if they have been set.
00173 // The default restoring beam is a null vector.
00174 // <group>
00175     static Vector<Quantum<Double> > defaultRestoringBeam();
00176     static ImageTypes defaultImageType();
00177     static String defaultObjectName();
00178 // </group>
00179 
00180 // Functions to interconvert between an ImageInfo and FITS keywords
00181 // (converted to a Record).    Failure of <src>fromFITS</src>
00182 // should probably not be regarded as fatal as the default ImageInfo
00183 // values are viable.  For each item contained
00184 // in the ImageInfo, an attempt to decode it from FITS is made.
00185 // If any of them fail, False is returned, but it attempts to decode
00186 // them all.  For those that fail an error message is held in <src>error</src> 
00187 // in the order restoring beam, and image type.
00188 // <src>error</src> will be returned of length 0 if the return 
00189 // value is True, else it will be length 2.
00190 // <group>
00191     Bool toFITS(String & error, RecordInterface & outRecord) const;
00192     Bool fromFITS(Vector<String>& error, const RecordInterface & inRecord);
00193 // </group>
00194 
00195 // Old version
00196     Bool fromFITSOld(Vector<String>& error, const RecordInterface & inRecord);
00197 
00198 
00199 
00200 // This function takes an unofficial fitsValue found on the Stokes axis
00201 // and returns the appropriate ImageType.  The idea is that you 
00202 // detect the unofficial value, drop the Stokes axis, and store
00203 // the value as an ImageType in ImageInfo.  Only values pertaining
00204 // to beam, optical depth and spectral index are handled here.  All others
00205 // give back Undefined.  See usage in Image FITS conversion classes.
00206     static ImageInfo::ImageTypes imageTypeFromFITS(Int fitsValue);
00207 
00208 // It might be useful to know what FITS keyword names are used in to/from
00209 // FITS so we can remove them so they won't be used more than once. The
00210 // names are in lower case.
00211     static Vector<String> keywordNamesFITS();
00212 
00213 // Convert the Miriad 'btype' strings to the ImageType.  Some 
00214 // Miriad 'btype's are dealt with in aips++ via the Stokes
00215 // axis (fractional_polarization, polarized_intensity, position_angle)
00216 // and so these will return Undefined.
00217    static ImageInfo::ImageTypes MiriadImageType (const String& type);
00218 
00219 private:
00220     Vector<Quantum<Double> > itsRestoringBeam;
00221     ImageInfo::ImageTypes itsImageType;
00222     String itsObjectName;
00223 
00224 // Common copy ctor/assignment operator code.
00225     void copy_other(const ImageInfo &other);
00226 };
00227 
00228 // <summary> Global functions </summary>
00229 // <group name=Output>
00230 // Output declaration - useful for debugging.
00231 ostream &operator<<(ostream &os, const ImageInfo &info);
00232 // </group>
00233 
00234 
00235 
00236 } //# NAMESPACE CASA - END
00237 
00238 #endif
00239 
00240 
00241 
00242 

Generated on Mon Sep 1 22:34:43 2008 for NRAOCASA by  doxygen 1.5.1