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