| 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> | 
|---|
| 22 | #include <casa/Arrays/Matrix.h> | 
|---|
| 23 | #include <casa/Logging/LogIO.h> | 
|---|
| 24 | #include <casa/Containers/Record.h> | 
|---|
| 25 |  | 
|---|
| 26 | #include <tables/Tables/Table.h> | 
|---|
| 27 | #include <tables/Tables/RefRows.h> | 
|---|
| 28 |  | 
|---|
| 29 | #include <ms/MeasurementSets/MeasurementSet.h> | 
|---|
| 30 | #include <ms/MeasurementSets/MSColumns.h> | 
|---|
| 31 |  | 
|---|
| 32 | #include <measures/Measures/MEpoch.h> | 
|---|
| 33 |  | 
|---|
| 34 | #include <atnf/PKSIO/SrcType.h> | 
|---|
| 35 |  | 
|---|
| 36 | #include "Scantable.h" | 
|---|
| 37 | #include "STHeader.h" | 
|---|
| 38 |  | 
|---|
| 39 | namespace asap | 
|---|
| 40 | { | 
|---|
| 41 |  | 
|---|
| 42 | class MSWriter | 
|---|
| 43 | { | 
|---|
| 44 | public: | 
|---|
| 45 | explicit MSWriter(casa::CountedPtr<Scantable> stable) ; | 
|---|
| 46 | virtual ~MSWriter() ; | 
|---|
| 47 |  | 
|---|
| 48 | virtual bool write(const std::string& filename, const casa::Record& rec) ; | 
|---|
| 49 |  | 
|---|
| 50 | protected: | 
|---|
| 51 |  | 
|---|
| 52 |  | 
|---|
| 53 | private: | 
|---|
| 54 |  | 
|---|
| 55 | // initialize writer from input Scantable | 
|---|
| 56 | void init() ; | 
|---|
| 57 |  | 
|---|
| 58 | // set up MS | 
|---|
| 59 | void setupMS() ; | 
|---|
| 60 |  | 
|---|
| 61 | // fill subtables | 
|---|
| 62 | void fillObservation() ; | 
|---|
| 63 | void fillAntenna() ; | 
|---|
| 64 | void fillProcessor() ; | 
|---|
| 65 | void fillSource() ; | 
|---|
| 66 | void fillWeather() ; | 
|---|
| 67 | void fillSysCal() ; | 
|---|
| 68 |  | 
|---|
| 69 | // add rows to subtables | 
|---|
| 70 | void addFeed( casa::Int id ) ; | 
|---|
| 71 | void addSpectralWindow( casa::Int spwid, casa::Int freqid ) ; | 
|---|
| 72 | void addField( casa::Int fid, casa::String fieldname, casa::String srcname, casa::Double t, casa::Vector<casa::Double> scanrate ) ; | 
|---|
| 73 | void addPointing( casa::String &name, casa::Double &me, casa::Double &interval, casa::Matrix<casa::Double> &dir ) ; | 
|---|
| 74 | casa::Int addPolarization( casa::Vector<casa::Int> polnos ) ; | 
|---|
| 75 | casa::Int addDataDescription( casa::Int polid, casa::Int spwid ) ; | 
|---|
| 76 | casa::Int addState( casa::Int type, casa::Int &subscan ) ; | 
|---|
| 77 |  | 
|---|
| 78 | // utility | 
|---|
| 79 | casa::Vector<casa::Int> toCorrType( casa::Vector<casa::Int> polnos ) ; | 
|---|
| 80 | void getValidTimeRange( casa::Double &me, casa::Double &interval, casa::Table &tab ) ; | 
|---|
| 81 | void getValidTimeRange( casa::Double &me, casa::Double &interval, casa::Vector<casa::Double> &atime, casa::Vector<casa::Double> &ainterval ) ; | 
|---|
| 82 | //void queryType( casa::Int type, casa::String &stype, casa::Bool &b ) ; | 
|---|
| 83 | void queryType( casa::Int type, casa::String &stype, casa::Bool &b, casa::Double &t, Double &l ) ; | 
|---|
| 84 |  | 
|---|
| 85 | // tool for HPC | 
|---|
| 86 | double gettimeofday_sec() ; | 
|---|
| 87 |  | 
|---|
| 88 | casa::CountedPtr<Scantable> table_ ; | 
|---|
| 89 | STHeader header_ ; | 
|---|
| 90 | //casa::CountedPtr<casa::MeasurementSet> mstable_ ; | 
|---|
| 91 | casa::MeasurementSet *mstable_ ; | 
|---|
| 92 |  | 
|---|
| 93 | casa::Bool useFloatData_ ; | 
|---|
| 94 | casa::Bool useData_ ; | 
|---|
| 95 | casa::Bool tcalSpec_ ; | 
|---|
| 96 | casa::Bool tsysSpec_ ; | 
|---|
| 97 |  | 
|---|
| 98 | casa::String ptTabName_ ; | 
|---|
| 99 |  | 
|---|
| 100 | casa::String polType_ ; | 
|---|
| 101 |  | 
|---|
| 102 | casa::String filename_ ; | 
|---|
| 103 |  | 
|---|
| 104 | casa::LogIO os_ ; | 
|---|
| 105 |  | 
|---|
| 106 | casa::Record tcalIdRec_ ; | 
|---|
| 107 | casa::Record tcalRowRec_ ; | 
|---|
| 108 |  | 
|---|
| 109 | MSWriter(); | 
|---|
| 110 | MSWriter(const MSWriter&); | 
|---|
| 111 | MSWriter& operator=(const MSWriter&); | 
|---|
| 112 |  | 
|---|
| 113 | }; | 
|---|
| 114 |  | 
|---|
| 115 |  | 
|---|
| 116 | }; | 
|---|
| 117 | #endif | 
|---|