casacore
Loading...
Searching...
No Matches
MeasIERS.h
Go to the documentation of this file.
1//# MeasIERS.h: Interface to IERS tables
2//# Copyright (C) 1996,1997,1999,2000,2002,2007,2016
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 MEASURES_MEASIERS_H
27#define MEASURES_MEASIERS_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/Tables/Table.h>
32#include <casacore/tables/Tables/TableRow.h>
33#include <casacore/tables/Tables/TableRecord.h>
34#include <casacore/casa/Containers/RecordField.h>
35
36#include <mutex>
37
38namespace casacore { //# NAMESPACE CASACORE - BEGIN
39
40//# Forward Declarations
41class String;
42
43// <summary> Interface to IERS tables </summary>
44
45// <use visibility=local>
46
47// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMeasMath" demos="">
48// </reviewed>
49
50// <prerequisite>
51// <li> <linkto class=MeasTable>MeasTable</linkto>
52// </prerequisite>
53//
54// <etymology>
55// From Measure and IERS
56// </etymology>
57//
58// <synopsis>
59// MeasIERS is the interface class to the global IERS data.
60// It has only static members.<br>
61// It has a member (<src>getTable()</src>) to open and check IERS
62// (and other Measures related Tables) type tables.
63// Tables are found using the aipsrc
64// (using <src>measures.<table>.directory</src>, or <src>measures.directory</src>)
65// mechanism. If not provided they are assumed to reside in standard places
66// (i.e. they are looked for in (udir in following normally given by
67// program as ephemerides or geodetic) '.', './data', '~/aips++/data/udir',
68// '$AIPSROOT/data/udir', '~/aips++/code/trial/apps/measures',
69// '$AIPSROOT/data/udir' (last two only ad interim)). They are also looked
70// for in <src>data/{ephemerides,geodetic}</src> (root and user aips++).
71//
72// If an explicit Table object is given the lookup is bypassed, and the Table
73// provided is used. The table should still be named.
74//
75// Tables are assumed to have the
76// VS_VERSION, VS_DATE, VS_CREATE and VS_TYPE keywords, and be of type IERS,
77// else an exception will be thrown.<br>
78// The <src>get()</src> method will obtain data from measured and predicted
79// Earth Orientation Parameters IERS tables (i.e. the <src>IERSeop97</src> and
80// the <src>IERSpredict</src> tables. If not forced, the data is taken from
81// the measured table if possible. Only if forced (see below), or if data is
82// not (yet) available in measured the predicted values are used. A warning
83// message is (once) issued if values are not available at all.
84//
85// MeasIERS looks at some <linkto class=Aipsrc>Aipsrc</linkto>
86// values to determine actions:
87// <ul>
88// <li> measures.measiers.b_notable : Do not use IERS tables to convert measures
89// <li> measures.measiers.b_forcepredict : Use values from prediction tables
90// even if Measured table asked by program.
91// <li> measures.measiers.d_predicttime : Use values from prediction tables if
92// (now - time) less than value given (default 5) (days)
93// </ul>
94// These values can be set in aipsrc as well as using
95// <linkto class=AipsrcValue>AipsrcValue</linkto> set() methods.
96// <note>
97// A message is Logged (once) if an IERS table cannot be found.
98// A message is logged (once) if a date outside the range in
99// the Tables is asked for.
100// </note>
101// <thrown>
102// <li> AipsError if table opened has wrong format or otherwise corrupted.
103// </thrown>
104// </synopsis>
105//
106// <example>
107// See the <src>dUTC()</src> method in
108// <linkto class=MeasTable>MeasTable</linkto> for an example of the
109// <src>getTable</src> method; and the <src>polarMotion()</src> method for
110// an example of <src>get()</src>.
111//
112// </example>
113//
114// <motivation>
115// To use the IERS data for time and nutation calculations
116// </motivation>
117//
118// <todo asof="1997/07/02">
119// </todo>
120
121class MeasIERS {
122
123public:
124 //# Typedefs
125 // Define the function pointer to be called to close files
126 typedef void (*CLOSEFUN) ();
127
128 //# Constants
129 static const Double INTV;
130
131 //# Enumerations
132 // Types of known data
133 enum Types {
134 // MJD (must be first in list)
136 // Polar motion x
138 // Polar motion y
140 // UT1-UTC
142 // Length of Day
144 // dPsi
146 // dEpsilon
148 // Polar motion x error
150 // Polar motion y error
152 // UT1-UTC error
154 // Length of Day error
156 // dPsi error
158 // dEpsilon error
160 // Number of types
162
163 // Types of files
164 enum Files {
165 // Measured EOP values
167 // Predicted EOP values
169 // # of known types
171 // Default
173
174 //# General Member Functions
175 // Get the value from an IERS table, interpolated for date(in MJD).
176 // The file can be PREDICTED or MEASURED, the type as given in enum.
177 static Bool get(Double &returnValue,
178 MeasIERS::Files file,
179 MeasIERS::Types type,
180 Double date);
181
182 // Find and open table tab, using the rc variable, the dir and the name.
183 // An rfn list gives the N row field names to be used
184 // Returned are an open table, the table keywordset (kws), a row record,
185 // pointers (rfp) to row data, the table version (vs), dt, and, directly,
186 // whether or not it was successful.
187 // Lookup for name is bypassed if the Table address tabin is provided.
188 // <thrown>
189 // <li> AipsError if missing VS_ keywords, columns, or they type is not IERS.
190 // </thrown>
191 static Bool getTable(Table &table, TableRecord &kws, ROTableRow &row,
193 String &vs, Double &dt,
194 Int N, const String rfn[],
195 const String &name,
196 const String &rc, const String &dir,
197 const Table *tabin = 0);
198
199 // Find and open table tab, using the rc variable, the dir and the name.
200 // reqcols gives the names (in order) of the columns which must be present.
201 // optcols gives the names of columns which should be added, in order after
202 // reqcols, if they are present.
203 // Returned are an open table, the table keywordset (kws), a row record,
204 // pointers (rfp) to row data, the table version (vs), dt, and, directly,
205 // whether or not it was successful. optcols is set to the optional columns
206 // that were found.
207 // Lookup for name is bypassed if the Table address tabin is provided.
208 // <thrown>
209 // <li> AipsError if missing VS_ keywords, required columns, or the type is not IERS.
210 // </thrown>
211 static Bool getTable(Table &table, TableRecord &kws, ROTableRow &row,
213 String &vs, Double &dt,
214 const Vector<String>& reqcols,
215 Vector<String>& optcols,
216 const String &name,
217 const String &rc, const String &dir,
218 const Table *tabin = 0);
219
220 // A helper function for getTable() which is conceivably usable outside it,
221 // for finding a table in the same way, but not requiring it to fit the IERS
222 // mold.
223 // Finds a Table for tab, by looking in tabin, rc, dir, and name.
224 // Returns whether or not it was successful.
225 static Bool findTab(Table& tab, const Table *tabin, const String &rc,
226 const String &dir, const String &name);
227
228 // Notify that a table has successfully been opened with getTable()
229 static void openNote(CLOSEFUN fun);
230
231 // Make sure all static tables are closed that were opened with getTable
232 // (like JPL, IERS). This is the preferred way to close the
233 // Measures related data tables. Only call it last at end of program.
234 static void closeTables();
235
236 // Close the set of IERS tables only. Only call it last at end of program.
237 static void closeMeas();
238
239private:
240
241 //# Constructors
242 // Default constructor, NOT defined
244
245 // Copy assign, NOT defined
247
248 //# Destructor
249 // Destructor, NOT defined and not declared to stop warning
250 // ~MeasIERS();
251
252 //# General member functions
253 // Initialise tables
254 static void initMeas();
255
256 // A helper function for getTable() which is not likely usable outside it.
257 // Sets dt and vs (the table version), and checks that
258 // ks has VS_DATE, VS_VERSION, VS_CREATE, and VS_TYPE,
259 // and that tab's type is IERS in its info.
260 // Returns whether or not it was successful.
262 const TableRecord& ks, const Table& tab);
263
264 //# Data members
265 // Object to ensure safe multi-threaded lazy single initialization
266 static std::once_flag theirCallOnceFlag;
267 // Current date
269 // Read data (meas - predict)
271 // File names
272 static const String tp[N_Files];
273 // Check prediction interval
275 // Use no table
277 // Force prediction
279 // Size of close notification list
281 // Tables notifying that they should be closed
283 // Number of close notifications
284 static uInt nNote;
285};
286
287//# Inline Implementations
288
289
290} //# NAMESPACE CASACORE - END
291
292#endif
size_t N
Axis number.
static Bool findTab(Table &tab, const Table *tabin, const String &rc, const String &dir, const String &name)
A helper function for getTable() which is conceivably usable outside it, for finding a table in the s...
void(* CLOSEFUN)()
Define the function pointer to be called to close files.
Definition MeasIERS.h:126
Types
Types of known data.
Definition MeasIERS.h:133
@ DLOD
Length of Day error.
Definition MeasIERS.h:155
@ MJD
MJD (must be first in list)
Definition MeasIERS.h:135
@ DX
Polar motion x error.
Definition MeasIERS.h:149
@ N_Types
Number of types.
Definition MeasIERS.h:161
@ DdPsi
dPsi error
Definition MeasIERS.h:157
@ DY
Polar motion y error.
Definition MeasIERS.h:151
@ DdUT1
UT1-UTC error.
Definition MeasIERS.h:153
@ Y
Polar motion y.
Definition MeasIERS.h:139
@ X
Polar motion x.
Definition MeasIERS.h:137
@ LOD
Length of Day.
Definition MeasIERS.h:143
@ DdEps
dEpsilon error
Definition MeasIERS.h:159
static Bool getTable(Table &table, TableRecord &kws, ROTableRow &row, RORecordFieldPtr< Double > rfp[], String &vs, Double &dt, Int N, const String rfn[], const String &name, const String &rc, const String &dir, const Table *tabin=0)
Find and open table tab, using the rc variable, the dir and the name.
static Double dateNow
Current date.
Definition MeasIERS.h:268
static Bool get(Double &returnValue, MeasIERS::Files file, MeasIERS::Types type, Double date)
Get the value from an IERS table, interpolated for date(in MJD).
static uInt predicttime_reg
Check prediction interval.
Definition MeasIERS.h:274
static uInt forcepredict_reg
Force prediction.
Definition MeasIERS.h:278
static const Double INTV
Definition MeasIERS.h:129
static void closeTables()
Make sure all static tables are closed that were opened with getTable (like JPL, IERS).
static const String tp[N_Files]
File names.
Definition MeasIERS.h:272
static void openNote(CLOSEFUN fun)
Notify that a table has successfully been opened with getTable()
MeasIERS()
Default constructor, NOT defined.
static Bool getTable(Table &table, TableRecord &kws, ROTableRow &row, Vector< RORecordFieldPtr< Double > > &rfp, String &vs, Double &dt, const Vector< String > &reqcols, Vector< String > &optcols, const String &name, const String &rc, const String &dir, const Table *tabin=0)
Find and open table tab, using the rc variable, the dir and the name.
static uInt notable_reg
Use no table.
Definition MeasIERS.h:276
static uInt sizeNote
Size of close notification list.
Definition MeasIERS.h:280
static Vector< Double > ldat[N_Files][N_Types]
Read data (meas - predict)
Definition MeasIERS.h:270
static CLOSEFUN * toclose
Tables notifying that they should be closed.
Definition MeasIERS.h:282
static void closeMeas()
Close the set of IERS tables only.
MeasIERS & operator=(const MeasIERS &other)
Copy assign, NOT defined.
static void initMeas()
Destructor, NOT defined and not declared to stop warning ~MeasIERS();.
Files
Types of files.
Definition MeasIERS.h:164
@ PREDICTED
Predicted EOP values.
Definition MeasIERS.h:168
@ MEASURED
Measured EOP values.
Definition MeasIERS.h:166
@ DEFAULT
Default.
Definition MeasIERS.h:172
static uInt nNote
Number of close notifications.
Definition MeasIERS.h:284
static std::once_flag theirCallOnceFlag
Object to ensure safe multi-threaded lazy single initialization.
Definition MeasIERS.h:266
static Bool handle_keywords(Double &dt, String &vs, const TableRecord &ks, const Table &tab)
A helper function for getTable() which is not likely usable outside it.
Read-Only access to an individual field from a Record.
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
unsigned int uInt
Definition aipstype.h:49
TableExprNode date(const TableExprNode &node)
Definition ExprNode.h:1515
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
double Double
Definition aipstype.h:53