casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AxesSpecifier.h
Go to the documentation of this file.
1 //# AxesSpecifier.h: Specification of axes to keep or remove
2 //# Copyright (C) 2000
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 #ifndef CASA_AXESSPECIFIER_H
30 #define CASA_AXESSPECIFIER_H
31 
32 
33 //# Includes
34 #include <casacore/casa/aips.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 
42 
43 // <summary>
44 // Specification of axes to keep or remove
45 // </summary>
46 
47 // <use visibility=export>
48 
49 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tAxesSpecifier.cc" demos="">
50 // </reviewed>
51 
52 // <prerequisite>
53 // <li> <linkto class="IPosition">IPosition</linkto>
54 // </prerequisite>
55 
56 // <synopsis>
57 // AxesSpecifier makes it possible to specify which axes should
58 // be used in a shape. Degenerate axes (i.e. axes with length 0)
59 // can be thrown away which makes it possible to reduce the
60 // dimensionality of an array. All degenerate axes can be thrown
61 // away, but one can also specify which ones should be kept.
62 // <p>
63 // Another option of this class is to reorder the axes, thus to
64 // make the axes of a lattice appear in a different order.
65 // This can be useful when two images with diferent axes orders
66 // have to be combined.
67 // <p>
68 // When an AxesSpecifier has to be used for a lattice, the lattice's
69 // shape has to be applied to the AxesSpecifier. The result is
70 // a <linkto class=AxesMapping>AxesMapping</linkto> object.
71 // This object is (for example) used internally in the
72 // <linkto class=SubLattice>SubLattice</linkto> class to know how
73 // to map the axes form the original lattice to the sublattice.
74 // <note role=caution>
75 // Reordering axes is not supported (yet) by the other Casacore classes
76 // like Lattices and Images.
77 // </note>
78 // </synopsis>
79 
80 // <example>
81 // This example tells that all degenerate axes have to be kept.
82 // The axes are reordered to 1,0,2. Thus the first and second axes are
83 // swapped.
84 // <srcblock>
85 // AxesSpecifier spec(True, IPosition(3,1,0,2));
86 // AxesMapping map = spec.apply (IPosition(3,4,1,5));
87 // AlwaysAssertExit (map.posToNew (IPosition(3,2,0,3)) == IPosition(3,0,2,3));
88 // AlwaysAssertExit (map.posToOld (IPosition(3,0,2,3)) == IPosition(3,2,0,3));
89 //
90 // The following specification would have the same effect, because the
91 // unspecified axes are kept in their natural order.
92 // AxesSpecifier spec(True, IPosition(1,1));
93 // </srcblock>
94 //
95 // The same example as above, but now degenerated axes are removed.
96 // Note that because the second axis is removed, the third axis now
97 // get the second axis, thus gets swapped with the first axis.
98 // <br>Also note the difference between the functions <src>posToOld</src>
99 // and <src>shapeToOld</src>.
100 // <srcblock>
101 // AxesSpecifier spec(False, IPosition(1,1));
102 // AxesMapping map = spec.apply (IPosition(3,4,1,5));
103 // AlwaysAssertExit (map.posToNew (IPosition(3,2,0,3)) == IPosition(2,3,2));
104 // AlwaysAssertExit (map.posToOld (IPosition(3,3,2)) == IPosition(3,2,0,3);
105 // AlwaysAssertExit (map.shapeToOld (IPosition(3,3,2)) == IPosition(3,2,1,3);
106 // </srcblock>
107 // </example>
108 
109 //# <todo asof="yyyy/mm/dd">
110 //# </todo>
111 
113 {
114 public:
115  // The default constructor keeps all axes.
116  AxesSpecifier();
117 
118  // Tell if no or all degenerate axes have to be removed.
119  explicit AxesSpecifier (Bool keepDegenerate);
120 
121  // Tell if no or all degenerate axes have to be removed.
122  // <br>The argument <src>axisPath</src> makes it possible to specify in
123  // which order the KEPT axes have to be used. Unspecified axes are
124  // appended to the end. It gives a means to reorder the axes of a lattice.
125  // <br>E.g. for a 4-dim lattice axisPath [2,0] means axis order [2,0,1,3].
126  explicit AxesSpecifier (Bool keepDegenerate, const IPosition& axisPath);
127 
128  // Tell which (degenerate) axes have to be kept.
129  // Non-degenerate axes will always be kept.
130  explicit AxesSpecifier (const IPosition& keepAxes);
131 
132  // The argument <src>keepAxes</src> tells which degenerate axes have
133  // to be kept. Non-degenerate axes will always be kept.
134  // <br>The argument <src>axisPath</src> makes it possible to specify in
135  // which order the KEPT axes have to be used. Unspecified axes are
136  // appended to the end. It gives a means to reorder the axes of a lattice.
137  // <br>E.g. for a 4-dim lattice axisPath [2,0] means axis order [2,0,1,3].
138  AxesSpecifier (const IPosition& keepAxes, const IPosition& axisPath);
139 
140  // Copy constructor (copy semantics).
141  AxesSpecifier(const AxesSpecifier& other);
142 
143  ~AxesSpecifier();
144 
145  // Assignment (copy semantics).
146  // This and that do not have to have the same length.
147  AxesSpecifier& operator= (const AxesSpecifier& other);
148 
149  // Apply the specification to a shape.
150  // It returns an <linkto class=AxesMapping>AxesMapping</linkto>
151  // object which takes care of mapping old to new axes order.
152  AxesMapping apply (const IPosition& shape) const;
153 
154  // Are we keeping all degenerate axes ?
155  Bool keep() const {return itsKeep;};
156 
157 private:
161 };
162 
163 
164 
165 } //# NAMESPACE CASACORE - END
166 
167 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
AxesSpecifier & operator=(const AxesSpecifier &other)
Assignment (copy semantics).
AxesSpecifier()
The default constructor keeps all axes.
Specification of axes to keep or remove.
Info about mapping array axes to another order.
Definition: AxesMapping.h:87
AxesMapping apply(const IPosition &shape) const
Apply the specification to a shape.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
Bool keep() const
Are we keeping all degenerate axes ?
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42