casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
ConverterIntensity.h
Go to the documentation of this file.
00001 //# Copyright (C) 2005
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 CONVERTERINTENSITY_H_
00027 #define CONVERTERINTENSITY_H_
00028 
00029 #include <QString>
00030 #include <QList>
00031 #include <casa/Arrays/Vector.h>
00032 
00033 namespace casa {
00034 
00039 class ConverterIntensity {
00040 public:
00041         static const QString FRACTION_OF_PEAK;
00042         static const QString KELVIN;
00043         static const QString JY_SR;
00044         static const QString JY_ARCSEC;
00045         static const QString JY_BEAM;
00046         static const QString JY;
00047         static const QString ADU;
00048         static const QString TIMES_PIXELS;
00049         static bool isSupportedUnits( const QString& yUnit );
00050         //Hertz values are needed corresponding to the values for Jy/Beam Kelvin conversions
00051         //only.  Both oldUnits and newUnits refer to the old and new units of the values
00052         //array.  In order to do FRACTION_OF_PEAK conversions, a maximum value with
00053         //corresponding maximum units must be passed in.
00054         static void convert( Vector<float>& values, const Vector<float> hertzValues,
00055                         const QString& oldUnits, const QString& newUnits,
00056                         double maxValue, const QString& maxUnits );
00057 
00058         //A solid angle in sr units is needed in order to do Kelvin conversions.
00059         static void setSolidAngle( double angle );
00060 
00061         //Beam area in "sr".  Needed for Jy/beam <-> Jy/arcsec^2 and Jy/sr conversions.
00062         static void setBeamArea( double beamArea );
00063 
00064         //Converts between Jy/Beam units.  For example, MJy/Beam <-> Jy/Beam
00065         static double convertJyBeams( const QString& sourceUnits, const QString& destUnits, double value );
00066         static double convertJY( const QString& oldUnits, const QString& newUnits, double value );
00067         static double convertJYSR( const QString& oldUnits,const QString& newUnits, double value );
00068         static double convertKelvin( const QString& oldUnits,const QString& newUnits, double value );
00069         virtual ~ConverterIntensity();
00070 
00071 private:
00072         ConverterIntensity();
00073         static double percentToValue( double yValue, double maxValue );
00074         static double valueToPercent( double yValue, double maxValue );
00075         static double convertQuantity( double yValue, double frequencyValue,
00076                         const QString& oldUnits, const QString& newUnits );
00077         static void convertJansky( Vector<float>& values, const QString& oldUnits,
00078                         const QString& newUnits );
00079         static void convertKelvin( Vector<float>& values, const QString& oldUnits,
00080                         const QString& newUnits );
00081         static bool isJansky( const QString& units );
00082         static bool isKelvin( const QString& units );
00083         static double convertNonKelvinUnits( double yValue,
00084                         const QString& oldUnits, const QString& newUnits );
00085         static QString getJanskyBaseUnits( const QString& units );
00086         static QString getKelvinBaseUnits( const QString& units );
00087         static QString stripPixels( const QString& units );
00088         static double beamToArcseconds( double yValue );
00089         static double arcsecondsToBeam( double yValue );
00090         static double srToArcseconds( double yValue );
00091         static double arcsecondsToSr( double yValue );
00092         static const QList<QString> BEAM_UNITS;
00093         static const QList<QString> JY_UNITS;
00094         static const QList<QString> JY_SR_UNITS;
00095         static const QList<QString> KELVIN_UNITS;
00096         static double beamSolidAngle;
00097         static const double SPEED_LIGHT_FACTOR;
00098         static const double FREQUENCY_FACTOR;
00099         static const double ARCSECONDS_PER_STERADIAN;
00100         static double beamArea;
00101 };
00102 
00103 } /* namespace casa */
00104 #endif /* CONVERTERINTENSITY_H_ */