SkyComponentFactory.h

Go to the documentation of this file.
00001 //# Copyright (C) 1995,1996,1999-2001
00002 //# Associated Universities, Inc. Washington DC, USA.
00003 //#
00004 //# This library is free software; you can redistribute it and/or modify it
00005 //# under the terms of the GNU Library General Public License as published by
00006 //# the Free Software Foundation; either version 2 of the License, or (at your
00007 //# option) any later version.
00008 //#
00009 //# This library is distributed in the hope that it will be useful, but WITHOUT
00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012 //# License for more details.
00013 //#
00014 //# You should have received a copy of the GNU Library General Public License
00015 //# along with this library; if not, write to the Free Software Foundation,
00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00017 //#
00018 //# Correspondence concerning AIPS++ should be addressed as follows:
00019 //#        Internet email: aips2-request@nrao.edu.
00020 //#        Postal address: AIPS++ Project Office
00021 //#                        National Radio Astronomy Observatory
00022 //#                        520 Edgemont Road
00023 //#                        Charlottesville, VA 22903-2475 USA
00024 
00025 
00026 #ifndef SKYCOMPONENTFACTORY_H_
00027 #define SKYCOMPONENTFACTORY_H_
00028 
00029 #include <casa/aips.h>
00030 
00031 #include <components/ComponentModels/SkyComponent.h>
00032 
00033 namespace casa {
00034 
00035 class GaussianBeam;
00036 class ImageInfo;
00037 
00038 template <class T> class ImageInterface;
00039 template <class T> class Vector;
00040 
00041 class SkyComponentFactory {
00042 public:
00043 
00044     typedef GaussianBeam Angular2DGaussian;
00045         // These functions convert between a vector of doubles holding SkyComponent values
00046         // (the output from SkyComponent::toPixel) and a SkyComponent.   The coordinate
00047         // values are in the 'x' and 'y' frames.  It is possible that the x and y axes of
00048         // the pixel array are lat/long (xIsLong=False)  rather than  long/lat.
00049         // facToJy converts the brightness units from whatevers per whatever
00050         // to Jy per whatever (e.g. mJy/beam to Jy/beam).  It is unity if it
00051         // can't be done and you get a warning.  In the SkyComponent the flux
00052         // is integral.  In the parameters vector it is peak.
00053         //
00054         //   pars(0) = FLux     image units (e.g. Jy/beam).
00055         //   pars(1) = x cen    abs pix
00056         //   pars(2) = y cen    abs pix
00057         //   pars(3) = major    pix
00058         //   pars(4) = minor    pix
00059         //   pars(5) = pa radians (pos +x -> +y)
00060         //
00061         //  5 values for ComponentType::Gaussian, CT::Disk.  3 values for CT::Point.
00062         //
00063         // <group>
00064         static SkyComponent encodeSkyComponent(
00065                 LogIO& os, Double& facToJy,
00066                 const CoordinateSystem& cSys,
00067                 const Unit& brightnessUnit,
00068                 ComponentType::Shape type,
00069                 const Vector<Double>& parameters,
00070                 Stokes::StokesTypes stokes,
00071                 Bool xIsLong, const GaussianBeam& beam
00072         );
00073 
00074         // for some reason, this method was in ImageAnalysis but also belongs here.
00075         // Obviously hugely confusing to have to methods with the same name and
00076         // which presumably are for the same thing in two different classes. I'm
00077         // moving ImageAnalysis' method here and also moving that implamentation to
00078         // here as well and also being consistent regarding callers (ie those that
00079         // called the ImageAnalysis method will now call this method). I couldn't
00080         // tell you which of the two implementations is the better one to use
00081         // for new code, but this version does call the version that already existed
00082         // in ImageUtilities, so this version seems to do a bit more.
00083         // I also hate having a class with anything like Utilities in the name,
00084         // but I needed to move this somewhere and can only tackle one issue
00085         // at a time.
00086         static SkyComponent encodeSkyComponent(
00087                 LogIO& os, Double& fluxRatio,
00088                 const ImageInterface<Float>& im,
00089                 casa::ComponentType::Shape modelType,
00090                 const Vector<Double>& parameters,
00091                 Stokes::StokesTypes stokes,
00092                 Bool xIsLong, Bool deconvolveIt,
00093                 const GaussianBeam& beam
00094         );
00095 
00096         // Deconvolve SkyComponent from beam
00097         // moved from ImageAnalysis. this needs to be moved to a more appropriate class at some point
00098         static SkyComponent deconvolveSkyComponent(
00099                 LogIO& os, const SkyComponent& skyIn,
00100                 const GaussianBeam& beam
00101         );
00102 
00103         // moved from ImageAnalysis. this needs to be moved to a more appropriate class at some point
00104         static Vector<Double> decodeSkyComponent (
00105                 const SkyComponent& sky, const ImageInfo& ii,
00106                 const CoordinateSystem& cSys, const Unit& brightnessUnit,
00107                 Stokes::StokesTypes stokes, Bool xIsLong
00108         );
00109         // </group>
00110 
00111         // Convert 2d shape from world (world parameters=x, y, major axis,
00112         // minor axis, position angle) to pixel (major, minor, pa).
00113         // Can handle quantum units 'pix'.  If one width is
00114         // in pixel units both must be in pixel units.  pixelAxes describes which
00115         // 2 pixel axes of the coordinate system our 2D shape is in.
00116         // If axes are not from the same coordinate type units must be pixels.
00117         // If doRef is True, then x and y are taken from the reference
00118         // value rather than the parameters vector.
00119 
00120         // On input, pa is N->E (at ref pix) for celestial planes.
00121         // Otherwise pa is in pixel coordinate system +x -> +y
00122         // On output, pa (radians) is positive +x -> +y in pixel frame
00123         static void worldWidthsToPixel(
00124                 Vector<Double>& dParameters,
00125                 const Vector<Quantum<Double> >& parameters,
00126                 const CoordinateSystem& cSys,
00127                 const IPosition& pixelAxes, Bool doRef=False
00128         );
00129 
00130         // Convert 2d shape  from pixels (parameters=x,y, major axis,
00131         // minor axis, position angle) to world (major, minor, pa)
00132         // at specified location. pixelAxes describes which
00133         // 2 pixel axes of the coordinate system our 2D shape is in.
00134         // If doRef is True, then x and y are taken from the reference
00135         // pixel rather than the paraneters vector.
00136         //
00137         // On input pa is positive for +x -> +y in pixel frame
00138         // On output pa is positive N->E
00139         // Returns True if major/minor exchanged themselves on conversion to world.
00140         static Bool pixelWidthsToWorld(
00141                 GaussianBeam& wParameters,
00142                 const Vector<Double>& pParameters,
00143                 const CoordinateSystem& cSys,
00144                 const IPosition& pixelAxes,
00145                 Bool doRef=False
00146         );
00147 
00148 private:
00149         // Convert 2d sky shape (parameters=major axis, minor axis, position angle)
00150         // from pixels to world at reference pixel. pixelAxes describes which
00151         // 2 pixel axes of the coordinate system our 2D shape is in.
00152         // On input pa is positive for +x -> +y in pixel frame
00153         // On output pa is positive N->E
00154         // Returns True if major/minor exchanged themselves on conversion to world.
00155         static Bool _skyPixelWidthsToWorld(
00156                 Angular2DGaussian& gauss2d,
00157                 const CoordinateSystem& cSys,
00158                 const Vector<Double>& pParameters,
00159                 const IPosition& pixelAxes, Bool doRef
00160         );
00161 
00162         // Convert a length and position angle in world units (for a non-coupled
00163         // coordinate) to pixels. The length is in some 2D plane in the
00164         // CoordinateSystem specified  by pixelAxes.
00165     static Double _worldWidthToPixel (
00166         Double positionAngle,
00167         const Quantum<Double>& length,
00168         const CoordinateSystem& cSys,
00169         const IPosition& pixelAxes
00170     );
00171 
00172     static Quantum<Double> _pixelWidthToWorld (
00173         Double positionAngle, Double length,
00174         const CoordinateSystem& cSys,
00175         const IPosition& pixelAxes
00176     );
00177 
00178 };
00179 
00180 } // end namespace casa
00181 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1