casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
NRODataset.h
Go to the documentation of this file.
00001 //#---------------------------------------------------------------------------
00002 //# NRODataset.h: Base class for NRO dataset.
00003 //#---------------------------------------------------------------------------
00004 //# Copyright (C) 2000-2006
00005 //# Associated Universities, Inc. Washington DC, USA.
00006 //#
00007 //# This library is free software; you can redistribute it and/or modify it
00008 //# under the terms of the GNU Library General Public License as published by
00009 //# the Free Software Foundation; either version 2 of the License, or (at your
00010 //# option) any later version.
00011 //#
00012 //# This library is distributed in the hope that it will be useful, but WITHOUT
00013 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00015 //# License for more details.
00016 //#
00017 //# You should have received a copy of the GNU Library General Public License
00018 //# along with this library; if not, write to the Free Software Foundation,
00019 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00020 //#
00021 //# Correspondence concerning AIPS++ should be addressed as follows:
00022 //#        Internet email: aips2-request@nrao.edu.
00023 //#        Postal address: AIPS++ Project Office
00024 //#                        National Radio Astronomy Observatory
00025 //#                        520 Edgemont Road
00026 //#                        Charlottesville, VA 22903-2475 USA
00027 //#
00028 //# $Id$
00029 //#---------------------------------------------------------------------------
00030 //# Original: 2009/02/27, Takeshi Nakazato, NAOJ
00031 //#---------------------------------------------------------------------------
00032 
00033 #ifndef NRO_DATASET_H
00034 #define NRO_DATASET_H
00035 
00036 #include <string> 
00037 #include <stdio.h>
00038 #include <vector> 
00039 #include <iostream>
00040 
00041 //#include <casa/aips.h>
00042 #include <casa/Logging/LogIO.h>
00043 #include <atnf/PKSIO/NRODataRecord.h>
00044 #include <casa/namespace.h>
00045 
00046 #define SCAN_HEADER_SIZE 424 
00047 
00048 
00049 using namespace std ;
00050 
00051 // <summary>
00052 // Base class for NRO accessor classes.
00053 // </summary>
00054 //
00055 // <prerequisite>
00056 //   <li> <linkto class=NROReader>NROReader</linkto>
00057 //   <li> <linkto class=NRODataRecord>NRODataRecord</linkto>
00058 // </prerequisite>
00059 //
00060 // <reviewed reviewer="" date="" tests="" demos="">
00061 // </reviewed>
00062 //
00063 // <etymology>
00064 // This class is a base class for classes that actually access data from NRO telescopes.
00065 // Concrete classes are defiened for each data type (OTF format or NRO FITS) and/or 
00066 // telescopes (45m or ASTE).
00067 // The class have two filler method: fillHeader and fillRecord. The former reads header 
00068 // information from the data. Since header data depends on the telescope and its configuration, 
00069 // it is an abstract in this class and is defined in each concrete class. 
00070 // On the other hand, the later reads each scan record (set of meta data 
00071 // and spectral data). The method uses <linkto class=NRODataRecord>NRODataRecord</linkto> 
00072 // to access scan record. It is implemented here since contents of scan record is 
00073 // quite similar for several types of data.
00074 // </etymology>
00075 //
00076 // <synopsis>
00077 // Abstract class that is designed as a base class for all accessor classes.
00078 // </synopsis>
00079 //
00080 
00081 class NRODataset
00082 {
00083  public:
00084   // Constructor 
00085   NRODataset( string name ) ;
00086 
00087   // Destructor 
00088   virtual ~NRODataset() ;
00089 
00090   // Data initialization
00091   virtual void initialize() ;
00092 
00093   // open file
00094   virtual int open() ;
00095 
00096   // close file
00097   virtual void close() ;
00098 
00099   // Fill data header from file
00100   virtual int fillHeader() = 0 ;
00101 
00102   // Fill data record
00103   virtual int fillRecord( int i ) ;
00104 
00105   // simple getter
00106   string getLOFIL() { return LOFIL ; } ;
00107   string getVER() { return VER ; } ;
00108   string getGROUP() { return GROUP ; } ;
00109   string getPROJ() { return PROJ ; } ;
00110   string getSCHED() { return SCHED ; } ;
00111   string getOBSVR() { return OBSVR ; } ;
00112   string getLOSTM() { return LOSTM ; } ;
00113   string getLOETM() { return LOETM ; } ;
00114   int getARYNM() { return ARYNM ; } ;
00115   int getNSCAN() { return NSCAN ; } ;
00116   string getTITLE() { return TITLE ; } ;
00117   string getOBJ() { return OBJ ; } ;
00118   string getEPOCH() { return EPOCH ; } ;
00119   double getRA0() { return RA0 ; } ;
00120   double getDEC0() { return DEC0 ; } ;
00121   double getGLNG0() { return GLNG0 ; } ;
00122   double getGLAT0() { return GLAT0 ; } ;
00123   int getNCALB() { return NCALB ; } ;
00124   int getSCNCD() { return SCNCD ; } ;
00125   string getSCMOD() { return SCMOD ; } ;
00126   double getURVEL() { return URVEL ; } ;
00127   string getVREF() { return VREF ; } ;
00128   string getVDEF() { return VDEF ; } ;
00129   string getSWMOD() { return SWMOD ; } ;
00130   double getFRQSW() { return FRQSW ; } ;   
00131   double getDBEAM() { return DBEAM ; } ;   
00132   double getMLTOF() { return MLTOF ; } ;    
00133   double getCMTQ() { return CMTQ ; } ;     
00134   double getCMTE() { return CMTE ; } ;
00135   double getCMTSOM() { return CMTSOM ; } ;
00136   double getCMTNODE() { return CMTNODE ; } ;
00137   double getCMTI() { return CMTI ; } ;
00138   string getCMTTM() { return CMTTM ; } ;
00139   double getSBDX() { return SBDX ; } ;
00140   double getSBDY() { return SBDY ; } ;
00141   double getSBDZ1() { return SBDZ1 ; } ;
00142   double getSBDZ2() { return SBDZ2 ; } ;
00143   double getDAZP() { return DAZP ; } ;
00144   double getDELP() { return DELP ; } ;
00145   int getCHBIND() { return CHBIND ; } ;
00146   int getNUMCH() { return NUMCH ; } ;
00147   int getCHMIN() { return CHMIN ; } ;
00148   int getCHMAX() { return CHMAX ; } ;
00149   double getALCTM() { return ALCTM ; } ;
00150   double getIPTIM() { return IPTIM ; } ;
00151   double getPA() { return PA ; } ;
00152   int getSCNLEN() { return SCNLEN ; } ;
00153   int getSBIND() { return SBIND ; } ;
00154   int getIBIT() { return IBIT ; } ;
00155   string getSITE() { return SITE ; } ;
00156   vector<string> getRX() { return RX ; } ;
00157   vector<double> getHPBW() { return HPBW ; } ;
00158   vector<double> getEFFA() { return EFFA ; } ;
00159   vector<double> getEFFB() { return EFFB ; } ;
00160   vector<double> getEFFL() { return EFFL ; } ;
00161   vector<double> getEFSS() { return EFSS ; } ;
00162   vector<double> getGAIN() { return GAIN ; } ;
00163   vector<string> getHORN() { return HORN ; } ;
00164   vector<string> getPOLTP() { return POLTP ; } ;
00165   vector<double> getPOLDR() { return POLDR ; } ;
00166   vector<double> getPOLAN() { return POLAN ; } ;
00167   vector<double> getDFRQ() { return DFRQ ; } ;
00168   vector<string> getSIDBD() { return SIDBD ; } ;
00169   vector<int> getREFN() { return REFN ; } ;
00170   vector<int> getIPINT() { return IPINT ; } ;
00171   vector<int> getMULTN() { return MULTN ; } ;
00172   vector<double> getMLTSCF() { return MLTSCF ; } ;
00173   vector<string> getLAGWIND() { return LAGWIND ; } ;
00174   vector<double> getBEBW() { return BEBW ; } ;
00175   vector<double> getBERES() { return BERES ; } ;
00176   vector<double> getCHWID() { return CHWID ; } ;
00177   vector<int> getARRY() { return ARRY ; } ;
00178   vector<int> getNFCAL() { return NFCAL ; } ;
00179   vector<double> getF0CAL() { return F0CAL ; } ;
00180   vector< vector<double> > getFQCAL() { return FQCAL ; } ;
00181   vector< vector<double> > getCHCAL() { return CHCAL ; } ;
00182   vector< vector<double> > getCWCAL() { return CWCAL ; } ;
00183   string getCDMY1() { return CDMY1 ; } ;
00184   vector<double> getDSBFC() { return DSBFC ;} ;
00185   int getDataSize() { return datasize_ ; } ;
00186   int getRowNum() { return rowNum_ ; } ;
00187 
00188   // get various parameters
00189   NRODataRecord *getRecord( int i ) ;
00190   virtual vector< vector<double> > getSpectrum() ;
00191   virtual vector<double> getSpectrum( int i ) ;
00192   virtual int getIndex( int irow ) ;
00193   virtual int getPolarizationNum() ;
00194   virtual vector<double> getStartIntTime() ;
00195   virtual double getStartIntTime( int i ) ;
00196   virtual double getMJD( char *time ) ;
00197   virtual vector<bool> getIFs() ;
00198   virtual vector<double> getFrequencies( int i ) ;
00199   virtual uInt getArrayId( string type ) ;
00200 
00201  protected:
00202   // fill header information
00203   virtual int fillHeader( int sameEndian ) = 0 ;
00204 
00205   // Endian conversion for int variable
00206   void convertEndian( int &value ) ;
00207 
00208   // Endian convertion for float variable
00209   void convertEndian( float &value ) ;
00210 
00211   // Endian conversion for double variable
00212   void convertEndian( double &value ) ;
00213 
00214   // Endian conversion for NRODataRecord
00215   void convertEndian( NRODataRecord *r ) ;
00216 
00217   // Read char data
00218   int readHeader( char *v, int size ) ;
00219 
00220   // Read int data
00221   int readHeader( int &v, int b ) ;
00222 
00223   // Read float data
00224   int readHeader( float &v, int b ) ;
00225 
00226   // Read double data
00227   int readHeader( double &v, int b ) ;
00228 
00229   // Release DataRecord
00230   void releaseRecord() ;
00231 
00232   // show primary information
00233   void show() ;
00234 
00235   // convert frequency frame
00236   virtual double toLSR( double v, double t, double x, double y ) ;
00237 
00238   // Type of file record
00239   string LOFIL ;
00240 
00241   // Version 
00242   string VER ;
00243 
00244   // Group name
00245   string GROUP ;
00246 
00247   // Project name
00248   string PROJ ;
00249 
00250   // Name of observation scheduling file
00251   string SCHED ;
00252 
00253   // Name of observer
00254   string OBSVR ;
00255 
00256   // Observation start time with format of "YYYYMMDDHHMMSS" (UTC)
00257   string LOSTM ;
00258 
00259   // observation end time with format of "YYYYMMDDHHMMSS" (UTC)
00260   string LOETM ;
00261 
00262   // Number of arrays (beams and IFs)
00263   int ARYNM ;
00264 
00265   // Number of scans
00266   int NSCAN ;
00267 
00268   // Title of observation
00269   string TITLE ;
00270 
00271   // Name of target object 
00272   string OBJ ;
00273 
00274   // Equinox (B1950 or J2000)
00275   string EPOCH ;
00276 
00277   // Right ascension [rad]
00278   double RA0 ;
00279 
00280   // Declination [rad]
00281   double DEC0 ;
00282 
00283   // Galactic longitude [rad]
00284   double GLNG0 ;
00285 
00286   // Galactic latitude [rad]
00287   double GLAT0 ;
00288 
00289   // Calibration interval
00290   int NCALB ;
00291 
00292   // Scan coordinate  (0: RADEC  1: LB  2: AZEL)
00293   int SCNCD ;
00294 
00295   // Scan sequence pattern
00296   string SCMOD ;
00297 
00298   // User-defined recessional velocity [m/s]
00299   double URVEL ;
00300 
00301   // Reference frame for recessional velocity  (LSR or HEL or GAL)
00302   string VREF ;
00303 
00304   // Definition of recessional velocity  (RAD or OPT)
00305   string VDEF ;
00306 
00307   // Switching mode  (POS or BEAM or FREQ)
00308   string SWMOD ;
00309 
00310   // Switching frequency [Hz]
00311   double FRQSW ;
00312 
00313   // Off-beam angle of beam switching [rad]
00314   double DBEAM ;
00315 
00316   // Initial inclination angle of multi-beam array 
00317   double MLTOF ;
00318 
00319   // Comet: Perihelion distance
00320   double CMTQ ;
00321 
00322   // Comet: Eccentricity
00323   double CMTE ;
00324 
00325   // Comet: Argument of perihelion
00326   double CMTSOM ;
00327 
00328   // Comet: Longitude of the ascending node 
00329   double CMTNODE ;
00330 
00331   // Comet: Orbital inclination angle
00332   double CMTI ;
00333 
00334   // Comet: Time of the perihelion passage
00335   string CMTTM ;
00336 
00337   // Correction for position of subreflector DX [mm] 
00338   double SBDX ;
00339 
00340   // Correction for position of subreflector DY [mm] 
00341   double SBDY ;
00342 
00343   // Correction for position of subreflector DZ1 [mm] 
00344   double SBDZ1 ;
00345 
00346   // Correction for position of subreflector DZ2 [mm] 
00347   double SBDZ2 ;
00348 
00349   // Correction for pointing on azimuth [rad]
00350   double DAZP ;
00351 
00352   // Correction for pointing on elevation [rad]
00353   double DELP ;
00354 
00355   // Number of channel binding  
00356   int CHBIND ;
00357 
00358   // Number of channel after binding
00359   int NUMCH ;
00360 
00361   // Channel range (minimum)
00362   int CHMIN ;
00363 
00364   // Channel range (maximum)
00365   int CHMAX ;
00366 
00367   // ALC time constant
00368   double ALCTM ;
00369 
00370   // Interval to get data from spectrometer
00371   double IPTIM ;
00372 
00373   // Position angle of the map
00374   double PA ;
00375 
00376   // Length of scan record [bytes]
00377   int SCNLEN ;
00378 
00379   // Range of space binding
00380   int SBIND ;
00381 
00382   // Quantization bit number (fixed to 12)
00383   int IBIT ;
00384 
00385   // Site (antenna) name  (45m or ASTE)
00386   string SITE ;
00387 
00388   // Dummy data
00389   string CDMY1 ;
00390 
00391   // Type of detector frontend 
00392   vector<string> RX ;
00393 
00394   // HPBW [rad]
00395   vector<double> HPBW ;
00396 
00397   // Aperture efficiencies 
00398   vector<double> EFFA ;
00399 
00400   // Beam efficiencies 
00401   vector<double> EFFB ;
00402 
00403   // Antenna efficiencies 
00404   vector<double> EFFL ;
00405 
00406   // FSS efficiencies 
00407   vector<double> EFSS ;
00408 
00409   // Antenna gain 
00410   vector<double> GAIN ;
00411 
00412   // Type of polarization at feed horn  (R or L or H or V)
00413   vector<string> HORN ;
00414 
00415   // Type of polarization  (CIRC or LINR)
00416   vector<string> POLTP ;
00417 
00418   // Rotation direction of circular polarization
00419   vector<double> POLDR ;
00420 
00421   // Polarization angle of linear polarization
00422   vector<double> POLAN ;
00423 
00424   // Switching frequency of frequcency switching [Hz]
00425   vector<double> DFRQ ;
00426 
00427   // Type of sideband  (LSB or USB or DSB)
00428   vector<string> SIDBD ;
00429 
00430   // Identifier of reference synthesizer
00431   vector<int> REFN ;
00432 
00433   // Temperature of calibrator
00434   vector<int> IPINT ;
00435 
00436   // Beam id of the multi-beam detector
00437   vector<int> MULTN ;
00438 
00439   // Scaling factor of the multi-beam detector
00440   vector<double> MLTSCF ;
00441 
00442   // Type of LAG window  (NONE or HANN or HAMM or BLCK)
00443   vector<string> LAGWIND ;
00444 
00445   // Bandwidth at backend
00446   vector<double> BEBW ;
00447 
00448   // Spectral resolution at backend
00449   vector<double> BERES ;
00450 
00451   // Channel width at backend
00452   vector<double> CHWID ;
00453 
00454   // Array usage  (1: used  0: not used)
00455   vector<int> ARRY ;
00456 
00457   // Frequency calibration: Number of measurement (max 10)
00458   vector<int> NFCAL ;
00459 
00460   // Frequency calibration: Central frequency [Hz]
00461   vector<double> F0CAL ;
00462 
00463   // Frequency calibration: Measured central frequency [Hz]
00464   vector< vector<double> > FQCAL ;
00465 
00466   // Frequency calibration: Measured channel number
00467   vector< vector<double> > CHCAL ;
00468 
00469   // Frequency calibration: Measured channel width [Hz]
00470   vector< vector<double> > CWCAL ;
00471 
00472   // DSB scaling factor
00473   vector<double> DSBFC ;
00474 
00475   // number of scan
00476   int scanNum_ ;
00477 
00478   // number of row
00479   int rowNum_ ;
00480 
00481   // length of scan (byte)
00482   int scanLen_ ;
00483 
00484   // length of spectral data (byte)
00485   int dataLen_ ;
00486 
00487   // Data size of the header [bytes]
00488   int datasize_ ;
00489 
00490   // maximum channel number
00491   int chmax_ ;
00492 
00493   // Current data id
00494   int dataid_ ;
00495 
00496   // Data record
00497   NRODataRecord *record_ ;
00498 
00499   // input filename
00500   string filename_ ;
00501 
00502   // file pointer
00503   FILE *fp_ ;
00504 
00505   // OS endian
00506   int endian_ ;
00507   int same_ ;
00508 
00509   // Logger
00510   //LogIO os ;
00511 
00512   // reference frequency for each array
00513   vector<double> refFreq_ ;
00514 } ;
00515 
00516 
00517 #endif /* NRO_HEADER_H */