casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageMetaDataRW.h
Go to the documentation of this file.
1 //# Copyright (C) 2009
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 //# $Id$
26 
27 #ifndef IMAGEANALYSIS_IMAGEMETADATARW_H
28 #define IMAGEANALYSIS_IMAGEMETADATARW_H
29 
31 
32 #include <casa/aips.h>
33 #include <memory>
34 
35 namespace casa {
36 
37 // <summary>
38 // A class in which to store and allow read-write access to image metadata.
39 // </summary>
40 
41 // <use visibility=export>
42 
43 // <reviewed reviewer="" date="" tests="" demos="">
44 // </reviewed>
45 
46 // <prerequisite>
47 // <li> <linkto class=casacore::ImageInterface>ImageInterface</linkto>
48 // </prerequisite>
49 
50 // <etymology>
51 // The ImageMetaDataRW class name is derived from its role as holding image metadata
52 // and providing read-write access.
53 // </etymology>
54 
55 // <synopsis>
56 // The ImageMetaDataRW object is meant to allow access to image metadata (eg, shape,
57 // coordinate system info such as spectral and polarization axes numbers, etc). It allows
58 // write access to some values. This class contains the writable methods and extends
59 // ImageMetaData which contains the read-only methods.
60 // </synopsis>
61 
62 // <example>
63 // Construct an object of this class by passing the associated image to the constructor.
64 // <srcblock>
65 // casacore::PagedImage<casacore::Float> myImage("myImage");
66 // ImageMetaDataRW<casacore::Float> myImageMetaData(myImage);
67 // </srcblock>
68 // </example>
69 
70 // <motivation>
71 // This class is meant to provide an object-oriented interface for accessing
72 // image metadata without polluting the casacore::ImageInterface and CoordinateSystem
73 // classes with these methods.
74 // </motivation>
75 
76 template <class T> class ImageMetaDataRW : public ImageMetaDataBase<T> {
77 
78 public:
79 
80  ImageMetaDataRW() = delete;
81 
82  ImageMetaDataRW(SPIIT image);
83 
84  // remove, if possible, the specified parameter. Returns true if removal
85  // was successful.
86  casacore::Bool remove(const casacore::String& key);
87 
88  // remove the specified mask. If the empty string is given, all masks will
89  // be removed. Returns true if successful, false otherwise or if the specfied
90  // mask does not exist.
92 
94 
95  // add a key-value pair
97 
98  // set (update) the value associated with the key.
99  casacore::Bool set(const casacore::String& key, const casacore::ValueHolder& value);
100 
101  // set the coordinate system from a Record.
102  void setCsys(const casacore::Record& coordinates);
103 
104 protected:
105  const casacore::ImageInfo& _getInfo() const;
106 
107  const casacore::CoordinateSystem& _getCoords() const;
108 
110 
112 
114 
116 
118 
119  std::vector<casacore::Quantity> _getIncrements() const;
120 
122 
124 
126 
128 
130 
132 
134 
136 
138 
140 
142 
144 
146 
147 private:
149 
150  // These are mutable because they are only to be set once and
151  // then cached. If this contract is broken, and they are set elsewhere
152  // defects will likely occur.
161  mutable std::vector<casacore::Quantity> _refVal, _increment;
163 
164  std::unique_ptr<casacore::CoordinateSystem> _makeCoordinateSystem(
165  const casacore::Record& coordinates, const casacore::IPosition& shape
166  );
167 
168  void _setCoordinateValue(const casacore::String& key, const casacore::ValueHolder& value);
169 
170  casacore::String _getString(const casacore::String& key, const casacore::ValueHolder& value) const;
171 
172  void _setUserDefined(const casacore::String& key, const casacore::ValueHolder& v);
173 
175 
177 
179 
180  const casacore::TableRecord _miscInfo() const;
181 
182  void _setMiscInfo(const casacore::TableRecord& rec);
183 
184  casacore::Bool _hasRegion(const casacore::String& maskName) const;
185 
187 
188  casacore::Bool _isWritable() const;
189 
190  template <class U, class V> void _modHistory(
191  const casacore::String& func, const casacore::String& keyword,
192  const U& oldVal, const V& newVal
193  );
194 
195  template <class U> void _addHistory(
196  const casacore::String& func, const casacore::String& keyword, const U& newVal
197  );
198 
199  void _toHistory(const casacore::String& origin, const casacore::String& record);
200 
201  template <class U> static casacore::String _quotify(const U& val);
202 };
203 
204 }
205 
206 #ifndef AIPS_NO_TEMPLATE_SRC
207 #include <imageanalysis/ImageAnalysis/ImageMetaDataRW.tcc>
208 #endif //# AIPS_NO_TEMPLATE_SRC
209 
210 #endif
casacore::String _bunit
These are mutable because they are only to be set once and then cached.
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::GaussianBeam _beam
casacore::Vector< casacore::String > _getStokes() const
casacore::Bool removeMask(const casacore::String &maskName)
remove the specified mask.
void _setCoordinateValue(const casacore::String &key, const casacore::ValueHolder &value)
const casacore::CoordinateSystem & _getCoords() const
casacore::String _reffreqtype
casacore::String _getProjection() const
casacore::Quantity _getRestFrequency() const
casacore::Bool _setImageInfo(const casacore::ImageInfo &info)
void _modHistory(const casacore::String &func, const casacore::String &keyword, const U &oldVal, const V &newVal)
std::vector< casacore::Quantity > _increment
casacore::Record _stats
casacore::Vector< casacore::String > _getAxisUnits() const
casacore::String _getImType() const
void setCsys(const casacore::Record &coordinates)
set the coordinate system from a Record.
std::vector< casacore::Quantity > _getIncrements() const
casacore::String _projection
casacore::Vector< casacore::String > _masks
casacore::MEpoch _obsdate
casacore::String _telescope
void _toHistory(const casacore::String &origin, const casacore::String &record)
casacore::Vector< casacore::Double > _getRefPixel() const
casacore::Vector< casacore::String > _axisUnits
casacore::Record _header
std::unique_ptr< casacore::CoordinateSystem > _makeCoordinateSystem(const casacore::Record &coordinates, const casacore::IPosition &shape)
casacore::Bool set(const casacore::String &key, const casacore::ValueHolder &value)
set (update) the value associated with the key.
const casacore::ImageInfo & _getInfo() const
void _addHistory(const casacore::String &func, const casacore::String &keyword, const U &newVal)
casacore::String _getBrightnessUnit() const
A Measure: instant in time.
Definition: MEpoch.h:104
casacore::String _equinox
Represents a Gaussian restoring beam associated with an image.
Definition: GaussianBeam.h:68
casacore::String _getString(const casacore::String &key, const casacore::ValueHolder &value) const
casacore::String _imtype
void _setUserDefined(const casacore::String &key, const casacore::ValueHolder &v)
casacore::String _object
#define SPIIT
Definition: ImageTypedefs.h:34
casacore::String _getObject() const
casacore::Bool _setUnit(const casacore::String &unit)
void _setMiscInfo(const casacore::TableRecord &rec)
casacore::String _getTelescope() const
casacore::Bool add(const casacore::String &key, const casacore::ValueHolder &value)
add a key-value pair
A holder for a value of any basic Casacore data type.
Definition: ValueHolder.h:67
casacore::String _getRefFreqType() const
casacore::String _getEquinox() const
std::vector< casacore::Quantity > _refVal
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Vector< casacore::String > _stokes
casacore::Record _getStatistics() const
casacore::Vector< casacore::String > _getMasks() const
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
A hierarchical collection of named fields of various types.
Definition: TableRecord.h:182
casacore::Bool _hasRegion(const casacore::String &maskName) const
casacore::Vector< casacore::Quantity > _getRefValue() const
virtual Origin origin() const =0
ABSTRACT METHODS //.
casacore::Quantity _restFreq
casacore::String _observer
casacore::Vector< casacore::String > _getAxisNames() const
const casacore::TableRecord _miscInfo() const
casacore::GaussianBeam _getBeam() const
casacore::Vector< casacore::String > _axisNames
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::Vector< casacore::Double > _refPixel
casacore::String _getObserver() const
static casacore::String _quotify(const U &val)
casacore::Bool _setCsys(const casacore::CoordinateSystem &csys)
A class in which to store and allow read-write access to image metadata.
Miscellaneous information related to an image.
Definition: ImageInfo.h:92
casacore::MEpoch _getObsDate() const
static casacore::Quantity _getQuantity(const casacore::ValueHolder &v)
casacore::Record toRecord(casacore::Bool verbose) const
convert the header info to a casacore::Record and list to logger if verbose=true
Interconvert pixel and world coordinates.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
casacore::Bool _isWritable() const