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

Last change on this file since 2435 was 2434, checked in by Takeshi Nakazato, 13 years ago

New Development: No

JIRA Issue: Yes CAS-3345

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: import T100H/V data

Put in Release Notes: No

Module(s): Module Names change impacts.

Description: Describe your changes here...

POLNO is properly handled for T100H/V data while IFNO keeps array number.

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