casacore
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>
32 #include <casacore/casa/Arrays/ArrayFwd.h>
33 #include <casacore/measures/Measures/MDirection.h>
34 #include <casacore/measures/Measures/MEpoch.h>
35 #include <casacore/measures/Measures/MCDirection.h>
36 #include <casacore/measures/Measures/MCEpoch.h>
37 #include <casacore/measures/Measures/MRadialVelocity.h>
38 #include <casacore/measures/Measures/MeasComet.h>
39 #include <casacore/measures/TableMeasures/ArrayMeasColumn.h>
40 #include <casacore/measures/TableMeasures/ScalarMeasColumn.h>
41 #include <casacore/measures/TableMeasures/ScalarQuantColumn.h>
42 #include <casacore/tables/Tables/ArrayColumn.h>
43 #include <casacore/tables/Tables/ScalarColumn.h>
44 #include <casacore/casa/BasicSL/String.h>
45 #include <map>
46 
47 namespace casacore { //# NAMESPACE CASACORE - BEGIN
48 
49 class MVDirection;
50 class MSField;
51 template <class Qtype> class Quantum;
52 
53 
54  // <summary>
55 // A class to provide easy access to MSField columns
56 // </summary>
57 
58 // <use visibility=export>
59 
60 // <reviewed reviewer="Bob Garwood" date="1997/02/01" tests="" demos="">
61 // </reviewed>
62 
63 // <prerequisite>
64 // <li> MSField
65 // <li> ArrayColumn
66 // <li> ScalarColumn
67 // </prerequisite>
68 //
69 // <etymology>
70 // MSFieldColumns stands for MeasurementSet Field Table columns.
71 // </etymology>
72 //
73 // <synopsis>
74 // This class provides access to the columns in the MSField Table,
75 // it does the declaration of all the Scalar and ArrayColumns with the
76 // correct types, so the application programmer doesn't have to
77 // worry about getting those right. There is an access function
78 // for every predefined column. Access to non-predefined columns will still
79 // have to be done with explicit declarations.
80 // See <linkto class=MSColumns> MSColumns</linkto> for an example.
81 // </synopsis>
82 //
83 // <motivation>
84 // See <linkto class=MSColumns> MSColumns</linkto> for the motivation.
85 // </motivation>
86 
88 {
89 public:
90  // Construct from the supplied Table
91  MSFieldColumns(const MSField& msField);
92 
93  // The desctructor does nothing special
95 
96  // Access to required columns
97  //
98  // Note that the direction measures with a stored polynomial have Col() added
99  // to their name. They are better accessed via the functions that have the
100  // same name, without the Col suffix, that will do the interpolation for
101  // you.
102  // <group>
106  {return delayDirMeas_p;}
112  {return phaseDirMeas_p;}
115  {return referenceDirMeas_p;}
120  // </group>
121 
122  // Const access to required columns
123  // <group>
124  const ScalarColumn<String>& code() const {return code_p;}
125  const ArrayColumn<Double>& delayDir() const {return delayDir_p;}
127  {return delayDirMeas_p;}
128  const ScalarColumn<Bool>& flagRow() const {return flagRow_p;}
129  const ScalarColumn<String>& name() const {return name_p;}
130  const ScalarColumn<Int>& numPoly() const {return numPoly_p;}
131  const ArrayColumn<Double>& phaseDir() const {return phaseDir_p;}
133  {return phaseDirMeas_p;}
136  {return referenceDirMeas_p;}
137  const ScalarColumn<Int>& sourceId() const {return sourceId_p;}
138  const ScalarColumn<Double>& time() const {return time_p;}
140  const ScalarMeasColumn<MEpoch>& timeMeas() const { return timeMeas_p;}
141  // </group>
142 
143  // Access to optional columns
144  // <group>
146  // </group>
147 
148  // Const access to optional columns
149  // <group>
150  const ScalarColumn<Int>& ephemerisId() const {return ephemerisId_p;}
151  // </group>
152 
153 
154  // Interpolate the direction Measure polynomial
156  Int numPoly, Double interTime,
157  Double timeOrigin);
158 
159 
160  // set the epoch reference type for the TIME column.
161  // <note role=tip>
162  // In principle this function can only be used if the table is empty,
163  // otherwise already written values may thereafter have an incorrect
164  // reference, offset, or unit. However, it is possible that part of the
165  // table gets written before these values are known. In that case the
166  // reference, offset, or units can be set by using a False
167  // <src>tableMustBeEmpty</src> argument.
168  // </note>
169  void setEpochRef(MEpoch::Types ref, Bool tableMustBeEmpty=True);
170 
171  // set the direction reference type for the REFERENCE_DIR, DELAY_DIR &
172  // PHASE_DIR columns. This can only be done when the table has no
173  // rows. Trying to do so at other times will throw an exception.
175 
176  // Access to interpolated directions from polynomials or ephemerides,
177  // the default time of zero will return the 0th order element of the polynomial.
178  // or, if there is an ephemeris, the position at the time origin of the ephemeris.
179  //
180  // If there is an ephemeris attached to a field table row, the nominal values of the
181  // direction columns are interpreted as an offset to the ephemeris. So if there is
182  // an ephemeris attached (EPHEMERIS_ID column contains value > -1), then the direction
183  // returned by delayDirMeas, phaseDirMeas, and referenceDirMeas is the ephemeris
184  // direction plus the offset taken from the corresponding direction column.
185  // This permits the convinient implementation of mosaics where several field table
186  // rows share one ephemeris and use different offsets in each row to create the
187  // mosaic pattern.
188  //
189  // The unaltered ephemeris direction can be queried with the method ephemerisDirMeas().
190  // If there is no ephemeris attached, ephemerisDirMeas() will return the same as
191  // referenceDirMeas().
192  //
193  // In addtion to the directions, if there is an ephemeris available,
194  // also the radial velocity and the distance rho can be accessed.
195  //
196  // The method needInterTime returns True if there is a polynomial or ephemeris
197  // connected to this field table row, and an interpolation time value should
198  // be provided.
199  // The method ephemPath returns the absolute path to the ephemeris table connected to
200  // the field table row, an empty string if there is none.
201  // <group>
207  Quantity rho(rownr_t row, Double time = 0) const;
210 
211  // </group>
212 
213  // Convenience function that returns the number of rows in any of the columns
214  rownr_t nrow() const {return name_p.nrow();}
215 
216  // returns the last row that has a reference direction, phase direction and
217  // delay direction that match, to within the specified angular separation,
218  // the supplied values. Only matches on rows where the direction is constant
219  // ie., NUM_POLY is 0 and where FLAG_ROW is False. Throws an exception
220  // (AipsError) if the reference frames do not match or if the separation does
221  // not have angular units (when compiled in debug mode). Returns -1 if no
222  // match could be found. If tryRow is positive, then that row is tested to
223  // see if it matches before any others are tested. Setting tryRow to a
224  // positive value greater than the table length will throw an exception
225  // (AipsError), when compiled in debug mode.
226  Int64 matchDirection(const MDirection& referenceDirection,
227  const MDirection& delayDirection,
228  const MDirection& phaseDirection,
229  const Quantum<Double>& maxSeparation,
230  Int64 tryRow=-1,
231  Double time=0);
232 
233  // Update the MeasComets objects belonging to this FIELD table.
234  // Needed when the entries in the EPHEMERIS_ID column have changed.
236 
237 protected:
238  //# default constructor creates a object that is not usable. Use the attach
239  //# function correct this.
241 
242  //# attach this object to the supplied table.
243  void attach(const MSField& msField);
244 
245 private:
246  //# Make the assignment operator and the copy constructor private to prevent
247  //# any compiler generated one from being used.
250 
251  //# Check if any optional columns exist and if so attach them.
252  //# Initialise the necessary MeasComet objects if the EPHEMERIS_ID column is present.
253  void attachOptionalCols(const MSField& msField);
254 
255  //# Functions which check the supplied values against the relevant column and
256  //# the specified row. The row must have a numpoly value of zero. The mvdir
257  //# argument is a temporary that is passed in to prevent it from being
258  //# created inside these small functions.
259  // <group>
261  const Double& sepInRad,
262  MVDirection& mvdir, Double time=0) const;
263  Bool matchDelayDir(rownr_t row, const MVDirection& dirVal,
264  const Double& sepInRad,
265  MVDirection& mvdir, Double time=0) const;
266  Bool matchPhaseDir(rownr_t row, const MVDirection& dirVal,
267  const Double& sepInRad,
268  MVDirection& mvdir, Double time=0) const;
269  // </group>
270 
272 
273  // Extract the direction Measure from the corresponding ephemeris
274  // using the nominal position as an offset.
275  // Note that interTime is assumed to use the same time reference frame
276  // as originEpoch.
278  Int index, Double& interTime,
279  MEpoch originEpoch) const;
280 
281  void getMJDs(Double& originMJD, Double& interMJD,
282  const Double interTime, const MEpoch originEpoch) const;
283 
284  //# MeasComet data
287  std::map<Int, Int> ephIdToMeasComet_p;
288 
289  //# required columns
299  //# optional columns
301 
302  //# Access to Measure columns
307 
308  //# Access to Quantum columns
310 
311 };
312 
313 //# Define the RO version for backward compatibility.
315 
316 } //# NAMESPACE CASACORE - END
317 
318 #endif
Types
Types of known MDirections Warning: The order defines the order in the translation matrix FromTo in ...
Definition: MDirection.h:188
Types
Types of known MEpochs Caution: The order defines the order in the translation matrix in the MCEpoch...
Definition: MEpoch.h:117
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...
MSFieldColumns & operator=(const MSFieldColumns &)
Bool matchPhaseDir(rownr_t row, const MVDirection &dirVal, const Double &sepInRad, MVDirection &mvdir, Double time=0) const
ArrayMeasColumn< MDirection > & phaseDirMeasCol()
Bool matchDelayDir(rownr_t row, const MVDirection &dirVal, const Double &sepInRad, MVDirection &mvdir, Double time=0) const
const ScalarColumn< Int > & sourceId() const
void attach(const MSField &msField)
const ScalarColumn< Bool > & flagRow() const
MSFieldColumns(const MSField &msField)
Construct from the supplied Table.
MSFieldColumns(const MSFieldColumns &)
std::map< Int, Int > ephIdToMeasComet_p
ArrayColumn< Double > & delayDir()
ScalarColumn< Double > & time()
ScalarColumn< Int > & numPoly()
ArrayColumn< Double > & referenceDir()
static MDirection interpolateDirMeas(const Array< MDirection > &arrDir, Int numPoly, Double interTime, Double timeOrigin)
Interpolate the direction Measure polynomial.
Bool matchReferenceDir(rownr_t row, const MVDirection &dirVal, const Double &sepInRad, MVDirection &mvdir, Double time=0) const
const ScalarColumn< String > & name() const
rownr_t nrow() const
Convenience function that returns the number of rows in any of the columns.
const ArrayColumn< Double > & referenceDir() const
ArrayMeasColumn< MDirection > & delayDirMeasCol()
void attachOptionalCols(const MSField &msField)
void updateMeasComets()
Update the MeasComets objects belonging to this FIELD table.
ScalarColumn< String > & code()
Access to required columns.
MDirection phaseDirMeas(rownr_t row, Double time=0) const
ScalarColumn< String > name_p
ScalarQuantColumn< Double > timeQuant_p
const ArrayColumn< Double > & phaseDir() const
const ArrayMeasColumn< MDirection > & phaseDirMeasCol() const
ScalarQuantColumn< Double > & timeQuant()
const ScalarColumn< String > & code() const
Const access to required columns.
ScalarMeasColumn< MEpoch > & timeMeas()
~MSFieldColumns()
The desctructor does nothing special.
void getMJDs(Double &originMJD, Double &interMJD, const Double interTime, const MEpoch originEpoch) const
const ArrayColumn< Double > & delayDir() const
ScalarColumn< Int > & ephemerisId()
Access to optional columns.
ArrayColumn< Double > referenceDir_p
const ScalarQuantColumn< Double > & timeQuant() const
ScalarColumn< Bool > flagRow_p
ScalarColumn< String > & name()
ScalarColumn< String > code_p
void setEpochRef(MEpoch::Types ref, Bool tableMustBeEmpty=True)
set the epoch reference type for the TIME column.
const ScalarColumn< Int > & ephemerisId() const
Const access to optional columns.
ScalarColumn< Int > & sourceId()
const ArrayMeasColumn< MDirection > & referenceDirMeasCol() const
ArrayMeasColumn< MDirection > referenceDirMeas_p
MDirection referenceDirMeas(rownr_t row, Double time=0) const
const ScalarMeasColumn< MEpoch > & timeMeas() const
void setDirectionRef(MDirection::Types ref)
set the direction reference type for the REFERENCE_DIR, DELAY_DIR & PHASE_DIR columns.
const ScalarColumn< Double > & time() const
ScalarMeasColumn< MEpoch > timeMeas_p
MDirection delayDirMeas(rownr_t row, Double time=0) const
Access to interpolated directions from polynomials or ephemerides, the default time of zero will retu...
ArrayColumn< Double > phaseDir_p
ArrayMeasColumn< MDirection > delayDirMeas_p
const ArrayMeasColumn< MDirection > & delayDirMeasCol() const
Bool needInterTime(rownr_t row) const
Quantity rho(rownr_t row, Double time=0) const
Vector< MeasComet * > measCometsV_p
ArrayMeasColumn< MDirection > & referenceDirMeasCol()
ScalarColumn< Int > ephemerisId_p
ScalarColumn< Bool > & flagRow()
MRadialVelocity radVelMeas(rownr_t row, Double time=0) const
ArrayMeasColumn< MDirection > phaseDirMeas_p
ScalarColumn< Int > sourceId_p
const ScalarColumn< Int > & numPoly() const
Int measCometIndex(rownr_t row) const
MDirection ephemerisDirMeas(rownr_t row, Double time=0) const
ScalarColumn< Double > time_p
Int64 matchDirection(const MDirection &referenceDirection, const MDirection &delayDirection, const MDirection &phaseDirection, const Quantum< Double > &maxSeparation, Int64 tryRow=-1, Double time=0)
returns the last row that has a reference direction, phase direction and delay direction that match,...
ScalarColumn< Int > numPoly_p
ArrayColumn< Double > delayDir_p
String ephemPath(rownr_t row) const
ArrayColumn< Double > & phaseDir()
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
MSFieldColumns ROMSFieldColumns
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43
double Double
Definition: aipstype.h:55
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46