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