MSTransformRegridder.h

Go to the documentation of this file.
00001 //# MSTransformRegridder.h: This file contains the interface definition of the MSTransformRegridder class.
00002 //#
00003 //#  CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
00004 //#  Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
00005 //#  Copyright (C) European Southern Observatory, 2011, All rights reserved.
00006 //#
00007 //#  This library is free software; you can redistribute it and/or
00008 //#  modify it under the terms of the GNU Lesser General Public
00009 //#  License as published by the Free software Foundation; either
00010 //#  version 2.1 of the License, or (at your option) any later version.
00011 //#
00012 //#  This library is distributed in the hope that it will be useful,
00013 //#  but WITHOUT ANY WARRANTY, without even the implied warranty of
00014 //#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 //#  Lesser General Public License for more details.
00016 //#
00017 //#  You should have received a copy of the GNU Lesser General Public
00018 //#  License along with this library; if not, write to the Free Software
00019 //#  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00020 //#  MA 02111-1307  USA
00021 //# $Id: $
00022 
00023 #ifndef MSTransformRegridder_H_
00024 #define MSTransformRegridder_H_
00025 
00026 // Logging
00027 #include <casa/Logging/LogIO.h>
00028 
00029 // Coordinate systems
00030 #include <measures/Measures/MeasTable.h>
00031 
00032 // MS handling
00033 #include <ms/MeasurementSets.h>
00034 
00035 // To use ostringstream
00036 #include <iomanip>
00037 
00038 // Enable record conversions
00039 #include <casa/Quanta/QuantumHolder.h>
00040 
00041 
00042 namespace casa { //# NAMESPACE CASA - BEGIN
00043 
00044 //  MSTransformRegridder definition
00045 class MSTransformRegridder
00046 {
00047 
00048 public:
00049 
00050         MSTransformRegridder();
00051         ~MSTransformRegridder();
00052 
00053         // Make one spectral window from all SPWs given by the SPW Ids vector
00054         static Bool combineSpws(        LogIO& os,
00055                                                                 String msName,
00056                                                                 const Vector<Int>& spwids, // Vector<Int>(1,-1) means: use all SPWs
00057                                                                 Vector<Double>& newCHAN_FREQ, // Will return the grid of the resulting SPW
00058                                                                 Vector<Double>& newCHAN_WIDTH,
00059                                                                 std::vector<std::vector<Int> >& averageWhichChan,
00060                                                                 std::vector<std::vector<Int> >& averageWhichSPW,
00061                                                                 std::vector<std::vector<Double> >& averageChanFrac,
00062                                                                 Bool verbose = False);
00063 
00064         // Make one spectral window from all SPWs given by the SPW Ids vector
00065         static Bool combineSpwsCore(    LogIO& os,
00066                                                                         MeasurementSet& ms_p,
00067                                                                         const Vector<Int>& spwids, // Vector<Int>(1,-1) means: use all SPWs
00068                                                                         Vector<Double>& newCHAN_FREQ, // Will return the grid of the resulting SPW
00069                                                                         Vector<Double>& newCHAN_WIDTH,
00070                                                                         std::vector<std::vector<Int> >& averageWhichChan,
00071                                                                         std::vector<std::vector<Int> >& averageWhichSPW,
00072                                                                         std::vector<std::vector<Double> >& averageChanFrac,
00073                                                                         Bool verbose = False);
00074 
00075         // A wrapper for regridChanBounds() which takes the user interface type re-gridding parameters
00076         // The ready-made grid is returned in newCHAN_FREQ and newCHAN_WIDTH
00077         static Bool calcChanFreqs(      LogIO& os,
00078                                                                 // Output
00079                                                                 Vector<Double>& newCHAN_FREQ,
00080                                                                 Vector<Double>& newCHAN_WIDTH,
00081                                                                 Double& weightScale,
00082                                                                 // Input (original grid)
00083                                                                 const Vector<Double>& oldCHAN_FREQ,
00084                                                                 const Vector<Double>& oldCHAN_WIDTH,
00085                                                                 // Re-gridding parameters
00086                                                                 const MDirection  phaseCenter,
00087                                                                 const MFrequency::Types theOldRefFrame,
00088                                                                 const MEpoch theObsTime,
00089                                                                 const MPosition mObsPos,
00090                                                                 const String& mode,
00091                                                                 const int nchan,
00092                                                                 const String& start,
00093                                                                 const String& width,
00094                                                                 const String& restfreq,
00095                                                                 const String& outframe,
00096                                                                 const String& veltype,
00097                                                                 const Bool verbose=False,
00098                                                                 // Additional radial velocity shift to apply, used e.g. when outframe=="SOURCE"
00099                                                                 const MRadialVelocity mRV=MRadialVelocity() );
00100 
00101           // Helper function for handling the re-gridding parameter user input
00102           static Bool convertGridPars(LogIO& os,
00103                                                           const String& mode,
00104                                                           const int nchan,
00105                                                           const String& start,
00106                                                           const String& width,
00107                                                           const String& interp,
00108                                                           const String& restfreq,
00109                                                           const String& outframe,
00110                                                           const String& veltype,
00111                                                           String& t_mode,
00112                                                           String& t_outframe,
00113                                                           String& t_regridQuantity,
00114                                                           Double& t_restfreq,
00115                                                           String& t_regridInterpMeth,
00116                                                           Double& t_cstart,
00117                                                           Double& t_bandwidth,
00118                                                           Double& t_cwidth,
00119                                                           Bool& t_centerIsStart,
00120                                                           Bool& t_startIsEnd,
00121                                                           Int& t_nchan,
00122                                                           Int& t_width,
00123                                                           Int& t_start);
00124 
00125           // Calculate the final new channel boundaries from the re-regridding parameters and
00126           // the old channel boundaries (already transformed to the desired reference frame).
00127           // Returns False if input parameters were invalid and no useful boundaries could be created
00128           static Bool regridChanBounds(Vector<Double>& newChanLoBound,
00129                                                            Vector<Double>& newChanHiBound,
00130                                                            const Double regridCenter,
00131                                                            const Double regridBandwidth,
00132                                                            const Double regridChanWidth,
00133                                                            const Double regridVeloRestfrq,
00134                                                            const String regridQuant,
00135                                                            const Vector<Double>& transNewXin,
00136                                                            const Vector<Double>& transCHAN_WIDTH,
00137                                                            String& message, // message to the user, especially in case of error
00138                                                            const Bool centerIsStart=False, // if true, the parameter regridCenter specifies the start
00139                                                            const Bool startIsEnd=False, // if true, and centerIsStart is true, regridCenter specifies the upper end in frequency
00140                                                            const Int nchan=0, // if != 0 : used instead of regridBandwidth, -1 means use all channels
00141                                                            const Int width=0, // if >0 and regridQuant=="freq": used instead of regridChanWidth
00142                                                            const Int start=-1); // if >=0 and regridQuant=="freq": used instead of regridCenter
00143 
00144           // The following inline convenience methods for regridSpw bypass the whole CASA measure system
00145           // because when they are used, they can assume that the frame stays the same and the units are OK
00146           static lDouble vrad(const lDouble freq, const lDouble rest){ return (C::c * (1. - freq/rest)); };
00147           static lDouble vopt(const lDouble freq, const lDouble rest){ return (C::c *(rest/freq - 1.)); };
00148           static lDouble lambda(const lDouble freq){ return (C::c/freq); };
00149           static lDouble freq_from_vrad(const lDouble vrad, const lDouble rest){ return (rest * (1. - vrad/C::c)); };
00150           static lDouble freq_from_vopt(const lDouble vopt, const lDouble rest){ return (rest / (1. + vopt/C::c)); };
00151           static lDouble freq_from_lambda(const lDouble lambda){ return (C::c/lambda); };
00152 };
00153 
00154 } //# NAMESPACE CASA - END
00155 
00156 #endif /* MSTransformRegridder_H_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1