| 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 <tables/Tables/TableColumn.h>
 | 
|---|
| 34 | 
 | 
|---|
| 35 | #include <ms/MeasurementSets/MeasurementSet.h>
 | 
|---|
| 36 | #include <ms/MeasurementSets/MSPointing.h>
 | 
|---|
| 37 | 
 | 
|---|
| 38 | #include "Scantable.h"
 | 
|---|
| 39 | 
 | 
|---|
| 40 | namespace asap
 | 
|---|
| 41 | {
 | 
|---|
| 42 | 
 | 
|---|
| 43 | class MSFiller
 | 
|---|
| 44 | {
 | 
|---|
| 45 | public:
 | 
|---|
| 46 |   explicit MSFiller(casa::CountedPtr<Scantable> stable) ;
 | 
|---|
| 47 |   virtual ~MSFiller() ;
 | 
|---|
| 48 |   
 | 
|---|
| 49 |   virtual bool open(const std::string& filename, const casa::Record& rec) ;
 | 
|---|
| 50 |   virtual void fill() ;
 | 
|---|
| 51 |   virtual void close() ;
 | 
|---|
| 52 |   
 | 
|---|
| 53 | protected:
 | 
|---|
| 54 |   
 | 
|---|
| 55 |   
 | 
|---|
| 56 | private:
 | 
|---|
| 57 |   
 | 
|---|
| 58 |   MSFiller();
 | 
|---|
| 59 |   MSFiller(const MSFiller&);
 | 
|---|
| 60 |   MSFiller& operator=(const MSFiller&);
 | 
|---|
| 61 | 
 | 
|---|
| 62 |   // fill subtables
 | 
|---|
| 63 |   //void fillFrequencies() ;
 | 
|---|
| 64 |   //void fillMolecules() ;
 | 
|---|
| 65 |   void fillWeather() ;
 | 
|---|
| 66 |   void fillFocus() ;
 | 
|---|
| 67 |   //void fillHistory() ;
 | 
|---|
| 68 |   //void fillFit() ;
 | 
|---|
| 69 |   void fillTcal( boost::object_pool<casa::ROTableColumn> *poolr ) ;
 | 
|---|
| 70 | 
 | 
|---|
| 71 |   // get SRCTYPE from STATE_ID
 | 
|---|
| 72 |   casa::Int getSrcType( casa::Int stateId, boost::object_pool<casa::ROTableColumn> *pool ) ;
 | 
|---|
| 73 | 
 | 
|---|
| 74 |   // get POLNO from CORR_TYPE
 | 
|---|
| 75 |   casa::Block<casa::uInt> getPolNo( casa::Int corrType ) ;
 | 
|---|
| 76 | 
 | 
|---|
| 77 |   // get poltype from CORR_TYPE 
 | 
|---|
| 78 |   casa::String getPolType( casa::Int corrType ) ;
 | 
|---|
| 79 | 
 | 
|---|
| 80 |   // get WEATHER_ID 
 | 
|---|
| 81 |   casa::uInt getWeatherId( casa::uInt idx, casa::Double wtime ) ;
 | 
|---|
| 82 | 
 | 
|---|
| 83 |   // get time stamp in SYSCAL table
 | 
|---|
| 84 |   // assume that tab is selected by ANTENNA_ID, FEED_ID, SPECTRAL_WINDOW_ID 
 | 
|---|
| 85 |   // and sorted by TIME
 | 
|---|
| 86 |   void getSysCalTime( casa::Vector<casa::MEpoch> &scTimeIn, casa::Vector<casa::Double> &scInterval, casa::Block<casa::MEpoch> &tcol, casa::Block<casa::Int> &tidx ) ;
 | 
|---|
| 87 | 
 | 
|---|
| 88 |   // get TCAL_ID 
 | 
|---|
| 89 |   casa::Block<casa::uInt> getTcalId( casa::Int feedId, casa::Int spwId, casa::MEpoch &t ) ;
 | 
|---|
| 90 | 
 | 
|---|
| 91 |   // get direction for DIRECTION, AZIMUTH, and ELEVATION columns
 | 
|---|
| 92 |   casa::uInt getDirection( casa::uInt idx, casa::Vector<casa::Double> &dir, casa::Vector<casa::Double> &srate, casa::String &ref, casa::MSPointing &tab, casa::Double t ) ;
 | 
|---|
| 93 | 
 | 
|---|
| 94 |   // create key for TCAL table
 | 
|---|
| 95 |   casa::String keyTcal( casa::Int feedid, casa::Int spwid, casa::String stime ) ; 
 | 
|---|
| 96 | 
 | 
|---|
| 97 |   // binary search
 | 
|---|
| 98 |   casa::uInt binarySearch( casa::Vector<casa::MEpoch> &timeList, casa::Double target ) ; 
 | 
|---|
| 99 | 
 | 
|---|
| 100 |   // tool for HPC
 | 
|---|
| 101 |   double gettimeofday_sec() ;
 | 
|---|
| 102 |   
 | 
|---|
| 103 |   casa::CountedPtr<Scantable> table_ ;
 | 
|---|
| 104 |   casa::MeasurementSet mstable_ ;
 | 
|---|
| 105 |   casa::String tablename_ ;
 | 
|---|
| 106 |   casa::Int antenna_ ;
 | 
|---|
| 107 |   casa::String antennaStr_ ;
 | 
|---|
| 108 |   casa::Bool getPt_ ;
 | 
|---|
| 109 | 
 | 
|---|
| 110 |   casa::Bool isFloatData_ ;
 | 
|---|
| 111 |   casa::Bool isData_ ;
 | 
|---|
| 112 | 
 | 
|---|
| 113 |   casa::Bool isDoppler_ ;
 | 
|---|
| 114 |   casa::Bool isFlagCmd_ ;
 | 
|---|
| 115 |   casa::Bool isFreqOffset_ ;
 | 
|---|
| 116 |   casa::Bool isHistory_ ;
 | 
|---|
| 117 |   casa::Bool isProcessor_ ;
 | 
|---|
| 118 |   casa::Bool isSysCal_ ;
 | 
|---|
| 119 |   casa::Bool isWeather_ ;
 | 
|---|
| 120 | 
 | 
|---|
| 121 |   casa::String colTsys_ ;
 | 
|---|
| 122 |   casa::String colTcal_ ;
 | 
|---|
| 123 | 
 | 
|---|
| 124 |   casa::LogIO os_ ;
 | 
|---|
| 125 |   
 | 
|---|
| 126 |   casa::Vector<casa::Double> mwTime_ ;
 | 
|---|
| 127 |   casa::Vector<casa::Double> mwInterval_ ;
 | 
|---|
| 128 | 
 | 
|---|
| 129 |   // Record for TCAL_ID
 | 
|---|
| 130 |   // "FIELD0": "SPW0": Vector<uInt>
 | 
|---|
| 131 |   //           "SPW1": Vector<uInt>
 | 
|---|
| 132 |   //  ...
 | 
|---|
| 133 |   casa::Record tcalrec_ ;
 | 
|---|
| 134 | 
 | 
|---|
| 135 |   //casa::ROTableColumn *scCol_ ;
 | 
|---|
| 136 | };
 | 
|---|
| 137 | 
 | 
|---|
| 138 | 
 | 
|---|
| 139 | };
 | 
|---|
| 140 | #endif
 | 
|---|