casa
$Rev:20696$
|
00001 //# FITSDateUtil.h: Class of static functions to help with FITS dates. 00002 //# Copyright (C) 2002 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# 00027 //# $Id: FITSDateUtil.h 18093 2004-11-30 17:51:10Z ddebonis $ 00028 00029 00030 #ifndef FITS_FITSDATEUTIL_H 00031 #define FITS_FITSDATEUTIL_H 00032 00033 #include <casa/aips.h> 00034 #include <measures/Measures/MEpoch.h> 00035 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 class String; 00039 class MVTime; 00040 00041 // <summary> 00042 // A class with static functions to help deal with FITS dates 00043 // </summary> 00044 00045 // <use visibility=export> 00046 00047 // <reviewed reviewer="Eric Sessoms" date="2002/08/19" tests="tFITSDateUtil.cc"> 00048 // </reviewed> 00049 00050 // <prerequisite> 00051 // <li> General knowledge of FITS, particularly FITS date keywords, 00052 // is assumed. 00053 // </prerequisite> 00054 // 00055 // <etymology> 00056 // This is a collection of static utility functions for creating and 00057 // interpreting FITS date keywords (e.g. DATE-OBS). 00058 // </etymology> 00059 // 00060 // <synopsis> 00061 // Its never necessary to construct a FITSDateUtil, just use the 00062 // static functions to help handle FITS dates. 00063 // </synopsis> 00064 // 00065 // <motivation> 00066 // The strings that make up the value of FITS dates have a 00067 // precise format. This class encompasses knowlege of the formats 00068 // used and hopefully simplifies their creation and conversion 00069 // to and from aips++ MVTimes. 00070 // </motivation> 00071 // 00072 00073 class FITSDateUtil 00074 { 00075 public: 00076 enum DateStyle { 00077 // dd/mm/yy 00078 OLD, 00079 // yyyy-mm-dd 00080 NEW_DATEONLY, 00081 // yyyy-mm-ddThh:mm:ss[.ss...] 00082 NEW_DATEANDTIME, 00083 // OLD if the current year is before 1998 AND "time" is before 1998, 00084 // otherwise NEW_DATEANDTIME. 00085 AUTO_PICK}; 00086 00087 // Convert an MVTime to a FITS date string and timesys string. The 00088 // time system must also be supplied. 00089 // Precision is only used when the time as well as the date is used 00090 // (NEW_DATEANDTIME or AUTO_PICK). 00091 // The default (16) gives 10^(-10) second accuracy, 6 gives second level 00092 // accuracy. Default is 10^(-6)s (1 micro-s) accuracy. 0 means date only, 00093 // no time (equivalent to NEW_DATEONLY). 00094 static void toFITS(String &date, String ×ys, const MVTime &time, 00095 MEpoch::Types system = MEpoch::UTC, 00096 DateStyle style= AUTO_PICK, uInt precision=12); 00097 00098 // Convert a FITS date string and TIMESYS keyword value into an MVTime and system. 00099 // Returns False if it can't decode date and timesys. It tries to convert as 00100 // much as possible, for example if it can't decode timesys it still 00101 // attempts to decode the time. It sets the date to Jan 1/1900 if it can't 00102 // decode the time, and UTC if it can't decode timesys. If timesys is the 00103 // empty string then UTC is assumed. 00104 static Bool fromFITS(MVTime &time, MEpoch::Types &system, 00105 const String &date, 00106 const String ×ys); 00107 00108 // Convert a FITS Date string to the current format. If the "in" format is 00109 // already correct it is just copied through. 00110 static Bool convertDateString(String &out, const String &in); 00111 00112 00113 // Determine the precision in a FITS date string. 00114 // Old style dates or no time returns 0, New style + time returns 6 + the number 00115 // of decimal points, i.e. if we have a time at all we assume it is at least 00116 // accurate to the second level. The result of this can be used in the call 00117 // to toFITS, i.e. it has the same meaning. 00118 // 00119 // This is mostly meant to be a helper function for convertDateString, but 00120 // it may be called by anyone. 00121 static uInt findPrecision(const String &fitsDate); 00122 }; 00123 00124 00125 } //# NAMESPACE CASA - END 00126 00127 #endif