Changeset 2291 for trunk/src/MSFiller.h
- Timestamp:
- 09/12/11 12:07:41 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/MSFiller.h
r2289 r2291 16 16 // STL 17 17 #include <string> 18 19 // Boost20 #include <boost/pool/object_pool.hpp>21 18 22 19 // AIPS++ … … 27 24 #include <casa/Arrays/Cube.h> 28 25 #include <casa/Logging/LogIO.h> 29 26 #include <casa/Containers/RecordField.h> 30 27 #include <casa/Containers/Record.h> 31 28 #include <casa/Containers/Block.h> 29 #include <casa/Quanta/MVTime.h> 32 30 33 31 #include <ms/MeasurementSets/MeasurementSet.h> 34 32 #include <ms/MeasurementSets/MSPointing.h> 35 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" 36 44 #include "Scantable.h" 45 #include "MathUtils.h" 46 47 using namespace casa; 37 48 38 49 namespace asap 39 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> void putField( const String &name, 103 // TableRecord &rec, 104 // T &val ) 105 // { 106 // RecordFieldPtr<T> rf( rec, name ) ; 107 // *rf = val ; 108 // } 109 // template<class T> void defineField( const String &name, 110 // TableRecord &rec, 111 // T &val ) 112 // { 113 // RecordFieldPtr<T> rf( rec, name ) ; 114 // rf.define( val ) ; 115 // } 116 template<class T> T interp( Double x0, Double x1, Double x, T y0, T y1 ) 117 { 118 Double dx0 = x - x0 ; 119 Double dx1 = x1 - x ; 120 return ( y0 * dx1 + y1 * dx0 ) / ( x1 - x0 ) ; 121 } 122 String keyTcal( const Int &feedid, const Int &spwid, const Double &time ) 123 { 124 String stime = MVTime( Quantity(time,Unit("s")) ).string( MVTime::YMD ) ; 125 String sfeed = "FEED" + String::toString( feedid ) ; 126 String sspw = "SPW" + String::toString( spwid ) ; 127 return sfeed+":"+sspw+":"+stime ; 128 } 129 String keyTcal( const Int &feedid, const Int &spwid, const String &stime ) 130 { 131 String sfeed = "FEED" + String::toString( feedid ) ; 132 String sspw = "SPW" + String::toString( spwid ) ; 133 return sfeed+":"+sspw+":"+stime ; 134 } 135 }; 40 136 41 137 class MSFiller 42 138 { 43 139 public: 44 explicit MSFiller( casa::CountedPtr<Scantable> stable) ;140 explicit MSFiller(CountedPtr<Scantable> stable) ; 45 141 virtual ~MSFiller() ; 46 142 47 virtual bool open(const std::string& filename, const casa::Record& rec) ;143 virtual bool open(const std::string& filename, const Record& rec) ; 48 144 virtual void fill() ; 49 145 virtual void close() ; … … 65 161 //void fillHistory() ; 66 162 //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 ) ; 163 void fillTcal() ; 110 164 111 165 // 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() ; 166 String keyTcal( Int feedid, Int spwid, String stime ) ; 120 167 121 168 // get frequency frame 122 169 std::string getFrame() ; 123 170 124 // reshape SPECTRA and FLAGTRA125 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 171 // initialize header 134 172 void initHeader( STHeader &header ) ; 135 173 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_ ; 174 CountedPtr<Scantable> table_ ; 175 MeasurementSet mstable_ ; 176 String tablename_ ; 177 Int antenna_ ; 178 String antennaStr_ ; 179 Bool getPt_ ; 180 181 Bool isFloatData_ ; 182 Bool isData_ ; 183 184 Bool isDoppler_ ; 185 Bool isFlagCmd_ ; 186 Bool isFreqOffset_ ; 187 Bool isHistory_ ; 188 Bool isProcessor_ ; 189 Bool isSysCal_ ; 190 Bool isWeather_ ; 191 192 String colTsys_ ; 193 String colTcal_ ; 194 195 LogIO os_ ; 196 197 Vector<Double> mwTime_ ; 198 Vector<Double> mwInterval_ ; 199 Vector<uInt> mwIndex_ ; 211 200 212 201 // Record for TCAL_ID … … 214 203 // "SPW1": Vector<uInt> 215 204 // ... 216 casa::Record tcalrec_ ; 217 218 //casa::ROTableColumn *scCol_ ; 205 Record tcalrec_ ; 206 //map< String,Vector<uInt> > tcalrec_ ; 219 207 }; 220 208
Note: See TracChangeset
for help on using the changeset viewer.