casacore
 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>
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
155  static MDirection interpolateDirMeas(const Array<MDirection>& arrDir,
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>
202  MDirection delayDirMeas(rownr_t row, Double time = 0) const;
203  MDirection phaseDirMeas(rownr_t row, Double time = 0) const;
206  MRadialVelocity radVelMeas(rownr_t row, Double time = 0) const;
207  Quantity rho(rownr_t row, Double time = 0) const;
208  Bool needInterTime(rownr_t row) const;
209  String ephemPath(rownr_t row) 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.
235  void updateMeasComets();
236 
237 protected:
238  //# default constructor creates a object that is not usable. Use the attach
239  //# function correct this.
240  MSFieldColumns();
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>
260  Bool matchReferenceDir(rownr_t row, const MVDirection& dirVal,
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 
271  Int measCometIndex(rownr_t row) const;
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.
277  MDirection extractDirMeas(const MDirection& offsetDir,
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
A Measure: astronomical direction.
Definition: MDirection.h:174
A 1-D Specialization of the Array class.
Definition: ArrayFwd.h:9
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
ScalarColumn< String > & code()
Access to required columns.
Bool needInterTime(rownr_t row) const
ScalarColumn< Bool > flagRow_p
ScalarMeasColumn< MEpoch > & timeMeas()
ScalarColumn< String > code_p
const ScalarColumn< String > & name() const
Bool matchReferenceDir(rownr_t row, const MVDirection &dirVal, const Double &sepInRad, MVDirection &mvdir, Double time=0) const
ScalarColumn< Int > ephemerisId_p
MDirection referenceDirMeas(rownr_t row, Double time=0) const
void updateMeasComets()
Update the MeasComets objects belonging to this FIELD table.
ArrayColumn< Double > phaseDir_p
Vector< MeasComet * > measCometsV_p
ArrayColumn< Double > & referenceDir()
void getMJDs(Double &originMJD, Double &interMJD, const Double interTime, const MEpoch originEpoch) const
MSFieldColumns ROMSFieldColumns
const ArrayMeasColumn< MDirection > & referenceDirMeasCol() const
const ArrayMeasColumn< MDirection > & phaseDirMeasCol() const
ScalarColumn< Double > time_p
const ArrayColumn< Double > & phaseDir() const
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...
A Measure: radial velocity.
~MSFieldColumns()
The desctructor does nothing special.
ArrayMeasColumn< MDirection > & delayDirMeasCol()
const ScalarColumn< Int > & ephemerisId() const
Const access to optional columns.
const ScalarColumn< Bool > & flagRow() const
A Measure: instant in time.
Definition: MEpoch.h:104
const ArrayMeasColumn< MDirection > & delayDirMeasCol() 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 access to MSField columns.
ScalarColumn< Int > & numPoly()
ScalarQuantColumn< Double > & timeQuant()
const ScalarColumn< Double > & time() const
Quantity rho(rownr_t row, Double time=0) const
MDirection ephemerisDirMeas(rownr_t row, Double time=0) const
void attachOptionalCols(const MSField &msField)
static MDirection interpolateDirMeas(const Array< MDirection > &arrDir, Int numPoly, Double interTime, Double timeOrigin)
Interpolate the direction Measure polynomial.
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()
ScalarColumn< String > & name()
ScalarColumn< Int > & sourceId()
ScalarColumn< Int > sourceId_p
double Double
Definition: aipstype.h:55
void attach(const MSField &msField)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
Bool matchPhaseDir(rownr_t row, const MVDirection &dirVal, const Double &sepInRad, MVDirection &mvdir, Double time=0) const
const ScalarMeasColumn< MEpoch > & timeMeas() const
ArrayMeasColumn< MDirection > & referenceDirMeasCol()
String ephemPath(rownr_t row) const
A Table intended to hold a MeasurementSet FIELD table.
Definition: MSField.h:78
ArrayColumn< Double > delayDir_p
ScalarColumn< Int > & ephemerisId()
Access to optional columns.
void setEpochRef(MEpoch::Types ref, Bool tableMustBeEmpty=True)
set the epoch reference type for the TIME column.
const ScalarQuantColumn< Double > & timeQuant() const
uInt64 rownr_t
Define the type of a row number in a table.
Definition: aipsxtype.h:46
ArrayMeasColumn< MDirection > & phaseDirMeasCol()
ArrayMeasColumn< MDirection > referenceDirMeas_p
const ScalarColumn< String > & code() const
Const access to required columns.
MSFieldColumns & operator=(const MSFieldColumns &)
Bool matchDelayDir(rownr_t row, const MVDirection &dirVal, const Double &sepInRad, MVDirection &mvdir, Double time=0) const
ScalarColumn< Int > numPoly_p
ScalarColumn< Bool > & flagRow()
ScalarQuantColumn< Double > timeQuant_p
ArrayMeasColumn< MDirection > phaseDirMeas_p
MDirection phaseDirMeas(rownr_t row, Double time=0) const
const ArrayColumn< Double > & referenceDir() const
String: the storage and methods of handling collections of characters.
Definition: String.h:225
ScalarMeasColumn< MEpoch > timeMeas_p
Int measCometIndex(rownr_t row) const
const ArrayColumn< Double > & delayDir() const
Vector of three direction cosines.
Definition: MVDirection.h:107
ArrayColumn< Double > referenceDir_p
Access to a scalar table column with arbitrary data type.
Definition: CopyRecord.h:47
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
ScalarColumn< String > name_p
ArrayMeasColumn< MDirection > delayDirMeas_p
const Bool True
Definition: aipstype.h:43
rownr_t nrow() const
Convenience function that returns the number of rows in any of the columns.
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...
MRadialVelocity radVelMeas(rownr_t row, Double time=0) const
const ScalarColumn< Int > & numPoly() const
void setDirectionRef(MDirection::Types ref)
set the direction reference type for the REFERENCE_DIR, DELAY_DIR &amp; PHASE_DIR columns.
ScalarColumn< Double > & time()
const ScalarColumn< Int > & sourceId() const
std::map< Int, Int > ephIdToMeasComet_p