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 public:
123 // # Typedefs
124 // Define the function pointer to be called to close files
125 typedef void (*CLOSEFUN)();
126
127 // # Constants
128 static const Double INTV;
129
130 // # Enumerations
131 // Types of known data
132 enum Types {
133 // MJD (must be first in list)
135 // Polar motion x
137 // Polar motion y
139 // UT1-UTC
141 // Length of Day
143 // dPsi
145 // dEpsilon
147 // Polar motion x error
149 // Polar motion y error
151 // UT1-UTC error
153 // Length of Day error
155 // dPsi error
157 // dEpsilon error
159 // Number of types
161 };
162
163 // Types of files
164 enum Files {
165 // Measured EOP values
167 // Predicted EOP values
169 // # of known types
171 // Default
173 };
174
175 // # General Member Functions
176 // Get the value from an IERS table, interpolated for date(in MJD).
177 // The file can be PREDICTED or MEASURED, the type as given in enum.
179
180 // Find and open table tab, using the rc variable, the dir and the name.
181 // An rfn list gives the N row field names to be used
182 // Returned are an open table, the table keywordset (kws), a row record,
183 // pointers (rfp) to row data, the table version (vs), dt, and, directly,
184 // whether or not it was successful.
185 // Lookup for name is bypassed if the Table address tabin is provided.
186 // <thrown>
187 // <li> AipsError if missing VS_ keywords, columns, or they type is not IERS.
188 // </thrown>
189 static Bool getTable(Table &table, TableRecord &kws, ROTableRow &row,
190 RORecordFieldPtr<Double> rfp[], String &vs, Double &dt, Int N,
191 const String rfn[], const String &name, const String &rc, const String &dir,
192 const Table *tabin = 0);
193
194 // Find and open table tab, using the rc variable, the dir and the name.
195 // reqcols gives the names (in order) of the columns which must be present.
196 // optcols gives the names of columns which should be added, in order after
197 // reqcols, if they are present.
198 // Returned are an open table, the table keywordset (kws), a row record,
199 // pointers (rfp) to row data, the table version (vs), dt, and, directly,
200 // whether or not it was successful. optcols is set to the optional columns
201 // that were found.
202 // Lookup for name is bypassed if the Table address tabin is provided.
203 // <thrown>
204 // <li> AipsError if missing VS_ keywords, required columns, or the type is not IERS.
205 // </thrown>
206 static Bool getTable(Table &table, TableRecord &kws, ROTableRow &row,
208 const Vector<String> &reqcols, Vector<String> &optcols, const String &name,
209 const String &rc, const String &dir, const Table *tabin = 0);
210
211 // A helper function for getTable() which is conceivably usable outside it,
212 // for finding a table in the same way, but not requiring it to fit the IERS
213 // mold.
214 // Finds a Table for tab, by looking in tabin, rc, dir, and name.
215 // Returns whether or not it was successful.
216 static Bool findTab(Table &tab, const Table *tabin, const String &rc, const String &dir,
217 const String &name);
218
219 // Notify that a table has successfully been opened with getTable()
220 static void openNote(CLOSEFUN fun);
221
222 // Make sure all static tables are closed that were opened with getTable
223 // (like JPL, IERS). This is the preferred way to close the
224 // Measures related data tables. Only call it last at end of program.
225 static void closeTables();
226
227 // Close the set of IERS tables only. Only call it last at end of program.
228 static void closeMeas();
229
230 private:
231 // # Constructors
232 // Default constructor, NOT defined
234
235 // Copy assign, NOT defined
237
238 // # Destructor
239 // Destructor, NOT defined and not declared to stop warning
240 // ~MeasIERS();
241
242 // # General member functions
243 // Initialise tables
244 static void initMeas();
245
246 // A helper function for getTable() which is not likely usable outside it.
247 // Sets dt and vs (the table version), and checks that
248 // ks has VS_DATE, VS_VERSION, VS_CREATE, and VS_TYPE,
249 // and that tab's type is IERS in its info.
250 // Returns whether or not it was successful.
251 static Bool handle_keywords(Double &dt, String &vs, const TableRecord &ks, const Table &tab);
252
253 // # Data members
254 // Object to ensure safe multi-threaded lazy single initialization
255 static std::once_flag theirCallOnceFlag;
256 // Current date
258 // Read data (meas - predict)
260 // File names
261 static const String tp[N_Files];
262 // Check prediction interval
264 // Use no table
266 // Force prediction
268 // Size of close notification list
270 // Tables notifying that they should be closed
272 // Number of close notifications
273 static uInt nNote;
274};
275
276// # Inline Implementations
277
278} // namespace casacore
279
280#endif
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:125
Types
Types of known data.
Definition MeasIERS.h:132
@ DLOD
Length of Day error.
Definition MeasIERS.h:154
@ MJD
MJD (must be first in list).
Definition MeasIERS.h:134
@ DX
Polar motion x error.
Definition MeasIERS.h:148
@ N_Types
Number of types.
Definition MeasIERS.h:160
@ DdPsi
dPsi error
Definition MeasIERS.h:156
@ DY
Polar motion y error.
Definition MeasIERS.h:150
@ DdUT1
UT1-UTC error.
Definition MeasIERS.h:152
@ Y
Polar motion y.
Definition MeasIERS.h:138
@ X
Polar motion x.
Definition MeasIERS.h:136
@ LOD
Length of Day.
Definition MeasIERS.h:142
@ DdEps
dEpsilon error
Definition MeasIERS.h:158
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:257
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:263
static uInt forcepredict_reg
Force prediction.
Definition MeasIERS.h:267
static const Double INTV
Definition MeasIERS.h:128
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:261
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:265
static uInt sizeNote
Size of close notification list.
Definition MeasIERS.h:269
static Vector< Double > ldat[N_Files][N_Types]
Read data (meas - predict).
Definition MeasIERS.h:259
static CLOSEFUN * toclose
Tables notifying that they should be closed.
Definition MeasIERS.h:271
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:273
static std::once_flag theirCallOnceFlag
Object to ensure safe multi-threaded lazy single initialization.
Definition MeasIERS.h:255
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:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
TableExprNode date(const TableExprNode &node)
Definition ExprNode.h:1320
String name() const
Return the name of the field.
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