//#--------------------------------------------------------------------------- //# NRODataset.h: Base class for NRO dataset. //#--------------------------------------------------------------------------- //# Copyright (C) 2000-2006 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have received a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id$ //#--------------------------------------------------------------------------- //# Original: 2009/02/27, Takeshi Nakazato, NAOJ //#--------------------------------------------------------------------------- #ifndef NRO_DATASET_H #define NRO_DATASET_H #include #include #include #include //#include #include #include #include #include #include #include #define SCAN_HEADER_SIZE 424 // // Base class for NRO accessor classes. // // // //
  • NROReader //
  • NRODataRecord // // // // // // // This class is a base class for classes that actually access data from NRO telescopes. // Concrete classes are defiened for each data type (OTF format or NRO FITS) and/or // telescopes (45m or ASTE). // The class have two filler method: fillHeader and fillRecord. The former reads header // information from the data. Since header data depends on the telescope and its configuration, // it is an abstract in this class and is defined in each concrete class. // On the other hand, the later reads each scan record (set of meta data // and spectral data). The method uses NRODataRecord // to access scan record. It is implemented here since contents of scan record is // quite similar for several types of data. // // // // Abstract class that is designed as a base class for all accessor classes. // // class NRODataset { public: // Constructor NRODataset( std::string name ) ; // Destructor virtual ~NRODataset() ; // Data initialization virtual void initialize() = 0 ; // open file virtual int open() ; // close file virtual void close() ; // Fill data header from file virtual int fillHeader() ; // Fill data record virtual int fillRecord( int i ) ; // simple getter const std::string getLOFIL() const { return LOFIL ; } ; const std::string getVER() const { return VER ; } ; const std::string getGROUP() const { return GROUP ; } ; const std::string getPROJ() const { return PROJ ; } ; const std::string getSCHED() const { return SCHED ; } ; const std::string getOBSVR() const { return OBSVR ; } ; const std::string getLOSTM() const { return LOSTM ; } ; const std::string getLOETM() const { return LOETM ; } ; const int getARYNM() const { return ARYNM ; } ; const int getNSCAN() const { return NSCAN ; } ; const std::string getTITLE() const { return TITLE ; } ; const std::string getOBJ() const { return OBJ ; } ; const std::string getEPOCH() const { return EPOCH ; } ; const double getRA0() const { return RA0 ; } ; const double getDEC0() const { return DEC0 ; } ; const double getGLNG0() const { return GLNG0 ; } ; const double getGLAT0() const { return GLAT0 ; } ; const int getNCALB() const { return NCALB ; } ; const int getSCNCD() const { return SCNCD ; } ; const std::string getSCMOD() const { return SCMOD ; } ; const double getURVEL() const { return URVEL ; } ; const std::string getVREF() const { return VREF ; } ; const std::string getVDEF() const { return VDEF ; } ; const std::string getSWMOD() const { return SWMOD ; } ; const double getFRQSW() const { return FRQSW ; } ; const double getDBEAM() const { return DBEAM ; } ; const double getMLTOF() const { return MLTOF ; } ; const double getCMTQ() const { return CMTQ ; } ; const double getCMTE() const { return CMTE ; } ; const double getCMTSOM() const { return CMTSOM ; } ; const double getCMTNODE() const { return CMTNODE ; } ; const double getCMTI() const { return CMTI ; } ; const std::string getCMTTM() const { return CMTTM ; } ; const double getSBDX() const { return SBDX ; } ; const double getSBDY() const { return SBDY ; } ; const double getSBDZ1() const { return SBDZ1 ; } ; const double getSBDZ2() const { return SBDZ2 ; } ; const double getDAZP() const { return DAZP ; } ; const double getDELP() const { return DELP ; } ; const int getCHBIND() const { return CHBIND ; } ; const int getNUMCH() const { return NUMCH ; } ; const int getCHMIN() const { return CHMIN ; } ; const int getCHMAX() const { return CHMAX ; } ; const double getALCTM() const { return ALCTM ; } ; const double getIPTIM() const { return IPTIM ; } ; const double getPA() const { return PA ; } ; const int getSCNLEN() const { return SCNLEN ; } ; const int getSBIND() const { return SBIND ; } ; const int getIBIT() const { return IBIT ; } ; const std::string getSITE() const { return SITE ; } ; const std::vector getRX() const { return RX ; } ; const std::vector getHPBW() const { return HPBW ; } ; const std::vector getEFFA() const { return EFFA ; } ; const std::vector getEFFB() const { return EFFB ; } ; const std::vector getEFFL() const { return EFFL ; } ; const std::vector getEFSS() const { return EFSS ; } ; const std::vector getGAIN() const { return GAIN ; } ; const std::vector getHORN() const { return HORN ; } ; const std::vector getPOLTP() const { return POLTP ; } ; const std::vector getPOLDR() const { return POLDR ; } ; const std::vector getPOLAN() const { return POLAN ; } ; const std::vector getDFRQ() const { return DFRQ ; } ; const std::vector getSIDBD() const { return SIDBD ; } ; const std::vector getREFN() const { return REFN ; } ; const std::vector getIPINT() const { return IPINT ; } ; const std::vector getMULTN() const { return MULTN ; } ; const std::vector getMLTSCF() const { return MLTSCF ; } ; const std::vector getLAGWIND() const { return LAGWIND ; } ; const std::vector getBEBW() const { return BEBW ; } ; const std::vector getBERES() const { return BERES ; } ; const std::vector getCHWID() const { return CHWID ; } ; const std::vector getARRY() const { return ARRY ; } ; const std::vector getNFCAL() const { return NFCAL ; } ; const std::vector getF0CAL() const { return F0CAL ; } ; const std::vector< std::vector > getFQCAL() const { return FQCAL ; } ; const std::vector< std::vector > getCHCAL() const { return CHCAL ; } ; const std::vector< std::vector > getCWCAL() const { return CWCAL ; } ; const std::string getCDMY1() const { return CDMY1 ; } ; const std::vector getDSBFC() const { return DSBFC ;} ; const int getDataSize() const { return datasize_ ; } ; const int getRowNum() const { return rowNum_ ; } ; // get various parameters NRODataRecord *getRecord( int i ) ; virtual std::vector< std::vector > getSpectrum() ; virtual std::vector getSpectrum( int i ) ; virtual int getIndex( int irow ) ; virtual int getPolarizationNum() ; virtual std::vector getStartIntTime() ; virtual double getStartIntTime( int i ) ; virtual double getScanTime( int i ) ; virtual double getMJD( const char *time ) ; virtual std::vector getIFs() ; virtual std::vector getFrequencies( int i ) ; virtual uInt getArrayId( std::string type ) ; virtual uInt getSortedArrayId( std::string type ) ; virtual uInt getPolNo( int irow ) ; protected: // initialize common part void initializeCommon() ; // fill header information virtual int fillHeader( int sameEndian ) = 0 ; int fillHeaderCommon( int sameEndian ) ; // Endian conversion for int variable void convertEndian( int &value ) ; // Endian convertion for float variable void convertEndian( float &value ) ; // Endian conversion for double variable void convertEndian( double &value ) ; // Endian conversion for NRODataRecord void convertEndian( NRODataRecord &r ) ; // Read char data int readHeader( char *v, int size ) ; // Read int data int readHeader( int &v, int b ) ; // Read float data int readHeader( float &v, int b ) ; // Read double data int readHeader( double &v, int b ) ; // Release DataRecord void releaseRecord() ; // show primary information void show() ; // convert frequency frame virtual double toLSR( double v, double t, double x, double y ) ; // POLNO from RX //uInt polNoFromRX( const char *rx ) ; uInt polNoFromRX( const std::string &rx ) ; // initialize array information (only for OTF data) void initArray(); // return ARRYMAX virtual int arrayMax() {return 0;} ; // get scanNum from NSCAN (NSCAN or NSCAN + 1) int getScanNum(); // Type of file record std::string LOFIL ; // Version std::string VER ; // Group name std::string GROUP ; // Project name std::string PROJ ; // Name of observation scheduling file std::string SCHED ; // Name of observer std::string OBSVR ; // Observation start time with format of "YYYYMMDDHHMMSS" (UTC) std::string LOSTM ; // observation end time with format of "YYYYMMDDHHMMSS" (UTC) std::string LOETM ; // Number of arrays (beams and IFs) int ARYNM ; // Number of scans int NSCAN ; // Title of observation std::string TITLE ; // Name of target object std::string OBJ ; // Equinox (B1950 or J2000) std::string EPOCH ; // Right ascension [rad] double RA0 ; // Declination [rad] double DEC0 ; // Galactic longitude [rad] double GLNG0 ; // Galactic latitude [rad] double GLAT0 ; // Calibration interval int NCALB ; // Scan coordinate (0: RADEC 1: LB 2: AZEL) int SCNCD ; // Scan sequence pattern std::string SCMOD ; // User-defined recessional velocity [m/s] double URVEL ; // Reference frame for recessional velocity (LSR or HEL or GAL) std::string VREF ; // Definition of recessional velocity (RAD or OPT) std::string VDEF ; // Switching mode (POS or BEAM or FREQ) std::string SWMOD ; // Switching frequency [Hz] double FRQSW ; // Off-beam angle of beam switching [rad] double DBEAM ; // Initial inclination angle of multi-beam array double MLTOF ; // Comet: Perihelion distance double CMTQ ; // Comet: Eccentricity double CMTE ; // Comet: Argument of perihelion double CMTSOM ; // Comet: Longitude of the ascending node double CMTNODE ; // Comet: Orbital inclination angle double CMTI ; // Comet: Time of the perihelion passage std::string CMTTM ; // Correction for position of subreflector DX [mm] double SBDX ; // Correction for position of subreflector DY [mm] double SBDY ; // Correction for position of subreflector DZ1 [mm] double SBDZ1 ; // Correction for position of subreflector DZ2 [mm] double SBDZ2 ; // Correction for pointing on azimuth [rad] double DAZP ; // Correction for pointing on elevation [rad] double DELP ; // Number of channel binding int CHBIND ; // Number of channel after binding int NUMCH ; // Channel range (minimum) int CHMIN ; // Channel range (maximum) int CHMAX ; // ALC time constant double ALCTM ; // Interval to get data from spectrometer double IPTIM ; // Position angle of the map double PA ; // Length of scan record [bytes] int SCNLEN ; // Range of space binding int SBIND ; // Quantization bit number (fixed to 12) int IBIT ; // Site (antenna) name (45m or ASTE) std::string SITE ; // Dummy data std::string CDMY1 ; // Type of detector frontend std::vector RX ; // HPBW [rad] std::vector HPBW ; // Aperture efficiencies std::vector EFFA ; // Beam efficiencies std::vector EFFB ; // Antenna efficiencies std::vector EFFL ; // FSS efficiencies std::vector EFSS ; // Antenna gain std::vector GAIN ; // Type of polarization at feed horn (R or L or H or V) std::vector HORN ; // Type of polarization (CIRC or LINR) std::vector POLTP ; // Rotation direction of circular polarization std::vector POLDR ; // Polarization angle of linear polarization std::vector POLAN ; // Switching frequency of frequcency switching [Hz] std::vector DFRQ ; // Type of sideband (LSB or USB or DSB) std::vector SIDBD ; // Identifier of reference synthesizer std::vector REFN ; // Temperature of calibrator std::vector IPINT ; // Beam id of the multi-beam detector std::vector MULTN ; // Scaling factor of the multi-beam detector std::vector MLTSCF ; // Type of LAG window (NONE or HANN or HAMM or BLCK) std::vector LAGWIND ; // Bandwidth at backend std::vector BEBW ; // Spectral resolution at backend std::vector BERES ; // Channel width at backend std::vector CHWID ; // Array usage (1: used 0: not used) std::vector ARRY ; // Frequency calibration: Number of measurement (max 10) std::vector NFCAL ; // Frequency calibration: Central frequency [Hz] std::vector F0CAL ; // Frequency calibration: Measured central frequency [Hz] std::vector< std::vector > FQCAL ; // Frequency calibration: Measured channel number std::vector< std::vector > CHCAL ; // Frequency calibration: Measured channel width [Hz] std::vector< std::vector > CWCAL ; // DSB scaling factor std::vector DSBFC ; // number of scan int scanNum_ ; // number of row int rowNum_ ; // length of scan (byte) int scanLen_ ; // length of spectral data (byte) int dataLen_ ; // Data size of the header [bytes] int datasize_ ; // maximum channel number int chmax_ ; // Current data id int dataid_ ; // Data record CountedPtr record_ ; // input filename std::string filename_ ; // file pointer FILE *fp_ ; // OS endian int same_ ; // Logger //LogIO os ; // reference frequency for each array std::vector refFreq_ ; // list of array names std::vector arrayNames_; // record to store REFPIX, REFVAL, INCREMENT pair for each array Record frec_ ; } ; // debug message output template inline void nro_debug_output( char *name, int len, std::vector &val ) { for ( int i = 0 ; i < len ; i++ ) { if ( i == 0 ) { cout << setw(8) << left << name ; } else if ( ( i % 5 ) == 0 ) { cout << endl << " " ; } cout << "\'" << val[i] << "\' " ; } cout << endl ; } template inline void nro_debug_output( char *name, int len1, int len2, std::vector< std::vector > &val ) { for ( int i = 0 ; i < len1 ; i++ ) { for ( int j = 0 ; j < len2 ; j++ ) { if ( j == 0 ) { if ( i < 10 ) cout << name << "0" << i << " " ; else cout << name << i << " " ; } else if ( ( j % 5 ) == 0 ) { cout << endl << " " ; } cout << "\'" << val[i][j] << "\' " ; } cout << endl ; } } #endif /* NRO_HEADER_H */