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