casacore
MVEpoch.h
Go to the documentation of this file.
1 //# MVEpoch.h: a class for high precision time
2 //# Copyright (C) 1996,1997,1998,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 //#
27 //# $Id$
28 
29 #ifndef CASA_MVEPOCH_H
30 #define CASA_MVEPOCH_H
31 
32 
33 //# Includes
34 #include <casacore/casa/aips.h>
35 #include <casacore/casa/Arrays/Vector.h>
36 #include <casacore/casa/Quanta/Quantum.h>
37 #include <casacore/casa/Quanta/MeasValue.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 //# Forward Declarations
42 class Unit;
43 
44 // <summary> A class for high precision time </summary>
45 
46 // <use visibility=export>
47 
48 // <reviewed reviewer="tcornwel" date="1996/02/22" tests="tMeasMath" demos="">
49 // </reviewed>
50 
51 // <prerequisite>
52 // <li> <linkto class=MeasValue>MeasValue</linkto> class
53 // </prerequisite>
54 //
55 // <etymology>
56 // MVEpoch from Measure, Value and Epoch
57 // </etymology>
58 //
59 // <synopsis>
60 // MVEpoch is a class for high precision (10<sup>-16</sup> s) epochs over a
61 // period of 6*10<sup>10</sup> a.<br>
62 // MVEpochs can be compared, a time interval can be added or subtracted, and
63 // the time difference can be found.
64 // The following constructors:
65 // <ul>
66 // <li> <src>MVEpoch()</src> default; assuming 0
67 // <li> <src>MVEpoch(Double)</src> with time given in days
68 // <li> <src>MVEpoch(Double, Double=0)</src> with times given in days
69 // <li> <src>MVEpoch(Quantity, Quantity=0)</src> with times given
70 // <li> <src>MVEpoch(Quantum<Vector<Double> >)</src> with times given
71 // <li> <src>MVEpoch(Vector<Double>)</src> with times in days
72 // <li> <src>MVEpoch(Vector<Quantity>)</src> with times
73 // </ul>
74 // </synopsis>
75 //
76 // <example>
77 // See <linkto class=MEpoch>MEpoch</linkto>
78 // </example>
79 //
80 // <motivation>
81 // To have high precision timing
82 // </motivation>
83 //
84 // <todo asof="1996/02/04">
85 // <li> A proper high precision time, including multiplication etc should
86 // be considered. E.g. a multi-byte number with 6 bytes day
87 // and 8 bytes fractional day.
88 // </todo>
89 
90 class MVEpoch : public MeasValue {
91 
92 public:
93 
94  //# Friends
95 
96  //# Constructors
97  // Default constructor, generates default 0 epoch
99  // Copy constructor
100  MVEpoch(const MVEpoch &other);
101  // Constructor with time in days
102  // <group>
103  MVEpoch(Double inday, Double infrac=0);
104  MVEpoch(const Vector<Double> &inday);
105  // </group>
106  // Constructor with Quantities
107  // <group>
108  MVEpoch(const Quantity &in);
109  MVEpoch(const Quantity &in1, const Quantity &in2);
112  // </group>
113 
114  //# Destructor
116 
117  //# Operators
118  // Copy assignment
119  MVEpoch &operator=(const MVEpoch &other);
120 
121  // Add times
122  // <group>
123  MVEpoch &operator+=(const MVEpoch &other);
124  MVEpoch operator+(const MVEpoch &other) const;
125  // </group>
126 
127  // Difference times
128  // <group>
129  MVEpoch &operator-=(const MVEpoch &other);
130  MVEpoch operator-(const MVEpoch &other) const;
131  // </group>
132 
133  // Comparisons
134  // <group>
135  Bool operator==(const MVEpoch &other) const;
136  Bool operator!=(const MVEpoch &other) const;
137  Bool near(const MVEpoch &other, Double tol = 1e-13) const;
138  Bool nearAbs(const MVEpoch &other, Double tol = 1e-13) const;
139  // </group>
140 
141  //# General Member Functions
142  // Constants
143  static const Double secInDay;
144  static const Unit unitDay;
145 
146  // Tell me your type
147  // <group>
148  virtual uInt type() const;
149  static void assure(const MeasValue &in);
150  // </group>
151 
152  // Adjust the time to its constituent parts. The returned result is always 1.0
153  // <group>
154  virtual void adjust();
155  virtual void adjust(Double &res);
156  // </group>
157 
158  // Get value in days
159  Double get() const;
160 
161  // Get value with units
162  // <group>
163  Quantity getTime() const;
164  Quantity getTime(const Unit &unit) const;
165  // </group>
166 
167  // Get value of integer days
168  Double getDay() const;
169 
170  // Get fraction of days
172 
173  // Print a value
174  virtual void print(ostream &os) const;
175 
176  // Clone a value
177  virtual MeasValue *clone() const;
178 
179  // Get the value in internal units
180  virtual Vector<Double> getVector() const;
181  // Set the value from internal units (set 0 for empty vector)
182  virtual void putVector(const Vector<Double> &in);
183  // Get the internal value as a <src>Vector<Quantity></src>. Usable in
184  // records. The getXRecordValue() gets additional information for records.
185  // Note that the Vectors could be empty.
186  // <group>
188  // </group>
189  // Set the internal value if correct values and dimensions
190  virtual Bool putValue(const Vector<Quantum<Double> > &in);
191 
192 private:
193  //# Data members
194  // Whole days
195  // Note that if higher precision is needed, the splitting could be in
196  // 0.001 days and fractions thereof
198  // Fraction of days
200 
201  //# Member functions
202  // Make days from quantity
203  Double makeDay(const Quantity &in) const;
204  // Add time from days
205  void addTime(Double in);
206 };
207 
208 //# Global functions
209 
210 
211 } //# NAMESPACE CASACORE - END
212 
213 #endif
casacore::MVEpoch::secInDay
static const Double secInDay
Constants.
Definition: MVEpoch.h:143
casacore::MVEpoch::operator==
Bool operator==(const MVEpoch &other) const
Comparisons.
casacore::MVEpoch::~MVEpoch
~MVEpoch()
casacore::MVEpoch::getTime
Quantity getTime() const
Get value with units.
casacore::MVEpoch::makeDay
Double makeDay(const Quantity &in) const
Make days from quantity.
casacore::MVEpoch::MVEpoch
MVEpoch(const Vector< Quantity > &in)
casacore::MVEpoch::unitDay
static const Unit unitDay
Definition: MVEpoch.h:144
casacore::MVEpoch::MVEpoch
MVEpoch(const Quantum< Vector< Double > > &in)
casacore::MVEpoch::MVEpoch
MVEpoch(Double inday, Double infrac=0)
Constructor with time in days.
casacore::MVEpoch::operator+=
MVEpoch & operator+=(const MVEpoch &other)
Add times.
casacore::MVEpoch::getTime
Quantity getTime(const Unit &unit) const
casacore::MVEpoch::near
Bool near(const MVEpoch &other, Double tol=1e-13) const
casacore::MVEpoch::wday
Double wday
Whole days Note that if higher precision is needed, the splitting could be in 0.001 days and fraction...
Definition: MVEpoch.h:197
casacore::MVEpoch::adjust
virtual void adjust()
Adjust the time to its constituent parts.
casacore::MVEpoch::adjust
virtual void adjust(Double &res)
Adjust value and return a normalisation value.
casacore::MeasValue
Base class for values in a Measure.
Definition: MeasValue.h:107
casacore::MVEpoch::MVEpoch
MVEpoch(const Quantity &in)
Constructor with Quantities.
casacore::MVEpoch::frday
Double frday
Fraction of days.
Definition: MVEpoch.h:199
casacore::MVEpoch::getDay
Double getDay() const
Get value of integer days.
casacore::MVEpoch::getRecordValue
virtual Vector< Quantum< Double > > getRecordValue() const
Get the internal value as a Vector<Quantity>.
casacore::MVEpoch::assure
static void assure(const MeasValue &in)
casacore::MVEpoch::MVEpoch
MVEpoch()
Default constructor, generates default 0 epoch.
casacore::MVEpoch::nearAbs
Bool nearAbs(const MVEpoch &other, Double tol=1e-13) const
casacore::MVEpoch::operator-=
MVEpoch & operator-=(const MVEpoch &other)
Difference times.
casacore::Double
double Double
Definition: aipstype.h:55
casacore::MVEpoch::operator!=
Bool operator!=(const MVEpoch &other) const
casacore::MVEpoch::getVector
virtual Vector< Double > getVector() const
Get the value in internal units.
casacore::MVEpoch::print
virtual void print(ostream &os) const
Print a value.
casacore::MVEpoch::addTime
void addTime(Double in)
Add time from days.
casacore::MVEpoch::get
Double get() const
Get value in days.
casacore::MVEpoch::operator=
MVEpoch & operator=(const MVEpoch &other)
Copy assignment.
casacore::uInt
unsigned int uInt
Definition: aipstype.h:51
casacore::MVEpoch::clone
virtual MeasValue * clone() const
Clone a value.
casacore
this file contains all the compiler specific defines
Definition: mainpage.dox:28
casacore::MVEpoch::MVEpoch
MVEpoch(const Quantity &in1, const Quantity &in2)
casacore::MVEpoch
A class for high precision time.
Definition: MVEpoch.h:90
casacore::MVEpoch::operator+
MVEpoch operator+(const MVEpoch &other) const
casacore::MVEpoch::getDayFraction
Double getDayFraction() const
Get fraction of days.
casacore::C::e
const Double e
e and functions thereof:
casacore::MVEpoch::type
virtual uInt type() const
Tell me your type.
casacore::MVEpoch::putValue
virtual Bool putValue(const Vector< Quantum< Double > > &in)
Set the internal value if correct values and dimensions.
casacore::MVEpoch::MVEpoch
MVEpoch(const MVEpoch &other)
Copy constructor.
casacore::Bool
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Unit
defines physical units
Definition: Unit.h:189
casacore::Vector< Double >
casacore::MVEpoch::MVEpoch
MVEpoch(const Vector< Double > &inday)
casacore::MVEpoch::operator-
MVEpoch operator-(const MVEpoch &other) const
casacore::MVEpoch::putVector
virtual void putVector(const Vector< Double > &in)
Set the value from internal units (set 0 for empty vector)
casacore::Quantum< Double >