| 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 | }
|
|---|
| 457 | freqref = vref ;
|
|---|
| 458 | // DEBUG
|
|---|
| 459 | freqref = "TOPO" ;
|
|---|
| 460 | //
|
|---|
| 461 | //cout << "freqref = " << freqref << endl ;
|
|---|
| 462 | NRODataRecord *record = dataset_->getRecord( 0 ) ;
|
|---|
| 463 | reffreq = record->FREQ0 ;
|
|---|
| 464 | //cout << "reffreq = " << reffreq << endl ;
|
|---|
| 465 | bw = dataset_->getBEBW()[0] ;
|
|---|
| 466 | //cout << "bw = " << bw << endl ;
|
|---|
| 467 | utc = getStartTime() ;
|
|---|
| 468 | //cout << "utc = " << utc << endl ;
|
|---|
| 469 | fluxunit = "K" ;
|
|---|
| 470 | //cout << "fluxunit = " << fluxunit << endl ;
|
|---|
| 471 | epoch = "UTC" ;
|
|---|
| 472 | //cout << "epoch = " << epoch << endl ;
|
|---|
| 473 | string poltp = dataset_->getPOLTP()[0] ;
|
|---|
| 474 | //cout << "poltp = '" << poltp << "'" << endl ;
|
|---|
| 475 | if ( poltp == "" || poltp[0] == ' ' )
|
|---|
| 476 | //poltp = "None" ;
|
|---|
| 477 | poltp = "linear" ; // if no polarization type specified, set to "linear"
|
|---|
| 478 | //else if ( strcmp( poltp, "LINR" ) == 0 )
|
|---|
| 479 | else if ( poltp.compare( 0, 1, "LINR", 0, 1 ) == 0 )
|
|---|
| 480 | poltp = "linear" ;
|
|---|
| 481 | //else if ( strcmp( poltp, "CIRL" ) == 0 )
|
|---|
| 482 | else if ( poltp.compare( 0, 1, "CIRL", 0, 1 ) == 0 )
|
|---|
| 483 | poltp = "circular" ;
|
|---|
| 484 | poltype = poltp ;
|
|---|
| 485 | //cout << "poltype = " << poltype << endl ;
|
|---|
| 486 |
|
|---|
| 487 | vector<Bool> ifs = getIFs() ;
|
|---|
| 488 | nif = ifs.size() ;
|
|---|
| 489 | //cout << "nif = " << nif << endl ;
|
|---|
| 490 |
|
|---|
| 491 | vector<Bool> beams = getBeams() ;
|
|---|
| 492 | nbeam = beams.size() ;
|
|---|
| 493 | //cout << "nbeam = " << nbeam << endl ;
|
|---|
| 494 |
|
|---|
| 495 | return 0 ;
|
|---|
| 496 | }
|
|---|
| 497 |
|
|---|
| 498 | string NROReader::getScanType( int i )
|
|---|
| 499 | {
|
|---|
| 500 | NRODataRecord *record = dataset_->getRecord( i ) ;
|
|---|
| 501 | string s = record->SCANTP ;
|
|---|
| 502 |
|
|---|
| 503 | return s ;
|
|---|
| 504 | }
|
|---|
| 505 |
|
|---|
| 506 | int NROReader::getScanInfo( int irow,
|
|---|
| 507 | uInt &scanno,
|
|---|
| 508 | uInt &cycleno,
|
|---|
| 509 | uInt &beamno,
|
|---|
| 510 | uInt &polno,
|
|---|
| 511 | vector<double> &freqs,
|
|---|
| 512 | Vector<Double> &restfreq,
|
|---|
| 513 | uInt &refbeamno,
|
|---|
| 514 | Double &scantime,
|
|---|
| 515 | Double &interval,
|
|---|
| 516 | String &srcname,
|
|---|
| 517 | String &fieldname,
|
|---|
| 518 | Array<Float> &spectra,
|
|---|
| 519 | Array<uChar> &flagtra,
|
|---|
| 520 | Array<Float> &tsys,
|
|---|
| 521 | Array<Double> &direction,
|
|---|
| 522 | Float &azimuth,
|
|---|
| 523 | Float &elevation,
|
|---|
| 524 | Float ¶ngle,
|
|---|
| 525 | Float &opacity,
|
|---|
| 526 | uInt &tcalid,
|
|---|
| 527 | Int &fitid,
|
|---|
| 528 | uInt &focusid,
|
|---|
| 529 | Float &temperature,
|
|---|
| 530 | Float &pressure,
|
|---|
| 531 | Float &humidity,
|
|---|
| 532 | Float &windvel,
|
|---|
| 533 | Float &winddir,
|
|---|
| 534 | Double &srcvel,
|
|---|
| 535 | Array<Double> &propermotion,
|
|---|
| 536 | Vector<Double> &srcdir,
|
|---|
| 537 | Array<Double> &scanrate )
|
|---|
| 538 | {
|
|---|
| 539 | // DEBUG
|
|---|
| 540 | //cout << "NROReader::getScanInfo() irow = " << irow << endl ;
|
|---|
| 541 | //
|
|---|
| 542 | NRODataRecord *record = dataset_->getRecord( irow ) ;
|
|---|
| 543 |
|
|---|
| 544 | // scanno
|
|---|
| 545 | scanno = (uInt)(record->ISCAN) ;
|
|---|
| 546 | //cout << "scanno = " << scanno << endl ;
|
|---|
| 547 |
|
|---|
| 548 | // cycleno
|
|---|
| 549 | cycleno = 0 ;
|
|---|
| 550 | //cout << "cycleno = " << cycleno << endl ;
|
|---|
| 551 |
|
|---|
| 552 | // beamno
|
|---|
| 553 | string arryt = string( record->ARRYT ) ;
|
|---|
| 554 | string sbeamno = arryt.substr( 1, arryt.size()-1 ) ;
|
|---|
| 555 | uInt ibeamno = atoi( sbeamno.c_str() ) ;
|
|---|
| 556 | beamno = ibeamno - 1 ;
|
|---|
| 557 | //cout << "beamno = " << beamno << endl ;
|
|---|
| 558 |
|
|---|
| 559 | // polno
|
|---|
| 560 | polno = 0 ;
|
|---|
| 561 | //cout << "polno = " << polno << endl ;
|
|---|
| 562 |
|
|---|
| 563 | // freqs (for IFNO and FREQ_ID)
|
|---|
| 564 | //freqs = getFrequencies( irow ) ;
|
|---|
| 565 | freqs = dataset_->getFrequencies( irow ) ;
|
|---|
| 566 | //cout << "freqs = [" << freqs[0] << ", " << freqs[1] << ", " << freqs[2] << "]" << endl ;
|
|---|
| 567 |
|
|---|
| 568 | // restfreq (for MOLECULE_ID)
|
|---|
| 569 | Vector<Double> rf( IPosition( 1, 1 ) ) ;
|
|---|
| 570 | rf( 0 ) = record->FREQ0 ;
|
|---|
| 571 | restfreq = rf ;
|
|---|
| 572 | //cout << "restfreq = " << rf << endl ;
|
|---|
| 573 |
|
|---|
| 574 | // refbeamno
|
|---|
| 575 | refbeamno = 0 ;
|
|---|
| 576 | //cout << "refbeamno = " << refbeamno << endl ;
|
|---|
| 577 |
|
|---|
| 578 | // scantime
|
|---|
| 579 | scantime = Double( dataset_->getStartIntTime( irow ) ) ;
|
|---|
| 580 | //cout << "scantime = " << scantime << endl ;
|
|---|
| 581 |
|
|---|
| 582 | // interval
|
|---|
| 583 | interval = Double( dataset_->getIPTIM() ) ;
|
|---|
| 584 | //cout << "interval = " << interval << endl ;
|
|---|
| 585 |
|
|---|
| 586 | // srcname
|
|---|
| 587 | srcname = String( dataset_->getOBJ() ) ;
|
|---|
| 588 | //cout << "srcname = " << srcname << endl ;
|
|---|
| 589 |
|
|---|
| 590 | // fieldname
|
|---|
| 591 | fieldname = String( dataset_->getOBJ() ) ;
|
|---|
| 592 | //cout << "fieldname = " << fieldname << endl ;
|
|---|
| 593 |
|
|---|
| 594 | // spectra
|
|---|
| 595 | vector<double> spec = dataset_->getSpectrum( irow ) ;
|
|---|
| 596 | Array<Float> sp( IPosition( 1, spec.size() ) ) ;
|
|---|
| 597 | int index = 0 ;
|
|---|
| 598 | for ( Array<Float>::iterator itr = sp.begin() ; itr != sp.end() ; itr++ ) {
|
|---|
| 599 | *itr = spec[index++] ;
|
|---|
| 600 | }
|
|---|
| 601 | spectra = sp ;
|
|---|
| 602 | //cout << "spec.size() = " << spec.size() << endl ;
|
|---|
| 603 |
|
|---|
| 604 | // flagtra
|
|---|
| 605 | Array<uChar> flag( spectra.shape() ) ;
|
|---|
| 606 | flag.set( 0 ) ;
|
|---|
| 607 | flagtra = flag ;
|
|---|
| 608 | //cout << "flag.size() = " << flag.size() << endl ;
|
|---|
| 609 |
|
|---|
| 610 | // tsys
|
|---|
| 611 | Array<Float> tmp( IPosition( 1, 1 ), record->TSYS ) ;
|
|---|
| 612 | tsys = tmp ;
|
|---|
| 613 | //cout << "tsys[0] = " << tsys[0] << endl ;
|
|---|
| 614 |
|
|---|
| 615 | // direction
|
|---|
| 616 | direction = getDirection( irow ) ;
|
|---|
| 617 | //cout << "direction = [" << direction[0] << ", " << direction[1] << "]" << endl ;
|
|---|
| 618 |
|
|---|
| 619 | // azimuth
|
|---|
| 620 | azimuth = record->RAZ ;
|
|---|
| 621 | //cout << "azimuth = " << azimuth << endl ;
|
|---|
| 622 |
|
|---|
| 623 | // elevation
|
|---|
| 624 | elevation = record->REL ;
|
|---|
| 625 | //cout << "elevation = " << elevation << endl ;
|
|---|
| 626 |
|
|---|
| 627 | // parangle
|
|---|
| 628 | parangle = 0.0 ;
|
|---|
| 629 | //cout << "parangle = " << parangle << endl ;
|
|---|
| 630 |
|
|---|
| 631 | // opacity
|
|---|
| 632 | opacity = 0.0 ;
|
|---|
| 633 | //cout << "opacity = " << opacity << endl ;
|
|---|
| 634 |
|
|---|
| 635 | // tcalid
|
|---|
| 636 | tcalid = 0 ;
|
|---|
| 637 | //cout << "tcalid = " << tcalid << endl ;
|
|---|
| 638 |
|
|---|
| 639 | // fitid
|
|---|
| 640 | fitid = -1 ;
|
|---|
| 641 | //cout << "fitid = " << fitid << endl ;
|
|---|
| 642 |
|
|---|
| 643 | // focusid
|
|---|
| 644 | focusid = 0 ;
|
|---|
| 645 | //cout << "focusid = " << focusid << endl ;
|
|---|
| 646 |
|
|---|
| 647 | // temperature (for WEATHER_ID)
|
|---|
| 648 | temperature = Float( record->TEMP ) ;
|
|---|
| 649 | //cout << "temperature = " << temperature << endl ;
|
|---|
| 650 |
|
|---|
| 651 | // pressure (for WEATHER_ID)
|
|---|
| 652 | pressure = Float( record->PATM ) ;
|
|---|
| 653 | //cout << "pressure = " << pressure << endl ;
|
|---|
| 654 |
|
|---|
| 655 | // humidity (for WEATHER_ID)
|
|---|
| 656 | humidity = Float( record->PH2O ) ;
|
|---|
| 657 | //cout << "humidity = " << humidity << endl ;
|
|---|
| 658 |
|
|---|
| 659 | // windvel (for WEATHER_ID)
|
|---|
| 660 | windvel = Float( record->VWIND ) ;
|
|---|
| 661 | //cout << "windvel = " << windvel << endl ;
|
|---|
| 662 |
|
|---|
| 663 | // winddir (for WEATHER_ID)
|
|---|
| 664 | winddir = Float( record->DWIND ) ;
|
|---|
| 665 | //cout << "winddir = " << winddir << endl ;
|
|---|
| 666 |
|
|---|
| 667 | // srcvel
|
|---|
| 668 | srcvel = dataset_->getURVEL() ;
|
|---|
| 669 | //cout << "srcvel = " << srcvel << endl ;
|
|---|
| 670 |
|
|---|
| 671 | // propermotion
|
|---|
| 672 | Array<Double> srcarr( IPosition( 1, 2 ) ) ;
|
|---|
| 673 | srcarr = 0.0 ;
|
|---|
| 674 | propermotion = srcarr ;
|
|---|
| 675 | //cout << "propermotion = [" << propermotion[0] << ", " << propermotion[1] << "]" << endl ;
|
|---|
| 676 |
|
|---|
| 677 | // srcdir
|
|---|
| 678 | srcdir = getSourceDirection() ;
|
|---|
| 679 | //cout << "srcdir = [" << srcdir[0] << ", " << srcdir[1] << endl ;
|
|---|
| 680 |
|
|---|
| 681 | // scanrate
|
|---|
| 682 | Array<Double> sr( IPosition( 1, 1 ) ) ;
|
|---|
| 683 | sr = 0.0 ;
|
|---|
| 684 | scanrate = sr ;
|
|---|
| 685 | //cout << "scanrate = " << scanrate[0] << endl ;
|
|---|
| 686 |
|
|---|
| 687 | return 0 ;
|
|---|
| 688 | }
|
|---|
| 689 |
|
|---|
| 690 | Int NROReader::getRowNum()
|
|---|
| 691 | {
|
|---|
| 692 | return dataset_->getRowNum() ;
|
|---|
| 693 | }
|
|---|