RegriddingTVI.h

Go to the documentation of this file.
00001 //# RegriddingTVI.h: This file contains the interface definition of the MSTransformManager 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 RegriddingTVI_H_
00024 #define RegriddingTVI_H_
00025 
00026 // Base class
00027 #include <mstransform/TVI/FreqAxisTVI.h>
00028 
00029 // To handle variant parameters
00030 #include <stdcasa/StdCasa/CasacSupport.h>
00031 
00032 // MS Access
00033 #include <ms/MeasurementSets.h>
00034 
00035 // To get observatory position from observatory name
00036 #include <measures/Measures/MeasTable.h>
00037 
00038 // calcChanFreqs
00039 #include <mstransform/MSTransform/MSTransformManager.h>
00040 
00041 // 1d interpolation methods
00042 #include <casacore/scimath/Mathematics/InterpolateArray1D.h>
00043 
00044 namespace casa { //# NAMESPACE CASA - BEGIN
00045 
00046 namespace vi { //# NAMESPACE VI - BEGIN
00047 
00049 // Enumerations (see equivalences in InterpolateArray1D.h)
00051 
00052 enum RegriddingMethod {
00053     // nearest neighbour
00054     nearestNeighbour,
00055     // linear
00056     linear,
00057     // cubic
00058     cubic,
00059     // cubic spline
00060     spline,
00061     // fft shift
00062     fftshift
00063   };
00064 
00065 const Unit Hz(String("Hz"));
00066 
00068 // RegriddingTVI class
00070 
00071 class RegriddingTVI : public FreqAxisTVI
00072 {
00073 
00074 public:
00075 
00076         RegriddingTVI(  ViImplementation2 * inputVii,
00077                                         const Record &configuration);
00078 
00079         // Report the the ViImplementation type
00080         virtual String ViiType() const { return String("Regridding( ")+getVii()->ViiType()+" )"; };
00081 
00082         // Navigation methods
00083         void origin ();
00084 
00085         // Frequency specification methods
00086     Int getReportingFrameOfReference () const; // Used by VisBufferImpl2 to determine default ref. frame
00087     Vector<Double> getFrequencies (     Double time, Int frameOfReference,
00088                                                                 Int spectralWindowId, Int msId) const;
00089     // Data accessors
00090     void flag(Cube<Bool>& flagCube) const;
00091     void floatData (Cube<Float> & vis) const;
00092     void visibilityObserved (Cube<Complex> & vis) const;
00093     void visibilityCorrected (Cube<Complex> & vis) const;
00094     void visibilityModel (Cube<Complex> & vis) const;
00095     void weightSpectrum(Cube<Float> &weightSp) const;
00096     void sigmaSpectrum (Cube<Float> &sigmaSp) const;
00097 
00098     Bool weightSpectrumExists () const {return True;}
00099     Bool sigmaSpectrumExists () const {return True;}
00100 
00101 protected:
00102 
00103     Bool parseConfiguration(const Record &configuration);
00104     void initialize();
00105 
00106     void initFrequencyGrid();
00107     void initFrequencyTransformationEngine() const;
00108 
00109     template<class T> void transformDataCube(   const Cube<T> &inputVis,
00110                                                                                         Cube<T> &outputVis) const;
00111 
00112         int nChan_p;
00113         String mode_p;
00114         String start_p;
00115         String width_p;
00116         String velocityType_p;
00117         String restFrequency_p;
00118         String interpolationMethodPar_p;
00119         String outputReferenceFramePar_p;
00120         casac::variant *phaseCenterPar_p;
00121         uInt regriddingMethod_p;
00122 
00123         Bool refFrameTransformation_p;
00124         Bool radialVelocityCorrection_p;
00125         Bool radialVelocityCorrectionSignificant_p;
00126 
00127         MEpoch referenceTime_p;
00128         MDirection phaseCenter_p;
00129         MPosition observatoryPosition_p;
00130         MRadialVelocity radialVelocity_p;
00131         MFrequency::Types outputReferenceFrame_p;
00132         MFrequency::Types inputReferenceFrame_p;
00133 
00134         mutable MFrequency::Convert freqTransEngine_p;
00135         mutable uInt freqTransEngineRowId_p;
00136 
00137         mutable Double fftShift_p;
00138     FFTServer<Float, Complex> fFFTServer_p;
00139 
00140         ROMSColumns *selectedInputMsCols_p;
00141         MSFieldColumns *inputMSFieldCols_p;
00142 
00143         mutable map<Int,Float> weightFactorMap_p;
00144         mutable map<Int,Float> sigmaFactorMap_p;
00145         mutable inputOutputSpwMap inputOutputSpwMap_p;
00146 };
00147 
00148 
00150 // RegriddingTVIFactory class
00152 
00153 class RegriddingTVIFactory : public ViFactory
00154 {
00155 
00156 public:
00157 
00158         RegriddingTVIFactory(Record &configuration,ViImplementation2 *inputVII);
00159 
00160 protected:
00161 
00162         vi::ViImplementation2 * createVi (VisibilityIterator2 *) const;
00163         vi::ViImplementation2 * createVi () const;
00164 
00165         Record configuration_p;
00166         ViImplementation2 *inputVii_p;
00167 };
00168 
00170 // RegriddingTransformEngine class
00172 
00173 template<class T> class RegriddingKernel; // Forward declaration
00174 
00175 template<class T> class RegriddingTransformEngine : public FreqAxisTransformEngine2<T>
00176 {
00177 
00178         using FreqAxisTransformEngine2<T>::inputData_p;
00179         using FreqAxisTransformEngine2<T>::outputData_p;
00180 
00181 public:
00182 
00183         RegriddingTransformEngine       (       RegriddingKernel<T> *kernel,
00184                                                                         DataCubeMap *inputData,
00185                                                                         DataCubeMap *outputData);
00186 
00187         void transform();
00188 
00189 protected:
00190 
00191         // This member has to be a pointer, otherwise there
00192         // are compile time problems due to the fact that
00193         // it is a pure virtual class.
00194         RegriddingKernel<T> *regriddingKernel_p;
00195 };
00196 
00198 // RegriddingKernel class
00200 
00201 template<class T> class RegriddingKernel
00202 {
00203 
00204 public:
00205 
00206         RegriddingKernel();
00207         virtual void kernel(DataCubeMap *inputData,DataCubeMap *outputData) = 0;
00208         virtual ~RegriddingKernel() {}
00209 
00210 protected:
00211 
00212         Vector<Bool> & getInputFlagVector(DataCubeMap *inputData);
00213         Vector<Bool> & getOutputFlagVector(DataCubeMap *outputData);
00214         Vector<T> & getInputDataVector(DataCubeMap *inputData);
00215         Vector<T> & getOutputDataVector(DataCubeMap *outputData);
00216 
00217         Vector<Bool> inputDummyFlagVector_p;
00218         Vector<Bool> outputDummyFlagVector_p;
00219         Vector<T> inputDummyDataVector_p;
00220         Vector<T> outputDummyDataVector_p;
00221 
00222         Bool inputDummyFlagVectorInitialized_p;
00223         Bool outputDummyFlagVectorInitialized_p;
00224         Bool inputDummyDataVectorInitialized_p;
00225         Bool outputDummyDataVectorInitialized_p;
00226 
00227 };
00228 
00230 // DataInterpolationKernel class
00232 
00233 template<class T> class DataInterpolationKernel : public RegriddingKernel<T>
00234 {
00235         using RegriddingKernel<T>::getInputFlagVector;
00236         using RegriddingKernel<T>::getOutputFlagVector;
00237         using RegriddingKernel<T>::getInputDataVector;
00238         using RegriddingKernel<T>::getOutputDataVector;
00239 
00240 public:
00241 
00242         DataInterpolationKernel(        uInt interpolationMethod,
00243                                                                 Vector<Double> *inputFreq,
00244                                                                 Vector<Double> *outputFreq);
00245 
00246         ~DataInterpolationKernel() {}
00247 
00248         void kernel(DataCubeMap *inputData,DataCubeMap *outputData);
00249 
00250 protected:
00251 
00252         uInt interpolationMethod_p;
00253         Vector<Double> *inputFreq_p;
00254         Vector<Double> *outputFreq_p;
00255 };
00256 
00258 // FlagFFTKernel class
00260 
00261 template<class T> class DataFFTKernel : public RegriddingKernel<T>
00262 {
00263         using RegriddingKernel<T>::getInputFlagVector;
00264         using RegriddingKernel<T>::getOutputFlagVector;
00265         using RegriddingKernel<T>::getInputDataVector;
00266         using RegriddingKernel<T>::getOutputDataVector;
00267 
00268 public:
00269 
00270         DataFFTKernel(Double fftShift);
00271 
00272         ~DataFFTKernel() {}
00273 
00274         void kernel(DataCubeMap *inputData,DataCubeMap *outputData);
00275 
00276 protected:
00277 
00278         void fftshift(  Vector<Complex> &inputDataVector,
00279                                         Vector<Bool> &inputFlagVector,
00280                                         Vector<Complex> &outputDataVector,
00281                                         Vector<Bool> &outputFlagVector);
00282 
00283         void fftshift(  Vector<Float> &inputDataVector,
00284                                         Vector<Bool> &inputFlagVector,
00285                                         Vector<Float> &outputDataVector,
00286                                         Vector<Bool> &outputFlagVector);
00287 
00288 
00289         Double fftShift_p;
00290         FFTServer<Float, Complex> fFFTServer_p;
00291 };
00292 
00293 } //# NAMESPACE VI - END
00294 
00295 } //# NAMESPACE CASA - END
00296 
00297 #endif /* RegriddingTVI_H_ */
00298 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1