1 | //
|
---|
2 | // C++ Interface: MSFiller
|
---|
3 | //
|
---|
4 | // Description:
|
---|
5 | //
|
---|
6 | // This class is specific filler for MS format
|
---|
7 | //
|
---|
8 | // Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2010
|
---|
9 | //
|
---|
10 | // Copyright: See COPYING file that comes with this distribution
|
---|
11 | //
|
---|
12 | //
|
---|
13 | #ifndef ASAPMSFILLER_H
|
---|
14 | #define ASAPMSFILLER_H
|
---|
15 |
|
---|
16 | // STL
|
---|
17 | #include <string>
|
---|
18 |
|
---|
19 | // AIPS++
|
---|
20 | #include <casa/aips.h>
|
---|
21 | #include <casa/Utilities/CountedPtr.h>
|
---|
22 | #include <casa/Arrays/Vector.h>
|
---|
23 | #include <casa/Arrays/Matrix.h>
|
---|
24 | #include <casa/Arrays/Cube.h>
|
---|
25 | #include <casa/Logging/LogIO.h>
|
---|
26 | #include <casa/Containers/RecordField.h>
|
---|
27 | #include <casa/Containers/Record.h>
|
---|
28 | #include <casa/Containers/Block.h>
|
---|
29 | #include <casa/Quanta/MVTime.h>
|
---|
30 |
|
---|
31 | #include <ms/MeasurementSets/MeasurementSet.h>
|
---|
32 | #include <ms/MeasurementSets/MSPointing.h>
|
---|
33 |
|
---|
34 | #include <tables/Tables/ScalarColumn.h>
|
---|
35 | #include <tables/Tables/ArrayColumn.h>
|
---|
36 | #include <tables/Tables/TableRow.h>
|
---|
37 |
|
---|
38 | #include <measures/TableMeasures/ScalarMeasColumn.h>
|
---|
39 | #include <measures/TableMeasures/ArrayMeasColumn.h>
|
---|
40 | #include <measures/TableMeasures/ScalarQuantColumn.h>
|
---|
41 | #include <measures/TableMeasures/ArrayQuantColumn.h>
|
---|
42 |
|
---|
43 | #include "TableTraverse.h"
|
---|
44 | #include "Scantable.h"
|
---|
45 | #include "MathUtils.h"
|
---|
46 |
|
---|
47 | using namespace casa;
|
---|
48 |
|
---|
49 | namespace asap
|
---|
50 | {
|
---|
51 |
|
---|
52 | class MSFillerUtils {
|
---|
53 | protected:
|
---|
54 | template<class T> void getScalar( const String &name,
|
---|
55 | const uInt &idx,
|
---|
56 | const Table &tab,
|
---|
57 | T &val )
|
---|
58 | {
|
---|
59 | ROScalarColumn<T> col( tab, name ) ;
|
---|
60 | val = col( idx ) ;
|
---|
61 | }
|
---|
62 | template<class T> void getArray( const String &name,
|
---|
63 | const uInt &idx,
|
---|
64 | const Table &tab,
|
---|
65 | Array<T> &val )
|
---|
66 | {
|
---|
67 | ROArrayColumn<T> col( tab, name ) ;
|
---|
68 | val = col( idx ) ;
|
---|
69 | }
|
---|
70 | template<class T> void getScalarMeas( const String &name,
|
---|
71 | const uInt &idx,
|
---|
72 | const Table &tab,
|
---|
73 | T &val )
|
---|
74 | {
|
---|
75 | ROScalarMeasColumn<T> measCol( tab, name ) ;
|
---|
76 | val = measCol( idx ) ;
|
---|
77 | }
|
---|
78 | template<class T> void getArrayMeas( const String &name,
|
---|
79 | const uInt &idx,
|
---|
80 | const Table &tab,
|
---|
81 | Array<T> &val )
|
---|
82 | {
|
---|
83 | ROArrayMeasColumn<T> measCol( tab, name ) ;
|
---|
84 | val = measCol( idx ) ;
|
---|
85 | }
|
---|
86 | template<class T> void getScalarQuant( const String &name,
|
---|
87 | const uInt &idx,
|
---|
88 | const Table &tab,
|
---|
89 | Quantum<T> &val )
|
---|
90 | {
|
---|
91 | ROScalarQuantColumn<T> quantCol( tab, name ) ;
|
---|
92 | val = quantCol( idx ) ;
|
---|
93 | }
|
---|
94 | template<class T> void getArrayQuant( const String &name,
|
---|
95 | const uInt &idx,
|
---|
96 | const Table &tab,
|
---|
97 | Array< Quantum<T> > &val )
|
---|
98 | {
|
---|
99 | ROArrayQuantColumn<T> quantCol( tab, name ) ;
|
---|
100 | val = quantCol( idx ) ;
|
---|
101 | }
|
---|
102 | template<class T> T interp( Double x0, Double x1, Double x, T y0, T y1 )
|
---|
103 | {
|
---|
104 | Double dx0 = x - x0 ;
|
---|
105 | Double dx1 = x1 - x ;
|
---|
106 | return ( y0 * dx1 + y1 * dx0 ) / ( x1 - x0 ) ;
|
---|
107 | }
|
---|
108 | String keyTcal( const Int &feedid, const Int &spwid, const Double &time )
|
---|
109 | {
|
---|
110 | String stime = MVTime( Quantity(time,Unit("s")) ).string( MVTime::YMD ) ;
|
---|
111 | String sfeed = "FEED" + String::toString( feedid ) ;
|
---|
112 | String sspw = "SPW" + String::toString( spwid ) ;
|
---|
113 | return sfeed+":"+sspw+":"+stime ;
|
---|
114 | }
|
---|
115 | String keyTcal( const Int &feedid, const Int &spwid, const String &stime )
|
---|
116 | {
|
---|
117 | String sfeed = "FEED" + String::toString( feedid ) ;
|
---|
118 | String sspw = "SPW" + String::toString( spwid ) ;
|
---|
119 | return sfeed+":"+sspw+":"+stime ;
|
---|
120 | }
|
---|
121 | };
|
---|
122 |
|
---|
123 | class MSFiller : public MSFillerUtils
|
---|
124 | {
|
---|
125 | public:
|
---|
126 | explicit MSFiller(CountedPtr<Scantable> stable) ;
|
---|
127 | virtual ~MSFiller() ;
|
---|
128 |
|
---|
129 | virtual bool open(const std::string& filename, const Record& rec) ;
|
---|
130 | virtual void fill() ;
|
---|
131 | virtual void close() ;
|
---|
132 |
|
---|
133 | protected:
|
---|
134 |
|
---|
135 |
|
---|
136 | private:
|
---|
137 |
|
---|
138 | MSFiller();
|
---|
139 | MSFiller(const MSFiller&);
|
---|
140 | MSFiller& operator=(const MSFiller&);
|
---|
141 |
|
---|
142 | // fill subtables
|
---|
143 | //void fillFrequencies() ;
|
---|
144 | //void fillMolecules() ;
|
---|
145 | void fillWeather() ;
|
---|
146 | void fillFocus() ;
|
---|
147 | //void fillHistory() ;
|
---|
148 | //void fillFit() ;
|
---|
149 | void fillTcal() ;
|
---|
150 | void infillTcal() ;
|
---|
151 |
|
---|
152 | // get frequency frame
|
---|
153 | std::string getFrame() ;
|
---|
154 |
|
---|
155 | // initialize header
|
---|
156 | void initHeader( STHeader &header ) ;
|
---|
157 |
|
---|
158 | // get base frame from SPECTRAL_WINDOW table
|
---|
159 | std::string frameFromSpwTable();
|
---|
160 |
|
---|
161 | CountedPtr<Scantable> table_ ;
|
---|
162 | MeasurementSet mstable_ ;
|
---|
163 | String tablename_ ;
|
---|
164 | Int antenna_ ;
|
---|
165 | String antennaStr_ ;
|
---|
166 | Bool getPt_ ;
|
---|
167 | Bool freqToLsr_ ;
|
---|
168 |
|
---|
169 | Bool isFloatData_ ;
|
---|
170 | Bool isData_ ;
|
---|
171 |
|
---|
172 | Bool isDoppler_ ;
|
---|
173 | Bool isFlagCmd_ ;
|
---|
174 | Bool isFreqOffset_ ;
|
---|
175 | Bool isHistory_ ;
|
---|
176 | Bool isProcessor_ ;
|
---|
177 | Bool isSysCal_ ;
|
---|
178 | Bool isWeather_ ;
|
---|
179 |
|
---|
180 | String colTsys_ ;
|
---|
181 | String colTcal_ ;
|
---|
182 |
|
---|
183 | LogIO os_ ;
|
---|
184 |
|
---|
185 | Vector<Double> mwTime_ ;
|
---|
186 | Vector<Double> mwInterval_ ;
|
---|
187 | Vector<uInt> mwIndex_ ;
|
---|
188 |
|
---|
189 | // Record for TCAL_ID
|
---|
190 | // "FIELD0": "SPW0": Vector<uInt>
|
---|
191 | // "SPW1": Vector<uInt>
|
---|
192 | // ...
|
---|
193 | Record tcalrec_ ;
|
---|
194 | //map< String,Vector<uInt> > tcalrec_ ;
|
---|
195 | };
|
---|
196 |
|
---|
197 |
|
---|
198 | };
|
---|
199 | #endif
|
---|