[1757] | 1 | //#---------------------------------------------------------------------------
|
---|
| 2 | //# NROReader.cc: Base class for NRO headerdata.
|
---|
| 3 | //#---------------------------------------------------------------------------
|
---|
| 4 | //# Copyright (C) 2000-2006
|
---|
| 5 | //# Associated Universities, Inc. Washington DC, USA.
|
---|
| 6 | //#
|
---|
| 7 | //# This library is free software; you can redistribute it and/or modify it
|
---|
| 8 | //# under the terms of the GNU Library General Public License as published by
|
---|
| 9 | //# the Free Software Foundation; either version 2 of the License, or (at your
|
---|
| 10 | //# option) any later version.
|
---|
| 11 | //#
|
---|
| 12 | //# This library is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 13 | //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
| 14 | //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
|
---|
| 15 | //# License for more details.
|
---|
| 16 | //#
|
---|
| 17 | //# You should have received a copy of the GNU Library General Public License
|
---|
| 18 | //# along with this library; if not, write to the Free Software Foundation,
|
---|
| 19 | //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
|
---|
| 20 | //#
|
---|
| 21 | //# Correspondence concerning AIPS++ should be addressed as follows:
|
---|
| 22 | //# Internet email: aips2-request@nrao.edu.
|
---|
| 23 | //# Postal address: AIPS++ Project Office
|
---|
| 24 | //# National Radio Astronomy Observatory
|
---|
| 25 | //# 520 Edgemont Road
|
---|
| 26 | //# Charlottesville, VA 22903-2475 USA
|
---|
| 27 | //#
|
---|
| 28 | //# $Id$
|
---|
| 29 | //#---------------------------------------------------------------------------
|
---|
| 30 | //# Original: 2008/10/30, Takeshi Nakazato, NAOJ
|
---|
| 31 | //#---------------------------------------------------------------------------
|
---|
| 32 |
|
---|
| 33 | #include <atnf/PKSIO/NROReader.h>
|
---|
| 34 | #include <atnf/PKSIO/NRO45Reader.h>
|
---|
| 35 | #include <atnf/PKSIO/ASTEReader.h>
|
---|
| 36 | #include <atnf/PKSIO/ASTEFXReader.h>
|
---|
| 37 | #include <atnf/PKSIO/NRO45FITSReader.h>
|
---|
| 38 | #include <atnf/PKSIO/NROOTFDataset.h>
|
---|
| 39 | #include <atnf/PKSIO/ASTEDataset.h>
|
---|
| 40 |
|
---|
| 41 | #include <measures/Measures/MDirection.h>
|
---|
| 42 | #include <measures/Measures/MCDirection.h>
|
---|
| 43 | #include <measures/Measures/MeasConvert.h>
|
---|
| 44 |
|
---|
| 45 | #include <casa/IO/RegularFileIO.h>
|
---|
| 46 | #include <casa/OS/File.h>
|
---|
| 47 | #include <casa/OS/Time.h>
|
---|
| 48 |
|
---|
| 49 | #include <stdio.h>
|
---|
| 50 | #include <string>
|
---|
| 51 | #include <iomanip>
|
---|
| 52 |
|
---|
| 53 | using namespace std ;
|
---|
| 54 |
|
---|
| 55 | //
|
---|
| 56 | // getNROReader
|
---|
| 57 | //
|
---|
| 58 | // Return an appropriate NROReader for a NRO 45m and ASTE dataset.
|
---|
| 59 | //
|
---|
| 60 | NROReader *getNROReader( const String filename,
|
---|
| 61 | String &datatype )
|
---|
| 62 | {
|
---|
| 63 | LogIO os( LogOrigin( "", "getNROReader()", WHERE ) ) ;
|
---|
| 64 |
|
---|
| 65 | // Check accessibility of the input.
|
---|
| 66 | File inFile( filename ) ;
|
---|
| 67 | if ( !inFile.exists() ) {
|
---|
| 68 | datatype = filename + " not found." ;
|
---|
| 69 | return 0 ;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | if ( !inFile.isReadable() ) {
|
---|
| 73 | datatype = filename + " is not readable." ;
|
---|
| 74 | return 0 ;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | // Determine the type of input.
|
---|
| 78 | NROReader *reader = 0;
|
---|
| 79 | if ( inFile.isRegular() ) {
|
---|
| 80 | FILE *file ;
|
---|
| 81 | file = fopen( filename.c_str(), "r" ) ;
|
---|
| 82 | // read LOFIL0
|
---|
| 83 | char buf[9];
|
---|
| 84 | fread( buf, 4, 1, file ) ;
|
---|
| 85 | buf[4] = '\0' ;
|
---|
| 86 | // DEBUG
|
---|
| 87 | //os << LogIO::NORMAL << "getNROReader:: buf = " << String(buf) << LogIO::POST ;
|
---|
| 88 | //
|
---|
| 89 | if ( string( buf ) == "XTEN" ) {
|
---|
| 90 | // FITS data
|
---|
| 91 | datatype = "NRO 45m FITS" ;
|
---|
| 92 | reader = new NRO45FITSReader( filename ) ;
|
---|
| 93 | }
|
---|
| 94 | else if ( string( buf ) == "RW-F") {
|
---|
| 95 | // ASTE-FX data
|
---|
| 96 | datatype = "ASTE-FX";
|
---|
| 97 | reader = new ASTEFXReader( filename );
|
---|
| 98 | } else {
|
---|
| 99 | // otherwise, read SITE0
|
---|
| 100 | NRODataset *d = new NROOTFDataset( filename ) ;
|
---|
| 101 | int size = d->getDataSize() - 188 ;
|
---|
| 102 | delete d ;
|
---|
| 103 | fseek( file, size, SEEK_SET ) ;
|
---|
| 104 | fread( buf, 8, 1, file ) ;
|
---|
| 105 | buf[8] = '\0' ;
|
---|
| 106 | // DEBUG
|
---|
| 107 | //cout << "getNROReader:: buf = " << buf << endl ;
|
---|
| 108 | //
|
---|
| 109 | if ( string( buf ) == "NRO" ) {
|
---|
| 110 | // NRO 45m data
|
---|
| 111 | datatype = "NRO 45m OTF" ;
|
---|
| 112 | reader = new NRO45Reader( filename );
|
---|
| 113 | }
|
---|
| 114 | else {
|
---|
| 115 | d = new ASTEDataset( filename ) ;
|
---|
| 116 | size = d->getDataSize() - 188 ;
|
---|
| 117 | delete d ;
|
---|
| 118 | fseek( file, size, SEEK_SET ) ;
|
---|
| 119 | fread( buf, 8, 1, file ) ;
|
---|
| 120 | buf[8] = '\0' ;
|
---|
| 121 | // DEBUG
|
---|
| 122 | //cout << "getNROReader:: buf = " << buf << endl ;
|
---|
| 123 | //
|
---|
| 124 | if ( string( buf ) == "ASTE" ) {
|
---|
| 125 | // ASTE data
|
---|
| 126 | datatype = "ASTE" ;
|
---|
| 127 | reader = new ASTEReader( filename ) ;
|
---|
| 128 | }
|
---|
| 129 | else {
|
---|
| 130 | datatype = "UNRECOGNIZED INPUT FORMAT";
|
---|
| 131 | }
|
---|
| 132 | }
|
---|
| 133 | }
|
---|
| 134 | fclose( file ) ;
|
---|
| 135 | } else {
|
---|
| 136 | datatype = "UNRECOGNIZED INPUT FORMAT";
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | // DEBUG
|
---|
| 140 | os << LogIO::NORMAL << "Data format of " << filename << ": " << datatype << LogIO::POST ;
|
---|
| 141 | //
|
---|
| 142 |
|
---|
| 143 | // return reader if exists
|
---|
| 144 | if ( reader ) {
|
---|
| 145 | reader->read() ;
|
---|
| 146 | return reader ;
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | return 0 ;
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | //
|
---|
| 154 | // getNROReader
|
---|
| 155 | //
|
---|
| 156 | // Search a list of directories for a NRO 45m and ASTE dataset and return an
|
---|
| 157 | // appropriate NROReader for it.
|
---|
| 158 | //
|
---|
| 159 | NROReader* getNROReader( const String name,
|
---|
| 160 | const Vector<String> directories,
|
---|
| 161 | int &iDir,
|
---|
| 162 | String &datatype )
|
---|
| 163 | {
|
---|
| 164 | int nDir = directories.size();
|
---|
| 165 | for ( iDir = 0; iDir < nDir; iDir++ ) {
|
---|
| 166 | string inName = directories[iDir] + "/" + name;
|
---|
| 167 | NROReader *reader = getNROReader( inName, datatype ) ;
|
---|
| 168 |
|
---|
| 169 | if (reader != 0) {
|
---|
| 170 | return reader;
|
---|
| 171 | }
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | iDir = -1;
|
---|
| 175 | return 0;
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 |
|
---|
| 179 | //----------------------------------------------------------------------
|
---|
| 180 | // constructor
|
---|
| 181 | NROReader::NROReader( string name ) {
|
---|
| 182 | // initialization
|
---|
| 183 | filename_ = name ;
|
---|
| 184 | dataset_ = NULL ;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | // destructor
|
---|
| 188 | NROReader::~NROReader()
|
---|
| 189 | {
|
---|
| 190 | if ( dataset_ != NULL ) {
|
---|
| 191 | delete dataset_ ;
|
---|
| 192 | dataset_ = NULL ;
|
---|
| 193 | }
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | // get spectrum
|
---|
| 197 | vector< vector<double> > NROReader::getSpectrum()
|
---|
| 198 | {
|
---|
| 199 | return dataset_->getSpectrum() ;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
| 202 | Int NROReader::getPolarizationNum()
|
---|
| 203 | {
|
---|
| 204 | return dataset_->getPolarizationNum() ;
|
---|
| 205 | }
|
---|
| 206 |
|
---|
| 207 | double NROReader::getStartTime()
|
---|
| 208 | {
|
---|
| 209 | //char *startTime = dataset_->getLOSTM() ;
|
---|
| 210 | string startTime = dataset_->getLOSTM() ;
|
---|
| 211 | //cout << "getStartTime() startTime = " << startTime << endl ;
|
---|
| 212 | return getMJD( startTime ) ;
|
---|
| 213 | }
|
---|
| 214 |
|
---|
| 215 | double NROReader::getEndTime()
|
---|
| 216 | {
|
---|
| 217 | //char *endTime = dataset_->getLOETM() ;
|
---|
| 218 | string endTime = dataset_->getLOETM() ;
|
---|
| 219 | return getMJD( endTime ) ;
|
---|
| 220 | }
|
---|
| 221 |
|
---|
| 222 | vector<double> NROReader::getStartIntTime()
|
---|
| 223 | {
|
---|
| 224 | return dataset_->getStartIntTime() ;
|
---|
| 225 | }
|
---|
| 226 |
|
---|
| 227 | double NROReader::getMJD( char *time )
|
---|
| 228 | {
|
---|
| 229 | // TODO: should be checked which time zone the time depends on
|
---|
| 230 | // 2008/11/14 Takeshi Nakazato
|
---|
| 231 | string strStartTime = string( time ) ;
|
---|
| 232 | string strYear = strStartTime.substr( 0, 4 ) ;
|
---|
| 233 | string strMonth = strStartTime.substr( 4, 2 ) ;
|
---|
| 234 | string strDay = strStartTime.substr( 6, 2 ) ;
|
---|
| 235 | string strHour = strStartTime.substr( 8, 2 ) ;
|
---|
| 236 | string strMinute = strStartTime.substr( 10, 2 ) ;
|
---|
| 237 | string strSecond = strStartTime.substr( 12, strStartTime.size() - 12 ) ;
|
---|
| 238 | uInt year = atoi( strYear.c_str() ) ;
|
---|
| 239 | uInt month = atoi( strMonth.c_str() ) ;
|
---|
| 240 | uInt day = atoi( strDay.c_str() ) ;
|
---|
| 241 | uInt hour = atoi( strHour.c_str() ) ;
|
---|
| 242 | uInt minute = atoi( strMinute.c_str() ) ;
|
---|
| 243 | double second = atof( strSecond.c_str() ) ;
|
---|
| 244 | Time t( year, month, day, hour, minute, second ) ;
|
---|
| 245 |
|
---|
| 246 | return t.modifiedJulianDay() ;
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | double NROReader::getMJD( string strStartTime )
|
---|
| 250 | {
|
---|
| 251 | // TODO: should be checked which time zone the time depends on
|
---|
| 252 | // 2008/11/14 Takeshi Nakazato
|
---|
| 253 | string strYear = strStartTime.substr( 0, 4 ) ;
|
---|
| 254 | string strMonth = strStartTime.substr( 4, 2 ) ;
|
---|
| 255 | string strDay = strStartTime.substr( 6, 2 ) ;
|
---|
| 256 | string strHour = strStartTime.substr( 8, 2 ) ;
|
---|
| 257 | string strMinute = strStartTime.substr( 10, 2 ) ;
|
---|
| 258 | string strSecond = strStartTime.substr( 12, strStartTime.size() - 12 ) ;
|
---|
| 259 | uInt year = atoi( strYear.c_str() ) ;
|
---|
| 260 | uInt month = atoi( strMonth.c_str() ) ;
|
---|
| 261 | uInt day = atoi( strDay.c_str() ) ;
|
---|
| 262 | uInt hour = atoi( strHour.c_str() ) ;
|
---|
| 263 | uInt minute = atoi( strMinute.c_str() ) ;
|
---|
| 264 | double second = atof( strSecond.c_str() ) ;
|
---|
| 265 | Time t( year, month, day, hour, minute, second ) ;
|
---|
| 266 |
|
---|
| 267 | return t.modifiedJulianDay() ;
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 | vector<Bool> NROReader::getIFs()
|
---|
| 271 | {
|
---|
| 272 | return dataset_->getIFs() ;
|
---|
| 273 | }
|
---|
| 274 |
|
---|
| 275 | vector<Bool> NROReader::getBeams()
|
---|
| 276 | {
|
---|
| 277 | vector<Bool> v ;
|
---|
| 278 | vector<int> arry = dataset_->getARRY() ;
|
---|
| 279 | for ( uInt i = 0 ; i < arry.size() ; i++ ) {
|
---|
| 280 | if ( arry[i] != 0 ) {
|
---|
| 281 | v.push_back( True ) ;
|
---|
| 282 | }
|
---|
| 283 | }
|
---|
| 284 |
|
---|
| 285 | // DEBUG
|
---|
| 286 | //cout << "NROReader::getBeams() number of beam is " << v.size() << endl ;
|
---|
| 287 | //
|
---|
| 288 |
|
---|
| 289 | return v ;
|
---|
| 290 | }
|
---|
| 291 |
|
---|
| 292 | // Get SRCDIRECTION in RADEC(J2000)
|
---|
| 293 | Vector<Double> NROReader::getSourceDirection()
|
---|
| 294 | {
|
---|
| 295 | LogIO os( LogOrigin( "NROReader", "getSourceDirection()", WHERE ) ) ;
|
---|
| 296 |
|
---|
| 297 | Vector<Double> v ;
|
---|
| 298 | Double srcra = Double( dataset_->getRA0() ) ;
|
---|
| 299 | Double srcdec = Double( dataset_->getDEC0() ) ;
|
---|
| 300 | char epoch[5] ;
|
---|
| 301 | strncpy( epoch, (dataset_->getEPOCH()).c_str(), 5 ) ;
|
---|
| 302 | if ( strncmp( epoch, "B1950", 5 ) == 0 ) {
|
---|
| 303 | // convert to J2000 value
|
---|
| 304 | MDirection result =
|
---|
| 305 | MDirection::Convert( MDirection( Quantity( srcra, "rad" ),
|
---|
| 306 | Quantity( srcdec, "rad" ),
|
---|
| 307 | MDirection::Ref( MDirection::B1950 ) ),
|
---|
| 308 | MDirection::Ref( MDirection::J2000 ) ) () ;
|
---|
| 309 | v = result.getAngle().getValue() ;
|
---|
| 310 | Double srcra2 = v( 0 ) ;
|
---|
| 311 | if ( srcra2 < 0.0 && srcra >= 0.0 )
|
---|
| 312 | v( 0 ) = 2.0 * M_PI + srcra2 ;
|
---|
| 313 | //cout << "NROReader::getSourceDirection() SRCDIRECTION convert from ("
|
---|
| 314 | //<< srcra << "," << srcdec << ") B1950 to ("
|
---|
| 315 | //<< v( 0 ) << ","<< v( 1 ) << ") J2000" << endl ;
|
---|
| 316 | os << LogIO::NORMAL << "SRCDIRECTION convert from ("
|
---|
| 317 | << srcra << "," << srcdec << ") B1950 to ("
|
---|
| 318 | << v( 0 ) << ","<< v( 1 ) << ") J2000" << LogIO::POST ;
|
---|
| 319 | }
|
---|
| 320 | else if ( strncmp( epoch, "J2000", 5 ) == 0 ) {
|
---|
| 321 | v.resize( 2 ) ;
|
---|
| 322 | v( 0 ) = srcra ;
|
---|
| 323 | v( 1 ) = srcdec ;
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | return v ;
|
---|
| 327 | }
|
---|
| 328 |
|
---|
| 329 | // Get DIRECTION in RADEC(J2000)
|
---|
| 330 | Vector<Double> NROReader::getDirection( int i )
|
---|
| 331 | {
|
---|
| 332 | LogIO os( LogOrigin( "NROReader", "getDirection()", WHERE ) ) ;
|
---|
| 333 |
|
---|
| 334 | Vector<Double> v ;
|
---|
| 335 | NRODataRecord *record = dataset_->getRecord( i ) ;
|
---|
| 336 | char epoch[5] ;
|
---|
| 337 | strncpy( epoch, (dataset_->getEPOCH()).c_str(), 5 ) ;
|
---|
| 338 | int icoord = dataset_->getSCNCD() ;
|
---|
| 339 | Double dirx = Double( record->SCX ) ;
|
---|
| 340 | Double diry = Double( record->SCY ) ;
|
---|
| 341 | if ( icoord == 1 ) {
|
---|
| 342 | // convert from LB to RADEC
|
---|
| 343 | MDirection result =
|
---|
| 344 | MDirection::Convert( MDirection( Quantity( dirx, "rad" ),
|
---|
| 345 | Quantity( diry, "rad" ),
|
---|
| 346 | MDirection::Ref( MDirection::GALACTIC ) ),
|
---|
| 347 | MDirection::Ref( MDirection::J2000 ) ) () ;
|
---|
| 348 | v = result.getAngle().getValue() ;
|
---|
| 349 | Double dirx2 = v( 0 ) ;
|
---|
| 350 | if ( dirx2 < 0.0 && dirx >= 0.0 )
|
---|
| 351 | v( 0 ) = 2.0 * M_PI + dirx2 ;
|
---|
| 352 | //cout << "NROReader::getDirection() DIRECTION convert from ("
|
---|
| 353 | //<< dirx << "," << diry << ") LB to ("
|
---|
| 354 | //<< v( 0 ) << ","<< v( 1 ) << ") RADEC" << endl ;
|
---|
| 355 | os << LogIO::NORMAL << "DIRECTION convert from ("
|
---|
| 356 | << dirx << "," << diry << ") LB to ("
|
---|
| 357 | << v( 0 ) << ","<< v( 1 ) << ") RADEC" << LogIO::POST ;
|
---|
| 358 | }
|
---|
| 359 | else if ( icoord == 2 ) {
|
---|
| 360 | // convert from AZEL to RADEC
|
---|
| 361 | MDirection result =
|
---|
| 362 | MDirection::Convert( MDirection( Quantity( dirx, "rad" ),
|
---|
| 363 | Quantity( diry, "rad" ),
|
---|
| 364 | MDirection::Ref( MDirection::AZEL ) ),
|
---|
| 365 | MDirection::Ref( MDirection::J2000 ) ) () ;
|
---|
| 366 | v = result.getAngle().getValue() ;
|
---|
| 367 | //cout << "NROReader::getDirection() DIRECTION convert from ("
|
---|
| 368 | //<< dirx << "," << diry << ") AZEL to ("
|
---|
| 369 | //<< v( 0 ) << ","<< v( 1 ) << ") RADEC" << endl ;
|
---|
| 370 | os << LogIO::NORMAL << "DIRECTION convert from ("
|
---|
| 371 | << dirx << "," << diry << ") AZEL to ("
|
---|
| 372 | << v( 0 ) << ","<< v( 1 ) << ") RADEC" << LogIO::POST ;
|
---|
| 373 | }
|
---|
| 374 | else if ( icoord == 0 ) {
|
---|
| 375 | if ( strncmp( epoch, "B1950", 5 ) == 0 ) {
|
---|
| 376 | // convert to J2000 value
|
---|
| 377 | MDirection result =
|
---|
| 378 | MDirection::Convert( MDirection( Quantity( dirx, "rad" ),
|
---|
| 379 | Quantity( diry, "rad" ),
|
---|
| 380 | MDirection::Ref( MDirection::B1950 ) ),
|
---|
| 381 | MDirection::Ref( MDirection::J2000 ) ) () ;
|
---|
| 382 | v = result.getAngle().getValue() ;
|
---|
| 383 | Double dirx2 = v( 0 ) ;
|
---|
| 384 | if ( dirx2 < 0.0 && dirx >= 0.0 )
|
---|
| 385 | v( 0 ) = 2.0 * M_PI + dirx2 ;
|
---|
| 386 | //cout << "STFiller::readNRO() DIRECTION convert from ("
|
---|
| 387 | //<< dirx << "," << diry << ") B1950 to ("
|
---|
| 388 | //<< v( 0 ) << ","<< v( 1 ) << ") J2000" << endl ;
|
---|
| 389 | os << LogIO::NORMAL << "DIRECTION convert from ("
|
---|
| 390 | << dirx << "," << diry << ") B1950 to ("
|
---|
| 391 | << v( 0 ) << ","<< v( 1 ) << ") J2000" << LogIO::POST ;
|
---|
| 392 | }
|
---|
| 393 | else if ( strncmp( epoch, "J2000", 5 ) == 0 ) {
|
---|
| 394 | v.resize( 2 ) ;
|
---|
| 395 | v( 0 ) = dirx ;
|
---|
| 396 | v( 1 ) = diry ;
|
---|
| 397 | }
|
---|
| 398 | }
|
---|
| 399 |
|
---|
| 400 | return v ;
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | int NROReader::getHeaderInfo( Int &nchan,
|
---|
| 404 | Int &npol,
|
---|
| 405 | Int &nif,
|
---|
| 406 | Int &nbeam,
|
---|
| 407 | String &observer,
|
---|
| 408 | String &project,
|
---|
| 409 | String &obstype,
|
---|
| 410 | String &antname,
|
---|
| 411 | Vector<Double> &antpos,
|
---|
| 412 | Float &equinox,
|
---|
| 413 | String &freqref,
|
---|
| 414 | Double &reffreq,
|
---|
| 415 | Double &bw,
|
---|
| 416 | Double &utc,
|
---|
| 417 | String &fluxunit,
|
---|
| 418 | String &epoch,
|
---|
| 419 | String &poltype )
|
---|
| 420 | {
|
---|
| 421 | nchan = dataset_->getNUMCH() ;
|
---|
| 422 | //cout << "nchan = " << nchan << endl ;
|
---|
| 423 | npol = getPolarizationNum() ;
|
---|
| 424 | //cout << "npol = " << npol << endl ;
|
---|
| 425 | observer = dataset_->getOBSVR() ;
|
---|
| 426 | //cout << "observer = " << observer << endl ;
|
---|
| 427 | project = dataset_->getPROJ() ;
|
---|
| 428 | //cout << "project = " << project << endl ;
|
---|
| 429 | obstype = dataset_->getSWMOD() ;
|
---|
| 430 | //cout << "obstype = " << obstype << endl ;
|
---|
| 431 | antname = dataset_->getSITE() ;
|
---|
| 432 | //cout << "antname = " << antname << endl ;
|
---|
| 433 | // TODO: should be investigated antenna position since there are
|
---|
| 434 | // no corresponding information in the header
|
---|
| 435 | // 2008/11/13 Takeshi Nakazato
|
---|
| 436 | //
|
---|
| 437 | // INFO: tentative antenna posiiton is obtained for NRO 45m from ITRF website
|
---|
| 438 | // 2008/11/26 Takeshi Nakazato
|
---|
| 439 | vector<double> pos = getAntennaPosition() ;
|
---|
| 440 | antpos = pos ;
|
---|
| 441 | //cout << "antpos = " << antpos << endl ;
|
---|
| 442 | string eq = dataset_->getEPOCH() ;
|
---|
| 443 | if ( eq.compare( 0, 5, "B1950" ) == 0 )
|
---|
| 444 | equinox = 1950.0 ;
|
---|
| 445 | else if ( eq.compare( 0, 5, "J2000" ) == 0 )
|
---|
| 446 | equinox = 2000.0 ;
|
---|
| 447 | //cout << "equinox = " << equinox << endl ;
|
---|
| 448 | string vref = dataset_->getVREF() ;
|
---|
| 449 | if ( vref.compare( 0, 3, "LSR" ) == 0 ) {
|
---|
| 450 | if ( vref.size() == 3 ) {
|
---|
| 451 | vref.append( "K" ) ;
|
---|
| 452 | }
|
---|
| 453 | else {
|
---|
| 454 | vref[3] = 'K' ;
|
---|
| 455 | }
|
---|
| 456 | }
|
---|
[1868] | 457 | //freqref = vref ;
|
---|
[2198] | 458 | //freqref = "LSRK" ;
|
---|
| 459 | freqref = "REST" ;
|
---|
[1757] | 460 | //cout << "freqref = " << freqref << endl ;
|
---|
| 461 | NRODataRecord *record = dataset_->getRecord( 0 ) ;
|
---|
| 462 | reffreq = record->FREQ0 ;
|
---|
| 463 | //cout << "reffreq = " << reffreq << endl ;
|
---|
| 464 | bw = dataset_->getBEBW()[0] ;
|
---|
| 465 | //cout << "bw = " << bw << endl ;
|
---|
| 466 | utc = getStartTime() ;
|
---|
| 467 | //cout << "utc = " << utc << endl ;
|
---|
| 468 | fluxunit = "K" ;
|
---|
| 469 | //cout << "fluxunit = " << fluxunit << endl ;
|
---|
| 470 | epoch = "UTC" ;
|
---|
| 471 | //cout << "epoch = " << epoch << endl ;
|
---|
| 472 | string poltp = dataset_->getPOLTP()[0] ;
|
---|
| 473 | //cout << "poltp = '" << poltp << "'" << endl ;
|
---|
| 474 | if ( poltp == "" || poltp[0] == ' ' )
|
---|
| 475 | //poltp = "None" ;
|
---|
| 476 | poltp = "linear" ; // if no polarization type specified, set to "linear"
|
---|
| 477 | //else if ( strcmp( poltp, "LINR" ) == 0 )
|
---|
| 478 | else if ( poltp.compare( 0, 1, "LINR", 0, 1 ) == 0 )
|
---|
| 479 | poltp = "linear" ;
|
---|
| 480 | //else if ( strcmp( poltp, "CIRL" ) == 0 )
|
---|
| 481 | else if ( poltp.compare( 0, 1, "CIRL", 0, 1 ) == 0 )
|
---|
| 482 | poltp = "circular" ;
|
---|
| 483 | poltype = poltp ;
|
---|
| 484 | //cout << "poltype = " << poltype << endl ;
|
---|
| 485 |
|
---|
[2154] | 486 | //vector<Bool> ifs = getIFs() ;
|
---|
| 487 | //nif = ifs.size() ;
|
---|
| 488 | nif = getNumIF() ;
|
---|
[1757] | 489 | //cout << "nif = " << nif << endl ;
|
---|
| 490 |
|
---|
[2154] | 491 | //vector<Bool> beams = getBeams() ;
|
---|
| 492 | //nbeam = beams.size() ;
|
---|
| 493 | nbeam = getNumBeam() ;
|
---|
[1757] | 494 | //cout << "nbeam = " << nbeam << endl ;
|
---|
| 495 |
|
---|
| 496 | return 0 ;
|
---|
| 497 | }
|
---|
| 498 |
|
---|
| 499 | string NROReader::getScanType( int i )
|
---|
| 500 | {
|
---|
| 501 | NRODataRecord *record = dataset_->getRecord( i ) ;
|
---|
| 502 | string s = record->SCANTP ;
|
---|
| 503 |
|
---|
| 504 | return s ;
|
---|
| 505 | }
|
---|
| 506 |
|
---|
| 507 | int NROReader::getScanInfo( int irow,
|
---|
| 508 | uInt &scanno,
|
---|
| 509 | uInt &cycleno,
|
---|
| 510 | uInt &beamno,
|
---|
| 511 | uInt &polno,
|
---|
| 512 | vector<double> &freqs,
|
---|
| 513 | Vector<Double> &restfreq,
|
---|
| 514 | uInt &refbeamno,
|
---|
| 515 | Double &scantime,
|
---|
| 516 | Double &interval,
|
---|
| 517 | String &srcname,
|
---|
| 518 | String &fieldname,
|
---|
| 519 | Array<Float> &spectra,
|
---|
| 520 | Array<uChar> &flagtra,
|
---|
| 521 | Array<Float> &tsys,
|
---|
| 522 | Array<Double> &direction,
|
---|
| 523 | Float &azimuth,
|
---|
| 524 | Float &elevation,
|
---|
| 525 | Float ¶ngle,
|
---|
| 526 | Float &opacity,
|
---|
| 527 | uInt &tcalid,
|
---|
| 528 | Int &fitid,
|
---|
| 529 | uInt &focusid,
|
---|
| 530 | Float &temperature,
|
---|
| 531 | Float &pressure,
|
---|
| 532 | Float &humidity,
|
---|
| 533 | Float &windvel,
|
---|
| 534 | Float &winddir,
|
---|
| 535 | Double &srcvel,
|
---|
| 536 | Array<Double> &propermotion,
|
---|
| 537 | Vector<Double> &srcdir,
|
---|
| 538 | Array<Double> &scanrate )
|
---|
| 539 | {
|
---|
| 540 | // DEBUG
|
---|
| 541 | //cout << "NROReader::getScanInfo() irow = " << irow << endl ;
|
---|
| 542 | //
|
---|
| 543 | NRODataRecord *record = dataset_->getRecord( irow ) ;
|
---|
| 544 |
|
---|
| 545 | // scanno
|
---|
| 546 | scanno = (uInt)(record->ISCAN) ;
|
---|
| 547 | //cout << "scanno = " << scanno << endl ;
|
---|
| 548 |
|
---|
| 549 | // cycleno
|
---|
| 550 | cycleno = 0 ;
|
---|
| 551 | //cout << "cycleno = " << cycleno << endl ;
|
---|
| 552 |
|
---|
| 553 | // beamno
|
---|
[2158] | 554 | string rxname = dataset_->getRX()[0] ;
|
---|
| 555 | if ( rxname.find("MULT2") != string::npos ) {
|
---|
| 556 | string arryt = string( record->ARRYT ) ;
|
---|
| 557 | string sbeamno = arryt.substr( 1, arryt.size()-1 ) ;
|
---|
| 558 | uInt ibeamno = atoi( sbeamno.c_str() ) ;
|
---|
| 559 | beamno = ibeamno - 1 ;
|
---|
| 560 | }
|
---|
| 561 | else {
|
---|
| 562 | beamno = 0 ;
|
---|
| 563 | }
|
---|
[1757] | 564 | //cout << "beamno = " << beamno << endl ;
|
---|
| 565 |
|
---|
| 566 | // polno
|
---|
| 567 | polno = 0 ;
|
---|
| 568 | //cout << "polno = " << polno << endl ;
|
---|
| 569 |
|
---|
| 570 | // freqs (for IFNO and FREQ_ID)
|
---|
| 571 | //freqs = getFrequencies( irow ) ;
|
---|
| 572 | freqs = dataset_->getFrequencies( irow ) ;
|
---|
| 573 | //cout << "freqs = [" << freqs[0] << ", " << freqs[1] << ", " << freqs[2] << "]" << endl ;
|
---|
| 574 |
|
---|
| 575 | // restfreq (for MOLECULE_ID)
|
---|
| 576 | Vector<Double> rf( IPosition( 1, 1 ) ) ;
|
---|
| 577 | rf( 0 ) = record->FREQ0 ;
|
---|
| 578 | restfreq = rf ;
|
---|
| 579 | //cout << "restfreq = " << rf << endl ;
|
---|
| 580 |
|
---|
| 581 | // refbeamno
|
---|
| 582 | refbeamno = 0 ;
|
---|
| 583 | //cout << "refbeamno = " << refbeamno << endl ;
|
---|
| 584 |
|
---|
| 585 | // scantime
|
---|
[2156] | 586 | //scantime = Double( dataset_->getStartIntTime( irow ) ) ;
|
---|
| 587 | scantime = Double( dataset_->getScanTime( irow ) ) ;
|
---|
[1757] | 588 | //cout << "scantime = " << scantime << endl ;
|
---|
| 589 |
|
---|
| 590 | // interval
|
---|
| 591 | interval = Double( dataset_->getIPTIM() ) ;
|
---|
| 592 | //cout << "interval = " << interval << endl ;
|
---|
| 593 |
|
---|
| 594 | // srcname
|
---|
| 595 | srcname = String( dataset_->getOBJ() ) ;
|
---|
| 596 | //cout << "srcname = " << srcname << endl ;
|
---|
| 597 |
|
---|
| 598 | // fieldname
|
---|
| 599 | fieldname = String( dataset_->getOBJ() ) ;
|
---|
| 600 | //cout << "fieldname = " << fieldname << endl ;
|
---|
| 601 |
|
---|
| 602 | // spectra
|
---|
| 603 | vector<double> spec = dataset_->getSpectrum( irow ) ;
|
---|
| 604 | Array<Float> sp( IPosition( 1, spec.size() ) ) ;
|
---|
| 605 | int index = 0 ;
|
---|
| 606 | for ( Array<Float>::iterator itr = sp.begin() ; itr != sp.end() ; itr++ ) {
|
---|
| 607 | *itr = spec[index++] ;
|
---|
| 608 | }
|
---|
| 609 | spectra = sp ;
|
---|
| 610 | //cout << "spec.size() = " << spec.size() << endl ;
|
---|
| 611 |
|
---|
| 612 | // flagtra
|
---|
| 613 | Array<uChar> flag( spectra.shape() ) ;
|
---|
| 614 | flag.set( 0 ) ;
|
---|
| 615 | flagtra = flag ;
|
---|
| 616 | //cout << "flag.size() = " << flag.size() << endl ;
|
---|
| 617 |
|
---|
| 618 | // tsys
|
---|
| 619 | Array<Float> tmp( IPosition( 1, 1 ), record->TSYS ) ;
|
---|
| 620 | tsys = tmp ;
|
---|
| 621 | //cout << "tsys[0] = " << tsys[0] << endl ;
|
---|
| 622 |
|
---|
| 623 | // direction
|
---|
| 624 | direction = getDirection( irow ) ;
|
---|
| 625 | //cout << "direction = [" << direction[0] << ", " << direction[1] << "]" << endl ;
|
---|
| 626 |
|
---|
| 627 | // azimuth
|
---|
| 628 | azimuth = record->RAZ ;
|
---|
| 629 | //cout << "azimuth = " << azimuth << endl ;
|
---|
| 630 |
|
---|
| 631 | // elevation
|
---|
| 632 | elevation = record->REL ;
|
---|
| 633 | //cout << "elevation = " << elevation << endl ;
|
---|
| 634 |
|
---|
| 635 | // parangle
|
---|
| 636 | parangle = 0.0 ;
|
---|
| 637 | //cout << "parangle = " << parangle << endl ;
|
---|
| 638 |
|
---|
| 639 | // opacity
|
---|
| 640 | opacity = 0.0 ;
|
---|
| 641 | //cout << "opacity = " << opacity << endl ;
|
---|
| 642 |
|
---|
| 643 | // tcalid
|
---|
| 644 | tcalid = 0 ;
|
---|
| 645 | //cout << "tcalid = " << tcalid << endl ;
|
---|
| 646 |
|
---|
| 647 | // fitid
|
---|
| 648 | fitid = -1 ;
|
---|
| 649 | //cout << "fitid = " << fitid << endl ;
|
---|
| 650 |
|
---|
| 651 | // focusid
|
---|
| 652 | focusid = 0 ;
|
---|
| 653 | //cout << "focusid = " << focusid << endl ;
|
---|
| 654 |
|
---|
| 655 | // temperature (for WEATHER_ID)
|
---|
| 656 | temperature = Float( record->TEMP ) ;
|
---|
| 657 | //cout << "temperature = " << temperature << endl ;
|
---|
| 658 |
|
---|
| 659 | // pressure (for WEATHER_ID)
|
---|
| 660 | pressure = Float( record->PATM ) ;
|
---|
| 661 | //cout << "pressure = " << pressure << endl ;
|
---|
| 662 |
|
---|
| 663 | // humidity (for WEATHER_ID)
|
---|
| 664 | humidity = Float( record->PH2O ) ;
|
---|
| 665 | //cout << "humidity = " << humidity << endl ;
|
---|
| 666 |
|
---|
| 667 | // windvel (for WEATHER_ID)
|
---|
| 668 | windvel = Float( record->VWIND ) ;
|
---|
| 669 | //cout << "windvel = " << windvel << endl ;
|
---|
| 670 |
|
---|
| 671 | // winddir (for WEATHER_ID)
|
---|
| 672 | winddir = Float( record->DWIND ) ;
|
---|
| 673 | //cout << "winddir = " << winddir << endl ;
|
---|
| 674 |
|
---|
| 675 | // srcvel
|
---|
| 676 | srcvel = dataset_->getURVEL() ;
|
---|
| 677 | //cout << "srcvel = " << srcvel << endl ;
|
---|
| 678 |
|
---|
| 679 | // propermotion
|
---|
| 680 | Array<Double> srcarr( IPosition( 1, 2 ) ) ;
|
---|
| 681 | srcarr = 0.0 ;
|
---|
| 682 | propermotion = srcarr ;
|
---|
| 683 | //cout << "propermotion = [" << propermotion[0] << ", " << propermotion[1] << "]" << endl ;
|
---|
| 684 |
|
---|
| 685 | // srcdir
|
---|
| 686 | srcdir = getSourceDirection() ;
|
---|
| 687 | //cout << "srcdir = [" << srcdir[0] << ", " << srcdir[1] << endl ;
|
---|
| 688 |
|
---|
| 689 | // scanrate
|
---|
| 690 | Array<Double> sr( IPosition( 1, 1 ) ) ;
|
---|
| 691 | sr = 0.0 ;
|
---|
| 692 | scanrate = sr ;
|
---|
| 693 | //cout << "scanrate = " << scanrate[0] << endl ;
|
---|
| 694 |
|
---|
| 695 | return 0 ;
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 | Int NROReader::getRowNum()
|
---|
| 699 | {
|
---|
| 700 | return dataset_->getRowNum() ;
|
---|
| 701 | }
|
---|