casa
$Rev:20696$
|
00001 //# FixVis.h: Does for MSes various fixes which do not involve calibrating. 00002 //# Copyright (C) 2008 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 //# $Id$ 00027 //# 00028 #ifndef SYN_FIXVIS_H 00029 #define SYN_FIXVIS_H 00030 00031 #include <casa/aips.h> 00032 #include <casa/BasicSL/String.h> 00033 #include <ms/MeasurementSets/MSColumns.h> 00034 #include <synthesis/MSVis/MSUVWGenerator.h> 00035 00036 // UVWMachine Does rotation, including B1950 <-> J2000, refocusing, and maybe 00037 // even SIN <-> (-)NCP reprojection of existing UVWs, but it does not generate 00038 // UVWs from an antenna table. 00039 // FTMachine::rotateUVW(Matrix<Double>& uvw, Vector<Double>& dphase, 00040 // const VisBuffer& vb) 00041 #include <synthesis/TransformMachines/FTMachine.h> 00042 00043 namespace casa { //# NAMESPACE CASA - BEGIN 00044 00045 class MeasurementSet; 00046 class LogIO; 00047 00048 // <summary>Performs for MeasurementSets various fixes which do not involve calibrating. 00049 // This includes (in order of implementation): 00050 // 1. Generating and inserting (u, v, w)s into a MS that may or may not 00051 // already have them. Includes antenna offsets when known. 00052 // 2. Correcting for differential aberration. 00053 // 3. Changing the phase tracking center. 00054 // 4. Changing the equinox (B1950 -> J2000). 00055 // 5. (maybe never) Changing the projection, i.e. SIN <-> (-)NCP. 00056 // </summary> 00057 // <use visibility=export> 00058 // 00059 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00060 // </reviewed> 00061 // 00062 // <prerequisite> 00063 // <li> <linkto class=MeasurementSet>MeasurementSet</linkto> 00064 // </prerequisite> 00065 // 00066 // <etymology> 00067 // It is a variation on the UVFIX task of AIPS. 00068 // </etymology> 00069 // 00070 // <synopsis> 00071 // (u, v, w)s are needed for imaging, but some data sets may not come with them 00072 // included. 00073 // 00074 // FixVis can also be used to shift the tangent point, and correct for 00075 // differential aberration. 00076 // </synopsis> 00077 // 00078 // <example> 00079 // <srcBlock> 00080 // MS inMS(fileName); 00081 // FixVis uvwfixer(inMS); 00082 // uvwfixer.setDataDescriptionIds(ddIds); 00083 // uvwfixer.setFields(fieldIds); 00084 // uvwfixer.fixuvw(); 00085 // </srcBlock> 00086 // A <src>FixVis</src> object is constructed 00087 // and the baselines are calculated and stored in inMS. 00088 // </example> 00089 // 00090 // <motivation> 00091 // Currently (10/30/2008), ASDMs from either the ALMA Test Facility or the 00092 // EVLA do not come with (u, v, w)s, and need to be processed with the UVFIX 00093 // task in AIPS. It would be preferable to process them entirely inside CASA. 00094 // </motivation> 00095 // 00096 // <todo asof=""> 00097 // </todo> 00098 00099 // class FixVis; 00100 00101 class FixVis : public FTMachine 00102 { 00103 public: 00104 // Constructor 00105 FixVis (MeasurementSet& ms, const String& dataColName=String("all")); 00106 00107 // Assignment (only copies reference to MS, need to reset selection etc) 00108 FixVis& operator=(FixVis& other); 00109 00110 // Destructor 00111 ~FixVis(); 00112 00113 // Set the required field Ids and return the # of selected fields. 00114 uInt setFields(const Vector<Int>& fieldIds); 00115 00117 //void setObsIDs(const String& obs) {obsString_p = obs;} 00118 00119 // Specifies new phase tracking centers for the selected fields 00120 void setPhaseDirs(const Vector<MDirection>& phaseDirs); 00121 00122 // Specifies distances for each selected field according to distances, which 00123 // must be in m and the same order as the Vector given to setFields. Throws 00124 // an exception if distances.nelements() != nsel_p. 00125 // Because of the way refocus() works, zeroes are ignored (no refocusing 00126 // done), but negative distances are accepted! 00127 void setDistances(const Vector<Double>& distances); 00128 00129 // Calculate the (u, v, w)s and store them in ms_p. 00130 Bool calc_uvw(const String& refcode, const Bool reuse=true); 00131 00132 // Convert the UVW column to a new reference frame by rotating the old 00133 // baselines instead of calculating fresh ones. 00134 void rotateUVW(const MDirection &indir, const MDirection::Ref& newref); 00135 00136 // For things like rotation, differential aberration correction, etc., when 00137 // there already is a UVW column, using FTMachine. Returns true if _any_ 00138 // fields are modified. 00139 Bool fixvis(const String& refcode); 00140 virtual void setMiscInfo(const Int qualifier){(void)qualifier;}; 00141 virtual void ComputeResiduals(VisBuffer&, Bool //useCorrected 00142 ) {} 00143 virtual String name() const { return "FixVis";}; 00144 00145 private: 00146 // Interpret field indices (MSSelection) 00147 Vector<Int> getFieldIdx(const String& fields); 00148 00149 // Makes sure msc_p is ready, and returns false if it fails. 00150 Bool ready_msc_p(); 00151 00152 // Convert the directions (phase tracking centers, + DELAY_DIR and 00153 // REFERENCE_DIR if they start in the same frame) in the FIELD table to 00154 // newFrame. Note that each direction column in the table only allows one 00155 // reference frame for the entire column, so all fields must share the same 00156 // frame. Calls ready_msc_p() as a side effect. 00157 void convertFieldDirs(const MDirection::Types outType); 00158 00159 // Private worker function for convertFieldDirs(). 00160 void convertFieldCols(MSFieldColumns& msfcs, 00161 const MDirection::Ref& newFrame, 00162 const Bool doAll3); 00163 00164 // Calls ready_msc_p() as a side effect. 00165 Bool makeSelection(const Int selectedField); 00166 00167 // Does phase tracking center and distance adjustment for mssel_p. 00168 void processSelected(uInt numInSel); 00169 00170 // FTMachine declares a LOT of pure virtual functions which FixVis does not 00171 // need. They are declared as no-ops here for now. 00172 ImageInterface<Complex>& getImage(Matrix<float>&, Bool) {return *image;} 00173 virtual void normalizeImage(Lattice<Complex>&,// skyImage, 00174 const Matrix<Double>&,// sumOfWts, 00175 Lattice<Float>&,// sensitivityImage, 00176 Bool //fftNorm 00177 ) 00178 {throw(AipsError("normalizeImage::normalizeImage() called"));} 00179 00180 void getWeightImage(ImageInterface<float>&, Matrix<float>&) {} 00181 void get(VisBuffer&, Int) {} 00182 void put(const VisBuffer& , Int , Bool , FTMachine::Type) {}; 00183 00184 // Bool getRestFreq(Vector<Double>& restFreq, const Int spw, const Int fldID); 00185 // void setObsInfo(ObsInfo& obsinfo); 00186 00187 void ok(); 00188 void init(); 00189 00190 // Initialize transform to Visibility plane using the image 00191 // as a template. 00192 void initializeToVis(ImageInterface<Complex>& image, 00193 const VisBuffer& vb); 00194 00195 // Finalize transform to Visibility plane. 00196 void finalizeToVis(); 00197 00198 // Initialize transform to Sky plane: initializes the image 00199 void initializeToSky(ImageInterface<Complex>& image, Matrix<Float>& weight, 00200 const VisBuffer& vb); 00201 00202 // Defined here only because FTMachine declares it purely virtual. 00203 void finalizeToSky() {} 00204 00205 // TODO?: trackDir. 00206 Bool setImageField(const Int fieldid, 00207 const Bool dotrackDir=false //, const MDirection& trackDir 00208 ); 00209 00210 Bool lock(); 00211 void unlock(); 00212 00213 // Log functions and variables 00214 LogIO sink_p; 00215 LogIO& logSink() {return sink_p;} 00216 00217 // Initialized in ctor. Make sure the order there matches with the order here. 00218 MeasurementSet ms_p; // Input/Output MS 00219 MSColumns *msc_p; // Ptr. to columns of mssel_p. 00220 uInt nsel_p; // Number of selected fields. 00221 uInt nAllFields_p; // The total # of fields in the MS. 00222 const uInt npix_p; // Not that there are any real pixels. 00223 const IPosition cimageShape_p; // No image will be made, but 00224 const IPosition tileShape_p; // the coords are stored in a fake one. 00225 const TiledShape tiledShape_p; 00226 Bool antennaSel_p; // Is selection being done by antenna? 00227 Bool freqFrameValid_p; // Freq frame is good and valid 00228 // conversions can be done (or not) 00229 //String obsString_p; // obsID selection 00230 Vector<Int> antennaId_p; // MSSelection::indexExprStr() doesn't 00231 // work with Vector<uInt>. 00232 Vector<String> antennaSelStr_p; 00233 Vector<Double> distances_p; // new distances (m) for each selected 00234 // field 00235 Vector<MS::PredefinedColumns> dataCols_p; 00236 uInt nDataCols_p; 00237 uInt nchan_p; 00238 Vector<Int> spectralwindowids_p; 00239 uInt lockCounter_p; 00240 00241 // Not initialized in ctor. 00242 MeasurementSet mssel_p; // The selected part of ms_p. 00243 ObsInfo latestObsInfo_p; 00244 Vector<Int> DDIds_p; // DataDescription Ids to process 00245 Vector<Int> FieldIds_p; // Field Ids to process 00246 Vector<MDirection> phaseDirs_p; // new phase centers for each selected 00247 // field 00248 Int nSpw_p; // Number of spws 00249 MPosition mLocation_p; 00250 Bool doTrackSource_p; 00251 Int fieldid_p; 00252 }; 00253 00254 } //# NAMESPACE CASA - END 00255 00256 #endif