casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SkyComponentFactory.h
Go to the documentation of this file.
1 //# Copyright (C) 1995,1996,1999-2001
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 
25 #ifndef COMPONENTS_SKYCOMPONENTFACTORY_H
26 #define COMPONENTS_SKYCOMPONENTFACTORY_H
27 
28 #include <casa/aips.h>
29 
31 
32 namespace casacore{
33 
34 class GaussianBeam;
35 class ImageInfo;
36 template <class T> class ImageInterface;
37 template <class T> class Vector;
38 }
39 
40 namespace casa {
41 
43 public:
44 
46  // These functions convert between a vector of doubles holding SkyComponent values
47  // (the output from SkyComponent::toPixel) and a SkyComponent. The coordinate
48  // values are in the 'x' and 'y' frames. It is possible that the x and y axes of
49  // the pixel array are lat/long (xIsLong=false) rather than long/lat.
50  // facToJy converts the brightness units from whatevers per whatever
51  // to Jy per whatever (e.g. mJy/beam to Jy/beam). It is unity if it
52  // can't be done and you get a warning. In the SkyComponent the flux
53  // is integral. In the parameters vector it is peak.
54  //
55  // pars(0) = FLux image units (e.g. Jy/beam).
56  // pars(1) = x cen abs pix
57  // pars(2) = y cen abs pix
58  // pars(3) = major pix
59  // pars(4) = minor pix
60  // pars(5) = pa radians (pos +x -> +y)
61  //
62  // 5 values for ComponentType::Gaussian, CT::Disk. 3 values for CT::Point.
63  //
64  // <group>
66  casacore::LogIO& os, casacore::Double& facToJy,
67  const casacore::CoordinateSystem& cSys,
68  const casacore::Unit& brightnessUnit,
70  const casacore::Vector<casacore::Double>& parameters,
72  casacore::Bool xIsLong, const casacore::GaussianBeam& beam
73  );
74 
75  // for some reason, this method was in ImageAnalysis but also belongs here.
76  // Obviously hugely confusing to have to methods with the same name and
77  // which presumably are for the same thing in two different classes. I'm
78  // moving ImageAnalysis' method here and also moving that implamentation to
79  // here as well and also being consistent regarding callers (ie those that
80  // called the ImageAnalysis method will now call this method). I couldn't
81  // tell you which of the two implementations is the better one to use
82  // for new code, but this version does call the version that already existed
83  // in casacore::ImageUtilities, so this version seems to do a bit more.
84  // I also hate having a class with anything like Utilities in the name,
85  // but I needed to move this somewhere and can only tackle one issue
86  // at a time.
87  template <class T> static SkyComponent encodeSkyComponent(
88  casacore::LogIO& os, casacore::Double& fluxRatio,
91  const casacore::Vector<casacore::Double>& parameters,
93  casacore::Bool xIsLong, casacore::Bool deconvolveIt,
94  const casacore::GaussianBeam& beam
95  );
96 
97  // Deconvolve SkyComponent from beam
98  // moved from ImageAnalysis. this needs to be moved to a more appropriate class at some point
100  casacore::LogIO& os, const SkyComponent& skyIn,
101  const casacore::GaussianBeam& beam
102  );
103 
104  // moved from ImageAnalysis. this needs to be moved to a more appropriate class at some point
106  const SkyComponent& sky, const casacore::ImageInfo& ii,
107  const casacore::CoordinateSystem& cSys, const casacore::Unit& brightnessUnit,
109  );
110  // </group>
111 
112  // Convert 2d shape from world (world parameters=x, y, major axis,
113  // minor axis, position angle) to pixel (major, minor, pa).
114  // Can handle quantum units 'pix'. If one width is
115  // in pixel units both must be in pixel units. pixelAxes describes which
116  // 2 pixel axes of the coordinate system our 2D shape is in.
117  // If axes are not from the same coordinate type units must be pixels.
118  // If doRef is true, then x and y are taken from the reference
119  // value rather than the parameters vector.
120 
121  // On input, pa is N->E (at ref pix) for celestial planes.
122  // Otherwise pa is in pixel coordinate system +x -> +y
123  // On output, pa (radians) is positive +x -> +y in pixel frame
124  static void worldWidthsToPixel(
127  const casacore::CoordinateSystem& cSys,
128  const casacore::IPosition& pixelAxes, casacore::Bool doRef=false
129  );
130 
131  // Convert 2d shape from pixels (parameters=x,y, major axis,
132  // minor axis, position angle) to world (major, minor, pa)
133  // at specified location. pixelAxes describes which
134  // 2 pixel axes of the coordinate system our 2D shape is in.
135  // If doRef is true, then x and y are taken from the reference
136  // pixel rather than the paraneters vector.
137  //
138  // On input pa is positive for +x -> +y in pixel frame
139  // On output pa is positive N->E
140  // Returns true if major/minor exchanged themselves on conversion to world.
142  casacore::GaussianBeam& wParameters,
143  const casacore::Vector<casacore::Double>& pParameters,
144  const casacore::CoordinateSystem& cSys,
145  const casacore::IPosition& pixelAxes,
146  casacore::Bool doRef=false
147  );
148 
149 private:
150  // Convert 2d sky shape (parameters=major axis, minor axis, position angle)
151  // from pixels to world at reference pixel. pixelAxes describes which
152  // 2 pixel axes of the coordinate system our 2D shape is in.
153  // On input pa is positive for +x -> +y in pixel frame
154  // On output pa is positive N->E
155  // Returns true if major/minor exchanged themselves on conversion to world.
157  Angular2DGaussian& gauss2d,
158  const casacore::CoordinateSystem& cSys,
159  const casacore::Vector<casacore::Double>& pParameters,
160  const casacore::IPosition& pixelAxes, casacore::Bool doRef
161  );
162 
163  // Convert a length and position angle in world units (for a non-coupled
164  // coordinate) to pixels. The length is in some 2D plane in the
165  // casacore::CoordinateSystem specified by pixelAxes.
167  casacore::Double positionAngle,
169  const casacore::CoordinateSystem& cSys,
170  const casacore::IPosition& pixelAxes
171  );
172 
175  const casacore::CoordinateSystem& cSys,
176  const casacore::IPosition& pixelAxes
177  );
178 
179 };
180 
181 }
182 
183 
184 #ifndef AIPS_NO_TEMPLATE_SRC
185 #include <components/ComponentModels/SkyComponentFactory2.tcc>
186 #endif
187 
188 
189 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
std::vector< double > Vector
Definition: ds9context.h:24
static SkyComponent deconvolveSkyComponent(casacore::LogIO &os, const SkyComponent &skyIn, const casacore::GaussianBeam &beam)
Deconvolve SkyComponent from beam moved from ImageAnalysis.
static casacore::Quantum< casacore::Double > _pixelWidthToWorld(casacore::Double positionAngle, casacore::Double length, const casacore::CoordinateSystem &cSys, const casacore::IPosition &pixelAxes)
static casacore::Double _worldWidthToPixel(casacore::Double positionAngle, const casacore::Quantum< casacore::Double > &length, const casacore::CoordinateSystem &cSys, const casacore::IPosition &pixelAxes)
Convert a length and position angle in world units (for a non-coupled coordinate) to pixels...
Shape
The shapes of all the components.
static casacore::Bool pixelWidthsToWorld(casacore::GaussianBeam &wParameters, const casacore::Vector< casacore::Double > &pParameters, const casacore::CoordinateSystem &cSys, const casacore::IPosition &pixelAxes, casacore::Bool doRef=false)
Convert 2d shape from pixels (parameters=x,y, major axis, minor axis, position angle) to world (major...
virtual Type type()
Return the type enum.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::GaussianBeam Angular2DGaussian
static casacore::Vector< casacore::Double > decodeSkyComponent(const SkyComponent &sky, const casacore::ImageInfo &ii, const casacore::CoordinateSystem &cSys, const casacore::Unit &brightnessUnit, casacore::Stokes::StokesTypes stokes, casacore::Bool xIsLong)
moved from ImageAnalysis.
Represents a Gaussian restoring beam associated with an image.
Definition: GaussianBeam.h:68
StokesTypes
The Stokes types are defined by this enum.
Definition: Stokes.h:66
defines physical units
Definition: Unit.h:189
static SkyComponent encodeSkyComponent(casacore::LogIO &os, casacore::Double &facToJy, const casacore::CoordinateSystem &cSys, const casacore::Unit &brightnessUnit, ComponentType::Shape type, const casacore::Vector< casacore::Double > &parameters, casacore::Stokes::StokesTypes stokes, casacore::Bool xIsLong, const casacore::GaussianBeam &beam)
These functions convert between a vector of doubles holding SkyComponent values (the output from SkyC...
A base class for astronomical images.
double Double
Definition: aipstype.h:55
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
static casacore::Bool _skyPixelWidthsToWorld(Angular2DGaussian &gauss2d, const casacore::CoordinateSystem &cSys, const casacore::Vector< casacore::Double > &pParameters, const casacore::IPosition &pixelAxes, casacore::Bool doRef)
Convert 2d sky shape (parameters=major axis, minor axis, position angle) from pixels to world at refe...
static void worldWidthsToPixel(casacore::Vector< casacore::Double > &dParameters, const casacore::Vector< casacore::Quantum< casacore::Double > > &parameters, const casacore::CoordinateSystem &cSys, const casacore::IPosition &pixelAxes, casacore::Bool doRef=false)
Convert 2d shape from world (world parameters=x, y, major axis, minor axis, position angle) to pixel ...
A component of a model of the sky.
Definition: SkyComponent.h:130
Miscellaneous information related to an image.
Definition: ImageInfo.h:92
Interconvert pixel and world coordinates.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42