casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArrayTime.h
Go to the documentation of this file.
1 /*
2  * ALMA - Atacama Large Millimeter Array
3  * (c) European Southern Observatory, 2002
4  * (c) Associated Universities Inc., 2002
5  * Copyright by ESO (in the framework of the ALMA collaboration),
6  * Copyright by AUI (in the framework of the ALMA collaboration),
7  * All rights reserved.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY, without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22  * MA 02111-1307 USA
23  *
24  * File ArrayTime.h
25  */
26 
27 #ifndef ArrayTime_CLASS
28 #define ArrayTime_CLASS
29 
30 #include <stdint.h>
31 #include <string>
32 
33 #include <vector>
34 
35 #include <alma/ASDM/Interval.h>
37 
38 #ifndef WITHOUT_ACS
39 #include <asdmIDLTypesC.h>
40 #endif
41 
42 #include <alma/ASDM/EndianStream.h>
43 
44 namespace asdm {
45 
89 class ArrayTime : public Interval {
90 
91 public:
92 
93  // Useful constants
94  const static int numberSigDigitsInASecond = 9;
95  const static int64_t unitsInASecond = 1000000000LL;
96  const static int64_t unitsInADayL = 86400000000000LL;
97  const static double unitsInADay ;
98  const static double unitsInADayDiv100 ;
99  const static double julianDayOfBase ;
100  const static int64_t julianDayOfBaseInUnitsInADayDiv100 = 2073600432000000000LL;
101 
102  static bool isLeapYear(int year);
103  static double getMJD(double jd);
104  static double getJD(double mjd);
105  static ArrayTime add(const ArrayTime &time, const Interval &interval);
106  static ArrayTime sub(const ArrayTime &time, const Interval &interval) ;
108 
116  ArrayTime();
117 
128  ArrayTime (const std::string &s);
129 
135  ArrayTime(const ArrayTime &t);
136 #ifndef WITHOUT_ACS
137 
142  ArrayTime (const asdmIDLTypes::IDLArrayTime &t);
143 #endif
144 
155  ArrayTime(int year, int month, double day);
156 
169  ArrayTime(int year, int month, int day, int hour, int minute, double second);
170 
176  ArrayTime(double modifiedJulianDay);
177 
184  ArrayTime(int modifiedJulianDay, double secondsInADay);
185 
192  ArrayTime(int64_t nanoseconds);
193 
199  double getJD() const;
200 
206  double getMJD() const;
207 
208 /*
209  double getJDI() const;
210  double getMJDI() const;
211 */
212 
213 #ifndef WITHOUT_ACS
214  asdmIDLTypes::IDLArrayTime toIDLArrayTime() const;
215 #endif
216  std::string toFITS() const;
217 
218 
222  void toBin(EndianOSStream& eoss);
223 
229  static void toBin(const std::vector<ArrayTime>& arrayTime, EndianOSStream& eoss);
230 
236  static void toBin(const std::vector<std::vector<ArrayTime> >& arrayTime, EndianOSStream& eoss);
237 
243  static void toBin(const std::vector<std::vector<std::vector<ArrayTime> > >& arrayTime, EndianOSStream& eoss);
244 
251  static ArrayTime fromBin(EndianIStream& eis);
252 
259  static std::vector<ArrayTime> from1DBin(EndianIStream & eis);
260 
267  static std::vector<std::vector<ArrayTime> > from2DBin(EndianIStream & eis);
268 
275  static std::vector<std::vector<std::vector<ArrayTime> > > from3DBin(EndianIStream & eis);
276 
277  int *getDateTime() const;
278  double getTimeOfDay() const;
279  int getDayOfWeek() const;
280  int getDayOfYear() const;
281  std::string timeOfDayToString() const;
282  double getLocalSiderealTime(double longitudeInHours) const;
283  double getGreenwichMeanSiderealTime() const;
284 
285  static double unitToJD(int64_t unit);
286  static double unitToMJD(int64_t unit);
287  static int64_t jdToUnit(double jd);
288  static int64_t mjdToUnit(double mjd);
289 
290  static double utcCorrection(double jd);
291 
292 private:
293 
294  static int64_t init(int year, int month, double day);
295  static int64_t init(int year, int month, int day, int hour, int minute, double second);
296  int64_t FITSString(std::string t) const;
297 
298 /*
299  static const int numberSigDigitsInASecond;
300  static const int64_t unitsInASecond;
301  static const int64_t unitsInADayL;
302  static const double unitsInADay;
303  static const double unitsInADayDiv100;
304  static const double julianDayOfBase;
305  static const int64_t julianDayOfBaseInUnitsInADayDiv100;
306 */
308  static const UTCCorrection UTCLast;
309 
310 };
311 
312 /*
313 inline double ArrayTime::getJDI() const {return getJD();}
314 inline double ArrayTime::getMJDI()const {return getMJD();}
315 */
316 } // End namespace asdm
317 
318 #endif /* ArrayTime_CLASS */
static const UTCCorrection UTCLast
Definition: ArrayTime.h:308
The Interval class implements an interval of time in units of nanoseconds.
Definition: Interval.h:58
ArrayTime()
The nullary constructor.
const Double hour
hour
double getJD() const
Return the julian day.
static int64_t jdToUnit(double jd)
static bool isLeapYear(int year)
The StringTokenizer class is a translation into C++ of the Java class of the same name in Java&#39;s util...
static ArrayTime sub(const ArrayTime &time, const Interval &interval)
ABSTRACT TOOL CLASSES A PlotTool is a higher level event handler for a PlotCanvas The idea is to take common tasks which may require multiple events and put them in one place PlotTools also provide additional functionality in that they can be active and blocking non blocking The PlotCanvas will only send events to active and will not send events to later tools or event handlers if the latest tool was blocking In this way a single tool can be used to handle ALL user interaction via the GUI at one time
Definition: PlotTool.h:43
static int64_t mjdToUnit(double mjd)
int getDayOfYear() const
const Double minute
minute
static std::vector< ArrayTime > from1DBin(EndianIStream &eis)
Read the binary representation of a vector of ArrayTime from an EndianIStream and use the read value ...
TableExprNode year(const TableExprNode &node)
Definition: ExprNode.h:1472
TableExprNode mjd(const TableExprNode &node)
Definition: ExprNode.h:1464
TableExprNode month(const TableExprNode &node)
Definition: ExprNode.h:1476
static ArrayTime add(const ArrayTime &time, const Interval &interval)
static const double unitsInADayDiv100
Definition: ArrayTime.h:98
double getGreenwichMeanSiderealTime() const
static std::string unit()
Definition: Interval.h:325
int * getDateTime() const
static const UTCCorrection * UTCCorrectionTable
Definition: ArrayTime.h:307
double getMJD() const
Return the modified julian day.
std::string timeOfDayToString() const
static const double julianDayOfBase
Definition: ArrayTime.h:99
const Double day
day
asdmIDLTypes::IDLArrayTime toIDLArrayTime() const
int getDayOfWeek() const
static const double unitsInADay
Definition: ArrayTime.h:97
The ArrayTime class implements the concept of a point in time, implemented as an Interval of time sin...
Definition: ArrayTime.h:89
static double unitToMJD(int64_t unit)
static const int numberSigDigitsInASecond
Useful constants.
Definition: ArrayTime.h:94
double getLocalSiderealTime(double longitudeInHours) const
std::string toFITS() const
static const int64_t julianDayOfBaseInUnitsInADayDiv100
Definition: ArrayTime.h:100
const Double second
Time interval [T]:
static ArrayTime fromBin(EndianIStream &eis)
Read the binary representation of an ArrayTime from a EndianIStream and use the read value to set an ...
static ArrayTime getArrayTime(StringTokenizer &t)
static const int64_t unitsInASecond
Definition: ArrayTime.h:95
static std::vector< std::vector< ArrayTime > > from2DBin(EndianIStream &eis)
Read the binary representation of a vector of vector of ArrayTime from an EndianIStream and use the r...
static double utcCorrection(double jd)
static std::vector< std::vector< std::vector< ArrayTime > > > from3DBin(EndianIStream &eis)
Read the binary representation of a vector of vector of vector of ArrayTime from an EndianIStream and...
double getTimeOfDay() const
void toBin(EndianOSStream &eoss)
Write the binary representation of this to a EndianOSStream.
static const int64_t unitsInADayL
Definition: ArrayTime.h:96
static double unitToJD(int64_t unit)
int64_t FITSString(std::string t) const
static int64_t init(int year, int month, double day)