source: trunk/external-alma/atnf/PKSIO/NROReader.cc@ 3077

Last change on this file since 3077 was 3066, checked in by Takeshi Nakazato, 9 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes/No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...


Make NRO reader classes warning free.

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