casacore
MEpoch.h
Go to the documentation of this file.
1 //# MEpoch.h: A Measure: instant in time
2 //# Copyright (C) 1995,1996,1997,1998,1999,2000,2002
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 //#
27 //# $Id$
28 
29 #ifndef MEASURES_MEPOCH_H
30 #define MEASURES_MEPOCH_H
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
34 #include <casacore/measures/Measures/MeasBase.h>
35 #include <casacore/measures/Measures/MeasRef.h>
36 #include <casacore/casa/Quanta/MVEpoch.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 //# Forward Declarations
41 class MEpoch;
42 class MCEpoch;
43 template <class M> class MeasConvert;
44 template <class M> class ArrayMeasColumn;
45 template <class M> class ScalarMeasColumn;
46 
47 //# Typedefs
48 
49 // <summary>
50 // A Measure: instant in time
51 // </summary>
52 
53 // <use visibility=export>
54 
55 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasure" demos="">
56 // </reviewed>
57 
58 // <prerequisite>
59 // <li> <linkto class=Measure>Measure</linkto> class
60 // </prerequisite>
61 //
62 // <etymology>
63 // Measure and Epoch
64 // </etymology>
65 //
66 // <synopsis>
67 // MEpoch forms derived Measure class for an instant in time.
68 // </synopsis>
69 //
70 // <example>
71 // Convert (with all steps explicit) a UTC to an IAT time.
72 // <srcblock>
73 // #include <casacore/measures/Measures.h>
74 // #include <casacore/measures/Measures/MEpoch.h>
75 // #include <casacore/measures/Measures/MCEpoch.h>
76 // #include <casacore/casa/logging/LogIO.h>
77 //
78 // cout << "TAI for UTC = MJD(50237.29): " <<
79 // MEpoch::Convert(MEpoch(MVEpoch(Quantity(50237.29, "d")),
80 // MEpoch::Ref(MEpoch::UTC)),
81 // MEpoch::Ref(MEpoch::TAI))() <<
82 // endl;
83 // LogIO os(LogOrigin("FluxCalc_SS_JPL_Butler", "readEphem"));
84 // os << LogIO::DEBUG1 << " at ";
85 // os.output() << MEpoch::Convert(MEpoch(MVEpoch(Quantity(50237.29, "d")),
86 // MEpoch::Ref(MEpoch::UTC)),
87 // MEpoch::Ref(MEpoch::TAI))();
88 // os << LogIO::POST;
89 // </srcblock>
90 // Results in:
91 // <srcblock>
92 // TAI for UTC = MJD(50237.29): Epoch: 50237::06:58:06.0000 (on stdout)
93 // at Epoch: 50237::06:58:06.0000 (in logger)
94 // </srcblock>
95 // </example>
96 //
97 // <motivation>
98 // </motivation>
99 //
100 // <todo asof="2000/06/15">
101 // <li>
102 // </todo>
103 
104 class MEpoch : public MeasBase<MVEpoch, MeasRef<MEpoch> > {
105 
106 public:
107  //# Friends
108  friend class MeasConvert<MEpoch>;
109 
110  //# Enumerations
111  // Types of known MEpochs
112  // <note role=caution> The order defines the order in the translation matrix
113  // in the MCEpoch class. Do not change the order without
114  // changing the array. Additions should be made before N_types, and
115  // an additional row and column should be coded in FromTo (MCEpoch), and
116  // in showType().</note>
117  enum Types {
118  // Local Apparent Sidereal Time
120  // Local Mean Sidereal Time
122  // Greenwich Mean ST1
124  // Greenwich Apparent ST
134  // Number of types
136  // Reduce result to integer days
137  RAZE = 32,
138  // All extra bits
140  // Synonyms
146  // Default
148  };
149 
150  //# Typedefs
151  // Measure value container for this class (i.e. MEpoch::MVType)
152  typedef MVEpoch MVType;
153  // Measure conversion routines for this class (i.e. MEpoch::MCType)
154  typedef MCEpoch MCType;
155  // Measure reference (i.e. MEpoch::Ref)
157  // Measure Convert (i.e. MEpoch::Convert)
159  // Measure table Columns (e.g., MEpoch::ScalarColumn)
162  // Reference enum Types (included originally for gcc 2.95)
164 
165  //# Constructors
166  // <note role=tip> In the following constructors and other functions, all
167  // <em>MeasRef</em> can be replaced with simple <src>Measure::TYPE</src>
168  // where no offsets or frames are needed in the reference. </note>
169  // Default constructor; generates an instant at MJD 0 UTC
170  MEpoch();
171  // Create from data and reference
172  // <group>
173  MEpoch(const MVEpoch &dt);
174  MEpoch(const MVEpoch &dt, const MEpoch::Ref &rf);
175  MEpoch(const MVEpoch &dt, MEpoch::Types rf);
176  MEpoch(const Quantity &dt);
177  MEpoch(const Quantity &dt, const MEpoch::Ref &rf);
178  MEpoch(const Quantity &dt, MEpoch::Types rf);
179  MEpoch(const Measure *dt);
180  MEpoch(const MeasValue *dt);
181  // </group>
182 
183  //# Destructor
184  virtual ~MEpoch();
185 
186  //# Operators
187 
188  //# General Member Functions
189  // Tell me your type
190  // <group>
191  virtual const String &tellMe() const;
192  static const String &showMe();
193  virtual uInt type() const;
194  static void assure(const Measure &in);
195  // </group>
196  // Translate reference code. The uInt version has a check for valid codes
197  // (i.e. it is a safe cast).
198  // <thrown>
199  // <li> AipsError in the uInt interface if illegal code given
200  // </thrown>
201  // <group>
202  static MEpoch::Types castType(uInt tp);
203  static const String &showType(MEpoch::Types tp);
204  static const String &showType(uInt tp);
205  // </group>
206  // Translate string to reference code
207  // <group>
208  static Bool getType(MEpoch::Types &tp, const String &in);
209  Bool giveMe(MEpoch::Ref &mr, const String &in);
210  // </group>
211  // Set the offset in the reference (False if non-matching Measure)
212  virtual Bool setOffset(const Measure &in);
213  // Set the reference type to the specified String. False if illegal
214  // string, reference set to DEFAULT.
215  virtual Bool setRefString(const String &in);
216  // Get the default reference type
217  virtual const String &getDefaultType() const;
218  // Get a list of all known reference codes. nall returns the number in list,
219  // nextra the number of specials (like planets) that should be at
220  // end of list). typ returns the list of corresponding types.
221  // <group>
222  virtual const String* allTypes(Int &nall, Int &nextra,
223  const uInt *&typ) const;
224  static const String* allMyTypes(Int &nall, Int &nextra,
225  const uInt *&typ);
226  // </group>
227  // Check if all internal tables of types (both enum and String) are
228  // complete and correct. This function is called automatically if and when
229  // necessary.
230  // <thrown>
231  // <li> AipsError if a (programming) error in the types.
232  // </thrown>
233  // <group>
234  virtual void checkTypes() const;
235  static void checkMyTypes();
236  // </group>
237  // Get the reference type (for records, including codes like R_)
238  virtual String getRefString() const;
239  // Get my type (as Register)
240  static uInt myType();
241 
242  // Get time in specified units
243  Quantity get(const Unit &inunit) const;
244 
245  // Create copy
246  // <group>
247  virtual Measure *clone() const;
248  // </group>
249 
250 private:
251  //# Enumerations
252 
253  //# Data
254 
255  //# Member functions
256 
257 };
258 
259 
260 } //# NAMESPACE CASACORE - END
261 
262 #endif
int Int
Definition: aipstype.h:50
Conversion of Measures.
Definition: MBaseline.h:44
virtual const String & tellMe() const
Tell me your type.
Local Mean Sidereal Time.
Definition: MEpoch.h:121
Bool giveMe(MEpoch::Ref &mr, const String &in)
virtual uInt type() const
Get the type (== Register() of derived Measure (faster than Strings) All should have: static uInt myT...
virtual const String & getDefaultType() const
Get the default reference type.
Local Apparent Sidereal Time.
Definition: MEpoch.h:119
virtual const String * allTypes(Int &nall, Int &nextra, const uInt *&typ) const
Get a list of all known reference codes.
static uInt myType()
Get my type (as Register)
MEpoch()
Tip: In the following constructors and other functions, all MeasRef can be replaced with simple Meas...
Physical quantities within reference frame.
Definition: Measure.h:235
Base class for all measures.
Definition: MeasBase.h:75
Read only access to table array Measure columns.
Definition: MBaseline.h:45
A Measure: instant in time.
Definition: MEpoch.h:104
static const String * allMyTypes(Int &nall, Int &nextra, const uInt *&typ)
static MEpoch::Types castType(uInt tp)
Translate reference code.
static void checkMyTypes()
virtual ~MEpoch()
defines physical units
Definition: Unit.h:189
MeasConvert< MEpoch > Convert
Measure Convert (i.e.
Definition: MEpoch.h:158
Synonyms.
Definition: MEpoch.h:141
static void assure(const Measure &in)
Base class for values in a Measure.
Definition: MeasValue.h:107
ScalarMeasColumn< MEpoch > ScalarColumn
Measure table Columns (e.g., MEpoch::ScalarColumn)
Definition: MEpoch.h:160
virtual void checkTypes() const
Check if all internal tables of types (both enum and String) are complete and correct.
static const String & showMe()
MeasRef< MEpoch > Ref
Measure reference (i.e.
Definition: MEpoch.h:156
MVEpoch MVType
Measure value container for this class (i.e.
Definition: MEpoch.h:152
static const String & showType(MEpoch::Types tp)
Reduce result to integer days.
Definition: MEpoch.h:137
virtual Bool setOffset(const Measure &in)
Set the offset in the reference (False if non-matching Measure)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
static Bool getType(MEpoch::Types &tp, const String &in)
Translate string to reference code.
Greenwich Mean ST1.
Definition: MEpoch.h:123
Types
Each derived class should have a Types enumeration, specifying the recognised frame types...
Definition: Measure.h:254
virtual Measure * clone() const
Create copy.
A class for high precision time.
Definition: MVEpoch.h:90
typedef WHATEVER_SUN_TYPEDEF(MEpoch) Types Types
Reference enum Types (included originally for gcc 2.95)
All extra bits.
Definition: MEpoch.h:139
Number of types.
Definition: MEpoch.h:135
Greenwich Apparent ST.
Definition: MEpoch.h:125
String: the storage and methods of handling collections of characters.
Definition: String.h:223
MEpoch conversion routines.
Definition: MCEpoch.h:92
Read only access to table scalar Measure columns.
Definition: MBaseline.h:46
virtual Bool setRefString(const String &in)
Set the reference type to the specified String.
virtual String getRefString() const
Get the reference type (for records, including codes like R_)
Types
Types of known MEpochs Caution: The order defines the order in the translation matrix in the MCEpoch...
Definition: MEpoch.h:117
ArrayMeasColumn< MEpoch > ArrayColumn
Definition: MEpoch.h:161
this file contains all the compiler specific defines
Definition: mainpage.dox:28
MCEpoch MCType
Measure conversion routines for this class (i.e.
Definition: MEpoch.h:154
unsigned int uInt
Definition: aipstype.h:51