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