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: 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
39namespace casacore { //# NAMESPACE CASACORE - BEGIN
40
41//# Forward Declarations
42class 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
90class MVEpoch : public MeasValue {
91
92public:
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 static void assure(const MeasValue &in);
149 // </group>
150
151 // Adjust the time to its constituent parts. The returned result is always 1.0
152 // <group>
153 virtual void adjust();
154 virtual void adjust(Double &res);
155 // </group>
156
157 // Get value in days
158 Double get() const;
159
160 // Get value with units
161 // <group>
163 Quantity getTime(const Unit &unit) const;
164 // </group>
165
166 // Get value of integer days
167 Double getDay() const;
168
169 // Get fraction of days
171
172 // Print a value
173 virtual void print(ostream &os) const;
174
175 // Clone a value
176 virtual MeasValue *clone() const;
177
178 // Get the value in internal units
179 virtual Vector<Double> getVector() const;
180 // Set the value from internal units (set 0 for empty vector)
181 virtual void putVector(const Vector<Double> &in);
182 // Get the internal value as a <src>Vector<Quantity></src>. Usable in
183 // records. The getXRecordValue() gets additional information for records.
184 // Note that the Vectors could be empty.
185 // <group>
187 // </group>
188 // Set the internal value if correct values and dimensions
189 virtual Bool putValue(const Vector<Quantum<Double> > &in);
190
191private:
192 //# Data members
193 // Whole days
194 // Note that if higher precision is needed, the splitting could be in
195 // 0.001 days and fractions thereof
197 // Fraction of days
199
200 //# Member functions
201 // Make days from quantity
202 Double makeDay(const Quantity &in) const;
203 // Add time from days
204 void addTime(Double in);
205};
206
207//# Global functions
208
209
210} //# NAMESPACE CASACORE - END
211
212#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:196
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:143
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:144
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:198
this file contains all the compiler specific defines
Definition mainpage.dox:28
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:42
double Double
Definition aipstype.h:55