ImageMetaDataBase.h

Go to the documentation of this file.
00001 //# ImageMetaData.h: Meta information for Images
00002 //# Copyright (C) 2009
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 IMAGES_IMAGEMETADATABASE_H
00029 #define IMAGES_IMAGEMETADATABASE_H
00030 
00031 #include <images/Images/ImageInterface.h>
00032 #include <imageanalysis/ImageTypedefs.h>
00033 #include <casa/aips.h>
00034 
00035 namespace casa {
00036 
00037 // <summary>
00038 // Base class for image metadata access.
00039 // </summary>
00040 
00041 // <use visibility=export>
00042 
00043 // <reviewed reviewer="" date="" tests="" demos="">
00044 // </reviewed>
00045 
00046 // <prerequisite>
00047 //   <li> <linkto class=ImageInterface>ImageInterface</linkto>
00048 // </prerequisite>
00049 
00050 // <etymology>
00051 // </etymology>
00052 
00053 // <synopsis> 
00054 // </synopsis>
00055 
00056 // <example>
00057 // </example>
00058 
00059 // <motivation> 
00060 
00061 // </motivation>
00062 
00063 
00064 class ImageMetaDataBase {
00065 
00066 public:
00067 
00068         const static String MASKS;
00069 
00070         virtual ~ImageMetaDataBase() {}
00071 
00072     CoordinateSystem coordsys(const vector<Int>& axes) const;
00073 
00074         uInt nChannels() const;
00075 
00076         // Is the specified channel number valid for this image?
00077         Bool isChannelNumberValid(const uInt chan) const;
00078 
00079         // Get the pixel number on the polarization axis of the specified stokes parameter.
00080         // If the specified stokes parameter does not exist in the image, the value returned
00081         // is not gauranteed to be anything other than outside the range of 0 to nStokes-1
00082         // inclusive. Return -1 if the specified stokes parameter is not present or
00083         // if this image does not have a polarization axis.
00084  
00085         Int stokesPixelNumber(const String& stokesString) const;
00086 
00087         // get the stokes parameter at the specified pixel value on the polarization axis.
00088         // returns "" if the specified pixel is out of range or if no polarization axis.
00089 
00090         String stokesAtPixel(const uInt pixel) const;
00091 
00092         // Get the number of stokes parameters in this image.
00093         uInt nStokes() const;
00094 
00095         // is the specified stokes parameter present in the image?
00096         Bool isStokesValid(const String& stokesString) const;
00097 
00098         // Get the shape of the direction axes. Returns a two element
00099         // Vector if there is a direction coordinate, if not returns a zero element
00100         // vector.
00101 
00102         Vector<Int> directionShape() const;
00103 
00104         // if the specified stokes parameter is valid. A message suitable for
00105         // error notification is returned in the form of an in-out parameter
00106         //if one or both of these is invalid.
00107         Bool areChannelAndStokesValid(
00108                 String& message, const uInt chan, const String& stokesString
00109     ) const;
00110 
00111         // get the bounding box in the image for the specified region.
00112         Record* getBoundingBox(const Record& region) const;
00113 
00114         // convert the header info to a Record and list to logger if verbose=True
00115         virtual Record toRecord(Bool verbose) const = 0;
00116 
00117         // get the value of the datum corresponding to the given FITS keyword.
00118         ValueHolder getFITSValue(const String& key) const;
00119 
00120         // if doVelocity=True, compute spectral velocities as well as frequencies, if False, only
00121         // compute frequencies.
00122         // <src>dirFrame</src> and <src>freqFrame</src> are the codes for the
00123         // frames for which it is desired that the returned measures should be specified.
00124         // In both cases, one can specify "native" for the native coordinate frame,
00125         // "cl" for the conversion layer frame, or any valid frame string from MDirection::showType()
00126         // or MFrequency::showType().
00127         Record toWorld(
00128             const Vector<double>& value, const String& format = "n",
00129             Bool doVelocity=True, const String& dirFrame="cl",
00130             const String& freqFrame="cl"
00131         ) const;
00132 
00133 protected:
00134         const static String _BEAMMAJOR, _BEAMMINOR, _BEAMPA, _BMAJ, _BMIN, _BPA,
00135                 _BUNIT, _CDELT, _CRPIX, _CRVAL, _CTYPE, _CUNIT, _DATAMAX, _DATAMIN,
00136                 _EPOCH, _EQUINOX, _IMTYPE, _MAXPIXPOS, _MAXPOS, _MINPIXPOS,
00137                 _MINPOS, _OBJECT, _OBSDATE, _OBSERVER, _PROJECTION,
00138                 _RESTFREQ, _REFFREQTYPE, _SHAPE, _TELESCOPE;
00139 
00140         virtual SPCIIF _getFloatImage() const = 0;
00141 
00142         virtual SPCIIC _getComplexImage() const = 0;
00143 
00144         ImageMetaDataBase() : _log() {}
00145 
00146         LogIO& _getLog() { return _log; }
00147 
00148         virtual const ImageInfo& _getInfo() const = 0;
00149 
00150         virtual const CoordinateSystem& _getCoords() const = 0;
00151 
00152         virtual Vector<String> _getAxisNames() const = 0;
00153 
00154         virtual Vector<String> _getAxisUnits() const = 0;
00155 
00156         virtual GaussianBeam _getBeam() const = 0;
00157 
00158         virtual String _getBrightnessUnit() const = 0;
00159 
00160         virtual String _getImType() const = 0;
00161 
00162         virtual vector<Quantity> _getIncrements() const = 0;
00163 
00164         virtual Vector<String> _getMasks() const = 0;
00165 
00166         virtual String _getObject() const = 0;
00167 
00168         virtual String _getEquinox() const = 0;
00169 
00170         virtual MEpoch _getObsDate() const = 0;
00171 
00172         String _getEpochString() const;
00173 
00174         virtual String _getObserver() const = 0;
00175 
00176         virtual String _getProjection() const;
00177 
00178         virtual String _getRefFreqType() const = 0;
00179 
00180         virtual Vector<Double> _getRefPixel() const = 0;
00181 
00182         virtual Vector<Quantity> _getRefValue() const = 0;
00183 
00184         virtual Quantity _getRestFrequency() const = 0;
00185 
00186         IPosition _getShape() const;
00187 
00188         virtual Record _getStatistics() const = 0;
00189 
00190         virtual String _getTelescope() const = 0;
00191 
00192         Record _makeHeader() const;
00193 
00194         void _toLog(const Record& header) const;
00195 
00196         uInt _getAxisNumber(const String& key) const;
00197 
00198         Record _calcStats() const;
00199 
00200         const TableRecord _miscInfo() const;
00201 
00202         uInt _ndim() const;
00203 
00204         virtual Vector<String> _getStokes() const = 0;
00205 
00206 private:
00207 
00208         mutable LogIO _log;
00209 
00210         mutable IPosition _shape;
00211 
00212         // precision < 0 => use default precision when printing numbers
00213         void _fieldToLog(const Record& header, const String& field, Int precision=-1) const;
00214 
00215         String _doStandardFormat(Double value, const String& unit) const;
00216 
00217         template <class T> Record _calcStatsT(
00218                 SHARED_PTR<const ImageInterface<T> > image
00219         ) const;
00220 
00221         Record _worldVectorToRecord(
00222             const CoordinateSystem& csys, const Vector<Double>& world, Int c,
00223             const String& format,
00224             Bool isAbsolute, Bool showAsAbsolute, Bool doVelocity,
00225             MDirection::Types dirFrame, MFrequency::Types freqFrame
00226         ) const;
00227 
00228         Record _worldVectorToMeasures(
00229             const CoordinateSystem& csys,
00230             const Vector<Double>& world, Int c, Bool abs, Bool doVelocity,
00231             MDirection::Types dirFrame, MFrequency::Types freqFrame
00232         ) const;
00233 
00234 };
00235 
00236 }
00237 
00238 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1