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