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