casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PVGenerator.h
Go to the documentation of this file.
1 //# tSubImage.cc: Test program for class SubImage
2 //# Copyright (C) 1998,1999,2000,2001,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This program is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU General Public License as published by the Free
7 //# Software Foundation; either version 2 of the License, or (at your option)
8 //# any later version.
9 //#
10 //# This program 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 General Public License for
13 //# more details.
14 //#
15 //# You should have received a copy of the GNU General Public License along
16 //# with this program; if not, write to the Free Software Foundation, Inc.,
17 //# 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 //# $Id: tSubImage.cc 20567 2009-04-09 23:12:39Z gervandiepen $
27 
28 #ifndef IMAGES_PVGENERATOR_H
29 #define IMAGES_PVGENERATOR_H
30 
32 #include <casa/namespace.h>
33 
34 
35 namespace casacore{
36 
37 class MDirection;
38 }
39 
40 namespace casa {
41 
42 class PVGenerator : public ImageTask<casacore::Float> {
43  // <summary>
44  // Top level interface for generating position-velocity images
45  // </summary>
46 
47  // <reviewed reviewer="" date="" tests="" demos="">
48  // </reviewed>
49 
50  // <prerequisite>
51  // </prerequisite>
52 
53  // <etymology>
54  // Collapses image.
55  // </etymology>
56 
57  // <synopsis>
58  // High level interface for generating position-velocity images.
59  // </synopsis>
60 
61  // <example>
62  // <srcblock>
63  // ImageCollapser collapser();
64  // collapser.collapse();
65  // </srcblock>
66  // </example>
67 
68 public:
69 
70  PVGenerator() = delete;
71 
72  // The region selection in the constructor only applies to the non-direction coordinates.
73  // The direction coordinate limits are effectively set by calling setEndPoints()
74  // after construction. The region selection in the constructor is only for things like
75  // spectral selection and polarization selection. In addition at most one of <src>regionRec</src>
76  // and <src>chanInp/stokes</src> should be supplied. If specifying <src>regionRec</src> that should
77  // be a non-null pointer and chanInp and stokes should both be empty strings. If specifying either or
78  // both of chanInp and/or stokes, the one(s) being specified should be non-empty strings corresponding
79  // to correct syntax for that particular parameter, and regionRec should be null.
80  // If you specify <src>regionRec</src>=0
81  // and <src>stokes</src>="", and <src>chanInp</src>="", that implies you want to use all
82  // spectral channels and all polarization planes in the input image.
84  const SPCIIF image,
85  const casacore::Record *const &regionRec, const casacore::String& chanInp,
86  const casacore::String& stokes, const casacore::String& maskInp,
87  const casacore::String& outname, const casacore::Bool overwrite
88  );
89 
90  PVGenerator(const PVGenerator&) = delete;
91 
92  // destructor
93  ~PVGenerator();
94 
95  // perform the collapse. Returns a pointer to the
96  // collapsed image.
97  SPIIF generate() const;
98 
99  // set the end points of the slice in direction space. casacore::Input values represent pixel
100  // coordinates in the input image.
101  void setEndpoints(
102  const std::pair<casacore::Double, casacore::Double>& start,
103  const std::pair<casacore::Double, casacore::Double>& end
104  );
105 
106  // set end points given center in pixels, length of segment in pixels, and position angle
107  // taken in the normal astronomical sense, measured from north through east.
108  void setEndpoints(
109  const std::pair<casacore::Double, casacore::Double>& center, casacore::Double length,
110  const casacore::Quantity& pa
111  );
112 
113  void setEndpoints(
114  const std::pair<casacore::Double, casacore::Double>& center, const casacore::Quantity& length,
115  const casacore::Quantity& pa
116  );
117 
118  void setEndpoints(
119  const casacore::MDirection& center, const casacore::Quantity& length,
120  const casacore::Quantity& pa
121  );
122 
123  // <src>length in pixels</src>
124  void setEndpoints(
125  const casacore::MDirection& center, casacore::Double length,
126  const casacore::Quantity& pa
127  );
128 
129  void setEndpoints(
130  const casacore::MDirection& start, const casacore::MDirection& end
131  );
132 
133  // Set the number of pixels perpendicular to the slice for which averaging
134  // should occur. Must be odd and >= 1. 1 => just use the pixels coincident with the slice
135  // (no averaging). 3 => Average three pixels, one pixel on either side of the slice and the
136  // pixel lying on the slice.
137  // Note this average is done after the image has been rotated.
138  void setWidth(casacore::uInt width);
139  // This will set the width by rounding <src>q</src> up so that the width is an odd number of pixels.
140  void setWidth(const casacore::Quantity& q);
141 
142  casacore::String getClass() const;
143 
144  // set the unit to be used for the offset axis in the resulting image (from calling
145  // generate()). Must conform to angular units
146  void setOffsetUnit(const casacore::String& s);
147 
148 
149 protected:
152  }
153 
154  inline std::vector<casacore::Coordinate::Type> _getNecessaryCoordinates() const {
155  std::vector<casacore::Coordinate::Type> v;
156  v.push_back(casacore::Coordinate::SPECTRAL);
157  v.push_back(casacore::Coordinate::DIRECTION);
158  return v;
159  }
160 
161  virtual casacore::Bool _mustHaveSquareDirectionPixels() const {return true;}
162 
163 private:
164  std::unique_ptr<std::vector<casacore::Double> > _start, _end;
167  static const casacore::String _class;
168 
170  SPCIIF rotated, const Vector<Double>& rotPixStart,
171  const Vector<Double>& rotPixEnd, Int xAxis, Int yAxis,
172  Double xdiff, Double ydiff
173  ) const;
174 
176  Int& collapsedAxis, SPCIIF rotated, Int xAxis, Int yAxis, const Vector<Double>& rotPixStart,
177  const Vector<Double>& rotPixEnd, Double halfwidth
178  ) const;
179 
181  SPIIF subImage, const std::vector<Double>& start, const std::vector<Double>& end,
182  Int xAxis, Int yAxis, Double halfwidth, Double paInRad
183  ) const;
184 
185  SPIIF _dropDegen(SPIIF collapsed, Int collapsedAxis) const;
186 
187  void _checkWidth(const casacore::Int64 xShape, const casacore::Int64 yShape) const;
188 
189  void _checkWidthSanity(
190  Double paInRad, Double halfwidth, const std::vector<Double>& start,
191  const std::vector<Double>& end, SPCIIF subImage, Int xAxis, Int yAxis
192  ) const;
193 
195 
196  void _moveRefPixel(
197  SPIIF subImage, CoordinateSystem& subCoords, const std::vector<Double>& start,
198  const std::vector<Double>& end, Double paInDeg, Int xAxis, Int yAxis
199  ) const;
200 
201  static casacore::String _pairToString(const std::pair<casacore::Double, casacore::Double>& p);
202 
203 };
204 }
205 
206 #endif
A Measure: astronomical direction.
Definition: MDirection.h:174
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
int Int
Definition: aipstype.h:50
void _checkRotatedImageSanity(SPCIIF rotated, const Vector< Double > &rotPixStart, const Vector< Double > &rotPixEnd, Int xAxis, Int yAxis, Double xdiff, Double ydiff) const
void _moveRefPixel(SPIIF subImage, CoordinateSystem &subCoords, const std::vector< Double > &start, const std::vector< Double > &end, Double paInDeg, Int xAxis, Int yAxis) const
SPCIIF _doRotate(SPIIF subImage, const std::vector< Double > &start, const std::vector< Double > &end, Int xAxis, Int yAxis, Double halfwidth, Double paInRad) const
SPIIF _dropDegen(SPIIF collapsed, Int collapsedAxis) const
casacore::String _unit
Definition: PVGenerator.h:166
void _checkWidth(const casacore::Int64 xShape, const casacore::Int64 yShape) const
SPIIF _doCollapse(Int &collapsedAxis, SPCIIF rotated, Int xAxis, Int yAxis, const Vector< Double > &rotPixStart, const Vector< Double > &rotPixEnd, Double halfwidth) const
casacore::String getClass() const
static casacore::String _pairToString(const std::pair< casacore::Double, casacore::Double > &p)
void setEndpoints(const std::pair< casacore::Double, casacore::Double > &start, const std::pair< casacore::Double, casacore::Double > &end)
set the end points of the slice in direction space.
const_iterator end() const
void _checkWidthSanity(Double paInRad, Double halfwidth, const std::vector< Double > &start, const std::vector< Double > &end, SPCIIF subImage, Int xAxis, Int yAxis) const
LatticeExprNode pa(const LatticeExprNode &left, const LatticeExprNode &right)
This function finds 180/pi*atan2(left,right)/2.
casacore::Quantity _increment() const
double Double
Definition: aipstype.h:55
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
std::unique_ptr< std::vector< casacore::Double > > _start
Definition: PVGenerator.h:164
std::shared_ptr< const casacore::ImageInterface< casacore::Float > > SPCIIF
Definition: ImageTypedefs.h:50
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
static const casacore::String _class
Definition: PVGenerator.h:167
CasacRegionManager::StokesControl _getStokesControl() const
Definition: PVGenerator.h:150
virtual casacore::Bool _mustHaveSquareDirectionPixels() const
Definition: PVGenerator.h:161
std::shared_ptr< casacore::ImageInterface< casacore::Float > > SPIIF
Definition: ImageTypedefs.h:51
~PVGenerator()
destructor
SPIIF generate() const
perform the collapse.
std::vector< casacore::Coordinate::Type > _getNecessaryCoordinates() const
Represents the minimum set of coordinates necessary for the task to function.
Definition: PVGenerator.h:154
void setWidth(casacore::uInt width)
Set the number of pixels perpendicular to the slice for which averaging should occur.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
PVGenerator()=delete
Top level interface for generating position-velocity images.
std::unique_ptr< std::vector< casacore::Double > > _end
Definition: PVGenerator.h:164
Interconvert pixel and world coordinates.
casacore::uInt _width
Definition: PVGenerator.h:165
unsigned int uInt
Definition: aipstype.h:51
void setOffsetUnit(const casacore::String &s)
set the unit to be used for the offset axis in the resulting image (from calling generate()).
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42