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