[1791] | 1 | // |
---|
| 2 | // C++ Interface: NROFiller |
---|
| 3 | // |
---|
| 4 | // Description: |
---|
| 5 | // This class is a concrete class that derives from FillerBase class. |
---|
| 6 | // The class implements the following methods to be able to read NRO |
---|
| 7 | // data (45m and ASTE). |
---|
| 8 | // |
---|
| 9 | // open() |
---|
| 10 | // close() |
---|
| 11 | // fill() |
---|
| 12 | // |
---|
| 13 | // |
---|
| 14 | // Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2010 |
---|
| 15 | // |
---|
| 16 | // Copyright: See COPYING file that comes with this distribution |
---|
| 17 | // |
---|
| 18 | // |
---|
| 19 | |
---|
[1792] | 20 | #include "NROFiller.h" |
---|
[1791] | 21 | #include "STHeader.h" |
---|
[1904] | 22 | #include <casa/Containers/Record.h> |
---|
[2019] | 23 | #include <casa/Quanta/MVTime.h> |
---|
[1791] | 24 | #include <atnf/PKSIO/SrcType.h> |
---|
| 25 | |
---|
| 26 | using namespace casa; |
---|
| 27 | |
---|
| 28 | namespace asap |
---|
| 29 | { |
---|
| 30 | NROFiller::NROFiller(CountedPtr<Scantable> stable) |
---|
| 31 | : FillerBase(stable) |
---|
| 32 | { |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | NROFiller::~NROFiller() |
---|
| 36 | { |
---|
| 37 | close() ; |
---|
| 38 | } |
---|
| 39 | |
---|
[1904] | 40 | bool NROFiller::open(const std::string& filename, const Record& rec) |
---|
[1791] | 41 | { |
---|
| 42 | bool status = true ; |
---|
| 43 | |
---|
| 44 | // get appropriate reader object |
---|
| 45 | String format ; |
---|
[1817] | 46 | reader_ = getNROReader( filename, format ) ; |
---|
| 47 | if ( reader_.null() == True ) { |
---|
[1791] | 48 | status = false ; |
---|
| 49 | return status ; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | // get header information |
---|
[1792] | 53 | STHeader hdr ; |
---|
| 54 | if ( reader_->getHeaderInfo( hdr.nchan, |
---|
| 55 | hdr.npol, |
---|
| 56 | hdr.nif, |
---|
| 57 | hdr.nbeam, |
---|
| 58 | hdr.observer, |
---|
| 59 | hdr.project, |
---|
| 60 | hdr.obstype, |
---|
| 61 | hdr.antennaname, |
---|
| 62 | hdr.antennaposition, |
---|
| 63 | hdr.equinox, |
---|
| 64 | hdr.freqref, |
---|
| 65 | hdr.reffreq, |
---|
| 66 | hdr.bandwidth, |
---|
| 67 | hdr.utc, |
---|
| 68 | hdr.fluxunit, |
---|
| 69 | hdr.epoch, |
---|
| 70 | hdr.poltype ) ) { |
---|
[1791] | 71 | status = false ; |
---|
| 72 | return status ; |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | // 2010/07/30 TBD: Do we need to set frame here? |
---|
[1799] | 76 | table_->frequencies().setFrame( hdr.freqref, true ) ; |
---|
[2262] | 77 | table_->frequencies().setFrame( hdr.freqref, false ) ; |
---|
[1791] | 78 | |
---|
| 79 | // set Header |
---|
[1792] | 80 | setHeader( hdr ) ; |
---|
[1791] | 81 | |
---|
| 82 | return status ; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | void NROFiller::fill() |
---|
| 86 | { |
---|
| 87 | // for each row |
---|
| 88 | uInt nRow = reader_->getRowNum() ; |
---|
| 89 | vector< vector<double > > freqs ; |
---|
| 90 | uInt scanno ; |
---|
| 91 | uInt cycleno ; |
---|
[2262] | 92 | uInt ifno ; |
---|
[1791] | 93 | uInt beamno ; |
---|
| 94 | uInt polno ; |
---|
| 95 | vector<double> fqs ; |
---|
| 96 | Vector<Double> restfreq ; |
---|
| 97 | uInt refbeamno ; |
---|
| 98 | Double scantime ; |
---|
| 99 | Double interval ; |
---|
| 100 | String srcname ; |
---|
| 101 | String fieldname ; |
---|
[2263] | 102 | Vector<Float> spectra ; |
---|
| 103 | Vector<uChar> flagtra ; |
---|
| 104 | Vector<Float> tsys ; |
---|
| 105 | Vector<Double> direction ; |
---|
[1791] | 106 | Float azimuth ; |
---|
| 107 | Float elevation ; |
---|
[2263] | 108 | Float parangle = 0.0 ; |
---|
[1791] | 109 | Float opacity ; |
---|
| 110 | uInt tcalid ; |
---|
| 111 | Int fitid ; |
---|
| 112 | uInt focusid ; |
---|
| 113 | Float temperature ; |
---|
| 114 | Float pressure ; |
---|
| 115 | Float humidity ; |
---|
| 116 | Float windvel ; |
---|
| 117 | Float winddir ; |
---|
| 118 | Double srcvel ; |
---|
[2263] | 119 | Vector<Double> propermotion( 2, 0.0 ) ; |
---|
[1791] | 120 | Vector<Double> srcdir ; |
---|
[2263] | 121 | Vector<Double> scanrate( 2, 0.0 ) ; |
---|
[1791] | 122 | Int rowCount = 0 ; |
---|
| 123 | |
---|
[1799] | 124 | STHeader header = table_->getHeader() ; |
---|
[1791] | 125 | String obsType = header.obstype.substr( 0, 3 ) ; |
---|
[2019] | 126 | Vector<Float> defaultTcal( 1, 1.0 ) ; |
---|
| 127 | String tcalTime = MVTime( header.utc ).string( MVTime::YMD ) ; |
---|
[2263] | 128 | |
---|
| 129 | // TCAL subtable rows |
---|
| 130 | setTcal( tcalTime, defaultTcal ) ; |
---|
| 131 | |
---|
| 132 | // FOCUS subtable rows |
---|
| 133 | setFocus( parangle ) ; |
---|
| 134 | |
---|
[1791] | 135 | for ( Int irow = 0 ; irow < (Int)nRow ; irow++ ) { |
---|
| 136 | // check scan intent |
---|
[1812] | 137 | string scanType = reader_->getScanType( irow ) ; |
---|
[1791] | 138 | SrcType::type srcType = SrcType::NOTYPE ; |
---|
| 139 | |
---|
| 140 | // skip "ZERO" scan |
---|
| 141 | if ( scanType.compare( 0, 4, "ZERO" ) == 0 ) { |
---|
| 142 | continue ; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | // set srcType |
---|
| 146 | if ( obsType == "POS" || obsType == "BEA" ) { |
---|
| 147 | if ( scanType.compare( 0, 2, "ON" ) == 0 ) |
---|
| 148 | srcType = SrcType::PSON ; |
---|
| 149 | else if ( scanType.compare( 0, 3, "OFF" ) == 0 ) |
---|
| 150 | srcType = SrcType::PSOFF ; |
---|
| 151 | } |
---|
| 152 | else if ( obsType == "FRE" ) { |
---|
| 153 | if ( scanType.compare( 0, 2, "ON" ) == 0 ) |
---|
| 154 | srcType = SrcType::FSON ; |
---|
| 155 | else if ( scanType.compare( 0, 3, "OFF" ) == 0 ) |
---|
| 156 | srcType = SrcType::FSOFF ; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | // get scan ifnromation |
---|
[1792] | 160 | if ( reader_->getScanInfo( irow, |
---|
[1791] | 161 | scanno, |
---|
| 162 | cycleno, |
---|
[2262] | 163 | ifno, |
---|
[1791] | 164 | beamno, |
---|
| 165 | polno, |
---|
| 166 | fqs, |
---|
| 167 | restfreq, |
---|
| 168 | refbeamno, |
---|
| 169 | scantime, |
---|
| 170 | interval, |
---|
| 171 | srcname, |
---|
| 172 | fieldname, |
---|
| 173 | spectra, |
---|
| 174 | flagtra, |
---|
| 175 | tsys, |
---|
| 176 | direction, |
---|
| 177 | azimuth, |
---|
| 178 | elevation, |
---|
| 179 | parangle, |
---|
| 180 | opacity, |
---|
| 181 | tcalid, |
---|
| 182 | fitid, |
---|
| 183 | focusid, |
---|
| 184 | temperature, |
---|
| 185 | pressure, |
---|
| 186 | humidity, |
---|
| 187 | windvel, |
---|
| 188 | winddir, |
---|
| 189 | srcvel, |
---|
| 190 | propermotion, |
---|
| 191 | srcdir, |
---|
| 192 | scanrate ) ) { |
---|
[1792] | 193 | throw AipsError( "Failed to read scan record" ) ; |
---|
[1791] | 194 | return ; |
---|
| 195 | } |
---|
| 196 | |
---|
[1792] | 197 | // set IDs and subtable rows |
---|
| 198 | // FREQUENCIES subtable row |
---|
| 199 | setFrequency( (Double)fqs[0], (Double)fqs[1], (Double)fqs[2] ) ; |
---|
| 200 | |
---|
| 201 | // MOLECULES subtable row |
---|
| 202 | setMolecule( restfreq ) ; |
---|
| 203 | |
---|
| 204 | // WEATHER subtable row |
---|
[2263] | 205 | setWeather2( temperature, pressure, humidity, windvel, winddir ) ; |
---|
[1792] | 206 | |
---|
[1791] | 207 | // set row attributes |
---|
| 208 | // SPECTRA, FLAGTRA, and TSYS |
---|
[2263] | 209 | setSpectrum( spectra, flagtra, tsys ) ; |
---|
[1791] | 210 | |
---|
| 211 | // SCANNO, CYCLENO, IFNO, POLNO, and BEAMNO |
---|
| 212 | setIndex( scanno, cycleno, ifno, polno, beamno ) ; |
---|
| 213 | |
---|
| 214 | // REFBEAMNO |
---|
| 215 | setReferenceBeam( (Int)refbeamno ) ; |
---|
| 216 | |
---|
| 217 | // DIRECTION |
---|
[2263] | 218 | setDirection( direction, azimuth, elevation ) ; |
---|
[1791] | 219 | |
---|
| 220 | // TIME and INTERVAL |
---|
| 221 | setTime( scantime, interval ) ; |
---|
| 222 | |
---|
| 223 | // SRCNAME, SRCTYPE, FIELDNAME, SRCDIRECTION, SRCPROPERMOTION, and SRCVELOCITY |
---|
[2263] | 224 | setSource( srcname, srcType, fieldname, srcdir, propermotion, srcvel ) ; |
---|
[1791] | 225 | |
---|
| 226 | // SCANRATE |
---|
[2263] | 227 | setScanRate( scanrate ) ; |
---|
[1791] | 228 | |
---|
| 229 | // OPACITY |
---|
| 230 | setOpacity( opacity ) ; |
---|
| 231 | |
---|
| 232 | // finally, commit row |
---|
| 233 | commitRow() ; |
---|
| 234 | |
---|
| 235 | // count up number of row committed |
---|
| 236 | rowCount++ ; |
---|
| 237 | } |
---|
| 238 | } |
---|
| 239 | |
---|
| 240 | void NROFiller::close() |
---|
| 241 | { |
---|
[1817] | 242 | if (reader_.null() != False) { |
---|
| 243 | reader_ = 0; |
---|
| 244 | } |
---|
| 245 | table_ = 0; |
---|
[1791] | 246 | } |
---|
| 247 | |
---|
| 248 | }; |
---|
| 249 | |
---|