casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FixVis.h
Go to the documentation of this file.
1 //# FixVis.h: Does for MSes various fixes which do not involve calibrating.
2 //# Copyright (C) 2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 //#
28 #ifndef SYN_FIXVIS_H
29 #define SYN_FIXVIS_H
30 
31 #include <casa/aips.h>
32 #include <casa/BasicSL/String.h>
35 
36 // casacore::UVWMachine Does rotation, including B1950 <-> J2000, refocusing, and maybe
37 // even SIN <-> (-)NCP reprojection of existing UVWs, but it does not generate
38 // UVWs from an antenna table.
39 // FTMachine::rotateUVW(casacore::Matrix<casacore::Double>& uvw, casacore::Vector<casacore::Double>& dphase,
40 // const VisBuffer& vb)
42 
43 namespace casacore{
44 
45 class MeasurementSet;
46 class LogIO;
47 }
48 
49 namespace casa { //# NAMESPACE CASA - BEGIN
50 
51 
52 // <summary>Performs for MeasurementSets various fixes which do not involve calibrating.
53 // This includes (in order of implementation):
54 // 1. Generating and inserting (u, v, w)s into a casacore::MS that may or may not
55 // already have them. Includes antenna offsets when known.
56 // 2. Correcting for differential aberration.
57 // 3. Changing the phase tracking center.
58 // 4. Changing the equinox (B1950 -> J2000).
59 // 5. (maybe never) Changing the projection, i.e. SIN <-> (-)NCP.
60 // </summary>
61 // <use visibility=export>
62 //
63 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
64 // </reviewed>
65 //
66 // <prerequisite>
67 // <li> <linkto class=casacore::MeasurementSet>MeasurementSet</linkto>
68 // </prerequisite>
69 //
70 // <etymology>
71 // It is a variation on the UVFIX task of AIPS.
72 // </etymology>
73 //
74 // <synopsis>
75 // (u, v, w)s are needed for imaging, but some data sets may not come with them
76 // included.
77 //
78 // FixVis can also be used to shift the tangent point, and correct for
79 // differential aberration.
80 // </synopsis>
81 //
82 // <example>
83 // <srcBlock>
84 // casacore::MS inMS(fileName);
85 // FixVis uvwfixer(inMS);
86 // uvwfixer.setDataDescriptionIds(ddIds);
87 // uvwfixer.setFields(fieldIds);
88 // uvwfixer.fixuvw();
89 // </srcBlock>
90 // A <src>FixVis</src> object is constructed
91 // and the baselines are calculated and stored in inMS.
92 // </example>
93 //
94 // <motivation>
95 // Currently (10/30/2008), ASDMs from either the ALMA Test Facility or the
96 // EVLA do not come with (u, v, w)s, and need to be processed with the UVFIX
97 // task in AIPS. It would be preferable to process them entirely inside CASA.
98 // </motivation>
99 //
100 // <todo asof="">
101 // </todo>
102 
103 // class FixVis;
104 
105 class FixVis : public FTMachine
106 {
107 public:
108 // Constructor
109  FixVis (casacore::MeasurementSet& ms, const casacore::String& dataColName=casacore::String("all"));
110 
111 // Assignment (only copies reference to casacore::MS, need to reset selection etc)
112  FixVis& operator=(FixVis& other);
113 
114 // Destructor
115  ~FixVis();
116 
117 // Set the required field Ids and return the # of selected fields.
119 
121  //void setObsIDs(const casacore::String& obs) {obsString_p = obs;}
122 
123  // Specifies new phase tracking centers for the selected fields
125 
126  // Specifies distances for each selected field according to distances, which
127  // must be in m and the same order as the casacore::Vector given to setFields. Throws
128  // an exception if distances.nelements() != nsel_p.
129  // Because of the way refocus() works, zeroes are ignored (no refocusing
130  // done), but negative distances are accepted!
131  void setDistances(const casacore::Vector<casacore::Double>& distances);
132 
133  // Calculate the (u, v, w)s and store them in ms_p.
134  casacore::Bool calc_uvw(const casacore::String& refcode, const casacore::Bool reuse=true);
135 
136  // Convert the UVW column to a new reference frame by rotating the old
137  // baselines instead of calculating fresh ones.
138  void rotateUVW(const casacore::MDirection &indir, const casacore::MDirection::Ref& newref);
139 
140  // For things like rotation, differential aberration correction, etc., when
141  // there already is a UVW column, using FTMachine. Returns true if _any_
142  // fields are modified.
143  casacore::Bool fixvis(const casacore::String& refcode);
144  virtual void setMiscInfo(const casacore::Int qualifier){(void)qualifier;};
145  virtual void ComputeResiduals(VisBuffer&, casacore::Bool //useCorrected
146  ) {}
147  virtual casacore::String name() const { return "FixVis";};
148 
149 private:
150  // Interpret field indices (casacore::MSSelection)
152 
153  // Makes sure msc_p is ready, and returns false if it fails.
155 
156  // Convert the directions (phase tracking centers, + DELAY_DIR and
157  // REFERENCE_DIR if they start in the same frame) in the FIELD table to
158  // newFrame. Note that each direction column in the table only allows one
159  // reference frame for the entire column, so all fields must share the same
160  // frame. Calls ready_msc_p() as a side effect.
161  void convertFieldDirs(const casacore::MDirection::Types outType);
162 
163  // Private worker function for convertFieldDirs().
165  const casacore::MDirection::Ref& newFrame,
166  const casacore::Bool doAll3);
167 
168  // Calls ready_msc_p() as a side effect.
169  casacore::Bool makeSelection(const casacore::Int selectedField);
170 
171  // Does phase tracking center and distance adjustment for mssel_p.
172  void processSelected(casacore::uInt numInSel);
173 
174  // FTMachine declares a LOT of pure virtual functions which FixVis does not
175  // need. They are declared as no-ops here for now.
178  const casacore::Matrix<casacore::Double>&,// sumOfWts,
179  casacore::Lattice<casacore::Float>&,// sensitivityImage,
180  casacore::Bool //fftNorm
181  )
182  {throw(casacore::AipsError("normalizeImage::normalizeImage() called"));}
183 
185  void get(VisBuffer&, casacore::Int) {}
187 
188  // casacore::Bool getRestFreq(casacore::Vector<casacore::Double>& restFreq, const casacore::Int spw, const casacore::Int fldID);
189  // void setObsInfo(casacore::ObsInfo& obsinfo);
190 
191  void ok();
192  void init();
193 
194  // Initialize transform to Visibility plane using the image
195  // as a template.
197  const VisBuffer& vb);
198 
199  // Finalize transform to Visibility plane.
200  void finalizeToVis();
201 
202  // Initialize transform to Sky plane: initializes the image
204  const VisBuffer& vb);
205 
206  // Defined here only because FTMachine declares it purely virtual.
207  void finalizeToSky() {}
208 
209  // TODO?: trackDir.
211  const casacore::Bool dotrackDir=false //, const casacore::MDirection& trackDir
212  );
213 
215  void unlock();
216 
217  // Log functions and variables
220 
221  // Initialized in ctor. Make sure the order there matches with the order here.
222  casacore::MeasurementSet ms_p; // casacore::Input/Output MS
223  casacore::MSColumns *msc_p; // Ptr. to columns of mssel_p.
224  casacore::uInt nsel_p; // Number of selected fields.
225  casacore::uInt nAllFields_p; // The total # of fields in the MS.
226  const casacore::uInt npix_p; // Not that there are any real pixels.
227  const casacore::IPosition cimageShape_p; // No image will be made, but
228  const casacore::IPosition tileShape_p; // the coords are stored in a fake one.
230  casacore::Bool antennaSel_p; // Is selection being done by antenna?
231  casacore::Bool freqFrameValid_p; // Freq frame is good and valid
232  // conversions can be done (or not)
233  //casacore::String obsString_p; // obsID selection
234  casacore::Vector<casacore::Int> antennaId_p; // casacore::MSSelection::indexExprStr() doesn't
235  // work with casacore::Vector<casacore::uInt>.
237  casacore::Vector<casacore::Double> distances_p; // new distances (m) for each selected
238  // field
244 
245  // Not initialized in ctor.
246  casacore::MeasurementSet mssel_p; // The selected part of ms_p.
248  casacore::Vector<casacore::Int> DDIds_p; // DataDescription Ids to process
250  casacore::Vector<casacore::MDirection> phaseDirs_p; // new phase centers for each selected
251  // field
252  casacore::Int nSpw_p; // Number of spws
256 };
257 
258 } //# NAMESPACE CASA - END
259 
260 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::Bool lock()
casacore::Vector< casacore::String > antennaSelStr_p
work with casacore::Vector&lt;casacore::uInt&gt;.
Definition: FixVis.h:236
A Measure: astronomical direction.
Definition: MDirection.h:174
casacore::uInt nsel_p
Definition: FixVis.h:224
A Measure: position on Earth.
Definition: MPosition.h:79
int Int
Definition: aipstype.h:50
const casacore::IPosition cimageShape_p
Definition: FixVis.h:227
casacore::Vector< casacore::Double > distances_p
Definition: FixVis.h:237
casacore::Vector< casacore::MS::PredefinedColumns > dataCols_p
field
Definition: FixVis.h:239
casacore::Int fieldid_p
Definition: FixVis.h:255
~FixVis()
Destructor.
casacore::Bool calc_uvw(const casacore::String &refcode, const casacore::Bool reuse=true)
Calculate the (u, v, w)s and store them in ms_p.
void initializeToSky(casacore::ImageInterface< casacore::Complex > &image, casacore::Matrix< casacore::Float > &weight, const VisBuffer &vb)
Initialize transform to Sky plane: initializes the image.
casacore::LogIO & logSink()
Definition: FixVis.h:219
Performs for MeasurementSets various fixes which do not involve calibrating. This includes (in order ...
Definition: FixVis.h:105
casacore::Bool antennaSel_p
Definition: FixVis.h:230
A 2-D Specialization of the Array class.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
FixVis(casacore::MeasurementSet &ms, const casacore::String &dataColName=casacore::String("all"))
Constructor.
casacore::Bool freqFrameValid_p
Definition: FixVis.h:231
casacore::ImageInterface< casacore::Complex > * image
Definition: FTMachine.h:409
void setDistances(const casacore::Vector< casacore::Double > &distances)
Specifies distances for each selected field according to distances, which must be in m and the same o...
casacore::Int nSpw_p
field
Definition: FixVis.h:252
void finalizeToSky()
Defined here only because FTMachine declares it purely virtual.
Definition: FixVis.h:207
casacore::uInt lockCounter_p
Definition: FixVis.h:243
Store miscellaneous information related to an observation.
Definition: ObsInfo.h:97
casacore::Vector< casacore::Int > antennaId_p
conversions can be done (or not) casacore::String obsString_p; // obsID selection ...
Definition: FixVis.h:234
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
A class to provide easy read-write access to MSField columns.
casacore::uInt setFields(const casacore::Vector< casacore::Int > &fieldIds)
Set the required field Ids and return the # of selected fields.
casacore::uInt nAllFields_p
Definition: FixVis.h:225
casacore::Bool makeSelection(const casacore::Int selectedField)
Calls ready_msc_p() as a side effect.
casacore::Bool fixvis(const casacore::String &refcode)
For things like rotation, differential aberration correction, etc., when there already is a UVW colum...
Define the shape and tile shape.
Definition: TiledShape.h:99
void convertFieldDirs(const casacore::MDirection::Types outType)
Convert the directions (phase tracking centers, + DELAY_DIR and REFERENCE_DIR if they start in the sa...
Specifies new phase tracking centers for the selected fields *void setPhaseDirs(const casacore::Vector< casacore::MDirection > &phaseDirs)
casacore::MeasurementSet mssel_p
Not initialized in ctor.
Definition: FixVis.h:246
casacore::Vector< casacore::Int > getFieldIdx(const casacore::String &fields)
Interpret field indices (casacore::MSSelection)
void convertFieldCols(casacore::MSFieldColumns &msfcs, const casacore::MDirection::Ref &newFrame, const casacore::Bool doAll3)
Private worker function for convertFieldDirs().
casacore::Vector< casacore::MDirection > phaseDirs_p
Definition: FixVis.h:250
virtual casacore::String name() const
Return the name of the machine.
Definition: FixVis.h:147
Type
Types of known Images that may be made using the makeImage method.
Definition: FTMachine.h:125
casacore::Bool ready_msc_p()
Makes sure msc_p is ready, and returns false if it fails.
void initializeToVis(casacore::ImageInterface< casacore::Complex > &image, const VisBuffer &vb)
Initialize transform to Visibility plane using the image as a template.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const casacore::TiledShape tiledShape_p
Definition: FixVis.h:229
casacore::MeasurementSet ms_p
Initialized in ctor.
Definition: FixVis.h:222
void ok()
casacore::Bool getRestFreq(casacore::Vector&lt;casacore::Double&gt;&amp; restFreq, const casacore::Int spw...
A Table intended to hold astronomical data (a set of Measurements).
virtual void ComputeResiduals(VisBuffer &, casacore::Bool)
Make the VB and VBStore interefaces for the interim re-factoring work.
Definition: FixVis.h:145
casacore::Vector< casacore::Int > DDIds_p
Definition: FixVis.h:248
casacore::uInt nDataCols_p
Definition: FixVis.h:240
const casacore::uInt npix_p
Definition: FixVis.h:226
casacore::uInt nchan_p
Definition: FixVis.h:241
Base class for all Casacore library errors.
Definition: Error.h:134
void rotateUVW(const casacore::MDirection &indir, const casacore::MDirection::Ref &newref)
Convert the UVW column to a new reference frame by rotating the old baselines instead of calculating ...
A class to provide easy read-write access to MeasurementSet columns.
Definition: MSColumns.h:221
casacore::Vector< casacore::Int > spectralwindowids_p
Definition: FixVis.h:242
casacore::Bool doTrackSource_p
Definition: FixVis.h:254
const casacore::IPosition tileShape_p
Definition: FixVis.h:228
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::MSColumns * msc_p
Definition: FixVis.h:223
casacore::ImageInterface< casacore::Complex > & getImage(casacore::Matrix< float > &, casacore::Bool)
FTMachine declares a LOT of pure virtual functions which FixVis does not need.
Definition: FixVis.h:176
void finalizeToVis()
Finalize transform to Visibility plane.
VisBuffers encapsulate one chunk of visibility data for processing.
Definition: VisBuffer.h:153
virtual void setMiscInfo(const casacore::Int qualifier)
set the order of the Taylor term for MFS this is to tell A-casacore::Projection to qualify the accumu...
Definition: FixVis.h:144
casacore::Bool setImageField(const casacore::Int fieldid, const casacore::Bool dotrackDir=false)
TODO?: trackDir.
casacore::LogIO sink_p
Log functions and variables.
Definition: FixVis.h:218
casacore::Vector< casacore::Int > FieldIds_p
Definition: FixVis.h:249
casacore::MPosition mLocation_p
Definition: FixVis.h:253
casacore::ObsInfo latestObsInfo_p
Definition: FixVis.h:247
void getWeightImage(casacore::ImageInterface< float > &, casacore::Matrix< float > &)
Get the final weights image.
Definition: FixVis.h:184
virtual void normalizeImage(casacore::Lattice< casacore::Complex > &, const casacore::Matrix< casacore::Double > &, casacore::Lattice< casacore::Float > &, casacore::Bool)
Definition: FixVis.h:177
unsigned int uInt
Definition: aipstype.h:51
void put(const VisBuffer &, casacore::Int, casacore::Bool, FTMachine::Type)
Put coherence to grid.
Definition: FixVis.h:186
void processSelected(casacore::uInt numInSel)
Does phase tracking center and distance adjustment for mssel_p.
defines interface for the Fourier Transform Machine
Definition: FTMachine.h:120
FixVis & operator=(FixVis &other)
Assignment (only copies reference to casacore::MS, need to reset selection etc)
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42