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