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