casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CasacRegionManager.h
Go to the documentation of this file.
1 //# RegionManager.h: framework independent class that provides
2 //# functionality to tool of same name
3 //# Copyright (C) 2007
4 //# Associated Universities, Inc. Washington DC, USA.
5 //#
6 //# This program is free software; you can redistribute it and/or modify it
7 //# under the terms of the GNU General Public License as published by the Free
8 //# Software Foundation; either version 2 of the License, or (at your option)
9 //# any later version.
10 //#
11 //# This program is distributed in the hope that it will be useful, but WITHOUT
12 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 //# more details.
15 //#
16 //# You should have received a copy of the GNU General Public License along
17 //# with this program; if not, write to the Free Software Foundation, Inc.,
18 //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
19 //#
20 //# Correspondence concerning AIPS++ should be addressed as follows:
21 //# Internet email: aips2-request@nrao.edu.
22 //# Postal address: AIPS++ Project Office
23 //# National Radio Astronomy Observatory
24 //# 520 Edgemont Road
25 //# Charlottesville, VA 22903-2475 USA
26 
27 #ifndef IMAGEANALYSIS_CASACREGIONMANAGER_H
28 #define IMAGEANALYSIS_CASACREGIONMANAGER_H
29 
31 
33 
34 namespace casa {
35 
47 
48 public:
49  const static casacore::String ALL;
50 
54  };
55 
57 
59 
60  CasacRegionManager(const CasacRegionManager&) = delete;
61 
63 
65 
66  // convert to a record a region specified by a rectangular directional <src>box</src>,
67  // <src>chans</src>, and <src>stokes</src>, or althernatively a pointer to
68  // a region record. If box, chans, or stokes is not blank, <src>regionPtr</src> should
69  // be null. Processing happens in the following order:
70  // 1. if <src>box</src> is not empty it, along with <src>chans</src> and <src>stokes</src>
71  // if specified, are used to determine the returned record. In this case <src>stokes</src>
72  // is not altered.
73  // 2. else if <src>regionPtr</src> is not null, it is used to determine the returned Record.
74  // In this case, stokes may be modified to reflect the stokes parameters included in the
75  // corresponding region.
76  // 3. else if <src>regionName</src> is not empty, the region file of the same is read and
77  // used to create the record, or if <src>regionName</src> is of the form "imagename:regionname" the region
78  // record is read from the corresponding iamge. In this case, stokes may be modified
79  // to reflect the stokes parameters included in the corresponding region.
80  // 4. else <src>chans</src> and <src>stokes</src> are used to determine the region casacore::Record, or
81  // if not given, the whole <src>imShape</src> is used.
82  // <src>box</src> is specified in comma seperated quadruplets representing blc and trc pixel
83  // locations, eg "100, 110, 200, 205". <src>stokes</src> is specified as the concatentation of
84  // stokes parameters, eg "IQUV". <src>chans</src> is specified in ways supported by CASA, eg
85  // "1~10" for channels 1 through 10.
86 
88  casacore::String& diagnostics, casacore::uInt& nSelectedChannels, casacore::String& stokes,
89  const casacore::Record * const &regionPtr, const casacore::String& regionName,
90  const casacore::String& chans, const StokesControl stokesControl,
91  const casacore::String& box, const casacore::IPosition& imShape, const casacore::String& imageName="",
92  casacore::Bool verbose=true
93  );
94 
96  casacore::String& diagnostics, casacore::uInt& nSelectedChannels, casacore::String& stokes,
97  const casacore::String& chans, const StokesControl stokesControl,
98  const casacore::String& box, const casacore::IPosition& imShape
99  ) const;
100 
102  const casacore::CoordinateSystem& csys, const casacore::String& regionStr,
103  const casacore::String& imageName, const casacore::IPosition& imShape,
104  casacore::Bool verbose=true
105  );
106 
107  // Return the range(s) of spectral channels selected by the specification or the
108  // region record (Note only one of <src>specification</src> or <src>regionRec</src>
109  // may be specified). <src>imShape</src> is not used if <src>specification</src>
110  // is in the "new" format (ie contains "range").
111  std::vector<casacore::uInt> setSpectralRanges(
112  casacore::uInt& nSelectedChannels,
113  const casacore::Record *const regionRec, const casacore::IPosition& imShape=casacore::IPosition(0)
114  ) const;
115 
116  std::vector<casacore::uInt> setSpectralRanges(
117  casacore::String specification, casacore::uInt& nSelectedChannels,
118  const casacore::IPosition& imShape=casacore::IPosition(0)
119  ) const;
120 
121 private:
122 
123  casacore::String _pairsToString(const std::vector<casacore::uInt>& pairs) const;
124 
125  std::vector<casacore::uInt> _setPolarizationRanges(
126  casacore::String& specification, const casacore::String& firstStokes, const casacore::uInt nStokes,
127  const StokesControl stokesControl
128  ) const;
129 
130  std::vector<casacore::Double> _setBoxCorners(const casacore::String& box) const;
131 
133  casacore::String& diagnostics,
134  const std::vector<casacore::Double>& boxCorners, const std::vector<casacore::uInt>& chanEndPts,
135  const std::vector<casacore::uInt>& polEndPts, const casacore::IPosition imShape
136  ) const;
137 
138  static void _setRegion(
139  casacore::Record& regionRecord, casacore::String& diagnostics,
140  const casacore::Record* regionPtr
141  );
142 
144  const casacore::Record& region, const StokesControl stokesControl, const casacore::IPosition& shape
145  ) const;
146 
147  void _setRegion(
148  casacore::Record& regionRecord, casacore::String& diagnostics,
149  const casacore::String& regionName, const casacore::IPosition& imShape,
150  const casacore::String& imageName,
151  const casacore::String& prependBox,
152  const casacore::String& globalOverrideChans,
153  const casacore::String& globalStokesOverride,
154  casacore::Bool verbose
155  );
156 
157  std::vector<casacore::uInt> _spectralRangeFromRangeFormat(
158  casacore::uInt& nSelectedChannels, const casacore::String& specification,
159  const casacore::IPosition& imShape
160  ) const;
161 
162  std::vector<casacore::uInt> _spectralRangeFromRegionRecord(
163  casacore::uInt& nSelectedChannels, const casacore::Record *const regionRec,
164  const casacore::IPosition& imShape
165  ) const;
166 
167  // does the image support the setting of a two dimensional box(es).
168  // If except is true, an exception will be thrown if this image does not
169  // support it. If not, false is returned in that case.
171 
172  std::vector<casacore::uInt> _initSpectralRanges(casacore::uInt& nSelectedChannels, const casacore::IPosition& imShape) const;
173 };
174 
175 } // casa namespace
176 #endif
177 
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
std::vector< casacore::uInt > _setPolarizationRanges(casacore::String &specification, const casacore::String &firstStokes, const casacore::uInt nStokes, const StokesControl stokesControl) const
std::vector< casacore::Double > _setBoxCorners(const casacore::String &box) const
casacore::String _pairsToString(const std::vector< casacore::uInt > &pairs) const
std::vector< casacore::uInt > _spectralRangeFromRegionRecord(casacore::uInt &nSelectedChannels, const casacore::Record *const regionRec, const casacore::IPosition &imShape) const
image component class
std::vector< casacore::uInt > _initSpectralRanges(casacore::uInt &nSelectedChannels, const casacore::IPosition &imShape) const
std::vector< casacore::uInt > setSpectralRanges(casacore::uInt &nSelectedChannels, const casacore::Record *const regionRec, const casacore::IPosition &imShape=casacore::IPosition(0)) const
Return the range(s) of spectral channels selected by the specification or the region record (Note onl...
static const casacore::String ALL
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::String _stokesFromRecord(const casacore::Record &region, const StokesControl stokesControl, const casacore::IPosition &shape) const
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
casacore::Record fromBCS(casacore::String &diagnostics, casacore::uInt &nSelectedChannels, casacore::String &stokes, const casacore::Record *const &regionPtr, const casacore::String &regionName, const casacore::String &chans, const StokesControl stokesControl, const casacore::String &box, const casacore::IPosition &imShape, const casacore::String &imageName="", casacore::Bool verbose=true)
convert to a record a region specified by a rectangular directional box, chans, and stokes...
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
CasacRegionManager & operator=(const CasacRegionManager &)=delete
Record * box(const Vector< Double > &blc, const Vector< Double > &trc, const Vector< Double > &inc, const String &absrel, const Bool frac, const String &comment="")
LCSlicer box.
casacore::ImageRegion _fromBCS(casacore::String &diagnostics, const std::vector< casacore::Double > &boxCorners, const std::vector< casacore::uInt > &chanEndPts, const std::vector< casacore::uInt > &polEndPts, const casacore::IPosition imShape) const
String: the storage and methods of handling collections of characters.
Definition: String.h:223
std::vector< casacore::uInt > _spectralRangeFromRangeFormat(casacore::uInt &nSelectedChannels, const casacore::String &specification, const casacore::IPosition &imShape) const
casacore::Bool _supports2DBox(casacore::Bool except) const
does the image support the setting of a two dimensional box(es).
Interconvert pixel and world coordinates.
static void _setRegion(casacore::Record &regionRecord, casacore::String &diagnostics, const casacore::Record *regionPtr)
unsigned int uInt
Definition: aipstype.h:51
static casacore::Record regionFromString(const casacore::CoordinateSystem &csys, const casacore::String &regionStr, const casacore::String &imageName, const casacore::IPosition &imShape, casacore::Bool verbose=true)