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