source: trunk/src/MSFiller.h @ 2289

Last change on this file since 2289 was 2289, checked in by ShinnosukeKawakami, 13 years ago

merged parallel branch to trunk

File size: 7.2 KB
Line 
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// Boost
20#include <boost/pool/object_pool.hpp>
21
22// AIPS++
23#include <casa/aips.h>
24#include <casa/Utilities/CountedPtr.h>
25#include <casa/Arrays/Vector.h>
26#include <casa/Arrays/Matrix.h>
27#include <casa/Arrays/Cube.h>
28#include <casa/Logging/LogIO.h>
29
30#include <casa/Containers/Record.h>
31#include <casa/Containers/Block.h>
32
33#include <ms/MeasurementSets/MeasurementSet.h>
34#include <ms/MeasurementSets/MSPointing.h>
35
36#include "Scantable.h"
37
38namespace asap
39{
40
41class MSFiller
42{
43public:
44  explicit MSFiller(casa::CountedPtr<Scantable> stable) ;
45  virtual ~MSFiller() ;
46 
47  virtual bool open(const std::string& filename, const casa::Record& rec) ;
48  virtual void fill() ;
49  virtual void close() ;
50 
51protected:
52 
53 
54private:
55 
56  MSFiller();
57  MSFiller(const MSFiller&);
58  MSFiller& operator=(const MSFiller&);
59
60  // fill subtables
61  //void fillFrequencies() ;
62  //void fillMolecules() ;
63  void fillWeather() ;
64  void fillFocus() ;
65  //void fillHistory() ;
66  //void fillFit() ;
67  void fillTcal( boost::object_pool<casa::ROTableColumn> *poolr ) ;
68
69  // get SRCTYPE from STATE_ID
70  casa::Int getSrcType( casa::Int stateId, boost::object_pool<casa::ROTableColumn> *pool ) ;
71
72  // get POLNO from CORR_TYPE
73  casa::Block<casa::uInt> getPolNo( casa::Int corrType ) ;
74
75  // get poltype from CORR_TYPE
76  casa::String getPolType( casa::Int corrType ) ;
77
78  // get WEATHER_ID
79  casa::uInt getWeatherId( casa::uInt idx, casa::Double wtime ) ;
80
81  // get time stamp in SYSCAL table
82  // assume that tab is selected by ANTENNA_ID, FEED_ID, SPECTRAL_WINDOW_ID
83  // and sorted by TIME
84  void getSysCalTime( casa::Vector<casa::MEpoch> &scTimeIn, casa::Vector<casa::Double> &scInterval, casa::Block<casa::MEpoch> &tcol, casa::Block<casa::Int> &tidx ) ;
85
86  // get TCAL_ID
87  casa::Block<casa::uInt> getTcalId( casa::Int feedId, casa::Int spwId, casa::MEpoch &t ) ;
88
89  // get direction for DIRECTION, AZIMUTH, and ELEVATION columns
90  casa::uInt getDirection( casa::uInt idx,
91                           casa::Vector<casa::Double> &dir,
92                           casa::Vector<casa::Double> &srate,
93                           casa::String &ref,
94                           casa::Vector<casa::Double> &ptcol,
95                           casa::ROArrayColumn<casa::Double> &pdcol,
96                           casa::Double t ) ;
97  casa::uInt getDirection( casa::uInt idx,
98                           casa::Vector<casa::Double> &dir,
99                           casa::Vector<casa::Double> &azel,
100                           casa::Vector<casa::Double> &srate,
101                           casa::Vector<casa::Double> &ptcol,
102                           casa::ROArrayColumn<casa::Double> &pdcol,
103                           casa::MEpoch &t, casa::MPosition &antpos ) ;
104  void getSourceDirection( casa::Vector<casa::Double> &dir,
105                           casa::Vector<casa::Double> &azel,
106                           casa::Vector<casa::Double> &srate,
107                           casa::MEpoch &t,
108                           casa::MPosition &antpos,
109                           casa::Vector<casa::MDirection> &srcdir ) ;
110
111  // create key for TCAL table
112  casa::String keyTcal( casa::Int feedid, casa::Int spwid, casa::String stime ) ;
113
114  // binary search
115  casa::uInt binarySearch( casa::Vector<casa::MEpoch> &timeList, casa::Double target ) ;
116  casa::uInt binarySearch( casa::Vector<casa::Double> &timeList, casa::Double target ) ;
117
118  // tool for HPC
119//   double gettimeofday_sec() ;
120
121  // get frequency frame
122  std::string getFrame() ;
123
124  // reshape SPECTRA and FLAGTRA
125  void reshapeSpectraAndFlagtra( casa::Cube<casa::Float> &sp,
126                                 casa::Cube<casa::Bool> &fl,
127                                 casa::Table &tab,
128                                 casa::Int &npol,
129                                 casa::Int &nchan,
130                                 casa::Int &nrow,
131                                 casa::Vector<casa::Int> &corrtype ) ;
132
133  // initialize header
134  void initHeader( STHeader &header ) ;
135
136  // get value from table column using object pool
137  casa::String asString( casa::String name,
138                         casa::uInt idx,
139                         casa::Table tab,
140                         boost::object_pool<casa::ROTableColumn> *pool ) ;
141  casa::Bool asBool( casa::String name,
142                     casa::uInt idx,
143                     casa::Table &tab,
144                     boost::object_pool<casa::ROTableColumn> *pool ) ;
145  casa::Int asInt( casa::String name,
146                   casa::uInt idx,
147                   casa::Table &tab,
148                   boost::object_pool<casa::ROTableColumn> *pool ) ;
149  casa::uInt asuInt( casa::String name,
150                     casa::uInt idx,
151                     casa::Table &tab,
152                     boost::object_pool<casa::ROTableColumn> *pool ) ;
153  casa::Float asFloat( casa::String name,
154                       casa::uInt idx,
155                       casa::Table &tab,
156                       boost::object_pool<casa::ROTableColumn> *pool ) ;
157  casa::Double asDouble( casa::String name,
158                         casa::uInt idx,
159                         casa::Table &tab,
160                         boost::object_pool<casa::ROTableColumn> *pool ) ;
161
162  void sourceInfo( casa::Int sourceId,
163                   casa::Int spwId,
164                   casa::String &name,
165                   casa::MDirection &direction,
166                   casa::Vector<casa::Double> &properMotion,
167                   casa::Vector<casa::Double> &restFreqs,
168                   casa::Vector<casa::String> &transitions,
169                   casa::Vector<casa::Double> &sysVels,
170                   boost::object_pool<casa::ROTableColumn> *pool ) ;
171
172  void spectralSetup( casa::Int spwId,
173                      casa::MEpoch &me,
174                      casa::MPosition &mp,
175                      casa::MDirection &md,
176                      casa::Double &refpix,
177                      casa::Double &refval,
178                      casa::Double &increment,
179                      casa::Int &nchan,
180                      casa::String &freqref,
181                      casa::Double &reffreq,
182                      casa::Double &bandwidth,
183                      boost::object_pool<casa::ROTableColumn> *pool ) ;
184
185  casa::CountedPtr<Scantable> table_ ;
186  casa::MeasurementSet mstable_ ;
187  casa::String tablename_ ;
188  casa::Int antenna_ ;
189  casa::String antennaStr_ ;
190  casa::Bool getPt_ ;
191
192  casa::Bool isFloatData_ ;
193  casa::Bool isData_ ;
194
195  casa::Bool isDoppler_ ;
196  casa::Bool isFlagCmd_ ;
197  casa::Bool isFreqOffset_ ;
198  casa::Bool isHistory_ ;
199  casa::Bool isProcessor_ ;
200  casa::Bool isSysCal_ ;
201  casa::Bool isWeather_ ;
202
203  casa::String colTsys_ ;
204  casa::String colTcal_ ;
205
206  casa::LogIO os_ ;
207 
208  casa::Vector<casa::Double> mwTime_ ;
209  casa::Vector<casa::Double> mwInterval_ ;
210  casa::Vector<casa::uInt> mwIndex_ ;
211
212  // Record for TCAL_ID
213  // "FIELD0": "SPW0": Vector<uInt>
214  //           "SPW1": Vector<uInt>
215  //  ...
216  casa::Record tcalrec_ ;
217
218  //casa::ROTableColumn *scCol_ ;
219};
220
221
222};
223#endif
Note: See TracBrowser for help on using the repository browser.