casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FITSDateUtil.h
Go to the documentation of this file.
1 //# FITSDateUtil.h: Class of static functions to help with FITS dates.
2 //# Copyright (C) 2002
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 
30 #ifndef FITS_FITSDATEUTIL_H
31 #define FITS_FITSDATEUTIL_H
32 
33 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 class String;
39 class MVTime;
40 
41 // <summary>
42 // A class with static functions to help deal with FITS dates
43 // </summary>
44 
45 // <use visibility=export>
46 
47 // <reviewed reviewer="Eric Sessoms" date="2002/08/19" tests="tFITSDateUtil.cc">
48 // </reviewed>
49 
50 // <prerequisite>
51 // <li> General knowledge of FITS, particularly FITS date keywords,
52 // is assumed.
53 // </prerequisite>
54 //
55 // <etymology>
56 // This is a collection of static utility functions for creating and
57 // interpreting FITS date keywords (e.g. DATE-OBS).
58 // </etymology>
59 //
60 // <synopsis>
61 // Its never necessary to construct a FITSDateUtil, just use the
62 // static functions to help handle FITS dates.
63 // </synopsis>
64 //
65 // <motivation>
66 // The strings that make up the value of FITS dates have a
67 // precise format. This class encompasses knowlege of the formats
68 // used and hopefully simplifies their creation and conversion
69 // to and from Casacore MVTimes.
70 // </motivation>
71 //
72 
74 {
75 public:
76  enum DateStyle {
77  // dd/mm/yy
78  OLD,
79  // yyyy-mm-dd
81  // yyyy-mm-ddThh:mm:ss[.ss...]
83  // OLD if the current year is before 1998 AND "time" is before 1998,
84  // otherwise NEW_DATEANDTIME.
86 
87  // Convert an MVTime to a FITS date string and timesys string. The
88  // time system must also be supplied.
89  // Precision is only used when the time as well as the date is used
90  // (NEW_DATEANDTIME or AUTO_PICK).
91  // The default (16) gives 10^(-10) second accuracy, 6 gives second level
92  // accuracy. Default is 10^(-6)s (1 micro-s) accuracy. 0 means date only,
93  // no time (equivalent to NEW_DATEONLY).
94  static void toFITS(String &date, String &timesys, const MVTime &time,
95  MEpoch::Types system = MEpoch::UTC,
96  DateStyle style= AUTO_PICK, uInt precision=12);
97 
98  // Convert a FITS date string and TIMESYS keyword value into an MVTime and system.
99  // Returns False if it can't decode date and timesys. It tries to convert as
100  // much as possible, for example if it can't decode timesys it still
101  // attempts to decode the time. It sets the date to Jan 1/1900 if it can't
102  // decode the time, and UTC if it can't decode timesys. If timesys is the
103  // empty string then UTC is assumed.
104  static Bool fromFITS(MVTime &time, MEpoch::Types &system,
105  const String &date,
106  const String &timesys);
107 
108  // Convert a FITS Date string to the current format. If the "in" format is
109  // already correct it is just copied through.
110  static Bool convertDateString(String &out, const String &in);
111 
112 
113  // Determine the precision in a FITS date string.
114  // Old style dates or no time returns 0, New style + time returns 6 + the number
115  // of decimal points, i.e. if we have a time at all we assume it is at least
116  // accurate to the second level. The result of this can be used in the call
117  // to toFITS, i.e. it has the same meaning.
118  //
119  // This is mostly meant to be a helper function for convertDateString, but
120  // it may be called by anyone.
121  static uInt findPrecision(const String &fitsDate);
122 };
123 
124 
125 } //# NAMESPACE CASACORE - END
126 
127 #endif
yyyy-mm-ddThh:mm:ss[.ss...]
Definition: FITSDateUtil.h:82
TableExprNode time(const TableExprNode &node)
Definition: ExprNode.h:1537
OLD if the current year is before 1998 AND &quot;time&quot; is before 1998, otherwise NEW_DATEANDTIME.
Definition: FITSDateUtil.h:85
static Bool convertDateString(String &out, const String &in)
Convert a FITS Date string to the current format.
static void toFITS(String &date, String &timesys, const MVTime &time, MEpoch::Types system=MEpoch::UTC, DateStyle style=AUTO_PICK, uInt precision=12)
Convert an MVTime to a FITS date string and timesys string.
static uInt findPrecision(const String &fitsDate)
Determine the precision in a FITS date string.
A class with static functions to help deal with FITS dates.
Definition: FITSDateUtil.h:73
static Bool fromFITS(MVTime &time, MEpoch::Types &system, const String &date, const String &timesys)
Convert a FITS date string and TIMESYS keyword value into an MVTime and system.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
String: the storage and methods of handling collections of characters.
Definition: String.h:223
Types
Types of known MEpochs Caution: The order defines the order in the translation matrix in the MCEpoch...
Definition: MEpoch.h:117
Class to handle date/time type conversions and I/O.
Definition: MVTime.h:269
unsigned int uInt
Definition: aipstype.h:51
TableExprNode date(const TableExprNode &node)
Definition: ExprNode.h:1468
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42