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