casacore
MSTimeParse.h
Go to the documentation of this file.
1 //# MSTimeParse.h: Classes to hold results from time grammar parser
2 //# Copyright (C) 1994,1995,1997,1998,1999,2000,2001,2003
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 MS_MSTIMEPARSE_H
29 #define MS_MSTIMEPARSE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/ms/MSSel/MSParse.h>
34 #include <casacore/ms/MSSel/MSSelectableMainColumn.h>
35 #include <casacore/measures/Measures/MEpoch.h>
36 #include <casacore/ms/MSSel/MSTimeDefinitions.h>
37 #include <casacore/casa/Containers/Block.h>
38 #include <casacore/casa/Arrays/Matrix.h>
39 
40 namespace casacore { //# NAMESPACE CASACORE - BEGIN
41 
42 //# Forward Declarations
43 
44 // <summary>
45 // Class to hold values from time grammar parser
46 // </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="" date="" tests="">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // </prerequisite>
56 
57 // <etymology>
58 // MSTimeParse is the class used to parse a time command.
59 // </etymology>
60 
61 // <synopsis>
62 // MSTimeParse is used by the parser of time sub-expression statements.
63 // The parser is written in Bison and Flex in files MSTimeGram.y and .l.
64 // The statements in there use the routines in this file to act
65 // upon a reduced rule.
66 // Since multiple tables can be given (with a shorthand), the table
67 // names are stored in a list. The variable names can be qualified
68 // by the table name and will be looked up in the appropriate table.
69 //
70 // The class MSTimeParse only contains information about a table
71 // used in the table command. Global variables (like a list and a vector)
72 // are used in MSTimeParse.cc to hold further information.
73 //
74 // Global functions are used to operate on the information.
75 // The main function is the global function msTimeCommand.
76 // It executes the given STaQL command and returns the resulting ms.
77 // This is, in fact, the only function to be used by a user.
78 // </synopsis>
79 
80 // <motivation>
81 // It is necessary to be able to give a ms command in ASCII.
82 // This can be used in a CLI or in the table browser to get a subset
83 // of a table or to sort a table.
84 // </motivation>
85 
86 //# <todo asof="$DATE:$">
87 //# A List of bugs, limitations, extensions or planned refinements.
88 //# </todo>
89 
90 class MSTimeParse : public MSParse
91 {
92 
93 public:
94  // Default constructor
96 
97  // Associate the ms and the shorthand.
98  MSTimeParse (const MeasurementSet* ms,const TableExprNode& otherTens,const Bool honourRowFlags=True);
99  MSTimeParse (const MeasurementSet* ms,const TableExprNode& colAsTEN,
100  MSSelectableMainColumn& msMainColInterface,
101  const TableExprNode& otherTEN,
102  const Bool honourRowFlags=True);
104 
105 // ~MSTimeParse()
106 // {
107 // if (node_p) delete node_p;node_p=0x0;
108 // if (otherTens_p) delete otherTens_p;otherTens_p=0x0;
109 // }
110 
112  bool daytime = false);
113  const TableExprNode *selectTimeGT(const MEpoch& lowboundTime,
114  bool daytime = false);
115  const TableExprNode *selectTimeLT(const MEpoch& upboundTime,
116  bool daytime = false);
117  const TableExprNode *selectTimeRange(const MEpoch& lowboundTime,
118  const MEpoch& upboundTime,
119  bool daytime = false,
120  Float edgeWidth=-1.0);
123 
124  /*
125  static const MEpoch *dayTimeConvert(Int day=-1, Int hour = -1,
126  Int minute = -1, Int second = -1,
127  Int millisec = -1);
128  */
129 
130  static void setDefaults(TimeFields& tf, Bool dataOrigin=True);
131  void getDefaults();
132  static void copyDefaults(TimeFields& target, TimeFields& source);
133  static const MEpoch *yearTimeConvert(Int year=-1, Int month=-1, Int day=-1,
134  Int hour = -1, Int minute = -1,
135  Int second = -1, Int millisec = -1);
136  static const MEpoch *yearTimeConvert(const TimeFields& tf);
137 
138  // Get table expression node object.
139  static const TableExprNode* node();
140 
141  Int year0() {return defaultYear;}
142  Int month0() {return defaultMonth;}
143  Int day0() {return defaultDay;}
144  Int hour0() {return defaultHour;}
149 
150  static void validate(const TimeFields& tf);
151  static void reset(){timeList.resize(3,0);}
152  static void cleanup() {if (node_p) delete node_p;node_p=0x0;}
153 
155  //private:
156 
161  static Double toTAIInSec(const MEpoch& time);
162  static MEpoch* yeartime;
163  static MEpoch* daytime;
170  void accumulateTimeList(const Double t0, const Double t1,const Double dT=-1);
174 };
175 
176 } //# NAMESPACE CASACORE - END
177 
178 #endif
MeasurementSet * ms()
Get ms object.
static void setDefaults(TimeFields &tf, Bool dataOrigin=True)
static MEpoch * daytime
Definition: MSTimeParse.h:163
const TableExprNode * selectTime(const MEpoch &time, bool daytime=false)
~MSTimeParse() { if (node_p) delete node_p;node_p=0x0; if (otherTens_p) delete otherTens_p;otherTens_...
const TableExprNode * selectTimeGT(const MEpoch &lowboundTime, bool daytime=false)
const String colName
Definition: MSTimeParse.h:167
static const MEpoch * yearTimeConvert(const TimeFields &tf)
Matrix< Double > selectedTimes()
Definition: MSTimeParse.h:121
static MSTimeParse * thisMSTParser
Definition: MSTimeParse.h:171
static void validate(const TimeFields &tf)
static TableExprNode columnAsTEN_p
Definition: MSTimeParse.h:172
static MSSelectableMainColumn * mainColumn_p
Definition: MSTimeParse.h:173
static Double toTAIInSec(const MEpoch &time)
const TableExprNode * selectTimeLT(const MEpoch &upboundTime, bool daytime=false)
static MeasurementSet * ms_p
Definition: MSTimeParse.h:160
static Bool defaultTimeComputed
Definition: MSTimeParse.h:158
static Matrix< Double > timeList
Definition: MSTimeParse.h:169
static TableExprNode * otherTens_p
private:
Definition: MSTimeParse.h:157
MSTimeParse(const MeasurementSet *ms, const TableExprNode &otherTens, const Bool honourRowFlags=True)
Associate the ms and the shorthand.
void accumulateTimeList(const Double t0, const Double t1, const Double dT=-1)
static const MEpoch * yearTimeConvert(Int year=-1, Int month=-1, Int day=-1, Int hour=-1, Int minute=-1, Int second=-1, Int millisec=-1)
MSTimeParse()
Default constructor.
static const TableExprNode * node()
Get table expression node object.
const TableExprNode * addCondition(TableExprNode &condition)
static void cleanup()
Definition: MSTimeParse.h:152
const TableExprNode * selectTimeRange(const MEpoch &lowboundTime, const MEpoch &upboundTime, bool daytime=false, Float edgeWidth=-1.0)
static TableExprNode * node_p
Definition: MSTimeParse.h:154
static MEpoch * yeartime
Definition: MSTimeParse.h:162
static void reset()
Definition: MSTimeParse.h:151
MSTimeParse(const MeasurementSet *ms, const TableExprNode &colAsTEN, MSSelectableMainColumn &msMainColInterface, const TableExprNode &otherTEN, const Bool honourRowFlags=True)
static void copyDefaults(TimeFields &target, TimeFields &source)
void resize(size_t nx, size_t ny, bool copyValues=false)
String: the storage and methods of handling collections of characters.
Definition: String.h:225
const Double hour
hour
const Double minute
minute
const Double second
Time interval [T]:
this file contains all the compiler specific defines
Definition: mainpage.dox:28
TableExprNode time(const TableExprNode &node)
Definition: ExprNode.h:1580
TableExprNode day(const TableExprNode &node)
Definition: ExprNode.h:1523
TableExprNode month(const TableExprNode &node)
Definition: ExprNode.h:1519
TableExprNode year(const TableExprNode &node)
Definition: ExprNode.h:1515
float Float
Definition: aipstype.h:54
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43
double Double
Definition: aipstype.h:55