casa
$Rev:20696$
|
00001 //# MSMoments.h: generate moments from MS 00002 //# Copyright (C) 1997,1998,1999,2000,2001 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id: MSMoments.h 20838 2009-12-01 10:10:55Z gervandiepen $ 00028 00029 #ifndef _MS_MSMOMENTS_H_ 00030 #define _MS_MSMOMENTS_H_ 00031 00032 #include <casa/aips.h> 00033 #include <casa/Arrays/Vector.h> 00034 #include <casa/Arrays/Slice.h> 00035 #include <casa/Arrays/Slicer.h> 00036 #include <ms/MeasurementSets/MeasurementSet.h> 00037 #include <ms/MeasurementSets/StokesConverter.h> 00038 #include <ms/MeasurementSets/MSDerivedValues.h> 00039 #include <ms/MeasurementSets/MSSelectionKeywords.h> 00040 //#include <images/Images/MomentsBase.h> 00041 #include <imageanalysis/ImageAnalysis/MomentCalculator.h> 00042 00043 namespace casa { //# NAMESPACE CASA - BEGIN 00044 00045 template<class T> class MomentCalcBase; 00046 template<class T> class MomentsBase; 00047 00048 00049 // <summary> 00050 // This class generates moments from a spectral data. 00051 // </summary> 00052 00053 // <use visibility=export> 00054 00055 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00056 // </reviewed> 00057 00058 // <prerequisite> 00059 // <li> <linkto class="MeasurementSet">MeasurementSet</linkto> 00060 // <li> <linkto class="ImageMoments">ImageMoments</linkto> 00061 // <li> <linkto class="LatticeApply">LatticeApply</linkto> 00062 // <li> <linkto class="MomentCalcBase">MomentCalcBase</linkto> 00063 // </prerequisite> 00064 // 00065 // <etymology> 00066 // This class computes moments from spectral data. 00067 // </etymology> 00068 // 00069 // <synopsis> 00070 // The primary goal of this class is to help spectral-line astronomers analyze their 00071 // spectral data by generating moments of a specified axis. 00072 // MSMoments is defined by analogy with ImageMoments 00073 // to satisfy a requirement that expects a functionality to generate moments 00074 // from spectral data in the form of MeasurementSet. 00075 // Differences between ImageMoments and MSMoments are the following two things: 00076 // 1)a form of input data and 2)allowed axis type to generate moments. 00077 // The output file names are constructed by a prefix plus some internally generated suffixes. 00078 // The prefix is provided from the user (<src>ourFileName</src>) or determined from 00079 // the input file name. 00080 // 00081 // The input for MSMoments class is 00082 // spectral data in the form of MeasurementSet in contrast to ImageMoments that 00083 // takes an image (ImageInterface) as input. As in the ImageMoments, MSMoments 00084 // only accepts spectral data of type <src>Float</src> and <src>Double</src>. 00085 // Effectively, it means that MSMoments only accepts MeasurementSet with FLOAT_DATA 00086 // column, i.e. autocorrelation data. 00087 // 00088 // <note role=caution> 00089 // Although MeasurementSet is able to store spectral data with different frequency 00090 // setting, i.e. multiple SPECTRAL_WINDOW_ID, MSMoments does not take care about that. 00091 // More specifically, MSMoments applies a certain single SPECTRAL_WINDOW_ID for all 00092 // spectral data that may have different ones. 00093 // Because of this limitation, input MeasurementSet must be selected at least by 00094 // DATA_DESCRIPTION_ID using MSSelection or iterating MSIter. 00095 // </note> 00096 // 00097 // In general, moments can be generated with respect to any moment axes. 00098 // In fact, ImageMoments allows to generate moments along any axes (spectral axis, 00099 // direction axes such as RA and DEC, and polarization axis). 00100 // However, MSMoments only allows to generate moments along spectral axis so far. 00101 // Implementation of generating moments along other axis is future work. 00102 // 00103 // Smoothing the data and making plots are not implemented so far. 00104 // </synopsis> 00105 // 00106 // <example> 00107 // <srcBlock> 00109 // 00110 // Vector<Int> moments(2); 00111 // moments(0) = ImageMoments<Float>::AVERAGE; 00112 // moments(1) = ImageMoments<Float>::WEIGHTED_MEAN_COORDINATE; 00113 // Vector<int> methods(2); 00114 // methods(0) = ImageMoments<Float>::WINDOW; 00115 // methods(1) = ImageMoments<Float>::INTERACTIVE; 00116 // Vector<Int> nxy(2); 00117 // nxy(0) = 3; 00118 // nxy(1) = 3; 00119 // 00121 // 00122 // MeasurementSet inMS(inName); 00124 // 00125 // LogOrigin or("myClass", "myFunction(...)", WHERE); 00126 // LogIO os(or); 00127 // ImageMoments<Float> moment(inMS, os); 00128 // 00130 // 00131 // if (!moment.setMoments(moments)) return 1; 00132 // 00134 // 00135 // if (!moment.createMoments()) return 1; 00136 // 00137 // </srcBlock> 00138 // In this example, we generate two moments (average intensity and intensity 00139 // weighted mean coordinate -- usually the velocity field). 00140 // The moment axis is automatically set to spectral axis. 00141 // The output file names are constructed by the 00142 // class from the input file name plus '.moments'. 00143 // </example> 00144 // 00145 // <motivation> 00146 // MSMoments is defined to enable to generate moments from single-dish spectral data 00147 // in the form of MeasurementSet. 00148 // </motivation> 00149 // 00150 // <todo asof="1998/12/11"> 00151 // <li> More flexible data selection 00152 // <li> Channel masking 00153 // <li> Implementation of generating moments along other axes than spectral one. 00154 // <li> Implement smoothing data 00155 // <li> Making plots 00156 // </todo> 00157 00158 template<class T> class MSMoments : public MomentsBase<T> 00159 { 00160 public: 00161 00162 friend class MomentCalcBase<T>; 00163 00164 // construct from an MS, the MS will supply the range of the various 00165 // parameters that can be selected on. 00166 MSMoments(MeasurementSet& ms, 00167 LogIO &os, 00168 Bool overwriteOutput, 00169 Bool showProgress); 00170 00171 // Copy constructor, this will initialize the MS with other's MS 00172 MSMoments(const MSMoments<T>& other); 00173 00174 // Destructor 00175 ~MSMoments(); 00176 00177 // Assignment operator. 00178 MSMoments<T> &operator=(const MSMoments<T> &other); 00179 00180 // Change or Set the MS this MSMoments refers to. 00181 Bool setNewMS(MeasurementSet& ms); 00182 00183 // Set the moment axis (0 relative). This returns <src>False</src> if 00184 // specified axis is not a spectral axis. If you don't 00185 // call this function, the default state of the class is to set the 00186 // moment axis to the spectral axis if it can find one. Otherwise 00187 // an error will result. 00188 Bool setMomentAxis (const Int& momentAxis); 00189 00190 // This function invokes smoothing of the input MS. Not implemented. 00191 Bool setSmoothMethod(const Vector<Int> &smoothAxes, 00192 const Vector<Int>& kernelTypes, 00193 const Vector<Quantum<Double> >& kernelWidths); 00194 00195 // This is the function that does all the computational work. It should be called 00196 // after the <src>set</src> functions. A return value of <src>False</src> 00197 // indicates that additional checking of the combined methods that you 00198 // have requested has shown that you have not given consistent state to the class. 00199 // The output PtrBlock will hold a pointer to output MeasurementSet. 00200 // It is your responsibility to delete the pointers. 00201 // The <src>doTemp</src> does no effect so far. 00202 // 00203 // If you specify outFileName, it is the root name for 00204 // the output files. Suffixes will be made up internally to append 00205 // to this root. If you only ask for one moment, 00206 // this will be the actual name of the output file. If you don't set this 00207 // variable, the default state of the class is to set the output name root to 00208 // the name of the input file. 00209 Bool createMoments( PtrBlock< MeasurementSet* >& data, 00210 Bool doTemp, 00211 const String& outFileName ) ; 00212 00213 // Get CoordinateSystem 00214 CoordinateSystem coordinates() ; 00215 00216 00217 // Get shape 00218 IPosition getShape() ; 00219 00220 private: 00221 00222 // Smooth data 00223 Bool smoothData (PtrHolder<MeasurementSet> &pSmoothedMS, 00224 String& smoothName); 00225 00226 // Determine noise level. Not implemented. 00227 Bool whatIsTheNoise (T& noise, 00228 MeasurementSet &ms); 00229 00230 // Data 00231 MeasurementSet *ms_p; 00232 00233 // Internal Selected Data 00234 MeasurementSet *msSel_p ; 00235 00236 // CoordinateSystem 00237 CoordinateSystem cSys_ ; 00238 00239 // Spectral Window ID 00240 Int spwId_ ; 00241 00242 // Data Description ID 00243 Int dataDescId_ ; 00244 00245 protected: 00246 using MomentsBase<T>::os_p; 00247 using MomentsBase<T>::showProgress_p; 00248 using MomentsBase<T>::momentAxisDefault_p; 00249 using MomentsBase<T>::peakSNR_p; 00250 using MomentsBase<T>::stdDeviation_p; 00251 using MomentsBase<T>::yMin_p; 00252 using MomentsBase<T>::yMax_p; 00253 using MomentsBase<T>::out_p; 00254 using MomentsBase<T>::smoothOut_p; 00255 using MomentsBase<T>::goodParameterStatus_p; 00256 using MomentsBase<T>::doWindow_p; 00257 using MomentsBase<T>::doFit_p; 00258 using MomentsBase<T>::doAuto_p; 00259 using MomentsBase<T>::doSmooth_p; 00260 using MomentsBase<T>::noInclude_p; 00261 using MomentsBase<T>::noExclude_p; 00262 using MomentsBase<T>::fixedYLimits_p; 00263 using MomentsBase<T>::momentAxis_p; 00264 using MomentsBase<T>::worldMomentAxis_p; 00265 using MomentsBase<T>::kernelTypes_p; 00266 using MomentsBase<T>::kernelWidths_p; 00267 using MomentsBase<T>::nxy_p; 00268 using MomentsBase<T>::moments_p; 00269 using MomentsBase<T>::selectRange_p; 00270 using MomentsBase<T>::smoothAxes_p; 00271 using MomentsBase<T>::plotter_p; 00272 using MomentsBase<T>::overWriteOutput_p; 00273 using MomentsBase<T>::error_p; 00274 using MomentsBase<T>::convertToVelocity_p; 00275 using MomentsBase<T>::velocityType_p; 00276 using MomentsBase<T>::checkMethod; 00277 using MomentsBase<T>::setInExCludeRange; 00278 public: 00279 using MomentsBase<T>::setVelocityType; 00280 using MomentsBase<T>::setSnr; 00281 using MomentsBase<T>::setWinFitMethod; 00282 using MomentsBase<T>::setMoments; 00283 using MomentsBase<T>::errorMessage; 00284 }; 00285 } //# NAMESPACE CASA - END 00286 00287 #ifndef CASACORE_NO_AUTO_TEMPLATES 00288 #include <synthesis/MSVis/MSMoments.tcc> 00289 #endif //# CASACORE_NO_AUTO_TEMPLATES 00290 #endif 00291