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