CasacRegionManager.h

Go to the documentation of this file.
00001 //# RegionManager.h: framework independent class that provides 
00002 //# functionality to tool of same name
00003 //# Copyright (C) 2007
00004 //# Associated Universities, Inc. Washington DC, USA.
00005 //#
00006 //# This program is free software; you can redistribute it and/or modify it
00007 //# under the terms of the GNU General Public License as published by the Free
00008 //# Software Foundation; either version 2 of the License, or (at your option)
00009 //# any later version.
00010 //#
00011 //# This program is distributed in the hope that it will be useful, but WITHOUT
00012 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00014 //# more details.
00015 //#
00016 //# You should have received a copy of the GNU General Public License along
00017 //# with this program; if not, write to the Free Software Foundation, Inc.,
00018 //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00019 //#
00020 //# Correspondence concerning AIPS++ should be addressed as follows:
00021 //#        Internet email: aips2-request@nrao.edu.
00022 //#        Postal address: AIPS++ Project Office
00023 //#                        National Radio Astronomy Observatory
00024 //#                        520 Edgemont Road
00025 //#                        Charlottesville, VA 22903-2475 USA
00026 
00027 #ifndef IMAGEANALYSIS_CASACREGIONMANAGER_H
00028 #define IMAGEANALYSIS_CASACREGIONMANAGER_H
00029 
00030 #include <images/Regions/RegionManager.h>
00031 
00032 #include <imageanalysis/IO/RegionTextParser.h>
00033 
00034 namespace casa {
00035 
00046 class CasacRegionManager: public RegionManager {
00047 
00048 public:
00049         const static String ALL;
00050 
00051         enum StokesControl {
00052                 USE_FIRST_STOKES,
00053                 USE_ALL_STOKES
00054         };
00055 
00056         CasacRegionManager();
00057 
00058         CasacRegionManager(const CoordinateSystem& csys);
00059 
00060         CasacRegionManager(const CasacRegionManager&) = delete;
00061 
00062         ~CasacRegionManager();
00063 
00064         CasacRegionManager& operator=(const CasacRegionManager&) = delete;
00065 
00066         // convert to a record a region specified by a rectangular directional <src>box</src>,
00067         // <src>chans</src>, and <src>stokes</src>, or althernatively a pointer to
00068         // a region record. If box, chans, or stokes is not blank, <src>regionPtr</src> should
00069         // be null. Processing happens in the following order:
00070         // 1. if <src>box</src> is not empty it, along with <src>chans</src> and <src>stokes</src>
00071         // if specified, are used to determine the returned record. In this case <src>stokes</src>
00072         // is not altered.
00073         // 2. else if <src>regionPtr</src> is not null, it is used to determine the returned Record.
00074         // In this case, stokes may be modified to reflect the stokes parameters included in the
00075         // corresponding region.
00076         // 3. else if <src>regionName</src> is not empty, the region file of the same is read and
00077         // used to create the record, or if <src>regionName</src> is of the form "imagename:regionname" the region
00078         // record is read from the corresponding iamge. In this case, stokes may be modified
00079         // to reflect the stokes parameters included in the corresponding region.
00080         // 4. else <src>chans</src> and <src>stokes</src> are used to determine the region Record, or
00081         // if not given, the whole <src>imShape</src> is used.
00082         // <src>box</src> is specified in comma seperated quadruplets representing blc and trc pixel
00083         // locations, eg "100, 110, 200, 205". <src>stokes</src> is specified as the concatentation of
00084         // stokes parameters, eg "IQUV". <src>chans</src> is specified in ways supported by CASA, eg
00085         // "1~10" for channels 1 through 10.
00086 
00087         Record fromBCS(
00088                 String& diagnostics, uInt& nSelectedChannels, String& stokes,
00089                 const Record  * const &regionPtr, const String& regionName,
00090                 const String& chans, const StokesControl stokesControl,
00091                 const String& box, const IPosition& imShape, const String& imageName="",
00092                 Bool verbose=True
00093         );
00094 
00095         ImageRegion fromBCS(
00096                         String& diagnostics, uInt& nSelectedChannels, String& stokes,
00097                         const String& chans, const StokesControl stokesControl,
00098                         const String& box, const IPosition& imShape
00099         ) const;
00100 
00101         static Record regionFromString(
00102                 const CoordinateSystem& csys, const String& regionStr,
00103                 const String& imageName, const IPosition& imShape /*,
00104                 const String& globalOverrideChans,
00105                 const String& globalStokesOverride */
00106         );
00107 
00108         // Return the range(s) of spectral channels selected by the specification or the
00109         // region record (Note only one of <src>specification</src> or <src>regionRec</src>
00110         // may be specified). <src>imShape</src> is not used if <src>specification</src>
00111         // is in the "new" format (ie contains "range").
00112         vector<uInt> setSpectralRanges(
00113                 uInt& nSelectedChannels,
00114                 const Record *const regionRec, const IPosition& imShape=IPosition(0)
00115         ) const;
00116 
00117         vector<uInt> setSpectralRanges(
00118                 String specification, uInt& nSelectedChannels,
00119                 /*
00120                 const String& globalChannelOverride,
00121                 const String& globalStokesOverrideconst,
00122                 */
00123                 const IPosition& imShape=IPosition(0)
00124         ) const;
00125 
00126 private:
00127 
00128         // disallow copy constructor and = operator
00129 
00130         // CasacRegionManager(const CasacRegionManager&) : RegionManager() {}
00131 
00132         /*
00133         CasacRegionManager& operator=(const CasacRegionManager&) {
00134                 ThrowCc("=operator disallowed");
00135         }
00136         */
00137 
00138         String _pairsToString(const vector<uInt>& pairs) const;
00139 
00140         vector<uInt> _setPolarizationRanges(
00141                 String& specification, const String& firstStokes, const uInt nStokes,
00142                 const StokesControl stokesControl
00143         ) const;
00144 
00145         vector<Double> _setBoxCorners(const String& box) const;
00146 
00147         ImageRegion _fromBCS(
00148                         String& diagnostics,
00149                         const vector<Double>& boxCorners, const vector<uInt>& chanEndPts,
00150                         const vector<uInt>& polEndPts, const IPosition imShape
00151         ) const;
00152 
00153         static void _setRegion(
00154                 Record& regionRecord, String& diagnostics,
00155                 const Record* regionPtr
00156         );
00157 
00158         String _stokesFromRecord(
00159                 const Record& region, const StokesControl stokesControl, const IPosition& shape
00160         ) const;
00161 
00162         void _setRegion(
00163                 Record& regionRecord, String& diagnostics,
00164                 const String& regionName, const IPosition& imShape,
00165                 const String& imageName,
00166                 const String& prependBox,
00167                 const String& globalOverrideChans,
00168                 const String& globalStokesOverride
00169         );
00170 
00171         vector<uInt> _spectralRangeFromRangeFormat(
00172                 uInt& nSelectedChannels, const String& specification,
00173                 const IPosition& imShape /*, const String& globalChannelOverride,
00174                 const String& globalStokesOverride */
00175         ) const;
00176 
00177         vector<uInt> _spectralRangeFromRegionRecord(
00178                 uInt& nSelectedChannels, const Record *const regionRec,
00179                 const IPosition& imShape
00180         ) const;
00181 
00182         // does the image support the setting of a two dimensional box(es).
00183         // If except is True, an exception will be thrown if this image does not
00184         // support it. If not, False is returned in that case.
00185         Bool _supports2DBox(Bool except) const;
00186 
00187         vector<uInt> _initSpectralRanges(uInt& nSelectedChannels, const IPosition& imShape) const;
00188 };
00189 
00190 } // casa namespace
00191 #endif
00192 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1