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 <display/Display/DisplayCoordinateSystem.h> 00033 #include <images/Images/ImageInterface.h> 00034 00035 namespace casa { 00036 00037 class GaussianBeam; 00038 00039 namespace viewer { 00040 00041 // This class provides a priori image information derived from the image itself. It was 00042 // created to standardize the access to image properties, since this information is needed 00043 // in a variety of places and is currently found in a variety of manners. The idea was that 00044 // it would provide easy, standardized (e.g. velocity provided in km/s) access. There are still 00045 // likely issues to iron out with expericence from new images. 00046 // 00047 // It may be desirable to have 2nd order image information, e.g. which axes map to the x, y 00048 // and z viewer display axes (or perhaps not), but if so, this information should be provided 00049 // by a derived class. 00050 // 00051 class ImageProperties { 00052 00053 public: 00054 ImageProperties( ); 00055 ImageProperties( const std::string &/*path*/ ); 00056 ImageProperties( SHARED_PTR<ImageInterface<Float> > ); 00057 ImageProperties( SHARED_PTR<ImageInterface<std::complex<float> > > ); /**** throws exception ****/ 00058 const ImageProperties &operator=( const std::string & ); 00059 00060 bool hasDirectionAxis( ) const { 00061 return has_direction_axis; 00062 } 00063 const std::string &directionType( ) const { 00064 return direction_type; 00065 } 00066 bool hasSpectralAxis( ) const { 00067 return has_spectral_axis; 00068 } 00069 const Vector<Int> &shape( ) const { 00070 return shape_; 00071 } 00072 Vector<double> raRange( ) const { 00073 return ra_range; 00074 } 00075 std::vector<std::string> raRangeAsStr( ) const { 00076 return ra_range_str; 00077 } 00078 Vector<double> decRange( ) const { 00079 return dec_range; 00080 } 00081 std::vector<std::string> decRangeAsStr( ) const { 00082 return dec_range_str; 00083 } 00084 size_t nBeams( ) const { 00085 return restoring_beams.size( ); 00086 } 00087 std::vector<std::vector<double> > restoringBeams( ) const; 00088 std::vector<double> restoringBeam( size_t channel ) const { 00089 return beam_as_vector(channel < restoring_beams.size( ) ? restoring_beams[channel] : restoring_beams[0]); 00090 } 00091 std::vector<std::string> restoringBeamAsStr( size_t channel ) const { 00092 return beam_as_string_vector(channel < restoring_beams.size( ) ? restoring_beams[channel] : restoring_beams[0]); 00093 } 00094 std::vector<double> medianRestoringBeam( ) const; 00095 std::vector<std::string> medianRestoringBeamAsStr( ) const; 00096 Vector<double> freqRange( const std::string &units="" ) const; 00097 const std::string &frequencyUnits( ) const { 00098 return freq_units; 00099 } 00100 00101 const std::string &velocityUnits( ) const { 00102 return velo_units; 00103 } 00104 const std::string &path( ) const { 00105 return path_; 00106 } 00107 00108 const DisplayCoordinateSystem &cs( ) const { return cs_; } 00109 00110 bool ok( ) const { 00111 return status_ok; 00112 } 00113 00114 // export required DisplayCoordinateSystem functions instead of returning a DisplayCoordinateSystem reference... 00115 int spectralAxisNumber() const { 00116 return cs_.spectralAxisNumber( ); 00117 } 00118 00119 const std::vector<double> &frequencies( ) const { return frequencies_; } 00120 const std::vector<double> &velocities( ) const { return velocities_; } 00121 00122 private: 00123 std::vector<double> beam_as_vector( const GaussianBeam &beam ) const; 00124 std::vector<std::string> beam_as_string_vector( const GaussianBeam &beam ) const; 00125 void clear_state( ); 00126 void initialize_state( SHARED_PTR<ImageInterface<Float> > image ); 00127 void reset( SHARED_PTR<ImageInterface<Float> > image ); 00128 void reset( const std::string &path="" ); 00129 bool status_ok; 00130 std::string path_; 00131 Vector<Int> shape_; 00132 bool has_direction_axis; 00133 std::string direction_type; 00134 bool has_spectral_axis; 00135 std::vector<double> frequencies_; 00136 std::vector<double> velocities_; 00137 std::string freq_units; 00138 std::string velo_units; 00139 Vector<double> ra_range; 00140 std::vector<std::string> ra_range_str; 00141 Vector<double> dec_range; 00142 std::vector<std::string> dec_range_str; 00143 std::vector<GaussianBeam> restoring_beams; 00144 DisplayCoordinateSystem cs_; 00145 }; 00146 } 00147 } 00148 00149 std::ostream &operator<<( std::ostream &os, const casa::DisplayCoordinateSystem &cs ); 00150 00151 std::ostream &operator<<( std::ostream &os, const casa::DisplayCoordinateSystem &cs ); 00152 namespace casa { 00153 namespace viewer { 00154 inline std::ostream &operator<<( std::ostream &os, const casa::DisplayCoordinateSystem &cs ) { return ::operator<<(os,cs); } 00155 } 00156 } 00157 00158 #endif