[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
|
---|
[2643] | 184 | NROReader::NROReader( string name )
|
---|
| 185 | : dataset_( NULL ),
|
---|
| 186 | srcdir_( 0 ),
|
---|
| 187 | msrcdir_( 0 )
|
---|
| 188 | {
|
---|
[1757] | 189 | // initialization
|
---|
| 190 | filename_ = name ;
|
---|
[2643] | 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 | {
|
---|
[2643] | 302 | if ( msrcdir_.nelements() == 2 )
|
---|
| 303 | return msrcdir_ ;
|
---|
[1757] | 304 |
|
---|
[2643] | 305 | srcdir_.resize( 2 ) ;
|
---|
| 306 | srcdir_[0] = Double( dataset_->getRA0() ) ;
|
---|
| 307 | srcdir_[1] = Double( dataset_->getDEC0() ) ;
|
---|
[1757] | 308 | char epoch[5] ;
|
---|
| 309 | strncpy( epoch, (dataset_->getEPOCH()).c_str(), 5 ) ;
|
---|
| 310 | if ( strncmp( epoch, "B1950", 5 ) == 0 ) {
|
---|
| 311 | // convert to J2000 value
|
---|
| 312 | MDirection result =
|
---|
[2643] | 313 | MDirection::Convert( MDirection( Quantity( srcdir_[0], "rad" ),
|
---|
| 314 | Quantity( srcdir_[1], "rad" ),
|
---|
[1757] | 315 | MDirection::Ref( MDirection::B1950 ) ),
|
---|
| 316 | MDirection::Ref( MDirection::J2000 ) ) () ;
|
---|
[2643] | 317 | msrcdir_ = result.getAngle().getValue() ;
|
---|
| 318 | if ( msrcdir_[0] < 0.0 && srcdir_[0] >= 0.0 )
|
---|
| 319 | msrcdir_[0] = 2.0 * M_PI + msrcdir_[0] ;
|
---|
[1757] | 320 | //cout << "NROReader::getSourceDirection() SRCDIRECTION convert from ("
|
---|
| 321 | //<< srcra << "," << srcdec << ") B1950 to ("
|
---|
| 322 | //<< v( 0 ) << ","<< v( 1 ) << ") J2000" << endl ;
|
---|
[2643] | 323 | //LogIO os( LogOrigin( "NROReader", "getSourceDirection()", WHERE ) ) ;
|
---|
[2261] | 324 | //os << LogIO::NORMAL << "SRCDIRECTION convert from ("
|
---|
| 325 | // << srcra << "," << srcdec << ") B1950 to ("
|
---|
| 326 | // << v( 0 ) << ","<< v( 1 ) << ") J2000" << LogIO::POST ;
|
---|
[1757] | 327 | }
|
---|
| 328 | else if ( strncmp( epoch, "J2000", 5 ) == 0 ) {
|
---|
[2643] | 329 | msrcdir_.reference( srcdir_ ) ;
|
---|
[1757] | 330 | }
|
---|
[2643] | 331 |
|
---|
| 332 | return msrcdir_ ;
|
---|
[1757] | 333 | }
|
---|
| 334 |
|
---|
| 335 | // Get DIRECTION in RADEC(J2000)
|
---|
| 336 | Vector<Double> NROReader::getDirection( int i )
|
---|
| 337 | {
|
---|
[2643] | 338 | Vector<Double> v( 2 ) ;
|
---|
[1757] | 339 | NRODataRecord *record = dataset_->getRecord( i ) ;
|
---|
| 340 | char epoch[5] ;
|
---|
| 341 | strncpy( epoch, (dataset_->getEPOCH()).c_str(), 5 ) ;
|
---|
| 342 | int icoord = dataset_->getSCNCD() ;
|
---|
[2643] | 343 | double scantime = dataset_->getScanTime( i ) ;
|
---|
| 344 | initConvert( icoord, scantime, epoch ) ;
|
---|
| 345 | v[0]= Double( record->SCX ) ;
|
---|
| 346 | v[1] = Double( record->SCY ) ;
|
---|
| 347 | if ( converter_.null() )
|
---|
| 348 | // no conversion
|
---|
| 349 | return v ;
|
---|
| 350 | else {
|
---|
| 351 | Vector<Double> v2 = (*converter_)( v ).getAngle().getValue() ;
|
---|
| 352 | if ( v2[0] < 0.0 && v[0] >= 0.0 )
|
---|
| 353 | v2[0] = 2.0 * M_PI + v2[0] ;
|
---|
| 354 | return v2 ;
|
---|
[1757] | 355 | }
|
---|
[2643] | 356 | }
|
---|
| 357 |
|
---|
| 358 | void NROReader::initConvert( int icoord, double t, char *epoch )
|
---|
| 359 | {
|
---|
| 360 | if ( icoord == 0 && strncmp( epoch, "J2000", 5 ) == 0 )
|
---|
| 361 | // no conversion
|
---|
| 362 | return ;
|
---|
| 363 |
|
---|
| 364 | if ( converter_.null() || icoord != coord_ ) {
|
---|
| 365 | LogIO os( LogOrigin( "NROReader", "initConvert()", WHERE ) ) ;
|
---|
| 366 | coord_ = icoord ;
|
---|
| 367 | if ( coord_ == 0 ) {
|
---|
| 368 | // RADEC (B1950) -> RADEC (J2000)
|
---|
| 369 | os << "Creating converter from RADEC (B1950) to RADEC (J2000)" << LogIO::POST ;
|
---|
| 370 | converter_ = new MDirection::Convert( MDirection::B1950,
|
---|
| 371 | MDirection::J2000 ) ;
|
---|
[1757] | 372 | }
|
---|
[2643] | 373 | else if ( coord_ == 1 ) {
|
---|
| 374 | // LB -> RADEC (J2000)
|
---|
| 375 | os << "Creating converter from GALACTIC to RADEC (J2000)" << LogIO::POST ;
|
---|
| 376 | converter_ = new MDirection::Convert( MDirection::GALACTIC,
|
---|
| 377 | MDirection::J2000 ) ;
|
---|
[1757] | 378 | }
|
---|
[2643] | 379 | else {
|
---|
| 380 | // coord_ == 2
|
---|
| 381 | // AZEL -> RADEC (J2000)
|
---|
| 382 | os << "Creating converter from AZEL to RADEC (J2000)" << LogIO::POST ;
|
---|
| 383 | if ( mf_.null() ) {
|
---|
| 384 | mf_ = new MeasFrame() ;
|
---|
| 385 | vector<double> antpos = getAntennaPosition() ;
|
---|
| 386 | Vector<Quantity> qantpos( 3 ) ;
|
---|
| 387 | for ( int ip = 0 ; ip < 3 ; ip++ )
|
---|
| 388 | qantpos[ip] = Quantity( antpos[ip], "m" ) ;
|
---|
| 389 | MPosition mp( MVPosition( qantpos ), MPosition::ITRF ) ;
|
---|
| 390 | mf_->set( mp ) ;
|
---|
| 391 | }
|
---|
| 392 | converter_ = new MDirection::Convert( MDirection::AZEL,
|
---|
| 393 | MDirection::Ref(MDirection::J2000,
|
---|
| 394 | *mf_ ) ) ;
|
---|
| 395 | }
|
---|
[1757] | 396 | }
|
---|
| 397 |
|
---|
[2643] | 398 | if ( coord_ == 2 ) {
|
---|
| 399 | MEpoch me( Quantity( t, "d" ), MEpoch::UTC ) ;
|
---|
| 400 | mf_->set( me ) ;
|
---|
| 401 | }
|
---|
[1757] | 402 | }
|
---|
| 403 |
|
---|
| 404 | int NROReader::getHeaderInfo( Int &nchan,
|
---|
| 405 | Int &npol,
|
---|
| 406 | Int &nif,
|
---|
| 407 | Int &nbeam,
|
---|
| 408 | String &observer,
|
---|
| 409 | String &project,
|
---|
| 410 | String &obstype,
|
---|
| 411 | String &antname,
|
---|
| 412 | Vector<Double> &antpos,
|
---|
| 413 | Float &equinox,
|
---|
| 414 | String &freqref,
|
---|
| 415 | Double &reffreq,
|
---|
| 416 | Double &bw,
|
---|
| 417 | Double &utc,
|
---|
| 418 | String &fluxunit,
|
---|
| 419 | String &epoch,
|
---|
| 420 | String &poltype )
|
---|
| 421 | {
|
---|
| 422 | nchan = dataset_->getNUMCH() ;
|
---|
| 423 | //cout << "nchan = " << nchan << endl ;
|
---|
| 424 | npol = getPolarizationNum() ;
|
---|
| 425 | //cout << "npol = " << npol << endl ;
|
---|
| 426 | observer = dataset_->getOBSVR() ;
|
---|
| 427 | //cout << "observer = " << observer << endl ;
|
---|
| 428 | project = dataset_->getPROJ() ;
|
---|
| 429 | //cout << "project = " << project << endl ;
|
---|
| 430 | obstype = dataset_->getSWMOD() ;
|
---|
| 431 | //cout << "obstype = " << obstype << endl ;
|
---|
| 432 | antname = dataset_->getSITE() ;
|
---|
| 433 | //cout << "antname = " << antname << endl ;
|
---|
| 434 | // TODO: should be investigated antenna position since there are
|
---|
| 435 | // no corresponding information in the header
|
---|
| 436 | // 2008/11/13 Takeshi Nakazato
|
---|
| 437 | //
|
---|
| 438 | // INFO: tentative antenna posiiton is obtained for NRO 45m from ITRF website
|
---|
| 439 | // 2008/11/26 Takeshi Nakazato
|
---|
| 440 | vector<double> pos = getAntennaPosition() ;
|
---|
| 441 | antpos = pos ;
|
---|
| 442 | //cout << "antpos = " << antpos << endl ;
|
---|
| 443 | string eq = dataset_->getEPOCH() ;
|
---|
[2200] | 444 | // if ( eq.compare( 0, 5, "B1950" ) == 0 )
|
---|
| 445 | // equinox = 1950.0 ;
|
---|
| 446 | // else if ( eq.compare( 0, 5, "J2000" ) == 0 )
|
---|
| 447 | // equinox = 2000.0 ;
|
---|
| 448 | // equinox is always 2000.0
|
---|
| 449 | equinox = 2000.0 ;
|
---|
[1757] | 450 | //cout << "equinox = " << equinox << endl ;
|
---|
| 451 | string vref = dataset_->getVREF() ;
|
---|
| 452 | if ( vref.compare( 0, 3, "LSR" ) == 0 ) {
|
---|
| 453 | if ( vref.size() == 3 ) {
|
---|
| 454 | vref.append( "K" ) ;
|
---|
| 455 | }
|
---|
| 456 | else {
|
---|
| 457 | vref[3] = 'K' ;
|
---|
| 458 | }
|
---|
| 459 | }
|
---|
[1868] | 460 | //freqref = vref ;
|
---|
[2198] | 461 | //freqref = "LSRK" ;
|
---|
| 462 | freqref = "REST" ;
|
---|
[1757] | 463 | //cout << "freqref = " << freqref << endl ;
|
---|
| 464 | NRODataRecord *record = dataset_->getRecord( 0 ) ;
|
---|
| 465 | reffreq = record->FREQ0 ;
|
---|
| 466 | //cout << "reffreq = " << reffreq << endl ;
|
---|
| 467 | bw = dataset_->getBEBW()[0] ;
|
---|
| 468 | //cout << "bw = " << bw << endl ;
|
---|
| 469 | utc = getStartTime() ;
|
---|
| 470 | //cout << "utc = " << utc << endl ;
|
---|
| 471 | fluxunit = "K" ;
|
---|
| 472 | //cout << "fluxunit = " << fluxunit << endl ;
|
---|
| 473 | epoch = "UTC" ;
|
---|
| 474 | //cout << "epoch = " << epoch << endl ;
|
---|
| 475 | string poltp = dataset_->getPOLTP()[0] ;
|
---|
| 476 | //cout << "poltp = '" << poltp << "'" << endl ;
|
---|
| 477 | if ( poltp == "" || poltp[0] == ' ' )
|
---|
| 478 | //poltp = "None" ;
|
---|
| 479 | poltp = "linear" ; // if no polarization type specified, set to "linear"
|
---|
| 480 | //else if ( strcmp( poltp, "LINR" ) == 0 )
|
---|
| 481 | else if ( poltp.compare( 0, 1, "LINR", 0, 1 ) == 0 )
|
---|
| 482 | poltp = "linear" ;
|
---|
| 483 | //else if ( strcmp( poltp, "CIRL" ) == 0 )
|
---|
| 484 | else if ( poltp.compare( 0, 1, "CIRL", 0, 1 ) == 0 )
|
---|
| 485 | poltp = "circular" ;
|
---|
| 486 | poltype = poltp ;
|
---|
| 487 | //cout << "poltype = " << poltype << endl ;
|
---|
| 488 |
|
---|
[2154] | 489 | //vector<Bool> ifs = getIFs() ;
|
---|
| 490 | //nif = ifs.size() ;
|
---|
| 491 | nif = getNumIF() ;
|
---|
[1757] | 492 | //cout << "nif = " << nif << endl ;
|
---|
| 493 |
|
---|
[2154] | 494 | //vector<Bool> beams = getBeams() ;
|
---|
| 495 | //nbeam = beams.size() ;
|
---|
| 496 | nbeam = getNumBeam() ;
|
---|
[1757] | 497 | //cout << "nbeam = " << nbeam << endl ;
|
---|
| 498 |
|
---|
| 499 | return 0 ;
|
---|
| 500 | }
|
---|
| 501 |
|
---|
| 502 | string NROReader::getScanType( int i )
|
---|
| 503 | {
|
---|
| 504 | NRODataRecord *record = dataset_->getRecord( i ) ;
|
---|
| 505 | string s = record->SCANTP ;
|
---|
| 506 |
|
---|
| 507 | return s ;
|
---|
| 508 | }
|
---|
| 509 |
|
---|
| 510 | int NROReader::getScanInfo( int irow,
|
---|
| 511 | uInt &scanno,
|
---|
| 512 | uInt &cycleno,
|
---|
[2201] | 513 | uInt &ifno,
|
---|
[1757] | 514 | uInt &beamno,
|
---|
| 515 | uInt &polno,
|
---|
| 516 | vector<double> &freqs,
|
---|
| 517 | Vector<Double> &restfreq,
|
---|
| 518 | uInt &refbeamno,
|
---|
| 519 | Double &scantime,
|
---|
| 520 | Double &interval,
|
---|
| 521 | String &srcname,
|
---|
| 522 | String &fieldname,
|
---|
[2289] | 523 | Vector<Float> &spectra,
|
---|
| 524 | Vector<uChar> &flagtra,
|
---|
| 525 | Vector<Float> &tsys,
|
---|
| 526 | Vector<Double> &direction,
|
---|
[1757] | 527 | Float &azimuth,
|
---|
| 528 | Float &elevation,
|
---|
| 529 | Float ¶ngle,
|
---|
| 530 | Float &opacity,
|
---|
| 531 | uInt &tcalid,
|
---|
| 532 | Int &fitid,
|
---|
| 533 | uInt &focusid,
|
---|
| 534 | Float &temperature,
|
---|
| 535 | Float &pressure,
|
---|
| 536 | Float &humidity,
|
---|
| 537 | Float &windvel,
|
---|
| 538 | Float &winddir,
|
---|
| 539 | Double &srcvel,
|
---|
[2289] | 540 | Vector<Double> &propermotion,
|
---|
[1757] | 541 | Vector<Double> &srcdir,
|
---|
[2289] | 542 | Vector<Double> &scanrate )
|
---|
[1757] | 543 | {
|
---|
[2289] | 544 | static const IPosition oneByOne( 1, 1 );
|
---|
| 545 |
|
---|
[1757] | 546 | // DEBUG
|
---|
| 547 | //cout << "NROReader::getScanInfo() irow = " << irow << endl ;
|
---|
| 548 | //
|
---|
| 549 | NRODataRecord *record = dataset_->getRecord( irow ) ;
|
---|
| 550 |
|
---|
| 551 | // scanno
|
---|
| 552 | scanno = (uInt)(record->ISCAN) ;
|
---|
| 553 | //cout << "scanno = " << scanno << endl ;
|
---|
| 554 |
|
---|
| 555 | // cycleno
|
---|
| 556 | cycleno = 0 ;
|
---|
| 557 | //cout << "cycleno = " << cycleno << endl ;
|
---|
| 558 |
|
---|
[2201] | 559 | // beamno and ifno
|
---|
[2158] | 560 | string rxname = dataset_->getRX()[0] ;
|
---|
| 561 | if ( rxname.find("MULT2") != string::npos ) {
|
---|
| 562 | string arryt = string( record->ARRYT ) ;
|
---|
[2201] | 563 | beamno = dataset_->getArrayId( arryt ) ;
|
---|
| 564 | ifno = 0 ;
|
---|
[2158] | 565 | }
|
---|
| 566 | else {
|
---|
| 567 | beamno = 0 ;
|
---|
[2201] | 568 | string arryt = string( record->ARRYT ) ;
|
---|
| 569 | ifno = dataset_->getArrayId( arryt ) ;
|
---|
[2158] | 570 | }
|
---|
[1757] | 571 | //cout << "beamno = " << beamno << endl ;
|
---|
| 572 |
|
---|
| 573 | // polno
|
---|
[2434] | 574 | polno = dataset_->getPolNo( irow ) ;
|
---|
[1757] | 575 | //cout << "polno = " << polno << endl ;
|
---|
| 576 |
|
---|
| 577 | // freqs (for IFNO and FREQ_ID)
|
---|
| 578 | //freqs = getFrequencies( irow ) ;
|
---|
| 579 | freqs = dataset_->getFrequencies( irow ) ;
|
---|
| 580 | //cout << "freqs = [" << freqs[0] << ", " << freqs[1] << ", " << freqs[2] << "]" << endl ;
|
---|
| 581 |
|
---|
| 582 | // restfreq (for MOLECULE_ID)
|
---|
[2289] | 583 | restfreq.resize( oneByOne ) ;
|
---|
| 584 | restfreq[0] = record->FREQ0 ;
|
---|
[1757] | 585 | //cout << "restfreq = " << rf << endl ;
|
---|
| 586 |
|
---|
| 587 | // refbeamno
|
---|
| 588 | refbeamno = 0 ;
|
---|
| 589 | //cout << "refbeamno = " << refbeamno << endl ;
|
---|
| 590 |
|
---|
| 591 | // scantime
|
---|
[2156] | 592 | //scantime = Double( dataset_->getStartIntTime( irow ) ) ;
|
---|
| 593 | scantime = Double( dataset_->getScanTime( irow ) ) ;
|
---|
[1757] | 594 | //cout << "scantime = " << scantime << endl ;
|
---|
| 595 |
|
---|
| 596 | // interval
|
---|
| 597 | interval = Double( dataset_->getIPTIM() ) ;
|
---|
| 598 | //cout << "interval = " << interval << endl ;
|
---|
| 599 |
|
---|
| 600 | // srcname
|
---|
| 601 | srcname = String( dataset_->getOBJ() ) ;
|
---|
| 602 | //cout << "srcname = " << srcname << endl ;
|
---|
| 603 |
|
---|
| 604 | // fieldname
|
---|
| 605 | fieldname = String( dataset_->getOBJ() ) ;
|
---|
| 606 | //cout << "fieldname = " << fieldname << endl ;
|
---|
| 607 |
|
---|
| 608 | // spectra
|
---|
| 609 | vector<double> spec = dataset_->getSpectrum( irow ) ;
|
---|
[2289] | 610 | spectra.resize( spec.size() ) ;
|
---|
[1757] | 611 | int index = 0 ;
|
---|
[2643] | 612 | Bool b ;
|
---|
| 613 | Float *fp = spectra.getStorage( b ) ;
|
---|
| 614 | Float *wp = fp ;
|
---|
| 615 | for ( vector<double>::iterator i = spec.begin() ;
|
---|
| 616 | i != spec.end() ; i++ ) {
|
---|
| 617 | *wp = *i ;
|
---|
| 618 | wp++ ;
|
---|
[1757] | 619 | }
|
---|
[2643] | 620 | spectra.putStorage( fp, b ) ;
|
---|
[1757] | 621 | //cout << "spec.size() = " << spec.size() << endl ;
|
---|
| 622 |
|
---|
| 623 | // flagtra
|
---|
[2489] | 624 | bool setValue = !( flagtra.nelements() == spectra.nelements() ) ;
|
---|
| 625 | if ( setValue ) {
|
---|
| 626 | //cout << "flagtra resized. reset values..." << endl ;
|
---|
[2643] | 627 | flagtra.resize( spectra.nelements() ) ;
|
---|
[2489] | 628 | flagtra.set( 0 ) ;
|
---|
| 629 | }
|
---|
[1757] | 630 | //cout << "flag.size() = " << flag.size() << endl ;
|
---|
| 631 |
|
---|
| 632 | // tsys
|
---|
[2289] | 633 | tsys.resize( oneByOne ) ;
|
---|
| 634 | tsys[0] = record->TSYS ;
|
---|
[1757] | 635 | //cout << "tsys[0] = " << tsys[0] << endl ;
|
---|
| 636 |
|
---|
| 637 | // direction
|
---|
| 638 | direction = getDirection( irow ) ;
|
---|
| 639 | //cout << "direction = [" << direction[0] << ", " << direction[1] << "]" << endl ;
|
---|
| 640 |
|
---|
| 641 | // azimuth
|
---|
| 642 | azimuth = record->RAZ ;
|
---|
| 643 | //cout << "azimuth = " << azimuth << endl ;
|
---|
| 644 |
|
---|
| 645 | // elevation
|
---|
| 646 | elevation = record->REL ;
|
---|
| 647 | //cout << "elevation = " << elevation << endl ;
|
---|
| 648 |
|
---|
| 649 | // parangle
|
---|
| 650 | parangle = 0.0 ;
|
---|
| 651 | //cout << "parangle = " << parangle << endl ;
|
---|
| 652 |
|
---|
| 653 | // opacity
|
---|
| 654 | opacity = 0.0 ;
|
---|
| 655 | //cout << "opacity = " << opacity << endl ;
|
---|
| 656 |
|
---|
| 657 | // tcalid
|
---|
| 658 | tcalid = 0 ;
|
---|
| 659 | //cout << "tcalid = " << tcalid << endl ;
|
---|
| 660 |
|
---|
| 661 | // fitid
|
---|
| 662 | fitid = -1 ;
|
---|
| 663 | //cout << "fitid = " << fitid << endl ;
|
---|
| 664 |
|
---|
| 665 | // focusid
|
---|
| 666 | focusid = 0 ;
|
---|
| 667 | //cout << "focusid = " << focusid << endl ;
|
---|
| 668 |
|
---|
| 669 | // temperature (for WEATHER_ID)
|
---|
| 670 | temperature = Float( record->TEMP ) ;
|
---|
| 671 | //cout << "temperature = " << temperature << endl ;
|
---|
| 672 |
|
---|
| 673 | // pressure (for WEATHER_ID)
|
---|
| 674 | pressure = Float( record->PATM ) ;
|
---|
| 675 | //cout << "pressure = " << pressure << endl ;
|
---|
| 676 |
|
---|
| 677 | // humidity (for WEATHER_ID)
|
---|
| 678 | humidity = Float( record->PH2O ) ;
|
---|
| 679 | //cout << "humidity = " << humidity << endl ;
|
---|
| 680 |
|
---|
| 681 | // windvel (for WEATHER_ID)
|
---|
| 682 | windvel = Float( record->VWIND ) ;
|
---|
| 683 | //cout << "windvel = " << windvel << endl ;
|
---|
| 684 |
|
---|
| 685 | // winddir (for WEATHER_ID)
|
---|
| 686 | winddir = Float( record->DWIND ) ;
|
---|
| 687 | //cout << "winddir = " << winddir << endl ;
|
---|
| 688 |
|
---|
| 689 | // srcvel
|
---|
| 690 | srcvel = dataset_->getURVEL() ;
|
---|
| 691 | //cout << "srcvel = " << srcvel << endl ;
|
---|
| 692 |
|
---|
| 693 | // propermotion
|
---|
[2289] | 694 | // do nothing
|
---|
[1757] | 695 |
|
---|
| 696 | // srcdir
|
---|
| 697 | srcdir = getSourceDirection() ;
|
---|
| 698 | //cout << "srcdir = [" << srcdir[0] << ", " << srcdir[1] << endl ;
|
---|
| 699 |
|
---|
| 700 | // scanrate
|
---|
[2289] | 701 | // do nothing
|
---|
[1757] | 702 |
|
---|
| 703 | return 0 ;
|
---|
| 704 | }
|
---|
| 705 |
|
---|
| 706 | Int NROReader::getRowNum()
|
---|
| 707 | {
|
---|
| 708 | return dataset_->getRowNum() ;
|
---|
| 709 | }
|
---|