casacore
Loading...
Searching...
No Matches
StokesCoordinate.h
Go to the documentation of this file.
1//# StokesCoordinate.h: Interconvert between pixel number and Stokes 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_STOKESCOORDINATE_H
28#define COORDINATES_STOKESCOORDINATE_H
29
30#include <casacore/casa/aips.h>
31#include <casacore/coordinates/Coordinates/Coordinate.h>
32#include <casacore/measures/Measures/Stokes.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 Stokes value.
42// </summary>
43
44// <use visibility=export>
45
46// <reviewed reviewer="Peter Barnes" date="1999/12/24" tests="tStokesCoordinate">
47// </reviewed>
48//
49// <prerequisite>
50// <li> <linkto class=Coordinate>Coordinate</linkto>
51// <li> <linkto class=Stokes>Stokes</linkto>
52// </prerequisite>
53//
54// <synopsis>
55// Although not really a "coordinate", an axis where pixel numbers are used
56// for different Stokes values is in wide use. The StokesCoordinate
57// is a poor fit to the Coordinate polymorphic model.
58// You will probably find that if you try to use the Coordinate
59// classes polymorphically, that StokesCoordinate will cause you
60// to break the polymorphism. I.e. you may have to deal with
61// a specific StokesCoordinate)
62//
63// The StokesCoordinate just maintains a list (given in the constructor) of
64// possibly non-monotonic Stokes values. The values of the list are the
65// world values (they are values from the Stokes::StokesTypes enum).
66// Thus world = list[pixel] where pixel is the pixel coordinate (0,1, ...)
67//
68// This means that concepts such as reference pixel, reference value,
69// increment etc are meaningless for StokesCoordinate. You can recover these
70// these attributes, but the functions to set these attributes have no effect.
71//
72// Note also that for the StokesCoordinate relative world coordinates are defined to be the
73// as absolute, since there is no meaning for a relative Stokes world value (e.g.
74// what is XX -RL ?? Relative pixel coordinates are defined.
75//
76// </synopsis>
77//
78// <note role=caution>
79// All pixel coordinates are zero relative.
80// </note>
81//
82// <example>
83// In this example we create a StokesCoordinate housing IQUV
84// <srcblock>
85// Vector<Int> iquv(4);
86// iquv(0) = Stokes::I; iquv(1) = Stokes::Q;
87// iquv(2) = Stokes::U; iquv(3) = Stokes::V;
88// StokesCoordinate stokes(iquv);
89// </srcblock>
90// </example>
91//
92// <motivation>
93// It is conventional to make a pseudo-axis of Stokes parameters.
94// Another approach is to make an image type called Stokes.
95// </motivation>
96//
97// <todo asof="1997/1/14">
98// <li> This could probably be generalized into an "enumeration axis" class.
99// </todo>
100//
101
103{
104public:
105
106 // The length of whichStokes is the length of the axis, and the values
107 // define which stokes are in which axis value. Often the vector will be of
108 // length 4 and will contain Stokes::I, Q, U and V, however any valid value
109 // from the stokes enum may be used. The values may not repeat however, e.g.
110 // only one axis position may contain "I".
111 explicit StokesCoordinate(const Vector<Int> &whichStokes);
112
113 // Copy constructor (copy semantics)
115
116 // Assignment (copy semantics)
118
119 // Destructor.
121
122 // Returns Coordinates::STOKES.
123 virtual Coordinate::Type type() const;
124
125 // Always returns the String "Stokes".
126 virtual String showType() const;
127
128 // Always returns 1.
129 // <group>
130 virtual uInt nPixelAxes() const;
131 virtual uInt nWorldAxes() const;
132 // </group>
133
134 // Convert a pixel to a world coordinate or vice versa. Returns True
135 // if the conversion succeeds, otherwise it returns False and method
136 // <src>errorMessage</src> returns an error message.
137 // The output vectors are appropriately resized before use.
138 // The Bool parameter in toWorld() is ignored as this coordinate does not
139 // support a conversion layer frame.
140 // <group>
141 virtual Bool toWorld(Vector<Double> &world,
142 const Vector<Double> &pixel, Bool=True) const;
143 virtual Bool toPixel(Vector<Double> &pixel,
144 const Vector<Double> &world) const;
145 // </group>
146
147 // Interconvert between pixel and world as a Stokes type.
148 // It returns False if no conversion could be done.
149 // <group>
152 // </group>
153
154 // Interconvert between world stored as a Double and world stored as
155 // a Stokes type. Since these functions are static, any valid
156 // Stokes type can be used. The second function returns
157 // Stokes::Undefined if world is illegal.
158 // <group>
161 // </group>
162
163 // Make absolute coordinates relative and vice-versa.
164 // For the StokesCoordinate relative world coordinates are defined to be the
165 // same as absolute world coordinates. Relative pixels do have meaning
166 // and are implemented (rel = abs - refPix)
167 // <group>
168 virtual void makePixelRelative (Vector<Double>& pixel) const;
169 virtual void makePixelAbsolute (Vector<Double>& pixel) const;
170 virtual void makeWorldRelative (Vector<Double>& world) const;
171 virtual void makeWorldAbsolute (Vector<Double>& world) const;
172 // </group>
173
174
175 // Get the Stokes values (Stokes::StokesType) that we constructed
176 // with into a vector
178
179 // Get the stokes string representations
181
182 // Set a new vector of Stokes values (a vector of Stokes::StokesType)
183 void setStokes (const Vector<Int> &whichStokes);
184
185 // Report the value of the requested attribute.
186 // <group>
190 virtual Vector<Double> increment() const;
192 // </group>
193
194 // Set the value of the requested attribute. For the StokesCoordinate,
195 // these have no effect (always return True) except for setWorldAxisNames.
196 // <group>
197 virtual Bool setWorldAxisNames(const Vector<String> &names);
198 virtual Bool setReferencePixel(const Vector<Double> &refPix);
200 virtual Bool setIncrement(const Vector<Double> &inc) ;
201 virtual Bool setReferenceValue(const Vector<Double> &refval) ;
202 // </group>
203
204 // The set function has no effect as the units must be empty for a StokesCoordinate
205 // Always returns True
206 // <group>
207 virtual Bool setWorldAxisUnits(const Vector<String> &units);
209 // </group>
210
211 // Set the world min and max ranges, for use in function <src>toMix</src>,
212 // for a lattice of the given shape (for this coordinate).
213 // The implementation here gives world coordinates at the start
214 // and end of the Stokes axis.
215 // The output vectors are resized. Returns False if fails (and
216 // then <src>setDefaultWorldMixRanges</src> generates the ranges)
217 // with a reason in <src>errorMessage()</src>.
218 // The <src>setDefaultWorldMixRanges</src> function
219 // gives you [-1e99->1e99].
220 // <group>
223 //</group>
224
225 // Format a StokesCoordinate world value with the common format
226 // interface (refer to the base class <linkto class=Coordinate>Coordinate</linkto>
227 // for basics.
228 //
229 // A StokesCoordinate is formatted differently from other Coordinate
230 // types. The world value is converted to the character representation
231 // as defined by the enum <src>StokesTypes</src> in the class
232 // <linkto class=Stokes>Stokes</linkto>.
233 //
234 // Thus, all other arguments to do with formatting and precision are ignored.
235 virtual String format(String& units,
237 Double worldValue,
238 uInt worldAxis,
239 Bool isAbsolute=True,
240 Bool showAsAbsolute=True,
241 Int precision = -1, Bool usePrecForMixed=False) const;
242
243 // Comparison function. Any private Double data members are compared
244 // with the specified fractional tolerance. Don't compare on the specified
245 // axes in the Coordinate. If the comparison returns False, method
246 // errorMessage returns a message about why.
247 // <group>
248 virtual Bool near(const Coordinate& other,
249 Double tol=1e-6) const;
250 virtual Bool near(const Coordinate& other,
251 const Vector<Int>& excludeAxes,
252 Double tol=1e-6) const;
253 // </group>
254
255 // Save the StokesCoordinate into the supplied record using the supplied field name.
256 // The field must not exist, otherwise <src>False</src> is returned.
257 virtual Bool save(RecordInterface &container,
258 const String &fieldName) const;
259
260 // Recover the StokesCoordinate from a record.
261 // A null pointer means that the restoration did not succeed - probably
262 // because fieldName doesn't exist or doesn't contain a CoordinateSystem.
263 static StokesCoordinate* restore(const RecordInterface &container,
264 const String &fieldName);
265
266 // Make a copy of the StokesCoordinate using new. The caller is responsible for calling
267 // delete.
268 virtual Coordinate *clone() const;
269
270
271 // Comparison only made for specified axes in this and other Coordinate
272 virtual Bool doNearPixel (const Coordinate& other,
273 const Vector<Bool>& thisAxes,
274 const Vector<Bool>& otherAxes,
275 Double tol=1.0e-6) const;
276
277private:
278
279 Bool toWorld(Double& world, const Double pixel) const;
280 Bool toPixel(Double& pixel, const Double world) const;
281//
283
284 // Keep these for subimaging purposes.
289
290 // Undefined and inaccessible
292};
293
294} //# NAMESPACE CASACORE - END
295
296
297#endif
298
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
void setStokes(const Vector< Int > &whichStokes)
Set a new vector of Stokes values (a vector of Stokes::StokesType)
static StokesCoordinate * restore(const RecordInterface &container, const String &fieldName)
Recover the StokesCoordinate from a record.
virtual Bool setReferencePixel(const Vector< Double > &refPix)
virtual void makeWorldRelative(Vector< Double > &world) const
virtual Coordinate * clone() const
Make a copy of the StokesCoordinate using new.
virtual uInt nPixelAxes() const
Always returns 1.
virtual Bool setWorldAxisNames(const Vector< String > &names)
Set the value of the requested attribute.
virtual Matrix< Double > linearTransform() const
Bool toWorld(Stokes::StokesTypes &stokes, Int pixel) const
virtual String showType() const
Always returns the String "Stokes".
Vector< Int > stokes() const
Get the Stokes values (Stokes::StokesType) that we constructed with into a vector.
virtual void setDefaultWorldMixRanges()
virtual Bool setWorldAxisUnits(const Vector< String > &units)
The set function has no effect as the units must be empty for a StokesCoordinate Always returns True.
Vector< String > stokesStrings() const
Get the stokes string representations.
virtual void makePixelAbsolute(Vector< Double > &pixel) const
StokesCoordinate()
Undefined and inaccessible.
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< Double > increment() const
static Stokes::StokesTypes toWorld(Double world)
static Double toWorld(Stokes::StokesTypes stokes)
Interconvert between world stored as a Double and world stored as a Stokes type.
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 StokesCoordinate world value with the common format interface (refer to the base class Coord...
StokesCoordinate(const Vector< Int > &whichStokes)
The length of whichStokes is the length of the axis, and the values define which stokes are in which ...
Bool toPixel(Int &pixel, Stokes::StokesTypes stokes) const
Interconvert between pixel and world as a Stokes type.
virtual Vector< Double > referenceValue() const
Bool toPixel(Double &pixel, const Double world) const
virtual ~StokesCoordinate()
Destructor.
virtual Bool setIncrement(const Vector< Double > &inc)
virtual Vector< Double > referencePixel() const
virtual Bool near(const Coordinate &other, Double tol=1e-6) const
Comparison function.
virtual Vector< String > worldAxisUnits() const
virtual Vector< String > worldAxisNames() const
Report the value of the requested attribute.
virtual void makeWorldAbsolute(Vector< Double > &world) const
virtual Coordinate::Type type() const
Returns Coordinates::STOKES.
virtual Bool save(RecordInterface &container, const String &fieldName) const
Save the StokesCoordinate into the supplied record using the supplied field name.
virtual Bool toPixel(Vector< Double > &pixel, const Vector< Double > &world) const
virtual uInt nWorldAxes() const
virtual void makePixelRelative(Vector< Double > &pixel) const
Make absolute coordinates relative and vice-versa.
StokesCoordinate(const StokesCoordinate &other)
Copy constructor (copy semantics)
virtual Bool setReferenceValue(const Vector< Double > &refval)
virtual Bool setLinearTransform(const Matrix< Double > &xform)
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.
virtual Bool near(const Coordinate &other, const Vector< Int > &excludeAxes, Double tol=1e-6) const
Bool toWorld(Double &world, const Double pixel) const
StokesCoordinate & operator=(const StokesCoordinate &other)
Assignment (copy semantics)
virtual Bool toWorld(Vector< Double > &world, const Vector< Double > &pixel, Bool=True) const
Convert a pixel to a world coordinate or vice versa.
Double crval_p
Keep these for subimaging purposes.
StokesTypes
The Stokes types are defined by this enum.
Definition Stokes.h:64
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