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

Last change on this file since 2781 was 2781, 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...

Support SAM45 OTF data that is slightly different definition on
number of scans in the data (whether includes ZERO or not).


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