[1974] | 1 | //
|
---|
| 2 | // C++ Interface: MSWriter
|
---|
| 3 | //
|
---|
| 4 | // Description:
|
---|
| 5 | //
|
---|
| 6 | // This class is specific writer 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 ASAPMSWRITER_H
|
---|
| 14 | #define ASAPMSWRITER_H
|
---|
| 15 |
|
---|
| 16 | // STL
|
---|
| 17 | #include <string>
|
---|
| 18 | // AIPS++
|
---|
| 19 | #include <casa/aips.h>
|
---|
| 20 | #include <casa/Utilities/CountedPtr.h>
|
---|
| 21 | #include <casa/Arrays/Vector.h>
|
---|
[1977] | 22 | #include <casa/Arrays/Matrix.h>
|
---|
[1974] | 23 | #include <casa/Logging/LogIO.h>
|
---|
[1977] | 24 | #include <casa/Containers/Record.h>
|
---|
[2291] | 25 | #include <casa/Containers/RecordField.h>
|
---|
[1974] | 26 |
|
---|
[1975] | 27 | #include <tables/Tables/Table.h>
|
---|
[1974] | 28 | #include <tables/Tables/RefRows.h>
|
---|
| 29 |
|
---|
| 30 | #include <ms/MeasurementSets/MeasurementSet.h>
|
---|
| 31 | #include <ms/MeasurementSets/MSColumns.h>
|
---|
| 32 |
|
---|
[1975] | 33 | #include <measures/Measures/MEpoch.h>
|
---|
| 34 |
|
---|
[1977] | 35 | #include <atnf/PKSIO/SrcType.h>
|
---|
| 36 |
|
---|
[1974] | 37 | #include "Scantable.h"
|
---|
| 38 | #include "STHeader.h"
|
---|
| 39 |
|
---|
| 40 | namespace asap
|
---|
| 41 | {
|
---|
[2291] | 42 | class MSWriterUtils
|
---|
| 43 | {
|
---|
| 44 | protected:
|
---|
| 45 | template<class T> void putField( const String &name,
|
---|
| 46 | TableRecord &r,
|
---|
| 47 | T &val )
|
---|
| 48 | {
|
---|
| 49 | RecordFieldPtr<T> rf( r, name ) ;
|
---|
| 50 | *rf = val ;
|
---|
| 51 | }
|
---|
| 52 | template<class T> void defineField( const String &name,
|
---|
| 53 | TableRecord &r,
|
---|
| 54 | T &val )
|
---|
| 55 | {
|
---|
| 56 | RecordFieldPtr<T> rf( r, name ) ;
|
---|
| 57 | rf.define( val ) ;
|
---|
| 58 | }
|
---|
| 59 | };
|
---|
[1974] | 60 |
|
---|
| 61 | class MSWriter
|
---|
| 62 | {
|
---|
| 63 | public:
|
---|
| 64 | explicit MSWriter(casa::CountedPtr<Scantable> stable) ;
|
---|
| 65 | virtual ~MSWriter() ;
|
---|
| 66 |
|
---|
| 67 | virtual bool write(const std::string& filename, const casa::Record& rec) ;
|
---|
| 68 |
|
---|
| 69 | protected:
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | private:
|
---|
| 73 |
|
---|
| 74 | // initialize writer from input Scantable
|
---|
| 75 | void init() ;
|
---|
| 76 |
|
---|
| 77 | // set up MS
|
---|
| 78 | void setupMS() ;
|
---|
| 79 |
|
---|
| 80 | // fill subtables
|
---|
| 81 | void fillObservation() ;
|
---|
| 82 | void fillAntenna() ;
|
---|
[1975] | 83 | void fillProcessor() ;
|
---|
| 84 | void fillSource() ;
|
---|
[1977] | 85 | void fillWeather() ;
|
---|
[2291] | 86 | void fillSysCal( std::map< casa::Int,casa::Vector<casa::uInt> > &idrec,
|
---|
| 87 | std::map< casa::Int,casa::Vector<casa::uInt> > &rowrec ) ;
|
---|
| 88 | // void fillSysCal( Record &idrec, Record &rowrec ) ;
|
---|
| 89 | // void fillSysCal() ;
|
---|
[1975] | 90 |
|
---|
[2104] | 91 | // fill empty rows
|
---|
| 92 | void infillSpectralWindow() ;
|
---|
| 93 |
|
---|
[1975] | 94 | // add rows to subtables
|
---|
[1974] | 95 | void addFeed( casa::Int id ) ;
|
---|
| 96 | void addSpectralWindow( casa::Int spwid, casa::Int freqid ) ;
|
---|
[1975] | 97 | void addField( casa::Int fid, casa::String fieldname, casa::String srcname, casa::Double t, casa::Vector<casa::Double> scanrate ) ;
|
---|
[2016] | 98 | void addPointing( casa::String &name, casa::Double &me, casa::Double &interval, casa::Matrix<casa::Double> &dir ) ;
|
---|
[1974] | 99 | casa::Int addPolarization( casa::Vector<casa::Int> polnos ) ;
|
---|
| 100 | casa::Int addDataDescription( casa::Int polid, casa::Int spwid ) ;
|
---|
[1977] | 101 | casa::Int addState( casa::Int type, casa::Int &subscan ) ;
|
---|
[1974] | 102 |
|
---|
| 103 | // utility
|
---|
| 104 | casa::Vector<casa::Int> toCorrType( casa::Vector<casa::Int> polnos ) ;
|
---|
[2016] | 105 | void getValidTimeRange( casa::Double &me, casa::Double &interval, casa::Table &tab ) ;
|
---|
[2018] | 106 | void getValidTimeRange( casa::Double &me, casa::Double &interval, casa::Vector<casa::Double> &atime, casa::Vector<casa::Double> &ainterval ) ;
|
---|
[2016] | 107 | //void queryType( casa::Int type, casa::String &stype, casa::Bool &b ) ;
|
---|
| 108 | void queryType( casa::Int type, casa::String &stype, casa::Bool &b, casa::Double &t, Double &l ) ;
|
---|
[2026] | 109 | casa::Double getDishDiameter( casa::String antname ) ;
|
---|
[2291] | 110 | void antennaProperty( casa::String &name, casa::String &mount, casa::String &type, casa::Double &diameter ) ;
|
---|
[1974] | 111 |
|
---|
[2016] | 112 | // tool for HPC
|
---|
[2258] | 113 | // double gettimeofday_sec() ;
|
---|
[2016] | 114 |
|
---|
[1974] | 115 | casa::CountedPtr<Scantable> table_ ;
|
---|
| 116 | STHeader header_ ;
|
---|
[2016] | 117 | //casa::CountedPtr<casa::MeasurementSet> mstable_ ;
|
---|
| 118 | casa::MeasurementSet *mstable_ ;
|
---|
[1974] | 119 |
|
---|
[2019] | 120 | casa::Bool isTcal_ ;
|
---|
| 121 | casa::Bool isWeather_ ;
|
---|
| 122 |
|
---|
[1977] | 123 | casa::Bool useFloatData_ ;
|
---|
| 124 | casa::Bool useData_ ;
|
---|
| 125 | casa::Bool tcalSpec_ ;
|
---|
| 126 | casa::Bool tsysSpec_ ;
|
---|
| 127 |
|
---|
[2016] | 128 | casa::String ptTabName_ ;
|
---|
| 129 |
|
---|
[1974] | 130 | casa::String polType_ ;
|
---|
| 131 |
|
---|
| 132 | casa::String filename_ ;
|
---|
| 133 |
|
---|
| 134 | casa::LogIO os_ ;
|
---|
[1977] | 135 |
|
---|
[2291] | 136 | // casa::Record tcalIdRec_ ;
|
---|
| 137 | // casa::Record tcalRowRec_ ;
|
---|
| 138 | casa::Record srcRec_ ;
|
---|
[1974] | 139 |
|
---|
| 140 | MSWriter();
|
---|
| 141 | MSWriter(const MSWriter&);
|
---|
| 142 | MSWriter& operator=(const MSWriter&);
|
---|
| 143 |
|
---|
| 144 | };
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | };
|
---|
| 148 | #endif
|
---|