casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointShape.h
Go to the documentation of this file.
1 //# PointShape.h:
2 //# Copyright (C) 1998,1999,2000,2001
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: 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 //#
27 //# $Id: PointShape.h 21130 2011-10-18 07:39:05Z gervandiepen $
28 
29 #ifndef COMPONENTS_POINTSHAPE_H
30 #define COMPONENTS_POINTSHAPE_H
31 
32 #include <casa/aips.h>
35 #include <casa/BasicSL/Complex.h>
36 
37 namespace casacore{
38 
39 class MVAngle;
40 class MDirection;
41 class RecordInterface;
42 class String;
43 template <class T> class Vector;
44 }
45 
46 namespace casa { //# NAMESPACE CASA - BEGIN
47 
48 
49 // <summary>A shape where emission comes from only one direction</summary>
50 
51 // <use visibility=export>
52 
53 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tPointShape" demos="dPointShape">
54 // </reviewed>
55 
56 // <prerequisite>
57 // <li> <linkto class=ComponentShape>ComponentShape</linkto>
58 // </prerequisite>
59 
60 // <synopsis>
61 
62 // This class represents the shape of components where the emission comes from
63 // only one point in the sky.
64 
65 // This class like the other component shapes becomes more useful when used
66 // through the <linkto class=SkyComponent>SkyComponent</linkto> class, which
67 // incorporates the flux and spectral variation of the emission, or through the
68 // <linkto class=ComponentList>ComponentList</linkto> class, which handles
69 // groups of SkyComponent objects.
70 
71 // For a point shape all the emission comes only from the reference direction
72 // which is specified in celestial co-ordinates, using a
73 // <linkto class=casacore::MDirection>MDirection</linkto> object. The direction can be
74 // specified both in the constructor or with the <src>setRefDirection</src>
75 // function.
76 
77 // The <src>sample</src> member functions are used to determine the proportion
78 // of flux the component at any point on the sky. For a point component this is
79 // either zero or one depending on whether the specified pixel contains the
80 // point source or not.
81 
82 // The <src>visibility</src> functions return the Fourier transform of the
83 // component at a specified spatial frequency. For a point shape the Fourier
84 // transform is a constant value. Hence these functions return one, regardless
85 // of the input parameters.
86 
87 // This class also contains functions (<src>toRecord</src> &
88 // <src>fromRecord</src>) which perform the conversion between Records and
89 // PointShape objects. These functions define how a PointShape object is
90 // represented in glish. The format of the record that is generated and
91 // accepted by these functions is:
92 // <srcblock>
93 // c := [type = 'point',
94 // direction = [type = 'direction',
95 // refer = 'j2000',
96 // m0 = [value = 0, unit = 'deg']
97 // m1 = [value = 0, unit = 'deg']
98 // ]
99 // ]
100 // </srcblock>
101 // The direction field contains a record representation of a direction measure
102 // and its format is defined in the Measures module. Its refer field defines
103 // the reference frame for the direction and the m0 and m1 fields define the
104 // latitude and longitude in that frame.
105 // </synopsis>
106 //
107 
108 // <example>
109 // Suppose I had an image of a region of the sky and we wanted to subtract
110 // a point source from it. This could be done as follows:
111 // <ul>
112 // <li> Construct a SkyComponent with to represent the point source
113 // <li> Project the component onto an image
114 // <li> Convolve the image by the point spread function
115 // <li> subtract the convolved model from the dirty image.
116 // </ul>
117 // Shown below is the code to perform the first step in this process, ie
118 // construct the SkyComponent. This example is also available in the
119 // <src>dPointShape.cc</src> file. Note that it is more accurate to do
120 // subtraction of point components in the (u,v) domain
121 // <srcblock>
122 // casacore::MDirection J1934_dir;
123 // { // get the right direction into J1934_dir
124 // casacore::Quantity J1934_ra; casacore::MVAngle::read(J1934_ra, "19:39:");
125 // casacore::Quantity J1934_dec; casacore::MVAngle::read(J1934_dec, "-63.43.");
126 // J1934_dir = casacore::MDirection(J1934_ra, J1934_dec, casacore::MDirection::J2000);
127 // }
128 // { // One way to construct the SkyComponent
129 // SkyComponent J1934(ComponentType::POINT, ComponentType::CONSTANT_SPECTRUM);
130 // J1934.shape().setRefDirection(J1934_dir);
131 // J1934.flux() = Flux<casacore::Double>(6.28, 0.1, 0.15, 0.01);
132 // printShape(J1934.shape());
133 // }
134 // { // An alternative way to construct the SkyComponent
135 // const Flux<casacore::Double> flux(6.28, 0.1, 0.15, 0.01);
136 // const PointShape shape(J1934_dir);
137 // const ConstantSpectrum spectrum;
138 // SkyComponent component(flux, shape, spectrum);
139 // printShape(component.shape());
140 // }
141 // </srcblock>
142 // Note how the member functions of the PointShape class (the setDirection
143 // function) are accessable through the shape function in the SkyComponent
144 // class. The printShape function is the example shown for the ComponentShape
145 // class.
146 // </example>
147 //
148 // <todo asof="1999/11/11">
149 // <li> Use Measures & Quanta in the interface to the visibility functions.
150 // </todo>
151 
152 // <linkfrom anchor="PointShape" classes="ComponentShape GaussianShape DiskShape">
153 // <here>PointShape</here> - a shape where emission comes from only one direction
154 // </linkfrom>
155 
157 {
158 public:
159  // The default PointShape is at the J2000 North Pole.
160  PointShape();
161 
162  // Construct a point shape at the specified direction.
163  PointShape(const casacore::MDirection& direction);
164 
165  // The copy constructor uses copy semantics.
166  PointShape(const PointShape& other);
167 
168  // The destructor does nothing special.
169  virtual ~PointShape();
170 
171  // The assignment operator uses copy semantics.
172  PointShape& operator=(const PointShape& other);
173 
174  // Return the type of shape. This function always returns
175  // ComponentType::POINT.
176  virtual ComponentType::Shape type() const;
177 
178  // Calculate the proportion of the flux that is in a pixel of the specified
179  // size centered on the specified direction. Because this is a point shape
180  // the returned value is either zero or one. It is one if the specified
181  // direction is less than half a pixelSize away from the reference direction.
182  virtual casacore::Double sample(const casacore::MDirection& direction,
183  const casacore::MVAngle& pixelLatSize,
184  const casacore::MVAngle& pixelLongSize) const;
185 
186  // Same as the previous function except that many directions can be sampled
187  // at once. The reference frame and pixel size must be the same for all the
188  // specified directions. This is a customised version.
189  virtual void sample(casacore::Vector<casacore::Double>& scale,
191  const casacore::MDirection::Ref& refFrame,
192  const casacore::MVAngle& pixelLatSize,
193  const casacore::MVAngle& pixelLongSize) const;
194 
195  // Return the Fourier transform of the component at the specified point in
196  // the spatial frequency domain. The point is specified by a 3 element vector
197  // (u,v,w) that has units of meters and the frequency of the observation, in
198  // Hertz. These two quantities can be used to derive the required spatial
199  // frequency <src>(s = uvw*freq/c)</src>. The w component is not used in
200  // these functions.
201 
202  // The reference position for the transform is the direction of the
203  // component. Hence the returned value is always a constant real value of
204  // one. The input arguments are ignored except in debug mode where the
205  // length of the uvw casacore::Vector and sign of the frequency variable are checked.
207  const casacore::Double& frequency) const;
208 
209  // Same as the previous function except that many (u,v,w) points can be
210  // sampled at once. As with the previous function the returned value is
211  // always a constant real vector of one. The input arguments are ignored
212  // except in debug mode where the shape of the uvw casacore::Matrix and the scale
213  // casacore::Vector are checked as is the sign of the frequency variable.
215  const casacore::Double& frequency) const;
216 
217  //Same as above except with many frequencies
219  const casacore::Vector<casacore::Double>& frequency) const;
220 
221  // A point shape is symmetric so this function always returns true;
222  virtual casacore::Bool isSymmetric() const;
223 
224  // Return a pointer to a copy of this object upcast to a ComponentShape
225  // object. The class that uses this function is responsible for deleting the
226  // pointer. This is used to implement a virtual copy constructor.
227  virtual ComponentShape* clone() const;
228 
229  // return the number of parameters in this shape and set/get them. As this
230  // is a point shape there are none. So calling <src>setParameters</src> or
231  // <src>setErrors</src> with anything other than a zero length casacore::Vector will
232  // throw an exception (when compiled in debug mode). The
233  // <src>nParameters</src> will always return zero and the
234  // <src>parameters</src> and <src>errors</src> functions will always return
235  // zero length Vectors.
236  // <group>
237  virtual casacore::uInt nParameters() const;
238  virtual void setParameters(const casacore::Vector<casacore::Double>& newParms);
240  virtual void setErrors(const casacore::Vector<casacore::Double>& newParms);
243  virtual void setOptParameters(const casacore::Vector<casacore::Double>& newOptParms);
244  // </group>
245 
246  // This functions convert between a casacore::Record and a PointShape. These functions
247  // define how a point shape is represented in glish and this is detailed in
248  // the synopsis above. They return false if the supplied casacore::Record is malformed
249  // and append an error message to the supplied casacore::String giving the reason.
250  // <group>
251  virtual casacore::Bool fromRecord(casacore::String& errorMessage,
252  const casacore::RecordInterface& record);
253  virtual casacore::Bool toRecord(casacore::String& errorMessage, casacore::RecordInterface& record) const;
254  // </group>
255 
256  // Convert the parameters of the component to the specified units. As a point
257  // component has no parameters this function does nothing and always returns
258  // true.
260 
261 
262 
263  // casacore::Function which checks the internal data of this class for consistent
264  // values. Returns true if everything is fine otherwise returns false.
265  virtual casacore::Bool ok() const;
266 
267  // return a pointer to this object.
268  virtual const ComponentShape* getPtr() const;
269 
270  virtual casacore::String sizeToString() const;
271 
272 private:
273 
274 // FInd out if a direction is located within a pixel
276  const casacore::MDirection::MVType& dirValue,
277  const casacore::MDirection::MVType* compDirValue) const;
278 };
279 
280 } //# NAMESPACE CASA - END
281 
282 #endif
A Measure: astronomical direction.
Definition: MDirection.h:174
virtual casacore::Bool toRecord(casacore::String &errorMessage, casacore::RecordInterface &record) const
Convert the class to an Record representation.
std::vector< double > Vector
Definition: ds9context.h:24
casacore::Double dirIsInPixel(casacore::Double longSize, casacore::Double latSize, casacore::Double nearSize, const casacore::MDirection::MVType &dirValue, const casacore::MDirection::MVType *compDirValue) const
FInd out if a direction is located within a pixel.
virtual void setErrors(const casacore::Vector< casacore::Double > &newParms)
virtual casacore::DComplex visibility(const casacore::Vector< casacore::Double > &uvw, const casacore::Double &frequency) const
Return the Fourier transform of the component at the specified point in the spatial frequency domain...
Shape
The shapes of all the components.
virtual const ComponentShape * getPtr() const
return a pointer to this object.
virtual void setParameters(const casacore::Vector< casacore::Double > &newParms)
PointShape()
The default PointShape is at the J2000 North Pole.
virtual ~PointShape()
The destructor does nothing special.
virtual ComponentType::Shape type() const
Return the type of shape.
Base class for component shapes.
double Double
Definition: aipstype.h:55
virtual casacore::Bool fromRecord(casacore::String &errorMessage, const casacore::RecordInterface &record)
This functions convert between a casacore::Record and a PointShape.
PointShape & operator=(const PointShape &other)
The assignment operator uses copy semantics.
virtual casacore::Vector< casacore::Double > parameters() const
virtual casacore::Double sample(const casacore::MDirection &direction, const casacore::MVAngle &pixelLatSize, const casacore::MVAngle &pixelLongSize) const
Calculate the proportion of the flux that is in a pixel of the specified size centered on the specifi...
virtual casacore::Bool convertUnit(casacore::String &, const casacore::RecordInterface &)
Convert the parameters of the component to the specified units.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual casacore::Vector< casacore::Double > optParameters() const
virtual casacore::uInt nParameters() const
return the number of parameters in this shape and set/get them.
A shape where emission comes from only one direction.
Definition: PointShape.h:156
virtual casacore::Bool isSymmetric() const
A point shape is symmetric so this function always returns true;.
virtual void setOptParameters(const casacore::Vector< casacore::Double > &newOptParms)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Vector of three direction cosines.
Definition: MVDirection.h:106
virtual casacore::Bool ok() const
casacore::Function which checks the internal data of this class for consistent values.
virtual casacore::String sizeToString() const
virtual ComponentShape * clone() const
Return a pointer to a copy of this object upcast to a ComponentShape object.
Abstract base class for Record classes.
virtual casacore::Vector< casacore::Double > errors() const
Class to handle angle type conversions and I/O.
Definition: MVAngle.h:245
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42