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

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

POLNO is properly set according to RX name. When RX name ends with 'V'
or is 'H20ch2', POLNO will be set to 1. Otherwise, POLNO is 0.


File size: 14.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 std::string getLOFIL() { return LOFIL ; } ;
106 std::string getVER() { return VER ; } ;
107 std::string getGROUP() { return GROUP ; } ;
108 std::string getPROJ() { return PROJ ; } ;
109 std::string getSCHED() { return SCHED ; } ;
110 std::string getOBSVR() { return OBSVR ; } ;
111 std::string getLOSTM() { return LOSTM ; } ;
112 std::string getLOETM() { return LOETM ; } ;
113 int getARYNM() { return ARYNM ; } ;
114 int getNSCAN() { return NSCAN ; } ;
115 std::string getTITLE() { return TITLE ; } ;
116 std::string getOBJ() { return OBJ ; } ;
117 std::string getEPOCH() { return EPOCH ; } ;
118 double getRA0() { return RA0 ; } ;
119 double getDEC0() { return DEC0 ; } ;
120 double getGLNG0() { return GLNG0 ; } ;
121 double getGLAT0() { return GLAT0 ; } ;
122 int getNCALB() { return NCALB ; } ;
123 int getSCNCD() { return SCNCD ; } ;
124 std::string getSCMOD() { return SCMOD ; } ;
125 double getURVEL() { return URVEL ; } ;
126 std::string getVREF() { return VREF ; } ;
127 std::string getVDEF() { return VDEF ; } ;
128 std::string getSWMOD() { return SWMOD ; } ;
129 double getFRQSW() { return FRQSW ; } ;
130 double getDBEAM() { return DBEAM ; } ;
131 double getMLTOF() { return MLTOF ; } ;
132 double getCMTQ() { return CMTQ ; } ;
133 double getCMTE() { return CMTE ; } ;
134 double getCMTSOM() { return CMTSOM ; } ;
135 double getCMTNODE() { return CMTNODE ; } ;
136 double getCMTI() { return CMTI ; } ;
137 std::string getCMTTM() { return CMTTM ; } ;
138 double getSBDX() { return SBDX ; } ;
139 double getSBDY() { return SBDY ; } ;
140 double getSBDZ1() { return SBDZ1 ; } ;
141 double getSBDZ2() { return SBDZ2 ; } ;
142 double getDAZP() { return DAZP ; } ;
143 double getDELP() { return DELP ; } ;
144 int getCHBIND() { return CHBIND ; } ;
145 int getNUMCH() { return NUMCH ; } ;
146 int getCHMIN() { return CHMIN ; } ;
147 int getCHMAX() { return CHMAX ; } ;
148 double getALCTM() { return ALCTM ; } ;
149 double getIPTIM() { return IPTIM ; } ;
150 double getPA() { return PA ; } ;
151 int getSCNLEN() { return SCNLEN ; } ;
152 int getSBIND() { return SBIND ; } ;
153 int getIBIT() { return IBIT ; } ;
154 std::string getSITE() { return SITE ; } ;
155 std::vector<std::string> getRX() { return RX ; } ;
156 std::vector<double> getHPBW() { return HPBW ; } ;
157 std::vector<double> getEFFA() { return EFFA ; } ;
158 std::vector<double> getEFFB() { return EFFB ; } ;
159 std::vector<double> getEFFL() { return EFFL ; } ;
160 std::vector<double> getEFSS() { return EFSS ; } ;
161 std::vector<double> getGAIN() { return GAIN ; } ;
162 std::vector<std::string> getHORN() { return HORN ; } ;
163 std::vector<std::string> getPOLTP() { return POLTP ; } ;
164 std::vector<double> getPOLDR() { return POLDR ; } ;
165 std::vector<double> getPOLAN() { return POLAN ; } ;
166 std::vector<double> getDFRQ() { return DFRQ ; } ;
167 std::vector<std::string> getSIDBD() { return SIDBD ; } ;
168 std::vector<int> getREFN() { return REFN ; } ;
169 std::vector<int> getIPINT() { return IPINT ; } ;
170 std::vector<int> getMULTN() { return MULTN ; } ;
171 std::vector<double> getMLTSCF() { return MLTSCF ; } ;
172 std::vector<std::string> getLAGWIND() { return LAGWIND ; } ;
173 std::vector<double> getBEBW() { return BEBW ; } ;
174 std::vector<double> getBERES() { return BERES ; } ;
175 std::vector<double> getCHWID() { return CHWID ; } ;
176 std::vector<int> getARRY() { return ARRY ; } ;
177 std::vector<int> getNFCAL() { return NFCAL ; } ;
178 std::vector<double> getF0CAL() { return F0CAL ; } ;
179 std::vector< std::vector<double> > getFQCAL() { return FQCAL ; } ;
180 std::vector< std::vector<double> > getCHCAL() { return CHCAL ; } ;
181 std::vector< std::vector<double> > getCWCAL() { return CWCAL ; } ;
182 std::string getCDMY1() { return CDMY1 ; } ;
183 std::vector<double> getDSBFC() { return DSBFC ;} ;
184 int getDataSize() { return datasize_ ; } ;
185 int getRowNum() { 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.