casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSTransformRegridder.h
Go to the documentation of this file.
1 //# MSTransformRegridder.h: This file contains the interface definition of the MSTransformRegridder class.
2 //#
3 //# CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
4 //# Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
5 //# Copyright (C) European Southern Observatory, 2011, All rights reserved.
6 //#
7 //# This library is free software; you can redistribute it and/or
8 //# modify it under the terms of the GNU Lesser General Public
9 //# License as published by the Free software Foundation; either
10 //# version 2.1 of the License, or (at your option) any later version.
11 //#
12 //# This library is distributed in the hope that it will be useful,
13 //# but WITHOUT ANY WARRANTY, without even the implied warranty of
14 //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 //# Lesser General Public License for more details.
16 //#
17 //# You should have received a copy of the GNU Lesser General Public
18 //# License along with this library; if not, write to the Free Software
19 //# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 //# MA 02111-1307 USA
21 //# $Id: $
22 
23 #ifndef MSTransformRegridder_H_
24 #define MSTransformRegridder_H_
25 
26 // Logging
27 #include <casa/Logging/LogIO.h>
28 
29 // casacore::Coordinate systems
31 
32 // casacore::MS handling
33 #include <ms/MeasurementSets.h>
34 
35 // To use ostringstream
36 #include <iomanip>
37 
38 // Enable record conversions
40 
41 
42 namespace casa { //# NAMESPACE CASA - BEGIN
43 
44 // MSTransformRegridder definition
46 {
47 
48 public:
49 
52 
53  // Make one spectral window from all SPWs given by the SPW Ids vector
55  casacore::String msName,
56  const casacore::Vector<casacore::Int>& spwids, // casacore::Vector<casacore::Int>(1,-1) means: use all SPWs
57  casacore::Vector<casacore::Double>& newCHAN_FREQ, // Will return the grid of the resulting SPW
59  std::vector<std::vector<casacore::Int> >& averageWhichChan,
60  std::vector<std::vector<casacore::Int> >& averageWhichSPW,
61  std::vector<std::vector<casacore::Double> >& averageChanFrac,
62  casacore::Bool verbose = false);
63 
64  // Make one spectral window from all SPWs given by the SPW Ids vector
67  const casacore::Vector<casacore::Int>& spwids, // casacore::Vector<casacore::Int>(1,-1) means: use all SPWs
68  casacore::Vector<casacore::Double>& newCHAN_FREQ, // Will return the grid of the resulting SPW
70  std::vector<std::vector<casacore::Int> >& averageWhichChan,
71  std::vector<std::vector<casacore::Int> >& averageWhichSPW,
72  std::vector<std::vector<casacore::Double> >& averageChanFrac,
73  casacore::Bool verbose = false);
74 
75  // A wrapper for regridChanBounds() which takes the user interface type re-gridding parameters
76  // The ready-made grid is returned in newCHAN_FREQ and newCHAN_WIDTH
78  // Output
81  casacore::Double& weightScale,
82  // casacore::Input (original grid)
83  const casacore::Vector<casacore::Double>& oldCHAN_FREQ,
84  const casacore::Vector<casacore::Double>& oldCHAN_WIDTH,
85  // Re-gridding parameters
86  const casacore::MDirection phaseCenter,
87  const casacore::MFrequency::Types theOldRefFrame,
88  const casacore::MEpoch theObsTime,
89  const casacore::MPosition mObsPos,
90  const casacore::String& mode,
91  const int nchan,
92  const casacore::String& start,
93  const casacore::String& width,
94  const casacore::String& restfreq,
95  const casacore::String& outframe,
96  const casacore::String& veltype,
97  const casacore::Bool verbose=false,
98  // Additional radial velocity shift to apply, used e.g. when outframe=="SOURCE"
100 
101  // Helper function for handling the re-gridding parameter user input
103  const casacore::String& mode,
104  const int nchan,
105  const casacore::String& start,
106  const casacore::String& width,
107  const casacore::String& interp,
108  const casacore::String& restfreq,
109  const casacore::String& outframe,
110  const casacore::String& veltype,
111  casacore::String& t_mode,
112  casacore::String& t_outframe,
113  casacore::String& t_regridQuantity,
114  casacore::Double& t_restfreq,
115  casacore::String& t_regridInterpMeth,
116  casacore::Double& t_cstart,
117  casacore::Double& t_bandwidth,
118  casacore::Double& t_cwidth,
119  casacore::Bool& t_centerIsStart,
120  casacore::Bool& t_startIsEnd,
121  casacore::Int& t_nchan,
122  casacore::Int& t_width,
123  casacore::Int& t_start);
124 
125  // Calculate the final new channel boundaries from the re-regridding parameters and
126  // the old channel boundaries (already transformed to the desired reference frame).
127  // Returns false if input parameters were invalid and no useful boundaries could be created
129  casacore::Vector<casacore::Double>& newChanHiBound,
130  const casacore::Double regridCenter,
131  const casacore::Double regridBandwidth,
132  const casacore::Double regridChanWidth,
133  const casacore::Double regridVeloRestfrq,
134  const casacore::String regridQuant,
135  const casacore::Vector<casacore::Double>& transNewXin,
136  const casacore::Vector<casacore::Double>& transCHAN_WIDTH,
137  casacore::String& message, // message to the user, especially in case of error
138  const casacore::Bool centerIsStart=false, // if true, the parameter regridCenter specifies the start
139  const casacore::Bool startIsEnd=false, // if true, and centerIsStart is true, regridCenter specifies the upper end in frequency
140  const casacore::Int nchan=0, // if != 0 : used instead of regridBandwidth, -1 means use all channels
141  const casacore::Int width=0, // if >0 and regridQuant=="freq": used instead of regridChanWidth
142  const casacore::Int start=-1); // if >=0 and regridQuant=="freq": used instead of regridCenter
143 
144  // The following inline convenience methods for regridSpw bypass the whole CASA measure system
145  // because when they are used, they can assume that the frame stays the same and the units are OK
146  static casacore::lDouble vrad(const casacore::lDouble freq, const casacore::lDouble rest){ return (casacore::C::c * (1. - freq/rest)); };
147  static casacore::lDouble vopt(const casacore::lDouble freq, const casacore::lDouble rest){ return (casacore::C::c *(rest/freq - 1.)); };
148  static casacore::lDouble lambda(const casacore::lDouble freq){ return (casacore::C::c/freq); };
149  static casacore::lDouble freq_from_vrad(const casacore::lDouble vrad, const casacore::lDouble rest){ return (rest * (1. - vrad/casacore::C::c)); };
150  static casacore::lDouble freq_from_vopt(const casacore::lDouble vopt, const casacore::lDouble rest){ return (rest / (1. + vopt/casacore::C::c)); };
152 };
153 
154 } //# NAMESPACE CASA - END
155 
156 #endif /* MSTransformRegridder_H_ */
static casacore::lDouble freq_from_vrad(const casacore::lDouble vrad, const casacore::lDouble rest)
A Measure: astronomical direction.
Definition: MDirection.h:174
static casacore::Bool calcChanFreqs(casacore::LogIO &os, casacore::Vector< casacore::Double > &newCHAN_FREQ, casacore::Vector< casacore::Double > &newCHAN_WIDTH, casacore::Double &weightScale, const casacore::Vector< casacore::Double > &oldCHAN_FREQ, const casacore::Vector< casacore::Double > &oldCHAN_WIDTH, const casacore::MDirection phaseCenter, const casacore::MFrequency::Types theOldRefFrame, const casacore::MEpoch theObsTime, const casacore::MPosition mObsPos, const casacore::String &mode, const int nchan, const casacore::String &start, const casacore::String &width, const casacore::String &restfreq, const casacore::String &outframe, const casacore::String &veltype, const casacore::Bool verbose=false, const casacore::MRadialVelocity mRV=casacore::MRadialVelocity())
A wrapper for regridChanBounds() which takes the user interface type re-gridding parameters The ready...
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
static casacore::Bool regridChanBounds(casacore::Vector< casacore::Double > &newChanLoBound, casacore::Vector< casacore::Double > &newChanHiBound, const casacore::Double regridCenter, const casacore::Double regridBandwidth, const casacore::Double regridChanWidth, const casacore::Double regridVeloRestfrq, const casacore::String regridQuant, const casacore::Vector< casacore::Double > &transNewXin, const casacore::Vector< casacore::Double > &transCHAN_WIDTH, casacore::String &message, const casacore::Bool centerIsStart=false, const casacore::Bool startIsEnd=false, const casacore::Int nchan=0, const casacore::Int width=0, const casacore::Int start=-1)
Calculate the final new channel boundaries from the re-regridding parameters and the old channel boun...
MSTransformRegridder definition.
static casacore::Bool convertGridPars(casacore::LogIO &os, const casacore::String &mode, const int nchan, const casacore::String &start, const casacore::String &width, const casacore::String &interp, const casacore::String &restfreq, const casacore::String &outframe, const casacore::String &veltype, casacore::String &t_mode, casacore::String &t_outframe, casacore::String &t_regridQuantity, casacore::Double &t_restfreq, casacore::String &t_regridInterpMeth, casacore::Double &t_cstart, casacore::Double &t_bandwidth, casacore::Double &t_cwidth, casacore::Bool &t_centerIsStart, casacore::Bool &t_startIsEnd, casacore::Int &t_nchan, casacore::Int &t_width, casacore::Int &t_start)
Helper function for handling the re-gridding parameter user input.
static casacore::lDouble vopt(const casacore::lDouble freq, const casacore::lDouble rest)
ostream-like interface to creating log messages.
Definition: LogIO.h:167
A Measure: radial velocity.
static casacore::lDouble freq_from_lambda(const casacore::lDouble lambda)
A Measure: instant in time.
Definition: MEpoch.h:104
double Double
Definition: aipstype.h:55
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A Table intended to hold astronomical data (a set of Measurements).
long double lDouble
Definition: aipstype.h:56
static casacore::lDouble lambda(const casacore::lDouble freq)
static casacore::Bool combineSpwsCore(casacore::LogIO &os, casacore::MeasurementSet &ms_p, const casacore::Vector< casacore::Int > &spwids, casacore::Vector< casacore::Double > &newCHAN_FREQ, casacore::Vector< casacore::Double > &newCHAN_WIDTH, std::vector< std::vector< casacore::Int > > &averageWhichChan, std::vector< std::vector< casacore::Int > > &averageWhichSPW, std::vector< std::vector< casacore::Double > > &averageChanFrac, casacore::Bool verbose=false)
Make one spectral window from all SPWs given by the SPW Ids vector.
const Double c
Fundamental physical constants (SI units):
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition: MFrequency.h:176
static casacore::lDouble freq_from_vopt(const casacore::lDouble vopt, const casacore::lDouble rest)
static casacore::Bool combineSpws(casacore::LogIO &os, casacore::String msName, const casacore::Vector< casacore::Int > &spwids, casacore::Vector< casacore::Double > &newCHAN_FREQ, casacore::Vector< casacore::Double > &newCHAN_WIDTH, std::vector< std::vector< casacore::Int > > &averageWhichChan, std::vector< std::vector< casacore::Int > > &averageWhichSPW, std::vector< std::vector< casacore::Double > > &averageChanFrac, casacore::Bool verbose=false)
Make one spectral window from all SPWs given by the SPW Ids vector.
static casacore::lDouble vrad(const casacore::lDouble freq, const casacore::lDouble rest)
The following inline convenience methods for regridSpw bypass the whole CASA measure system because w...