casacore
QualityCoordinate.h
Go to the documentation of this file.
1//# QualityCoordinate.h: Interconvert between pixel number and Quality value.
2//# Copyright (C) 1997,1998,1999,2000,2001,2002,2003,2004
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//#
27//# $Id$
28
29
30#ifndef COORDINATES_QUALITYCOORDINATE_H
31#define COORDINATES_QUALITYCOORDINATE_H
32
33#include <casacore/casa/aips.h>
34#include <casacore/coordinates/Coordinates/Coordinate.h>
35#include <casacore/measures/Measures/Quality.h>
36#include <casacore/casa/Containers/Block.h>
37#include <casacore/casa/Arrays/Vector.h>
38
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41
42
43// <summary>
44// Interconvert between pixel and Quality value.
45// </summary>
46
47// <use visibility=export>
48
49// <reviewed tests="tQualityCoordinate">
50// </reviewed>
51//
52// <prerequisite>
53// <li> <linkto class=Coordinate>Coordinate</linkto>
54// <li> <linkto class=Quality>Quality</linkto>
55// </prerequisite>
56//
57// <synopsis>
58// </synopsis>
59//
60// <note role=caution>
61// All pixel coordinates are zero relative.
62// </note>
63//
64// <example>
65// In this example we create a QualityCoordinate containing 'DATA'
66// and 'ERROR'
67// <srcblock>
68// Vector<Int> newQuality(2);
69// newQuality(0) = Quality::DATA;
70// newQuality(1) = Quality::ERROR;
71// qual = QualityCoordinate(newQuality);
72// </srcblock>
73// </example>
74//
75// <motivation>
76// </motivation>
77//
78
80{
81public:
82
83 // The length of whichQuality is the length of the axis, and the values
84 // define which quality are in which axis value. Often the vector will be of
85 // length 2 and will contain Quality::DATA, and ERROR.
86 explicit QualityCoordinate(const Vector<Int> &whichQuality);
87
88 // Copy constructor (copy semantics)
90
91 // Assignment (copy semantics)
93
94 // Destructor.
96
97 // Returns Coordinates::QUALITY.
98 virtual Coordinate::Type type() const;
99
100 // Always returns the String "Quality".
101 virtual String showType() const;
102
103 // Always returns 1.
104 // <group>
105 virtual uInt nPixelAxes() const;
106 virtual uInt nWorldAxes() const;
107 // </group>
108
109 // Convert a pixel to a world coordinate or vice versa. Returns True
110 // if the conversion succeeds, otherwise it returns False and method
111 // <src>errorMessage</src> returns an error message.
112 // The output vectors are appropriately resized before use.
113 // The Bool parameter in toWorld() is ignored as this coordinate does not
114 // support a conversion layer frame.
115 // <group>
116 virtual Bool toWorld(Vector<Double> &world,
117 const Vector<Double> &pixel, Bool=True) const;
118 virtual Bool toPixel(Vector<Double> &pixel,
119 const Vector<Double> &world) const;
120 // </group>
121
122 // Interconvert between pixel and world as a Quality type.
123 // It returns False if no conversion could be done.
124 // <group>
127 // </group>
128
129 // Interconvert between world stored as a Double and world stored as
130 // a Quality type. Since these functions are static, any valid
131 // Quality type can be used. The second function returns
132 // Quality::Undefined if world is illegal.
133 // <group>
136 // </group>
137
138 // Make absolute coordinates relative and vice-versa.
139 // For the QualityCoordinate relative world coordinates are defined to be the
140 // same as absolute world coordinates. Relative pixels do have meaning
141 // and are implemented (rel = abs - refPix)
142 // <group>
143 virtual void makePixelRelative (Vector<Double>& pixel) const;
144 virtual void makePixelAbsolute (Vector<Double>& pixel) const;
145 virtual void makeWorldRelative (Vector<Double>& world) const;
146 virtual void makeWorldAbsolute (Vector<Double>& world) const;
147 // </group>
148
149
150 // Get the Quality values (Quality::QualityType) that we constructed
151 // with into a vector
153
154 // Set a new vector of Quality values (a vector of Quality::QualityType)
155 void setQuality (const Vector<Int> &whichQuality);
156
157 // Report the value of the requested attribute.
158 // <group>
162 virtual Vector<Double> increment() const;
164 // </group>
165
166 // Set the value of the requested attribute. For the QualityCoordinate,
167 // these have no effect (always return True) except for setWorldAxisNames.
168 // <group>
169 virtual Bool setWorldAxisNames(const Vector<String> &names);
170 virtual Bool setReferencePixel(const Vector<Double> &refPix);
172 virtual Bool setIncrement(const Vector<Double> &inc) ;
173 virtual Bool setReferenceValue(const Vector<Double> &refval) ;
174 // </group>
175
176 // The set function has no effect as the units must be empty for a QualityCoordinate
177 // Always returns True
178 // <group>
179 virtual Bool setWorldAxisUnits(const Vector<String> &units);
181 // </group>
182
183 // Set the world min and max ranges, for use in function <src>toMix</src>,
184 // for a lattice of the given shape (for this coordinate).
185 // The implementation here gives world coordinates at the start
186 // and end of the Quality axis.
187 // The output vectors are resized. Returns False if fails (and
188 // then <src>setDefaultWorldMixRanges</src> generates the ranges)
189 // with a reason in <src>errorMessage()</src>.
190 // The <src>setDefaultWorldMixRanges</src> function
191 // gives you [-1e99->1e99].
192 // <group>
195 //</group>
196
197 // Format a QualityCoordinate world value with the common format
198 // interface (refer to the base class <linkto class=Coordinate>Coordinate</linkto>
199 // for basics.
200 //
201 // A QualityCoordinate is formatted differently from other Coordinate
202 // types. The world value is converted to the character representation
203 // as defined by the enum <src>QualityTypes</src> in the class
204 // <linkto class=Quality>Quality</linkto>.
205 //
206 // Thus, all other arguments to do with formatting and precision are ignored.
207 virtual String format(String& units,
209 Double worldValue,
210 uInt worldAxis,
211 Bool isAbsolute=True,
212 Bool showAsAbsolute=True,
213 Int precision = -1, Bool usePrecForMixed=False) const;
214
215 // Comparison function. Any private Double data members are compared
216 // with the specified fractional tolerance. Don't compare on the specified
217 // axes in the Coordinate. If the comparison returns False, method
218 // errorMessage returns a message about why.
219 // <group>
220 virtual Bool near(const Coordinate& other,
221 Double tol=1e-6) const;
222 virtual Bool near(const Coordinate& other,
223 const Vector<Int>& excludeAxes,
224 Double tol=1e-6) const;
225 // </group>
226
227 // Save the QualityCoordinate into the supplied record using the supplied field name.
228 // The field must not exist, otherwise <src>False</src> is returned.
229 virtual Bool save(RecordInterface &container,
230 const String &fieldName) const;
231
232 // Recover the QualityCoordinate from a record.
233 // A null pointer means that the restoration did not succeed - probably
234 // because fieldName doesn't exist or doesn't contain a CoordinateSystem.
235 static QualityCoordinate* restore(const RecordInterface &container,
236 const String &fieldName);
237
238 // Make a copy of the QualityCoordinate using new. The caller is responsible for calling
239 // delete.
240 virtual Coordinate *clone() const;
241
242
243 // Comparison only made for specified axes in this and other Coordinate
244 virtual Bool doNearPixel (const Coordinate& other,
245 const Vector<Bool>& thisAxes,
246 const Vector<Bool>& otherAxes,
247 Double tol=1.0e-6) const;
248
249private:
250
251 Bool toWorld(Double& world, const Double pixel) const;
252 Bool toPixel(Double& pixel, const Double world) const;
253//
255
256 // Keep these for subimaging purposes.
261
262 // Undefined and inaccessible
264};
265
266} //# NAMESPACE CASACORE - END
267
268
269#endif
270
Type
This enum lists the types of the derived classes.
Definition: Coordinate.h:144
formatType
This enum is used for formatting world values into Strings.
Definition: Coordinate.h:162
Vector< Int > quality() const
Get the Quality values (Quality::QualityType) that we constructed with into a vector.
static Quality::QualityTypes toWorld(Double world)
virtual void makeWorldRelative(Vector< Double > &world) const
Double crval_p
Keep these for subimaging purposes.
virtual Bool toPixel(Vector< Double > &pixel, const Vector< Double > &world) const
virtual Vector< Double > referencePixel() const
virtual Vector< Double > referenceValue() const
static QualityCoordinate * restore(const RecordInterface &container, const String &fieldName)
Recover the QualityCoordinate from a record.
virtual ~QualityCoordinate()
Destructor.
Bool toWorld(Double &world, const Double pixel) const
virtual Bool toWorld(Vector< Double > &world, const Vector< Double > &pixel, Bool=True) const
Convert a pixel to a world coordinate or vice versa.
virtual Bool save(RecordInterface &container, const String &fieldName) const
Save the QualityCoordinate into the supplied record using the supplied field name.
Bool toPixel(Double &pixel, const Double world) const
virtual uInt nPixelAxes() const
Always returns 1.
virtual String format(String &units, Coordinate::formatType format, Double worldValue, uInt worldAxis, Bool isAbsolute=True, Bool showAsAbsolute=True, Int precision=-1, Bool usePrecForMixed=False) const
Format a QualityCoordinate world value with the common format interface (refer to the base class Coor...
virtual Bool setWorldMixRanges(const IPosition &shape)
Set the world min and max ranges, for use in function toMix, for a lattice of the given shape (for th...
virtual Vector< String > worldAxisNames() const
Report the value of the requested attribute.
virtual Bool setWorldAxisNames(const Vector< String > &names)
Set the value of the requested attribute.
QualityCoordinate(const Vector< Int > &whichQuality)
The length of whichQuality is the length of the axis, and the values define which quality are in whic...
virtual Vector< String > worldAxisUnits() const
virtual Bool setLinearTransform(const Matrix< Double > &xform)
virtual Bool near(const Coordinate &other, Double tol=1e-6) const
Comparison function.
void setQuality(const Vector< Int > &whichQuality)
Set a new vector of Quality values (a vector of Quality::QualityType)
virtual Bool setWorldAxisUnits(const Vector< String > &units)
The set function has no effect as the units must be empty for a QualityCoordinate Always returns True...
QualityCoordinate()
Undefined and inaccessible.
virtual String showType() const
Always returns the String "Quality".
virtual Bool doNearPixel(const Coordinate &other, const Vector< Bool > &thisAxes, const Vector< Bool > &otherAxes, Double tol=1.0e-6) const
Comparison only made for specified axes in this and other Coordinate.
Bool toWorld(Quality::QualityTypes &quality, Int pixel) const
virtual Matrix< Double > linearTransform() const
virtual Bool near(const Coordinate &other, const Vector< Int > &excludeAxes, Double tol=1e-6) const
virtual Bool setReferencePixel(const Vector< Double > &refPix)
static Double toWorld(Quality::QualityTypes quality)
Interconvert between world stored as a Double and world stored as a Quality type.
virtual void makePixelRelative(Vector< Double > &pixel) const
Make absolute coordinates relative and vice-versa.
virtual Bool setReferenceValue(const Vector< Double > &refval)
virtual Vector< Double > increment() const
QualityCoordinate(const QualityCoordinate &other)
Copy constructor (copy semantics)
virtual Bool setIncrement(const Vector< Double > &inc)
virtual void setDefaultWorldMixRanges()
virtual Coordinate * clone() const
Make a copy of the QualityCoordinate using new.
virtual uInt nWorldAxes() const
Bool toPixel(Int &pixel, Quality::QualityTypes quality) const
Interconvert between pixel and world as a Quality type.
virtual Coordinate::Type type() const
Returns Coordinates::QUALITY.
virtual void makePixelAbsolute(Vector< Double > &pixel) const
virtual void makeWorldAbsolute(Vector< Double > &world) const
QualityCoordinate & operator=(const QualityCoordinate &other)
Assignment (copy semantics)
String: the storage and methods of handling collections of characters.
Definition: String.h:225
const Double e
e and functions thereof:
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
unsigned int uInt
Definition: aipstype.h:51
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition: ExprNode.h:1987
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43
double Double
Definition: aipstype.h:55