ArrayTime.h

00001 /* 00002 * ALMA - Atacama Large Millimeter Array 00003 * (c) European Southern Observatory, 2002 00004 * (c) Associated Universities Inc., 2002 00005 * Copyright by ESO (in the framework of the ALMA collaboration), 00006 * Copyright by AUI (in the framework of the ALMA collaboration), 00007 * All rights reserved. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * This library is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY, without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00022 * MA 02111-1307 USA 00023 * 00024 * File ArrayTime.h 00025 */ 00026 00027 #ifndef ArrayTime_CLASS 00028 #define ArrayTime_CLASS 00029 00030 #include <string> 00031 using std::string; 00032 00033 #include <vector> 00034 using std::vector; 00035 00036 #include <Interval.h> 00037 #include <UTCCorrection.h> 00038 00039 #ifndef WITHOUT_ACS 00040 #include <asdmIDLTypesC.h> 00041 using asdmIDLTypes::IDLArrayTime; 00042 #endif 00043 00044 #include "EndianStream.h" 00045 using asdm::EndianOSStream; 00046 using asdm::EndianISStream; 00047 00048 namespace asdm { 00049 00093 class ArrayTime : public Interval { 00094 00095 public: 00096 00097 // Useful constants 00098 const static int numberSigDigitsInASecond = 9; 00099 const static long long unitsInASecond = 1000000000LL; 00100 const static long long unitsInADayL = 86400000000000LL; 00101 const static double unitsInADay ; 00102 const static double unitsInADayDiv100 ; 00103 const static double julianDayOfBase ; 00104 const static long long julianDayOfBaseInUnitsInADayDiv100 = 2073600432000000000LL; 00105 00106 static bool isLeapYear(int year); 00107 static double getMJD(double jd); 00108 static double getJD(double mjd); 00109 static ArrayTime add(const ArrayTime &time, const Interval &interval); 00110 static ArrayTime sub(const ArrayTime &time, const Interval &interval) ; 00111 static ArrayTime getArrayTime(StringTokenizer &t) ; 00112 00113 ArrayTime(); 00114 ArrayTime (const string &s); 00115 ArrayTime(const ArrayTime &t); 00116 #ifndef WITHOUT_ACS 00117 ArrayTime (const IDLArrayTime &t); 00118 #endif 00119 ArrayTime(int year, int month, double day); 00120 ArrayTime(int year, int month, int day, int hour, int minute, double second); 00121 ArrayTime(double modifiedJulianDay); 00122 ArrayTime(int modifiedJulianDay, double secondsInADay); 00123 ArrayTime(long long nanoseconds); 00124 00125 double getJD() const; 00126 double getMJD() const; 00127 double getJDI() const; 00128 double getMJDI() const; 00129 00130 #ifndef WITHOUT_ACS 00131 IDLArrayTime toIDLArrayTime() const; 00132 #endif 00133 string toFITS() const; 00134 00135 00139 void toBin(EndianOSStream& eoss); 00140 00146 static void toBin(const vector<ArrayTime>& arrayTime, EndianOSStream& eoss); 00147 00153 static void toBin(const vector<vector<ArrayTime> >& arrayTime, EndianOSStream& eoss); 00154 00160 static void toBin(const vector<vector<vector<ArrayTime> > >& arrayTime, EndianOSStream& eoss); 00161 00168 static ArrayTime fromBin(EndianISStream& eiss); 00169 00176 static vector<ArrayTime> from1DBin(EndianISStream & eiss); 00177 00184 static vector<vector<ArrayTime> > from2DBin(EndianISStream & eiss); 00185 00192 static vector<vector<vector<ArrayTime> > > from3DBin(EndianISStream & eiss); 00193 00194 int *getDateTime() const; 00195 double getTimeOfDay() const; 00196 int getDayOfWeek() const; 00197 int getDayOfYear() const; 00198 string timeOfDayToString() const; 00199 double getLocalSiderealTime(double longitudeInHours) const; 00200 double getGreenwichMeanSiderealTime() const; 00201 00202 static double unitToJD(long long unit); 00203 static double unitToMJD(long long unit); 00204 static long long jdToUnit(double jd); 00205 static long long mjdToUnit(double mjd); 00206 00207 static double utcCorrection(double jd); 00208 00209 private: 00210 00211 static long long init(int year, int month, double day); 00212 static long long init(int year, int month, int day, int hour, int minute, double second); 00213 long long FITSString(string t) const; 00214 00215 /* 00216 static const int numberSigDigitsInASecond; 00217 static const long long unitsInASecond; 00218 static const long long unitsInADayL; 00219 static const double unitsInADay; 00220 static const double unitsInADayDiv100; 00221 static const double julianDayOfBase; 00222 static const long long julianDayOfBaseInUnitsInADayDiv100; 00223 */ 00224 static const UTCCorrection *UTCCorrectionTable; 00225 static const UTCCorrection UTCLast; 00226 00227 }; 00228 00229 inline double ArrayTime::getJDI() const {return getJD();} 00230 inline double ArrayTime::getMJDI()const {return getMJD();} 00231 } // End namespace asdm 00232 00233 #endif /* ArrayTime_CLASS */

Generated on Tue Nov 18 17:43:40 2008 for ASDM C++ Implementation by doxygen 1.3.8