casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GBTFITSreader.h
Go to the documentation of this file.
00001 //#---------------------------------------------------------------------------
00002 //# GBTFITSreader.h: CFITSIO interface class for GBT SDFITS input.
00003 //#---------------------------------------------------------------------------
00004 //# livedata - processing pipeline for single-dish, multibeam spectral data.
00005 //# Copyright (C) 2000-2009, Australia Telescope National Facility, CSIRO
00006 //#
00007 //# This file is part of livedata.
00008 //#
00009 //# livedata is free software: you can redistribute it and/or modify it under
00010 //# the terms of the GNU General Public License as published by the Free
00011 //# Software Foundation, either version 3 of the License, or (at your option)
00012 //# any later version.
00013 //#
00014 //# livedata is distributed in the hope that it will be useful, but WITHOUT
00015 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00017 //# more details.
00018 //#
00019 //# You should have received a copy of the GNU General Public License along
00020 //# with livedata.  If not, see <http://www.gnu.org/licenses/>.
00021 //#
00022 //# Correspondence concerning livedata may be directed to:
00023 //#        Internet email: mcalabre@atnf.csiro.au
00024 //#        Postal address: Dr. Mark Calabretta
00025 //#                        Australia Telescope National Facility, CSIRO
00026 //#                        PO Box 76
00027 //#                        Epping NSW 1710
00028 //#                        AUSTRALIA
00029 //#
00030 //# http://www.atnf.csiro.au/computing/software/livedata.html
00031 //# $Id: SDFITSreader.h,v 19.22 2009-09-29 07:33:39 cal103 Exp $
00032 //#---------------------------------------------------------------------------
00033 //# The GBTFITSreader class reads single dish FITS files from Green Bank 
00034 //# telescopes. This class is actually a specific version of SDFITSreader.
00035 //#
00036 //# Original: 2000/08/09, Mark Calabretta, ATNF
00037 //#   Update: 2010/07/29, Takeshi Nakazato, NAOJ
00038 //#---------------------------------------------------------------------------
00039 
00040 #ifndef ATNF_GBTFITSREADER_H
00041 #define ATNF_GBTFITSREADER_H
00042 
00043 #include <atnf/PKSIO/FITSreader.h>
00044 #include <atnf/PKSIO/MBrecord.h>
00045 
00046 #include <casa/Logging/LogIO.h>
00047 #include <casa/Arrays/Vector.h>
00048 
00049 #include <fitsio.h>
00050 
00051 using namespace std;
00052 using namespace casa;
00053 
00054 // <summary>
00055 // class for GBT SDFITS input using CFITSIO.
00056 // </summary>
00057 
00058 class GBTFITSreader : public FITSreader
00059 {
00060   public:
00061     // Default constructor.
00062     GBTFITSreader();
00063 
00064     // Destructor.
00065     virtual ~GBTFITSreader();
00066 
00067     // Open an SDFITS file for reading.
00068     virtual int open(
00069         char*  sdname,
00070         int    &nBeam,
00071         int*   &beams,
00072         int    &nIF,
00073         int*   &IFs,
00074         int*   &nChan,
00075         int*   &nPol,
00076         int*   &haveXPol,
00077         int    &haveBase,
00078         int    &haveSpectra,
00079         int    &extraSysCal);
00080 
00081     // Get parameters describing the data.
00082     virtual int getHeader(
00083         char   observer[32],
00084         char   project[32],
00085         char   telescope[32],
00086         double antPos[3],
00087         char   obsMode[32],
00088         char   bunit[32],
00089         float  &equinox,
00090         char   radecsys[32],
00091         char   dopplerFrame[32],
00092         char   datobs[32],
00093         double &utc,
00094         double &refFreq,
00095         double &bandwidth);
00096 
00097     // Get frequency parameters for each IF.
00098     virtual int getFreqInfo(
00099         int     &nIF,
00100         double* &startFreq,
00101         double* &endFreq);
00102 
00103     // Find the range of the data selected in time and position.
00104     virtual int findRange(
00105         int    &nRow,
00106         int    &nSel,
00107         char   dateSpan[2][32],
00108         double utcSpan[2],
00109         double* &positions);
00110 
00111     // Read the next data record.
00112     virtual int read(MBrecord &record);
00113 
00114     // Close the SDFITS file.
00115     virtual void close(void);
00116 
00117   private:
00118     int      cCycleNo, cExtraSysCal, cNAxes, cStatus;
00119     long     cBeamAxis, cDecAxis, cFreqAxis, cNAxis[5], cNAxisTime, cNRow,
00120              cRaAxis, cRow, cStokesAxis, cTimeAxis, cTimeIdx;
00121     double   cLastUTC;
00122     fitsfile *cSDptr;
00123     class FITSparm *cData;
00124 
00125     // These are to differentiate 0-, and 1-relative beam and IF numbering.
00126     int  cBeam_1rel, cIF_1rel;
00127 
00128     // for GBT
00129     int *cPols ;
00130 
00131     enum {SCAN, CYCLE, DATE_OBS, TIME, EXPOSURE, OBJECT, OBJ_RA, OBJ_DEC,
00132           RESTFRQ, OBSMODE, BEAM, IF, FqRefVal, FqDelt, FqRefPix, RA, DEC,
00133           TimeRefVal, TimeDelt, TimeRefPix, SCANRATE, TSYS, CALFCTR, XCALFCTR,
00134           BASELIN, BASESUB, DATA, FLAGGED, DATAXED, XPOLDATA, REFBEAM, TCAL,
00135           TCALTIME, AZIMUTH, ELEVATIO, PARANGLE, FOCUSAXI, FOCUSTAN, FOCUSROT,
00136           TAMBIENT, PRESSURE, HUMIDITY, WINDSPEE, WINDDIRE, STOKES, SIG, CAL, 
00137           VFRAME, RVSYS, VELDEF, TIMESTAMP, DURATION, SAMPLER, NDATA};
00138 
00139     // Message handling.
00140     void log(LogOrigin origin, LogIO::Command cmd, const char *msg = 0x0);
00141 
00142     void findData(int iData, char *name, int type);
00143     void  findCol(char *name, int *colnum);
00144     int   readDim(int iData, long iRow, int *naxis, long naxes[]);
00145     int  readParm(char *name, int type, void *value);
00146     int  readData(char *name, int type, long iRow, void *value);
00147     int  readData(int iData, long iRow, void *value);
00148     int  readCol(int iData, void *value);
00149     int  readTime(long iRow, int iPix, char *datobs, double &utc);
00150 
00151     // These are for ALFA data: "BDFITS" or "CIMAFITS".  Statics are required
00152     // for CIMAFITS v2.0 because CAL ON/OFF data is split into separate files.
00153     static int  sInit, sReset;
00154     static int  (*sALFAcalNon)[2], (*sALFAcalNoff)[2];
00155     static float (*sALFAcal)[2], (*sALFAcalOn)[2], (*sALFAcalOff)[2];
00156 
00157     int   cALFA, cALFA_BD, cALFA_CIMA, cALFAscan, cScanNo;
00158     float cALFAacc;
00159     int   alfaCal(short iBeam, short iIF, short iPol);
00160     float alfaGain(float zd);
00161 
00162     // For multiple binary table SDFITS (GBT)
00163     long cRowRelative( long iRow ) ;
00164     Vector<Int> nIFPerHDU() ;
00165     Double getRefValLSR( int irow ) ;
00166     Double getRefValLSR( long iRow, int idx, char *sampler, double restfreq ) ;
00167     Int mergeIFPerHDU( int start, int n ) ;
00168 
00169     // These are for GBT data.
00170     int   cGBT, cFirstScanNo;
00171     double cGLastUTC[4] ;
00172     int cGLastScan[4] ;
00173     int cGCycleNo[4] ;
00174     long *cNRowT ;
00175     long *cNRowCum ;
00176     int *hduId ;
00177     int numHDU ;
00178     vector<String> cRefValKey ;
00179     vector<double> cRefVal ;
00180     vector<double> cIncVal ;
00181     Vector<Int> cIFNO ;
00182     vector<int> cNumKeys ;
00183   //double cAntPos[3] ;
00184 };
00185 
00186 #endif