casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ImageProperties.h
Go to the documentation of this file.
00001 //# ImageProperties.qo.h: an object that collects data-range and other info about a casa image
00002 //# Copyright (C) 2012
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 DISPLAY_IMAGEINFO_H_
00029 #define DISPLAY_IMAGEINFO_H_
00030 #include <string>
00031 #include <casa/Arrays/Vector.h>
00032 #include <coordinates/Coordinates/CoordinateSystem.h>
00033 #include <components/ComponentModels/GaussianBeam.h>
00034 #include <images/Images/ImageInterface.h>
00035 
00036 namespace casa {
00037     namespace viewer {
00038 
00039         // This class provides a priori image information derived from the image itself. It was
00040         // created to standardize the access to image properties, since this information is needed
00041         // in a variety of places and is currently found in a variety of manners. The idea was that
00042         // it would provide easy, standardized (e.g. velocity provided in km/s) access. There are still
00043         // likely issues to iron out with expericence from new images.
00044         //
00045         // It may be desirable to have 2nd order image information, e.g. which axes map to the x, y
00046         // and z viewer display axes (or perhaps not), but if so, this information should be provided
00047         // by a derived class.
00048         //
00049         class ImageProperties {
00050 
00051             public:
00052                 ImageProperties( );
00053                 ImageProperties( const std::string &/*path*/ );
00054                 ImageProperties( ImageInterface<Float> * );
00055                 ImageProperties( ImageInterface<std::complex<float> >* );   /**** throws exception ****/
00056                 const ImageProperties &operator=( const std::string & );
00057 
00058                 bool hasDirectionAxis( ) const { return has_direction_axis; }
00059                 const std::string &directionType( ) const { return direction_type; }
00060                 bool hasSpectralAxis( ) const { return has_spectral_axis; }
00061                 const Vector<Int> &shape( ) const { return shape_; }
00062                 Vector<double> raRange( ) const { return ra_range; }
00063                 std::vector<std::string> raRangeAsStr( ) const { return ra_range_str; }
00064                 Vector<double> decRange( ) const { return dec_range; }
00065                 std::vector<std::string> decRangeAsStr( ) const { return dec_range_str; }
00066                 size_t nBeams( ) const { return restoring_beams.size( ); }
00067                 std::vector<std::vector<double> > restoringBeams( ) const;
00068                 std::vector<double> restoringBeam( size_t channel ) const
00069                         { return beam_as_vector(channel < restoring_beams.size( ) ? restoring_beams[channel] : restoring_beams[0]); }
00070                 std::vector<std::string> restoringBeamAsStr( size_t channel ) const
00071                         { return beam_as_string_vector(channel < restoring_beams.size( ) ? restoring_beams[channel] : restoring_beams[0]); }
00072                 std::vector<double> medianRestoringBeam( ) const;
00073                 std::vector<std::string> medianRestoringBeamAsStr( ) const;
00074                 Vector<double> freqRange( const std::string &units="" ) const;
00075                 const std::string &freqUnits( ) const { return freq_units; }
00076                 Vector<double> veloRange( const std::string &units="" ) const;
00077                 const std::string &veloUnits( ) const { return velo_units; }
00078                 const std::string &path( ) const { return path_; }
00079                 bool ok( ) const { return status_ok; }
00080 
00081                 // export required CoordinateSystem functions instead of returning a CoordinateSystem reference...
00082                 int spectralAxisNumber() const { return cs_.spectralAxisNumber( ); }
00083 
00084             private:
00085                 std::vector<double> beam_as_vector( const GaussianBeam &beam ) const;
00086                 std::vector<std::string> beam_as_string_vector( const GaussianBeam &beam ) const;
00087                 void clear_state( );
00088                 void initialize_state( ImageInterface<Float> *image );
00089                 void reset( ImageInterface<Float> *image );
00090                 void reset( const std::string &path="" );
00091                 bool status_ok;
00092                 std::string path_;
00093                 Vector<Int> shape_;
00094                 bool has_direction_axis;
00095                 std::string direction_type;
00096                 bool has_spectral_axis;
00097                 Vector<double> freq_range;
00098                 std::string freq_units;
00099                 Vector<double> velo_range;
00100                 std::string velo_units;
00101                 Vector<double> ra_range;
00102                 std::vector<std::string> ra_range_str;
00103                 Vector<double> dec_range;
00104                 std::vector<std::string> dec_range_str;
00105                 std::vector<GaussianBeam> restoring_beams;
00106                 CoordinateSystem cs_;
00107         };
00108     }
00109 }
00110 
00111 
00112 #endif