source: trunk/external-alma/atnf/PKSIO/NRODataset.h@ 2765

Last change on this file since 2765 was 2764, checked in by Takeshi Nakazato, 12 years ago

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: 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...

Doppler keyword in FREQUENCIES subtable is taken from VREF keyword
in NRO data.


File size: 15.9 KB
Line 
1//#---------------------------------------------------------------------------
2//# NRODataset.h: Base class for NRO dataset.
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: 2009/02/27, Takeshi Nakazato, NAOJ
31//#---------------------------------------------------------------------------
32
33#ifndef NRO_DATASET_H
34#define NRO_DATASET_H
35
36#include <string>
37#include <stdio.h>
38#include <vector>
39#include <iostream>
40
41//#include <casa/aips.h>
42#include <casa/Logging/LogIO.h>
43#include <casa/Containers/Record.h>
44#include <atnf/PKSIO/NRODataRecord.h>
45#include <casa/namespace.h>
46#include <casa/iomanip.h>
47
48#define SCAN_HEADER_SIZE 424
49
50// <summary>
51// Base class for NRO accessor classes.
52// </summary>
53//
54// <prerequisite>
55// <li> <linkto class=NROReader>NROReader</linkto>
56// <li> <linkto class=NRODataRecord>NRODataRecord</linkto>
57// </prerequisite>
58//
59// <reviewed reviewer="" date="" tests="" demos="">
60// </reviewed>
61//
62// <etymology>
63// This class is a base class for classes that actually access data from NRO telescopes.
64// Concrete classes are defiened for each data type (OTF format or NRO FITS) and/or
65// telescopes (45m or ASTE).
66// The class have two filler method: fillHeader and fillRecord. The former reads header
67// information from the data. Since header data depends on the telescope and its configuration,
68// it is an abstract in this class and is defined in each concrete class.
69// On the other hand, the later reads each scan record (set of meta data
70// and spectral data). The method uses <linkto class=NRODataRecord>NRODataRecord</linkto>
71// to access scan record. It is implemented here since contents of scan record is
72// quite similar for several types of data.
73// </etymology>
74//
75// <synopsis>
76// Abstract class that is designed as a base class for all accessor classes.
77// </synopsis>
78//
79
80class NRODataset
81{
82 public:
83 // Constructor
84 NRODataset( std::string name ) ;
85
86 // Destructor
87 virtual ~NRODataset() ;
88
89 // Data initialization
90 virtual void initialize() ;
91
92 // open file
93 virtual int open() ;
94
95 // close file
96 virtual void close() ;
97
98 // Fill data header from file
99 virtual int fillHeader() = 0 ;
100
101 // Fill data record
102 virtual int fillRecord( int i ) ;
103
104 // simple getter
105 const std::string getLOFIL() const { return LOFIL ; } ;
106 const std::string getVER() const { return VER ; } ;
107 const std::string getGROUP() const { return GROUP ; } ;
108 const std::string getPROJ() const { return PROJ ; } ;
109 const std::string getSCHED() const { return SCHED ; } ;
110 const std::string getOBSVR() const { return OBSVR ; } ;
111 const std::string getLOSTM() const { return LOSTM ; } ;
112 const std::string getLOETM() const { return LOETM ; } ;
113 const int getARYNM() const { return ARYNM ; } ;
114 const int getNSCAN() const { return NSCAN ; } ;
115 const std::string getTITLE() const { return TITLE ; } ;
116 const std::string getOBJ() const { return OBJ ; } ;
117 const std::string getEPOCH() const { return EPOCH ; } ;
118 const double getRA0() const { return RA0 ; } ;
119 const double getDEC0() const { return DEC0 ; } ;
120 const double getGLNG0() const { return GLNG0 ; } ;
121 const double getGLAT0() const { return GLAT0 ; } ;
122 const int getNCALB() const { return NCALB ; } ;
123 const int getSCNCD() const { return SCNCD ; } ;
124 const std::string getSCMOD() const { return SCMOD ; } ;
125 const double getURVEL() const { return URVEL ; } ;
126 const std::string getVREF() const { return VREF ; } ;
127 const std::string getVDEF() const { return VDEF ; } ;
128 const std::string getSWMOD() const { return SWMOD ; } ;
129 const double getFRQSW() const { return FRQSW ; } ;
130 const double getDBEAM() const { return DBEAM ; } ;
131 const double getMLTOF() const { return MLTOF ; } ;
132 const double getCMTQ() const { return CMTQ ; } ;
133 const double getCMTE() const { return CMTE ; } ;
134 const double getCMTSOM() const { return CMTSOM ; } ;
135 const double getCMTNODE() const { return CMTNODE ; } ;
136 const double getCMTI() const { return CMTI ; } ;
137 const std::string getCMTTM() const { return CMTTM ; } ;
138 const double getSBDX() const { return SBDX ; } ;
139 const double getSBDY() const { return SBDY ; } ;
140 const double getSBDZ1() const { return SBDZ1 ; } ;
141 const double getSBDZ2() const { return SBDZ2 ; } ;
142 const double getDAZP() const { return DAZP ; } ;
143 const double getDELP() const { return DELP ; } ;
144 const int getCHBIND() const { return CHBIND ; } ;
145 const int getNUMCH() const { return NUMCH ; } ;
146 const int getCHMIN() const { return CHMIN ; } ;
147 const int getCHMAX() const { return CHMAX ; } ;
148 const double getALCTM() const { return ALCTM ; } ;
149 const double getIPTIM() const { return IPTIM ; } ;
150 const double getPA() const { return PA ; } ;
151 const int getSCNLEN() const { return SCNLEN ; } ;
152 const int getSBIND() const { return SBIND ; } ;
153 const int getIBIT() const { return IBIT ; } ;
154 const std::string getSITE() const { return SITE ; } ;
155 const std::vector<std::string> getRX() const { return RX ; } ;
156 const std::vector<double> getHPBW() const { return HPBW ; } ;
157 const std::vector<double> getEFFA() const { return EFFA ; } ;
158 const std::vector<double> getEFFB() const { return EFFB ; } ;
159 const std::vector<double> getEFFL() const { return EFFL ; } ;
160 const std::vector<double> getEFSS() const { return EFSS ; } ;
161 const std::vector<double> getGAIN() const { return GAIN ; } ;
162 const std::vector<std::string> getHORN() const { return HORN ; } ;
163 const std::vector<std::string> getPOLTP() const { return POLTP ; } ;
164 const std::vector<double> getPOLDR() const { return POLDR ; } ;
165 const std::vector<double> getPOLAN() const { return POLAN ; } ;
166 const std::vector<double> getDFRQ() const { return DFRQ ; } ;
167 const std::vector<std::string> getSIDBD() const { return SIDBD ; } ;
168 const std::vector<int> getREFN() const { return REFN ; } ;
169 const std::vector<int> getIPINT() const { return IPINT ; } ;
170 const std::vector<int> getMULTN() const { return MULTN ; } ;
171 const std::vector<double> getMLTSCF() const { return MLTSCF ; } ;
172 const std::vector<std::string> getLAGWIND() const { return LAGWIND ; } ;
173 const std::vector<double> getBEBW() const { return BEBW ; } ;
174 const std::vector<double> getBERES() const { return BERES ; } ;
175 const std::vector<double> getCHWID() const { return CHWID ; } ;
176 const std::vector<int> getARRY() const { return ARRY ; } ;
177 const std::vector<int> getNFCAL() const { return NFCAL ; } ;
178 const std::vector<double> getF0CAL() const { return F0CAL ; } ;
179 const std::vector< std::vector<double> > getFQCAL() const { return FQCAL ; } ;
180 const std::vector< std::vector<double> > getCHCAL() const { return CHCAL ; } ;
181 const std::vector< std::vector<double> > getCWCAL() const { return CWCAL ; } ;
182 const std::string getCDMY1() const { return CDMY1 ; } ;
183 const std::vector<double> getDSBFC() const { return DSBFC ;} ;
184 const int getDataSize() const { return datasize_ ; } ;
185 const int getRowNum() const { return rowNum_ ; } ;
186
187 // get various parameters
188 NRODataRecord *getRecord( int i ) ;
189 virtual std::vector< std::vector<double> > getSpectrum() ;
190 virtual std::vector<double> getSpectrum( int i ) ;
191 virtual int getIndex( int irow ) ;
192 virtual int getPolarizationNum() ;
193 virtual std::vector<double> getStartIntTime() ;
194 virtual double getStartIntTime( int i ) ;
195 virtual double getScanTime( int i ) ;
196 virtual double getMJD( char *time ) ;
197 virtual std::vector<bool> getIFs() ;
198 virtual std::vector<double> getFrequencies( int i ) ;
199 virtual uInt getArrayId( std::string type ) ;
200 virtual uInt getPolNo( int irow ) ;
201
202 protected:
203 // fill header information
204 virtual int fillHeader( int sameEndian ) = 0 ;
205
206 // Endian conversion for int variable
207 void convertEndian( int &value ) ;
208
209 // Endian convertion for float variable
210 void convertEndian( float &value ) ;
211
212 // Endian conversion for double variable
213 void convertEndian( double &value ) ;
214
215 // Endian conversion for NRODataRecord
216 void convertEndian( NRODataRecord *r ) ;
217
218 // Read char data
219 int readHeader( char *v, int size ) ;
220
221 // Read int data
222 int readHeader( int &v, int b ) ;
223
224 // Read float data
225 int readHeader( float &v, int b ) ;
226
227 // Read double data
228 int readHeader( double &v, int b ) ;
229
230 // Release DataRecord
231 void releaseRecord() ;
232
233 // show primary information
234 void show() ;
235
236 // convert frequency frame
237 virtual double toLSR( double v, double t, double x, double y ) ;
238
239 // POLNO from RX
240 //uInt polNoFromRX( const char *rx ) ;
241 uInt polNoFromRX( const std::string &rx ) ;
242
243 // Type of file record
244 std::string LOFIL ;
245
246 // Version
247 std::string VER ;
248
249 // Group name
250 std::string GROUP ;
251
252 // Project name
253 std::string PROJ ;
254
255 // Name of observation scheduling file
256 std::string SCHED ;
257
258 // Name of observer
259 std::string OBSVR ;
260
261 // Observation start time with format of "YYYYMMDDHHMMSS" (UTC)
262 std::string LOSTM ;
263
264 // observation end time with format of "YYYYMMDDHHMMSS" (UTC)
265 std::string LOETM ;
266
267 // Number of arrays (beams and IFs)
268 int ARYNM ;
269
270 // Number of scans
271 int NSCAN ;
272
273 // Title of observation
274 std::string TITLE ;
275
276 // Name of target object
277 std::string OBJ ;
278
279 // Equinox (B1950 or J2000)
280 std::string EPOCH ;
281
282 // Right ascension [rad]
283 double RA0 ;
284
285 // Declination [rad]
286 double DEC0 ;
287
288 // Galactic longitude [rad]
289 double GLNG0 ;
290
291 // Galactic latitude [rad]
292 double GLAT0 ;
293
294 // Calibration interval
295 int NCALB ;
296
297 // Scan coordinate (0: RADEC 1: LB 2: AZEL)
298 int SCNCD ;
299
300 // Scan sequence pattern
301 std::string SCMOD ;
302
303 // User-defined recessional velocity [m/s]
304 double URVEL ;
305
306 // Reference frame for recessional velocity (LSR or HEL or GAL)
307 std::string VREF ;
308
309 // Definition of recessional velocity (RAD or OPT)
310 std::string VDEF ;
311
312 // Switching mode (POS or BEAM or FREQ)
313 std::string SWMOD ;
314
315 // Switching frequency [Hz]
316 double FRQSW ;
317
318 // Off-beam angle of beam switching [rad]
319 double DBEAM ;
320
321 // Initial inclination angle of multi-beam array
322 double MLTOF ;
323
324 // Comet: Perihelion distance
325 double CMTQ ;
326
327 // Comet: Eccentricity
328 double CMTE ;
329
330 // Comet: Argument of perihelion
331 double CMTSOM ;
332
333 // Comet: Longitude of the ascending node
334 double CMTNODE ;
335
336 // Comet: Orbital inclination angle
337 double CMTI ;
338
339 // Comet: Time of the perihelion passage
340 std::string CMTTM ;
341
342 // Correction for position of subreflector DX [mm]
343 double SBDX ;
344
345 // Correction for position of subreflector DY [mm]
346 double SBDY ;
347
348 // Correction for position of subreflector DZ1 [mm]
349 double SBDZ1 ;
350
351 // Correction for position of subreflector DZ2 [mm]
352 double SBDZ2 ;
353
354 // Correction for pointing on azimuth [rad]
355 double DAZP ;
356
357 // Correction for pointing on elevation [rad]
358 double DELP ;
359
360 // Number of channel binding
361 int CHBIND ;
362
363 // Number of channel after binding
364 int NUMCH ;
365
366 // Channel range (minimum)
367 int CHMIN ;
368
369 // Channel range (maximum)
370 int CHMAX ;
371
372 // ALC time constant
373 double ALCTM ;
374
375 // Interval to get data from spectrometer
376 double IPTIM ;
377
378 // Position angle of the map
379 double PA ;
380
381 // Length of scan record [bytes]
382 int SCNLEN ;
383
384 // Range of space binding
385 int SBIND ;
386
387 // Quantization bit number (fixed to 12)
388 int IBIT ;
389
390 // Site (antenna) name (45m or ASTE)
391 std::string SITE ;
392
393 // Dummy data
394 std::string CDMY1 ;
395
396 // Type of detector frontend
397 std::vector<std::string> RX ;
398
399 // HPBW [rad]
400 std::vector<double> HPBW ;
401
402 // Aperture efficiencies
403 std::vector<double> EFFA ;
404
405 // Beam efficiencies
406 std::vector<double> EFFB ;
407
408 // Antenna efficiencies
409 std::vector<double> EFFL ;
410
411 // FSS efficiencies
412 std::vector<double> EFSS ;
413
414 // Antenna gain
415 std::vector<double> GAIN ;
416
417 // Type of polarization at feed horn (R or L or H or V)
418 std::vector<std::string> HORN ;
419
420 // Type of polarization (CIRC or LINR)
421 std::vector<std::string> POLTP ;
422
423 // Rotation direction of circular polarization
424 std::vector<double> POLDR ;
425
426 // Polarization angle of linear polarization
427 std::vector<double> POLAN ;
428
429 // Switching frequency of frequcency switching [Hz]
430 std::vector<double> DFRQ ;
431
432 // Type of sideband (LSB or USB or DSB)
433 std::vector<std::string> SIDBD ;
434
435 // Identifier of reference synthesizer
436 std::vector<int> REFN ;
437
438 // Temperature of calibrator
439 std::vector<int> IPINT ;
440
441 // Beam id of the multi-beam detector
442 std::vector<int> MULTN ;
443
444 // Scaling factor of the multi-beam detector
445 std::vector<double> MLTSCF ;
446
447 // Type of LAG window (NONE or HANN or HAMM or BLCK)
448 std::vector<std::string> LAGWIND ;
449
450 // Bandwidth at backend
451 std::vector<double> BEBW ;
452
453 // Spectral resolution at backend
454 std::vector<double> BERES ;
455
456 // Channel width at backend
457 std::vector<double> CHWID ;
458
459 // Array usage (1: used 0: not used)
460 std::vector<int> ARRY ;
461
462 // Frequency calibration: Number of measurement (max 10)
463 std::vector<int> NFCAL ;
464
465 // Frequency calibration: Central frequency [Hz]
466 std::vector<double> F0CAL ;
467
468 // Frequency calibration: Measured central frequency [Hz]
469 std::vector< std::vector<double> > FQCAL ;
470
471 // Frequency calibration: Measured channel number
472 std::vector< std::vector<double> > CHCAL ;
473
474 // Frequency calibration: Measured channel width [Hz]
475 std::vector< std::vector<double> > CWCAL ;
476
477 // DSB scaling factor
478 std::vector<double> DSBFC ;
479
480 // number of scan
481 int scanNum_ ;
482
483 // number of row
484 int rowNum_ ;
485
486 // length of scan (byte)
487 int scanLen_ ;
488
489 // length of spectral data (byte)
490 int dataLen_ ;
491
492 // Data size of the header [bytes]
493 int datasize_ ;
494
495 // maximum channel number
496 int chmax_ ;
497
498 // Current data id
499 int dataid_ ;
500
501 // Data record
502 NRODataRecord *record_ ;
503
504 // input filename
505 std::string filename_ ;
506
507 // file pointer
508 FILE *fp_ ;
509
510 // OS endian
511 int same_ ;
512
513 // Logger
514 //LogIO os ;
515
516 // reference frequency for each array
517 std::vector<double> refFreq_ ;
518
519 // record to store REFPIX, REFVAL, INCREMENT pair for each array
520 Record frec_ ;
521} ;
522
523// debug message output
524template<class T> inline void nro_debug_output( char *name, int len, std::vector<T> &val )
525{
526 for ( int i = 0 ; i < len ; i++ ) {
527 if ( i == 0 ) {
528 cout << setw(8) << left << name ;
529 }
530 else if ( ( i % 5 ) == 0 ) {
531 cout << endl << " " ;
532 }
533 cout << "\'" << val[i] << "\' " ;
534 }
535 cout << endl ;
536}
537
538template<class T> inline void nro_debug_output( char *name, int len1, int len2, std::vector< std::vector<T> > &val )
539{
540 for ( int i = 0 ; i < len1 ; i++ ) {
541 for ( int j = 0 ; j < len2 ; j++ ) {
542 if ( j == 0 ) {
543 if ( i < 10 )
544 cout << name << "0" << i << " " ;
545 else
546 cout << name << i << " " ;
547 }
548 else if ( ( j % 5 ) == 0 ) {
549 cout << endl << " " ;
550 }
551 cout << "\'" << val[i][j] << "\' " ;
552 }
553 cout << endl ;
554 }
555}
556
557
558#endif /* NRO_HEADER_H */
Note: See TracBrowser for help on using the repository browser.