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