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

Last change on this file since 2763 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
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>
[1757]44#include <atnf/PKSIO/NRODataRecord.h>
45#include <casa/namespace.h>
[2436]46#include <casa/iomanip.h>
[1757]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
[2748]84 NRODataset( std::string name ) ;
[1757]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
[2748]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 ; } ;
[1757]113 int getARYNM() { return ARYNM ; } ;
114 int getNSCAN() { return NSCAN ; } ;
[2748]115 std::string getTITLE() { return TITLE ; } ;
116 std::string getOBJ() { return OBJ ; } ;
117 std::string getEPOCH() { return EPOCH ; } ;
[1757]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 ; } ;
[2748]124 std::string getSCMOD() { return SCMOD ; } ;
[1757]125 double getURVEL() { return URVEL ; } ;
[2748]126 std::string getVREF() { return VREF ; } ;
127 std::string getVDEF() { return VDEF ; } ;
128 std::string getSWMOD() { return SWMOD ; } ;
[1757]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 ; } ;
[2748]137 std::string getCMTTM() { return CMTTM ; } ;
[1757]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 ; } ;
[2748]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 ;} ;
[1757]184 int getDataSize() { return datasize_ ; } ;
185 int getRowNum() { return rowNum_ ; } ;
186
187 // get various parameters
188 NRODataRecord *getRecord( int i ) ;
[2748]189 virtual std::vector< std::vector<double> > getSpectrum() ;
190 virtual std::vector<double> getSpectrum( int i ) ;
[1757]191 virtual int getIndex( int irow ) ;
192 virtual int getPolarizationNum() ;
[2748]193 virtual std::vector<double> getStartIntTime() ;
[1757]194 virtual double getStartIntTime( int i ) ;
[2156]195 virtual double getScanTime( int i ) ;
[1757]196 virtual double getMJD( char *time ) ;
[2748]197 virtual std::vector<bool> getIFs() ;
198 virtual std::vector<double> getFrequencies( int i ) ;
199 virtual uInt getArrayId( std::string type ) ;
[2434]200 virtual uInt getPolNo( int irow ) ;
[1757]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
[1868]236 // convert frequency frame
237 virtual double toLSR( double v, double t, double x, double y ) ;
238
[2434]239 // POLNO from RX
[2748]240 //uInt polNoFromRX( const char *rx ) ;
241 uInt polNoFromRX( const std::string &rx ) ;
[2434]242
[1757]243 // Type of file record
[2748]244 std::string LOFIL ;
[1757]245
246 // Version
[2748]247 std::string VER ;
[1757]248
249 // Group name
[2748]250 std::string GROUP ;
[1757]251
252 // Project name
[2748]253 std::string PROJ ;
[1757]254
255 // Name of observation scheduling file
[2748]256 std::string SCHED ;
[1757]257
258 // Name of observer
[2748]259 std::string OBSVR ;
[1757]260
261 // Observation start time with format of "YYYYMMDDHHMMSS" (UTC)
[2748]262 std::string LOSTM ;
[1757]263
264 // observation end time with format of "YYYYMMDDHHMMSS" (UTC)
[2748]265 std::string LOETM ;
[1757]266
267 // Number of arrays (beams and IFs)
268 int ARYNM ;
269
270 // Number of scans
271 int NSCAN ;
272
273 // Title of observation
[2748]274 std::string TITLE ;
[1757]275
276 // Name of target object
[2748]277 std::string OBJ ;
[1757]278
279 // Equinox (B1950 or J2000)
[2748]280 std::string EPOCH ;
[1757]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
[2748]301 std::string SCMOD ;
[1757]302
303 // User-defined recessional velocity [m/s]
304 double URVEL ;
305
306 // Reference frame for recessional velocity (LSR or HEL or GAL)
[2748]307 std::string VREF ;
[1757]308
309 // Definition of recessional velocity (RAD or OPT)
[2748]310 std::string VDEF ;
[1757]311
312 // Switching mode (POS or BEAM or FREQ)
[2748]313 std::string SWMOD ;
[1757]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
[2748]340 std::string CMTTM ;
[1757]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)
[2748]391 std::string SITE ;
[1757]392
393 // Dummy data
[2748]394 std::string CDMY1 ;
[1757]395
396 // Type of detector frontend
[2748]397 std::vector<std::string> RX ;
[1757]398
399 // HPBW [rad]
[2748]400 std::vector<double> HPBW ;
[1757]401
402 // Aperture efficiencies
[2748]403 std::vector<double> EFFA ;
[1757]404
405 // Beam efficiencies
[2748]406 std::vector<double> EFFB ;
[1757]407
408 // Antenna efficiencies
[2748]409 std::vector<double> EFFL ;
[1757]410
411 // FSS efficiencies
[2748]412 std::vector<double> EFSS ;
[1757]413
414 // Antenna gain
[2748]415 std::vector<double> GAIN ;
[1757]416
417 // Type of polarization at feed horn (R or L or H or V)
[2748]418 std::vector<std::string> HORN ;
[1757]419
420 // Type of polarization (CIRC or LINR)
[2748]421 std::vector<std::string> POLTP ;
[1757]422
423 // Rotation direction of circular polarization
[2748]424 std::vector<double> POLDR ;
[1757]425
426 // Polarization angle of linear polarization
[2748]427 std::vector<double> POLAN ;
[1757]428
429 // Switching frequency of frequcency switching [Hz]
[2748]430 std::vector<double> DFRQ ;
[1757]431
432 // Type of sideband (LSB or USB or DSB)
[2748]433 std::vector<std::string> SIDBD ;
[1757]434
435 // Identifier of reference synthesizer
[2748]436 std::vector<int> REFN ;
[1757]437
438 // Temperature of calibrator
[2748]439 std::vector<int> IPINT ;
[1757]440
441 // Beam id of the multi-beam detector
[2748]442 std::vector<int> MULTN ;
[1757]443
444 // Scaling factor of the multi-beam detector
[2748]445 std::vector<double> MLTSCF ;
[1757]446
447 // Type of LAG window (NONE or HANN or HAMM or BLCK)
[2748]448 std::vector<std::string> LAGWIND ;
[1757]449
450 // Bandwidth at backend
[2748]451 std::vector<double> BEBW ;
[1757]452
453 // Spectral resolution at backend
[2748]454 std::vector<double> BERES ;
[1757]455
456 // Channel width at backend
[2748]457 std::vector<double> CHWID ;
[1757]458
459 // Array usage (1: used 0: not used)
[2748]460 std::vector<int> ARRY ;
[1757]461
462 // Frequency calibration: Number of measurement (max 10)
[2748]463 std::vector<int> NFCAL ;
[1757]464
465 // Frequency calibration: Central frequency [Hz]
[2748]466 std::vector<double> F0CAL ;
[1757]467
468 // Frequency calibration: Measured central frequency [Hz]
[2748]469 std::vector< std::vector<double> > FQCAL ;
[1757]470
471 // Frequency calibration: Measured channel number
[2748]472 std::vector< std::vector<double> > CHCAL ;
[1757]473
474 // Frequency calibration: Measured channel width [Hz]
[2748]475 std::vector< std::vector<double> > CWCAL ;
[1757]476
477 // DSB scaling factor
[2748]478 std::vector<double> DSBFC ;
[1757]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
[2748]505 std::string filename_ ;
[1757]506
507 // file pointer
508 FILE *fp_ ;
509
510 // OS endian
511 int same_ ;
512
513 // Logger
514 //LogIO os ;
[1868]515
516 // reference frequency for each array
[2748]517 std::vector<double> refFreq_ ;
[2198]518
519 // record to store REFPIX, REFVAL, INCREMENT pair for each array
520 Record frec_ ;
[1757]521} ;
522
[2436]523// debug message output
[2748]524template<class T> inline void nro_debug_output( char *name, int len, std::vector<T> &val )
[2436]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}
[1757]537
[2748]538template<class T> inline void nro_debug_output( char *name, int len1, int len2, std::vector< std::vector<T> > &val )
[2436]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
[1757]558#endif /* NRO_HEADER_H */
Note: See TracBrowser for help on using the repository browser.