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