[1974] | 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>
|
---|
[1987] | 18 |
|
---|
[1974] | 19 | // AIPS++
|
---|
| 20 | #include <casa/aips.h>
|
---|
| 21 | #include <casa/Utilities/CountedPtr.h>
|
---|
| 22 | #include <casa/Arrays/Vector.h>
|
---|
[1987] | 23 | #include <casa/Arrays/Matrix.h>
|
---|
[1993] | 24 | #include <casa/Arrays/Cube.h>
|
---|
[1974] | 25 | #include <casa/Logging/LogIO.h>
|
---|
[2291] | 26 | #include <casa/Containers/RecordField.h>
|
---|
[1974] | 27 | #include <casa/Containers/Record.h>
|
---|
[2002] | 28 | #include <casa/Containers/Block.h>
|
---|
[2291] | 29 | #include <casa/Quanta/MVTime.h>
|
---|
[1974] | 30 |
|
---|
| 31 | #include <ms/MeasurementSets/MeasurementSet.h>
|
---|
[1987] | 32 | #include <ms/MeasurementSets/MSPointing.h>
|
---|
[1974] | 33 |
|
---|
[2291] | 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"
|
---|
[1974] | 44 | #include "Scantable.h"
|
---|
[2291] | 45 | #include "MathUtils.h"
|
---|
[1974] | 46 |
|
---|
[2291] | 47 | using namespace casa;
|
---|
| 48 |
|
---|
[1974] | 49 | namespace asap
|
---|
| 50 | {
|
---|
| 51 |
|
---|
[2291] | 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 | };
|
---|
| 136 |
|
---|
[1974] | 137 | class MSFiller
|
---|
| 138 | {
|
---|
| 139 | public:
|
---|
[2291] | 140 | explicit MSFiller(CountedPtr<Scantable> stable) ;
|
---|
[1974] | 141 | virtual ~MSFiller() ;
|
---|
| 142 |
|
---|
[2291] | 143 | virtual bool open(const std::string& filename, const Record& rec) ;
|
---|
[1974] | 144 | virtual void fill() ;
|
---|
| 145 | virtual void close() ;
|
---|
| 146 |
|
---|
| 147 | protected:
|
---|
| 148 |
|
---|
| 149 |
|
---|
| 150 | private:
|
---|
| 151 |
|
---|
| 152 | MSFiller();
|
---|
| 153 | MSFiller(const MSFiller&);
|
---|
| 154 | MSFiller& operator=(const MSFiller&);
|
---|
| 155 |
|
---|
| 156 | // fill subtables
|
---|
| 157 | //void fillFrequencies() ;
|
---|
| 158 | //void fillMolecules() ;
|
---|
| 159 | void fillWeather() ;
|
---|
| 160 | void fillFocus() ;
|
---|
| 161 | //void fillHistory() ;
|
---|
| 162 | //void fillFit() ;
|
---|
[2291] | 163 | void fillTcal() ;
|
---|
[1974] | 164 |
|
---|
[1990] | 165 | // create key for TCAL table
|
---|
[2291] | 166 | String keyTcal( Int feedid, Int spwid, String stime ) ;
|
---|
[2003] | 167 |
|
---|
[2217] | 168 | // get frequency frame
|
---|
| 169 | std::string getFrame() ;
|
---|
[2237] | 170 |
|
---|
| 171 | // initialize header
|
---|
| 172 | void initHeader( STHeader &header ) ;
|
---|
| 173 |
|
---|
[2291] | 174 | CountedPtr<Scantable> table_ ;
|
---|
| 175 | MeasurementSet mstable_ ;
|
---|
| 176 | String tablename_ ;
|
---|
| 177 | Int antenna_ ;
|
---|
| 178 | String antennaStr_ ;
|
---|
| 179 | Bool getPt_ ;
|
---|
[2237] | 180 |
|
---|
[2291] | 181 | Bool isFloatData_ ;
|
---|
| 182 | Bool isData_ ;
|
---|
[2237] | 183 |
|
---|
[2291] | 184 | Bool isDoppler_ ;
|
---|
| 185 | Bool isFlagCmd_ ;
|
---|
| 186 | Bool isFreqOffset_ ;
|
---|
| 187 | Bool isHistory_ ;
|
---|
| 188 | Bool isProcessor_ ;
|
---|
| 189 | Bool isSysCal_ ;
|
---|
| 190 | Bool isWeather_ ;
|
---|
[2237] | 191 |
|
---|
[2291] | 192 | String colTsys_ ;
|
---|
| 193 | String colTcal_ ;
|
---|
[1974] | 194 |
|
---|
[2291] | 195 | LogIO os_ ;
|
---|
[1974] | 196 |
|
---|
[2291] | 197 | Vector<Double> mwTime_ ;
|
---|
| 198 | Vector<Double> mwInterval_ ;
|
---|
| 199 | Vector<uInt> mwIndex_ ;
|
---|
[1974] | 200 |
|
---|
[1987] | 201 | // Record for TCAL_ID
|
---|
| 202 | // "FIELD0": "SPW0": Vector<uInt>
|
---|
| 203 | // "SPW1": Vector<uInt>
|
---|
| 204 | // ...
|
---|
[2291] | 205 | Record tcalrec_ ;
|
---|
| 206 | //map< String,Vector<uInt> > tcalrec_ ;
|
---|
[1974] | 207 | };
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 | };
|
---|
| 211 | #endif
|
---|