casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageProperties.h
Go to the documentation of this file.
1 //# ImageProperties.qo.h: an object that collects data-range and other info about a casa image
2 //# Copyright (C) 2012
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef DISPLAY_IMAGEINFO_H_
29 #define DISPLAY_IMAGEINFO_H_
30 #include <string>
31 #include <casa/Arrays/Vector.h>
34 
35 namespace casacore{
36 
37  class GaussianBeam;
38 }
39 
40 namespace casa {
41 
42 
43  namespace viewer {
44 
45  // This class provides a priori image information derived from the image itself. It was
46  // created to standardize the access to image properties, since this information is needed
47  // in a variety of places and is currently found in a variety of manners. The idea was that
48  // it would provide easy, standardized (e.g. velocity provided in km/s) access. There are still
49  // likely issues to iron out with expericence from new images.
50  //
51  // It may be desirable to have 2nd order image information, e.g. which axes map to the x, y
52  // and z viewer display axes (or perhaps not), but if so, this information should be provided
53  // by a derived class.
54  //
56 
57  public:
58  ImageProperties( );
59  ImageProperties( const std::string &/*path*/ );
61  ImageProperties( std::shared_ptr<casacore::ImageInterface<std::complex<float> > > ); /**** throws exception ****/
62  const ImageProperties &operator=( const std::string & );
63 
64  bool hasDirectionAxis( ) const {
65  return has_direction_axis;
66  }
67  const std::string &directionType( ) const {
68  return direction_type;
69  }
70  bool hasSpectralAxis( ) const {
71  return has_spectral_axis;
72  }
74  return shape_;
75  }
77  return ra_range;
78  }
79  std::vector<std::string> raRangeAsStr( ) const {
80  return ra_range_str;
81  }
83  return dec_range;
84  }
85  std::vector<std::string> decRangeAsStr( ) const {
86  return dec_range_str;
87  }
88  size_t nBeams( ) const {
89  return restoring_beams.size( );
90  }
91  std::vector<std::vector<double> > restoringBeams( ) const;
92  std::vector<double> restoringBeam( size_t channel ) const {
93  return beam_as_vector(channel < restoring_beams.size( ) ? restoring_beams[channel] : restoring_beams[0]);
94  }
95  std::vector<std::string> restoringBeamAsStr( size_t channel ) const {
96  return beam_as_string_vector(channel < restoring_beams.size( ) ? restoring_beams[channel] : restoring_beams[0]);
97  }
98  std::vector<double> medianRestoringBeam( ) const;
99  std::vector<std::string> medianRestoringBeamAsStr( ) const;
100  casacore::Vector<double> freqRange( const std::string &units="" ) const;
101  const std::string &frequencyUnits( ) const {
102  return freq_units;
103  }
104 
105  const std::string &velocityUnits( ) const {
106  return velo_units;
107  }
108  const std::string &path( ) const {
109  return path_;
110  }
111 
112  const DisplayCoordinateSystem &cs( ) const { return cs_; }
113 
114  bool ok( ) const {
115  return status_ok;
116  }
117 
118  // export required DisplayCoordinateSystem functions instead of returning a DisplayCoordinateSystem reference...
119  int spectralAxisNumber() const {
120  return cs_.spectralAxisNumber( );
121  }
122 
123  const std::vector<double> &frequencies( ) const { return frequencies_; }
124  const std::vector<double> &velocities( ) const { return velocities_; }
125 
126  private:
127  std::vector<double> beam_as_vector( const casacore::GaussianBeam &beam ) const;
128  std::vector<std::string> beam_as_string_vector( const casacore::GaussianBeam &beam ) const;
129  void clear_state( );
130  void initialize_state( std::shared_ptr<casacore::ImageInterface<casacore::Float> > image );
131  void reset( std::shared_ptr<casacore::ImageInterface<casacore::Float> > image );
132  void reset( const std::string &path="" );
133  bool status_ok;
134  std::string path_;
137  std::string direction_type;
139  std::vector<double> frequencies_;
140  std::vector<double> velocities_;
141  std::string freq_units;
142  std::string velo_units;
144  std::vector<std::string> ra_range_str;
146  std::vector<std::string> dec_range_str;
147  std::vector<casacore::GaussianBeam> restoring_beams;
149  };
150  }
151 }
152 
153 namespace casa {
154 
155 std::ostream &operator<<( std::ostream &os, const casa::DisplayCoordinateSystem &cs );
156 
157 std::ostream &operator<<( std::ostream &os, const casa::DisplayCoordinateSystem &cs );
158  namespace viewer {
159  inline std::ostream &operator<<( std::ostream &os, const casa::DisplayCoordinateSystem &cs ) { return casa::operator<<(os,cs); }
160  }
161 }
162 
163 #endif
casacore::Vector< double > ra_range
int spectralAxisNumber() const
export required DisplayCoordinateSystem functions instead of returning a DisplayCoordinateSystem refe...
std::vector< casacore::GaussianBeam > restoring_beams
ostream & operator<<(ostream &os, const PageHeaderCache &cache)
std::ostream & operator<<(std::ostream &out, const casa::viewer::Position &pos)
Definition: Position.h:71
const std::vector< double > & velocities() const
const std::vector< double > & frequencies() const
const std::string & path() const
std::vector< std::string > dec_range_str
std::vector< std::string > medianRestoringBeamAsStr() const
const std::string & velocityUnits() const
casacore::Vector< double > dec_range
casacore::Vector< double > raRange() const
std::vector< std::vector< double > > restoringBeams() const
const std::string & directionType() const
Represents a Gaussian restoring beam associated with an image.
Definition: GaussianBeam.h:68
DisplayCoordinateSystem cs_
int spectralAxisNumber(bool doWorld=false) const
const casacore::Vector< casacore::Int > & shape() const
std::vector< double > frequencies_
const DisplayCoordinateSystem & cs() const
std::vector< std::string > restoringBeamAsStr(size_t channel) const
std::vector< double > beam_as_vector(const casacore::GaussianBeam &beam) const
std::vector< std::string > raRangeAsStr() const
const ImageProperties & operator=(const std::string &)
const std::string & frequencyUnits() const
This class provides a priori image information derived from the image itself.
std::vector< double > restoringBeam(size_t channel) const
casacore::Vector< casacore::Int > shape_
std::vector< std::string > beam_as_string_vector(const casacore::GaussianBeam &beam) const
void initialize_state(std::shared_ptr< casacore::ImageInterface< casacore::Float > > image)
std::vector< std::string > decRangeAsStr() const
void reset(std::shared_ptr< casacore::ImageInterface< casacore::Float > > image)
std::vector< double > velocities_
casacore::Vector< double > decRange() const
std::vector< std::string > ra_range_str
std::vector< double > medianRestoringBeam() const
casacore::Vector< double > freqRange(const std::string &units="") const
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42