casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSFieldColumns.h
Go to the documentation of this file.
1 //# MSFieldColumns.h: provides easy access to MSField columns
2 //# Copyright (C) 1996,1999,2000
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 MS_MSFIELDCOLUMNS_H
29 #define MS_MSFIELDCOLUMNS_H
30 
31 #include <casacore/casa/aips.h>
44 #include <map>
45 
46 namespace casacore { //# NAMESPACE CASACORE - BEGIN
47 
48 class MVDirection;
49 class MSField;
50 template <class Qtype> class Quantum;
51 template <class T> class Matrix;
52 
53 // <summary>
54 // A class to provide easy access to MSField columns
55 // </summary>
56 
57 // <use visibility=export>
58 
59 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
60 // </reviewed>
61 
62 // <prerequisite>
63 // <li> MSField
64 // <li> ArrayColumn
65 // <li> ScalarColumn
66 // </prerequisite>
67 //
68 // <etymology>
69 // ROMSFieldColumns stands for Read-Only MeasurementSet Field Table columns.
70 // </etymology>
71 //
72 // <synopsis>
73 // This class provides read-only access to the columns in the MSField Table.
74 // It does the declaration of all the Scalar and ArrayColumns with the
75 // correct types, so the application programmer doesn't have to
76 // worry about getting those right. There is an access function
77 // for every predefined column. Access to non-predefined columns will still
78 // have to be done with explicit declarations.
79 // See <linkto class=ROMSColumns> ROMSColumns</linkto> for an example.
80 // </synopsis>
81 //
82 // <motivation>
83 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
84 // </motivation>
85 
87 {
88 public:
89  // Construct from the supplied Table
90  ROMSFieldColumns(const MSField& msField);
91 
92  // The desctructor does nothing special
94 
95  // Read-only access to required columns
96  // <group>
97  const ROScalarColumn<String>& code() const {return code_p;}
98  const ROArrayColumn<Double>& delayDir() const {return delayDir_p;}
99  const ROArrayMeasColumn<MDirection>& delayDirMeasCol() const
100  {return delayDirMeas_p;}
101  const ROScalarColumn<Bool>& flagRow() const {return flagRow_p;}
102  const ROScalarColumn<String>& name() const {return name_p;}
103  const ROScalarColumn<Int>& numPoly() const {return numPoly_p;}
104  const ROArrayColumn<Double>& phaseDir() const {return phaseDir_p;}
105  const ROArrayMeasColumn<MDirection>& phaseDirMeasCol() const
106  {return phaseDirMeas_p;}
107  const ROArrayColumn<Double>& referenceDir() const {return referenceDir_p;}
108  const ROArrayMeasColumn<MDirection>& referenceDirMeasCol() const
109  {return referenceDirMeas_p;}
110  const ROScalarColumn<Int>& sourceId() const {return sourceId_p;}
111  const ROScalarColumn<Double>& time() const {return time_p;}
112  const ROScalarQuantColumn<Double>& timeQuant() const { return timeQuant_p;}
113  const ROScalarMeasColumn<MEpoch>& timeMeas() const { return timeMeas_p;}
114  // </group>
115 
116  // Read-only access to optional columns
117  // <group>
118  const ROScalarColumn<Int>& ephemerisId() const {return ephemerisId_p;}
119  // </group>
120 
121  // Access to interpolated directions from polynomials or ephemerides,
122  // the default time of zero will return the 0th order element of the polynomial.
123  // or, if there is an ephemeris, the position at the time origin of the ephemeris.
124  //
125  // If there is an ephemeris attached to a field table row, the nominal values of the
126  // direction columns are interpreted as an offset to the ephemeris. So if there is
127  // an ephemeris attached (EPHEMERIS_ID column contains value > -1), then the direction
128  // returned by delayDirMeas, phaseDirMeas, and referenceDirMeas is the ephemeris
129  // direction plus the offset taken from the corresponding direction column.
130  // This permits the convinient implementation of mosaics where several field table
131  // rows share one ephemeris and use different offsets in each row to create the
132  // mosaic pattern.
133  //
134  // The unaltered ephemeris direction can be queried with the method ephemerisDirMeas().
135  // If there is no ephemeris attached, ephemerisDirMeas() will return the same as
136  // referenceDirMeas().
137  //
138  // In addtion to the directions, if there is an ephemeris available,
139  // also the radial velocity and the distance rho can be accessed.
140  //
141  // The method needInterTime returns True if there is a polynomial or ephemeris
142  // connected to this field table row, and an interpolation time value should
143  // be provided.
144  // The method ephemPath returns the absolute path to the ephemeris table connected to
145  // the field table row, an empty string if there is none.
146  // <group>
147  MDirection delayDirMeas(Int row, Double time = 0) const;
148  MDirection phaseDirMeas(Int row, Double time = 0) const;
149  MDirection referenceDirMeas(Int row, Double time = 0) const;
150  MDirection ephemerisDirMeas(Int row, Double time = 0) const;
151  MRadialVelocity radVelMeas(Int row, Double time = 0) const;
152  Quantity rho(Int row, Double time = 0) const;
153  Bool needInterTime(Int row) const;
154  String ephemPath(Int row) const;
155 
156  // </group>
157 
158  // Convenience function that returns the number of rows in any of the columns
159  uInt nrow() const {return name_p.nrow();}
160 
161  // returns the last row that has a reference direction, phase direction and
162  // delay direction that match, to within the specified angular separation,
163  // the supplied values. Only matches on rows where the direction is constant
164  // ie., NUM_POLY is 0 and where FLAG_ROW is False. Throws an exception
165  // (AipsError) if the reference frames do not match or if the separation does
166  // not have angular units (when compiled in debug mode). Returns -1 if no
167  // match could be found. If tryRow is positive, then that row is tested to
168  // see if it matches before any others are tested. Setting tryRow to a
169  // positive value greater than the table length will throw an exception
170  // (AipsError), when compiled in debug mode.
171  Int matchDirection(const MDirection& referenceDirection,
172  const MDirection& delayDirection,
173  const MDirection& phaseDirection,
174  const Quantum<Double>& maxSeparation,
175  Int tryRow=-1,
176  Double time=0);
177 
178  // Update the MeasComets objects belonging to this FIELD table.
179  // Needed when the entries in the EPHEMERIS_ID column have changed.
180  void updateMeasComets();
181 
182 
183 protected:
184  //# default constructor creates a object that is not usable. Use the attach
185  //# function correct this.
187 
188  //# attach this object to the supplied table.
189  void attach(const MSField& msField);
190 
191  Int measCometIndex(int row) const;
194  std::map<Int, Int> ephIdToMeasComet_p;
195 
196  // Extract the direction Measure from the corresponding ephemeris
197  // using the nominal position as an offset.
198  // Note that interTime is assumed to use the same time reference frame
199  // as originEpoch.
200  MDirection extractDirMeas(const MDirection& offsetDir,
201  Int index, Double& interTime,
202  MEpoch originEpoch) const;
203 
204  void getMJDs(Double& originMJD, Double& interMJD,
205  const Double interTime, const MEpoch originEpoch) const;
206 
207 private:
208  //# Make the assignment operator and the copy constructor private to prevent
209  //# any compiler generated one from being used.
212 
213  //# Check if any optional columns exist and if so attach them.
214  //# Initialise the necessary MeasComet objects if the EPHEMERIS_ID column is present.
215  void attachOptionalCols(const MSField& msField);
216 
217  //# Functions which check the supplied values against the relevant column and
218  //# the specified row. The row must have a numpoly value of zero. The mvdir
219  //# argument is a temporary that is passed in to prevent it from being
220  //# created inside these small functions.
221  // <group>
222  Bool matchReferenceDir(uInt row, const MVDirection& dirVal,
223  const Double& sepInRad,
224  MVDirection& mvdir, Double time=0) const;
225  Bool matchDelayDir(uInt row, const MVDirection& dirVal,
226  const Double& sepInRad,
227  MVDirection& mvdir, Double time=0) const;
228  Bool matchPhaseDir(uInt row, const MVDirection& dirVal,
229  const Double& sepInRad,
230  MVDirection& mvdir, Double time=0) const;
231  // </group>
232 
233  //# required columns
234  ROScalarColumn<String> name_p;
235  ROScalarColumn<String> code_p;
236  ROScalarColumn<Double> time_p;
237  ROScalarColumn<Int> numPoly_p;
238  ROArrayColumn<Double> delayDir_p;
239  ROArrayColumn<Double> phaseDir_p;
240  ROArrayColumn<Double> referenceDir_p;
241  ROScalarColumn<Int> sourceId_p;
242  ROScalarColumn<Bool> flagRow_p;
243  //# optional columns
244  ROScalarColumn<Int> ephemerisId_p;
245 
246  //# Access to Measure columns
247  ROScalarMeasColumn<MEpoch> timeMeas_p;
248  ROArrayMeasColumn<MDirection> delayDirMeas_p;
249  ROArrayMeasColumn<MDirection> phaseDirMeas_p;
250  ROArrayMeasColumn<MDirection> referenceDirMeas_p;
251 
252  //# Access to Quantum columns
253  ROScalarQuantColumn<Double> timeQuant_p;
254 };
255 
256 // <summary>
257 // A class to provide easy read-write access to MSField columns
258 // </summary>
259 
260 // <use visibility=export>
261 
262 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
263 // </reviewed>
264 
265 // <prerequisite>
266 // <li> MSField
267 // <li> ArrayColumn
268 // <li> ScalarColumn
269 // </prerequisite>
270 //
271 // <etymology>
272 // MSFieldColumns stands for MeasurementSet Field Table columns.
273 // </etymology>
274 //
275 // <synopsis>
276 // This class provides access to the columns in the MSField Table,
277 // it does the declaration of all the Scalar and ArrayColumns with the
278 // correct types, so the application programmer doesn't have to
279 // worry about getting those right. There is an access function
280 // for every predefined column. Access to non-predefined columns will still
281 // have to be done with explicit declarations.
282 // See <linkto class=MSColumns> MSColumns</linkto> for an example.
283 // </synopsis>
284 //
285 // <motivation>
286 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
287 // </motivation>
288 
290 {
291 public:
292  // Construct from the supplied Table
293  MSFieldColumns(MSField& msField);
294 
295  // The desctructor does nothing special
296  ~MSFieldColumns();
297 
298  // Read-write access to required columns
299  //
300  // Note that the direction measures with a stored polynomial have Col() added
301  // to their name. They are better accessed via the functions that have the
302  // same name, without the Col suffix, that will do the interpolation for
303  // you. These functions are in the ROMSFieldColumns class.
304  // <group>
308  {return delayDirMeas_p;}
314  {return phaseDirMeas_p;}
317  {return referenceDirMeas_p;}
322  // </group>
323 
324  // Read-write access to optional columns
325  // <group>
327  // </group>
328 
329  // Read-only access to required columns
330  // <group>
331  const ROScalarColumn<String>& code() const {
332  return ROMSFieldColumns::code();}
333  const ROArrayColumn<Double>& delayDir() const {
334  return ROMSFieldColumns::delayDir();}
335  const ROArrayMeasColumn<MDirection>& delayDirMeasCol() const {
337  const ROScalarColumn<Bool>& flagRow() const {
338  return ROMSFieldColumns::flagRow();}
339  const ROScalarColumn<String>& name() const {
340  return ROMSFieldColumns::name();}
341  const ROScalarColumn<Int>& numPoly() const {
342  return ROMSFieldColumns::numPoly();}
343  const ROArrayColumn<Double>& phaseDir() const {
344  return ROMSFieldColumns::phaseDir();}
345  const ROArrayMeasColumn<MDirection>& phaseDirMeasCol() const {
347  const ROArrayColumn<Double>& referenceDir() const {
349  const ROArrayMeasColumn<MDirection>& referenceDirMeasCol() const {
351  const ROScalarColumn<Int>& sourceId() const {
352  return ROMSFieldColumns::sourceId();}
353  const ROScalarColumn<Double>& time() const {
354  return ROMSFieldColumns::time();}
355  const ROScalarQuantColumn<Double>& timeQuant() const {
356  return ROMSFieldColumns::timeQuant();}
357  const ROScalarMeasColumn<MEpoch>& timeMeas() const {
358  return ROMSFieldColumns::timeMeas();}
359  // </group>
360 
361  // Read-only access to optional columns
362  // <group>
363  const ROScalarColumn<Int>& ephemerisId() const {
365  // </group>
366 
367  // Interpolate the direction Measure polynomial
368  static MDirection interpolateDirMeas(const Array<MDirection>& arrDir,
369  Int numPoly, Double interTime,
370  Double timeOrigin);
371 
372 
373  // set the epoch reference type for the TIME column.
374  // <note role=tip>
375  // In principle this function can only be used if the table is empty,
376  // otherwise already written values may thereafter have an incorrect
377  // reference, offset, or unit. However, it is possible that part of the
378  // table gets written before these values are known. In that case the
379  // reference, offset, or units can be set by using a False
380  // <src>tableMustBeEmpty</src> argument.
381  // </note>
382  void setEpochRef(MEpoch::Types ref, Bool tableMustBeEmpty=True);
383 
384  // set the direction reference type for the REFERENCE_DIR, DELAY_DIR &
385  // PHASE_DIR columns. This can only be done when the table has no
386  // rows. Trying to do so at other times will throw an exception.
388 
389 protected:
390  //# default constructor creates a object that is not usable. Use the attach
391  //# function correct this.
392  MSFieldColumns();
393 
394  //# attach this object to the supplied table.
395  void attach(MSField& msField);
396 
397 private:
398  //# Make the assignment operator and the copy constructor private to prevent
399  //# any compiler generated one from being used.
402 
403  //# Check if any optional columns exist and if so attach them.
404  //# Initialise the necessary MeasComet objects if the EPHEMERIS_ID column is present.
405  void attachOptionalCols(MSField& msField);
406 
407  //# required columns
417  //# optional columns
419 
420  //# Access to Measure columns
425 
426  //# Access to Quantum columns
428 
429 };
430 
431 
432 } //# NAMESPACE CASACORE - END
433 
434 #endif
const ROArrayMeasColumn< MDirection > & phaseDirMeasCol() const
A Measure: astronomical direction.
Definition: MDirection.h:174
A 1-D Specialization of the Array class.
ROScalarColumn< String > name_p
int Int
Definition: aipstype.h:50
String ephemPath(Int row) const
ScalarColumn< String > & code()
Read-write access to required columns.
ScalarColumn< Bool > flagRow_p
ScalarMeasColumn< MEpoch > & timeMeas()
void attach(MSField &msField)
ScalarColumn< String > code_p
const ROArrayMeasColumn< MDirection > & delayDirMeasCol() const
ROScalarColumn< Int > sourceId_p
ScalarColumn< Int > ephemerisId_p
std::map< Int, Int > ephIdToMeasComet_p
A class to provide easy access to MSField columns.
ArrayColumn< Double > phaseDir_p
ROScalarMeasColumn< MEpoch > timeMeas_p
const ROScalarColumn< Int > & ephemerisId() const
Read-only access to optional columns.
const ROArrayColumn< Double > & referenceDir() const
const ROArrayMeasColumn< MDirection > & referenceDirMeasCol() const
ArrayColumn< Double > & referenceDir()
const ROScalarColumn< Int > & sourceId() const
ROScalarColumn< String > code_p
const ROScalarColumn< Bool > & flagRow() const
const ROScalarColumn< Int > & sourceId() const
MDirection extractDirMeas(const MDirection &offsetDir, Int index, Double &interTime, MEpoch originEpoch) const
Extract the direction Measure from the corresponding ephemeris using the nominal position as an offse...
ScalarColumn< Double > time_p
void getMJDs(Double &originMJD, Double &interMJD, const Double interTime, const MEpoch originEpoch) const
Bool needInterTime(Int row) const
A Measure: radial velocity.
Bool matchReferenceDir(uInt row, const MVDirection &dirVal, const Double &sepInRad, MVDirection &mvdir, Double time=0) const
Quantity rho(Int row, Double time=0) const
~MSFieldColumns()
The desctructor does nothing special.
ArrayMeasColumn< MDirection > & delayDirMeasCol()
const ROArrayColumn< Double > & delayDir() const
const ROScalarColumn< Double > & time() const
A Measure: instant in time.
Definition: MEpoch.h:104
~ROMSFieldColumns()
The desctructor does nothing special.
MDirection phaseDirMeas(Int row, Double time=0) const
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.
ROScalarQuantColumn< Double > timeQuant_p
ScalarColumn< Int > & numPoly()
ScalarQuantColumn< Double > & timeQuant()
const ROArrayMeasColumn< MDirection > & phaseDirMeasCol() const
Int measCometIndex(int row) const
const ROArrayMeasColumn< MDirection > & referenceDirMeasCol() const
static MDirection interpolateDirMeas(const Array< MDirection > &arrDir, Int numPoly, Double interTime, Double timeOrigin)
Interpolate the direction Measure polynomial.
Vector< MeasComet * > measCometsV_p
void attachOptionalCols(MSField &msField)
ArrayColumn< Double > & phaseDir()
Int matchDirection(const MDirection &referenceDirection, const MDirection &delayDirection, const MDirection &phaseDirection, const Quantum< Double > &maxSeparation, Int tryRow=-1, Double time=0)
returns the last row that has a reference direction, phase direction and delay direction that match...
Bool matchDelayDir(uInt row, const MVDirection &dirVal, const Double &sepInRad, MVDirection &mvdir, Double time=0) const
ScalarColumn< String > & name()
ScalarColumn< Int > & sourceId()
ROScalarColumn< Int > ephemerisId_p
ScalarColumn< Int > sourceId_p
ROScalarColumn< Int > numPoly_p
double Double
Definition: aipstype.h:55
const ROScalarColumn< String > & name() const
const ROArrayColumn< Double > & referenceDir() const
const ROArrayColumn< Double > & delayDir() const
const ROScalarQuantColumn< Double > & timeQuant() const
Bool matchPhaseDir(uInt row, const MVDirection &dirVal, const Double &sepInRad, MVDirection &mvdir, Double time=0) const
ROArrayMeasColumn< MDirection > phaseDirMeas_p
const ROScalarMeasColumn< MEpoch > & timeMeas() const
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
uInt nrow() const
Convenience function that returns the number of rows in any of the columns.
ROScalarColumn< Double > time_p
MDirection referenceDirMeas(Int row, Double time=0) const
const ROScalarMeasColumn< MEpoch > & timeMeas() const
MDirection delayDirMeas(Int row, Double time=0) const
Access to interpolated directions from polynomials or ephemerides, the default time of zero will retu...
const ROArrayMeasColumn< MDirection > & delayDirMeasCol() const
const ROScalarColumn< String > & name() const
ArrayMeasColumn< MDirection > & referenceDirMeasCol()
ROArrayColumn< Double > delayDir_p
const ROScalarColumn< String > & code() const
Read-only access to required columns.
A Table intended to hold a MeasurementSet FIELD table.
Definition: MSField.h:78
ArrayColumn< Double > delayDir_p
void attachOptionalCols(const MSField &msField)
ScalarColumn< Int > & ephemerisId()
Read-write access to optional columns.
void setEpochRef(MEpoch::Types ref, Bool tableMustBeEmpty=True)
set the epoch reference type for the TIME column.
const ROScalarColumn< Int > & numPoly() const
ArrayMeasColumn< MDirection > & phaseDirMeasCol()
ArrayMeasColumn< MDirection > referenceDirMeas_p
ROArrayMeasColumn< MDirection > delayDirMeas_p
const ROScalarQuantColumn< Double > & timeQuant() const
MSFieldColumns & operator=(const MSFieldColumns &)
const ROScalarColumn< Bool > & flagRow() const
ROScalarColumn< Bool > flagRow_p
ROArrayColumn< Double > referenceDir_p
ScalarColumn< Int > numPoly_p
void updateMeasComets()
Update the MeasComets objects belonging to this FIELD table.
ScalarColumn< Bool > & flagRow()
ScalarQuantColumn< Double > timeQuant_p
ArrayMeasColumn< MDirection > phaseDirMeas_p
const ROScalarColumn< String > & code() const
Read-only access to required columns.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
ScalarMeasColumn< MEpoch > timeMeas_p
ROArrayMeasColumn< MDirection > referenceDirMeas_p
MRadialVelocity radVelMeas(Int row, Double time=0) const
Vector of three direction cosines.
Definition: MVDirection.h:106
ArrayColumn< Double > referenceDir_p
const ROScalarColumn< Double > & time() const
void attach(const MSField &msField)
Access to a scalar table column with arbitrary data type.
Definition: MSFitsOutput.h:41
ArrayColumn< Double > & delayDir()
Types
Types of known MEpochs Caution: The order defines the order in the translation matrix in the MCEpoch...
Definition: MEpoch.h:117
const ROArrayColumn< Double > & phaseDir() const
ScalarColumn< String > name_p
ArrayMeasColumn< MDirection > delayDirMeas_p
const Bool True
Definition: aipstype.h:43
ROMSFieldColumns & operator=(const ROMSFieldColumns &)
MDirection ephemerisDirMeas(Int row, Double time=0) const
const ROScalarColumn< Int > & numPoly() const
void setDirectionRef(MDirection::Types ref)
set the direction reference type for the REFERENCE_DIR, DELAY_DIR &amp; PHASE_DIR columns.
const ROArrayColumn< Double > & phaseDir() const
ScalarColumn< Double > & time()
unsigned int uInt
Definition: aipstype.h:51
ROArrayColumn< Double > phaseDir_p
const ROScalarColumn< Int > & ephemerisId() const
Read-only access to optional columns.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42